@@ -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,6 +140,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
133140 } ;
134141
135142 if visit {
143+ let use_prelude = if use_prelude { UsePrelude :: Yes } else { UsePrelude :: No } ;
136144 if let break_result @ Some ( ..) = visitor ( self , scope, use_prelude, ctxt) {
137145 return break_result;
138146 }
@@ -579,7 +587,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
579587 None ,
580588 ignore_binding,
581589 ) {
582- if use_prelude || this. is_builtin_macro ( binding. res ( ) ) {
590+ if matches ! ( use_prelude, UsePrelude :: Yes )
591+ || this. is_builtin_macro ( binding. res ( ) )
592+ {
583593 result = Ok ( ( binding, Flags :: MISC_FROM_PRELUDE ) ) ;
584594 }
585595 }
0 commit comments