@@ -476,16 +476,23 @@ struct MoveOnlyChecker {
476476 MoveOnlyChecker (SILFunction *fn, DeadEndBlocks *deBlocks)
477477 : fn(fn), copyOfBorrowedProjectionChecker(deBlocks) {}
478478
479+ // / Search through the current function for candidate mark_must_check
480+ // / [noimplicitcopy]. If we find one that does not fit a pattern that we
481+ // / understand, emit an error diagnostic telling the programmer that the move
482+ // / checker did not know how to recognize this code pattern.
483+ // /
484+ // / \returns true if we deleted a mark_must_check inst that we didn't
485+ // / recognize after emitting the diagnostic.
486+ bool searchForCandidateMarkMustChecks ();
487+
479488 bool check (NonLocalAccessBlockAnalysis *accessBlockAnalysis,
480489 DominanceInfo *domTree);
481490};
482491
483492} // namespace
484493
485- bool MoveOnlyChecker::check (NonLocalAccessBlockAnalysis *accessBlockAnalysis,
486- DominanceInfo *domTree) {
494+ bool MoveOnlyChecker::searchForCandidateMarkMustChecks () {
487495 bool changed = false ;
488-
489496 for (auto &block : *fn) {
490497 for (auto ii = block.begin (), ie = block.end (); ii != ie;) {
491498 auto *mmci = dyn_cast<MarkMustCheckInst>(&*ii);
@@ -530,6 +537,24 @@ bool MoveOnlyChecker::check(NonLocalAccessBlockAnalysis *accessBlockAnalysis,
530537 changed = true ;
531538 }
532539 }
540+ return changed;
541+ }
542+
543+ bool MoveOnlyChecker::check (NonLocalAccessBlockAnalysis *accessBlockAnalysis,
544+ DominanceInfo *domTree) {
545+ bool changed = false ;
546+
547+ // First search for candidates to process and emit diagnostics on any
548+ // mark_must_check [noimplicitcopy] we didn't recognize.
549+ changed |= searchForCandidateMarkMustChecks ();
550+
551+ // If we didn't find any introducers to check, just return changed.
552+ //
553+ // NOTE: changed /can/ be true here if we had any mark_must_check
554+ // [noimplicitcopy] that we didn't understand and emitting a diagnostic upon
555+ // and then deleting.
556+ if (moveIntroducersToProcess.empty ())
557+ return changed;
533558
534559 auto callbacks =
535560 InstModCallbacks ().onDelete ([&](SILInstruction *instToDelete) {
0 commit comments