@@ -23,6 +23,18 @@ use Namespace::*;
2323
2424type Visibility = ty:: Visibility < LocalDefId > ;
2525
26+ #[ derive( Copy , Clone ) ]
27+ pub enum UsePrelude {
28+ No ,
29+ Yes ,
30+ }
31+
32+ impl From < UsePrelude > for bool {
33+ fn from ( up : UsePrelude ) -> bool {
34+ matches ! ( up, UsePrelude :: Yes )
35+ }
36+ }
37+
2638impl < ' a , ' tcx > Resolver < ' a , ' tcx > {
2739 /// A generic scope visitor.
2840 /// Visits scopes in order to resolve some identifier in them or perform other actions.
@@ -32,12 +44,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3244 scope_set : ScopeSet < ' a > ,
3345 parent_scope : & ParentScope < ' a > ,
3446 ctxt : SyntaxContext ,
35- mut visitor : impl FnMut (
36- & mut Self ,
37- Scope < ' a > ,
38- /*use_prelude*/ bool ,
39- SyntaxContext ,
40- ) -> Option < T > ,
47+ mut visitor : impl FnMut ( & mut Self , Scope < ' a > , UsePrelude , SyntaxContext ) -> Option < T > ,
4148 ) -> Option < T > {
4249 // General principles:
4350 // 1. Not controlled (user-defined) names should have higher priority than controlled names
@@ -133,7 +140,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
133140 } ;
134141
135142 if visit {
136- if let break_result @ Some ( ..) = visitor ( self , scope, use_prelude, ctxt) {
143+ if let break_result @ Some ( ..) = visitor (
144+ self ,
145+ scope,
146+ if use_prelude { UsePrelude :: Yes } else { UsePrelude :: No } ,
147+ ctxt,
148+ ) {
137149 return break_result;
138150 }
139151 }
@@ -579,7 +591,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
579591 None ,
580592 ignore_binding,
581593 ) {
582- if use_prelude || this. is_builtin_macro ( binding. res ( ) ) {
594+ if matches ! ( use_prelude, UsePrelude :: Yes )
595+ || this. is_builtin_macro ( binding. res ( ) )
596+ {
583597 result = Ok ( ( binding, Flags :: MISC_FROM_PRELUDE ) ) ;
584598 }
585599 }
0 commit comments