@@ -2307,31 +2307,39 @@ bool TypeResolver::diagnoseMoveOnlyMissingOwnership(
2307
2307
if (options.contains (TypeResolutionFlags::HasOwnership))
2308
2308
return false ;
2309
2309
2310
- // Do not run this on SIL files since there is currently a bug where we are
2311
- // trying to parse it in SILBoxes.
2312
- //
2313
- // To track what we want to do long term: rdar://105635373.
2310
+ // Don't diagnose in SIL; ownership is already required there.
2314
2311
if (options.contains (TypeResolutionFlags::SILType))
2315
2312
return false ;
2316
2313
2317
- diagnose (repr->getLoc (),
2318
- diag::moveonly_parameter_missing_ownership);
2314
+ // ////////////////
2315
+ // At this point, we know we have a noncopyable parameter that is missing an
2316
+ // ownership specifier, so we need to emit an error
2317
+
2318
+ // We don't yet support any ownership specifiers for parameters of subscript
2319
+ // decls, give a tailored error message saying you simply can't use a
2320
+ // noncopyable type here.
2321
+ if (options.hasBase (TypeResolverContext::SubscriptDecl)) {
2322
+ diagnose (repr->getLoc (), diag::moveonly_parameter_subscript_unsupported);
2323
+ } else {
2324
+ // general error diagnostic
2325
+ diagnose (repr->getLoc (),
2326
+ diag::moveonly_parameter_missing_ownership);
2319
2327
2320
- diagnose (repr->getLoc (), diag::moveonly_parameter_ownership_suggestion,
2321
- " borrowing" , " for an immutable reference" )
2322
- .fixItInsert (repr->getStartLoc (), " borrowing " );
2328
+ diagnose (repr->getLoc (), diag::moveonly_parameter_ownership_suggestion,
2329
+ " borrowing" , " for an immutable reference" )
2330
+ .fixItInsert (repr->getStartLoc (), " borrowing " );
2323
2331
2324
- diagnose (repr->getLoc (), diag::moveonly_parameter_ownership_suggestion,
2325
- " inout" , " for a mutable reference" )
2326
- .fixItInsert (repr->getStartLoc (), " inout " );
2332
+ diagnose (repr->getLoc (), diag::moveonly_parameter_ownership_suggestion,
2333
+ " inout" , " for a mutable reference" )
2334
+ .fixItInsert (repr->getStartLoc (), " inout " );
2327
2335
2328
- diagnose (repr->getLoc (), diag::moveonly_parameter_ownership_suggestion,
2329
- " consuming" , " to take the value from the caller" )
2330
- .fixItInsert (repr->getStartLoc (), " consuming " );
2336
+ diagnose (repr->getLoc (), diag::moveonly_parameter_ownership_suggestion,
2337
+ " consuming" , " to take the value from the caller" )
2338
+ .fixItInsert (repr->getStartLoc (), " consuming " );
2339
+ }
2331
2340
2332
2341
// to avoid duplicate diagnostics
2333
2342
repr->setInvalid ();
2334
-
2335
2343
return true ;
2336
2344
}
2337
2345
0 commit comments