@@ -125,18 +125,17 @@ pub struct NameResolution<'a> {
125
125
126
126
impl < ' a > NameResolution < ' a > {
127
127
fn try_define ( & mut self , binding : & ' a NameBinding < ' a > ) -> Result < ( ) , & ' a NameBinding < ' a > > {
128
- match self . binding {
129
- Some ( old_binding) if !old_binding. defined_with ( DefModifiers :: PRELUDE ) => {
130
- if binding. defined_with ( DefModifiers :: GLOB_IMPORTED ) {
131
- self . duplicate_globs . push ( binding) ;
132
- } else if old_binding. defined_with ( DefModifiers :: GLOB_IMPORTED ) {
133
- self . duplicate_globs . push ( old_binding) ;
134
- self . binding = Some ( binding) ;
135
- } else {
136
- return Err ( old_binding) ;
137
- }
128
+ if let Some ( old_binding) = self . binding {
129
+ if binding. defined_with ( DefModifiers :: GLOB_IMPORTED ) {
130
+ self . duplicate_globs . push ( binding) ;
131
+ } else if old_binding. defined_with ( DefModifiers :: GLOB_IMPORTED ) {
132
+ self . duplicate_globs . push ( old_binding) ;
133
+ self . binding = Some ( binding) ;
134
+ } else {
135
+ return Err ( old_binding) ;
138
136
}
139
- _ => self . binding = Some ( binding) ,
137
+ } else {
138
+ self . binding = Some ( binding) ;
140
139
}
141
140
142
141
Ok ( ( ) )
@@ -160,7 +159,6 @@ impl<'a> NameResolution<'a> {
160
159
fn try_result ( & self , allow_private_imports : bool )
161
160
-> Option < ResolveResult < & ' a NameBinding < ' a > > > {
162
161
match self . result ( allow_private_imports) {
163
- Success ( binding) if binding. defined_with ( DefModifiers :: PRELUDE ) => None ,
164
162
Failed ( _) => None ,
165
163
result @ _ => Some ( result) ,
166
164
}
@@ -192,8 +190,6 @@ impl<'a> NameResolution<'a> {
192
190
} ;
193
191
194
192
for duplicate_glob in self . duplicate_globs . iter ( ) {
195
- if duplicate_glob. defined_with ( DefModifiers :: PRELUDE ) { continue }
196
-
197
193
// FIXME #31337: We currently allow items to shadow glob-imported re-exports.
198
194
if !binding. is_import ( ) {
199
195
if let NameBindingKind :: Import { binding, .. } = duplicate_glob. kind {
@@ -360,7 +356,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
360
356
// resolution for it so that later resolve stages won't complain.
361
357
if let SingleImport { target, .. } = e. import_directive . subclass {
362
358
let dummy_binding = self . resolver . arenas . alloc_name_binding ( NameBinding {
363
- modifiers : DefModifiers :: PRELUDE ,
359
+ modifiers : DefModifiers :: GLOB_IMPORTED ,
364
360
kind : NameBindingKind :: Def ( Def :: Err ) ,
365
361
span : None ,
366
362
} ) ;
0 commit comments