@@ -23,6 +23,18 @@ use Namespace::*;
23
23
24
24
type Visibility = ty:: Visibility < LocalDefId > ;
25
25
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
+
26
38
impl < ' a , ' tcx > Resolver < ' a , ' tcx > {
27
39
/// A generic scope visitor.
28
40
/// Visits scopes in order to resolve some identifier in them or perform other actions.
@@ -32,12 +44,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
32
44
scope_set : ScopeSet < ' a > ,
33
45
parent_scope : & ParentScope < ' a > ,
34
46
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 > ,
41
48
) -> Option < T > {
42
49
// General principles:
43
50
// 1. Not controlled (user-defined) names should have higher priority than controlled names
@@ -133,6 +140,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
133
140
} ;
134
141
135
142
if visit {
143
+ let use_prelude = if use_prelude { UsePrelude :: Yes } else { UsePrelude :: No } ;
136
144
if let break_result @ Some ( ..) = visitor ( self , scope, use_prelude, ctxt) {
137
145
return break_result;
138
146
}
@@ -579,7 +587,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
579
587
None ,
580
588
ignore_binding,
581
589
) {
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
+ {
583
593
result = Ok ( ( binding, Flags :: MISC_FROM_PRELUDE ) ) ;
584
594
}
585
595
}
0 commit comments