@@ -2307,31 +2307,39 @@ bool TypeResolver::diagnoseMoveOnlyMissingOwnership(
23072307 if (options.contains (TypeResolutionFlags::HasOwnership))
23082308 return false ;
23092309
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.
23142311 if (options.contains (TypeResolutionFlags::SILType))
23152312 return false ;
23162313
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);
23192327
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 " );
23232331
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 " );
23272335
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+ }
23312340
23322341 // to avoid duplicate diagnostics
23332342 repr->setInvalid ();
2334-
23352343 return true ;
23362344}
23372345
0 commit comments