1+ use std:: ops:: ControlFlow ;
2+
13use Determinacy :: * ;
24use Namespace :: * ;
35use rustc_ast:: { self as ast, NodeId } ;
@@ -56,7 +58,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
5658 Scope < ' ra > ,
5759 UsePrelude ,
5860 SyntaxContext ,
59- ) -> Option < T > ,
61+ ) -> ControlFlow < T > ,
6062 ) -> Option < T > {
6163 // General principles:
6264 // 1. Not controlled (user-defined) names should have higher priority than controlled names
@@ -156,8 +158,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
156158
157159 if visit {
158160 let use_prelude = if use_prelude { UsePrelude :: Yes } else { UsePrelude :: No } ;
159- if let break_result @ Some ( ..) = visitor ( & mut self , scope, use_prelude, ctxt) {
160- return break_result;
161+ if let ControlFlow :: Break ( break_result) =
162+ visitor ( & mut self , scope, use_prelude, ctxt)
163+ {
164+ return Some ( break_result) ;
161165 }
162166 }
163167
@@ -536,7 +540,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
536540 Ok ( ( binding, Flags :: MODULE | misc_flags) )
537541 }
538542 Err ( ( Determinacy :: Undetermined , Weak :: No ) ) => {
539- return Some ( Err ( Determinacy :: determined ( force) ) ) ;
543+ return ControlFlow :: Break ( Err ( Determinacy :: determined ( force) ) ) ;
540544 }
541545 Err ( ( Determinacy :: Undetermined , Weak :: Yes ) ) => {
542546 Err ( Determinacy :: Undetermined )
@@ -641,15 +645,15 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
641645 match result {
642646 Ok ( ( binding, flags) ) => {
643647 if !sub_namespace_match ( binding. macro_kinds ( ) , macro_kind) {
644- return None ;
648+ return ControlFlow :: Continue ( ( ) ) ;
645649 }
646650
647651 // Below we report various ambiguity errors.
648652 // We do not need to report them if we are either in speculative resolution,
649653 // or in late resolution when everything is already imported and expanded
650654 // and no ambiguities exist.
651655 if matches ! ( finalize, None | Some ( Finalize { stage: Stage :: Late , .. } ) ) {
652- return Some ( Ok ( binding) ) ;
656+ return ControlFlow :: Break ( Ok ( binding) ) ;
653657 }
654658
655659 if let Some ( ( innermost_binding, innermost_flags) ) = innermost_result {
@@ -732,7 +736,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
732736 misc1 : misc ( innermost_flags) ,
733737 misc2 : misc ( flags) ,
734738 } ) ;
735- return Some ( Ok ( innermost_binding) ) ;
739+ return ControlFlow :: Break ( Ok ( innermost_binding) ) ;
736740 }
737741 }
738742 } else {
@@ -744,7 +748,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
744748 Err ( Determinacy :: Undetermined ) => determinacy = Determinacy :: Undetermined ,
745749 }
746750
747- None
751+ ControlFlow :: Continue ( ( ) )
748752 } ,
749753 ) ;
750754
0 commit comments