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