@@ -75,7 +75,6 @@ pub struct NameResolution<'a> {
7575 single_imports : SingleImports < ' a > ,
7676 /// The least shadowable known binding for this name, or None if there are no known bindings.
7777 pub binding : Option < & ' a NameBinding < ' a > > ,
78- duplicate_globs : Vec < & ' a NameBinding < ' a > > ,
7978}
8079
8180#[ derive( Clone , Debug ) ]
@@ -141,7 +140,6 @@ impl<'a> Resolver<'a> {
141140 module : Module < ' a > ,
142141 name : Name ,
143142 ns : Namespace ,
144- allow_private_imports : bool ,
145143 ignore_unresolved_invocations : bool ,
146144 record_used : Option < Span > )
147145 -> ResolveResult < & ' a NameBinding < ' a > > {
@@ -153,18 +151,8 @@ impl<'a> Resolver<'a> {
153151 _ => return Failed ( None ) , // This happens when there is a cycle of imports
154152 } ;
155153
156- let new_import_semantics = self . new_import_semantics ;
157- let is_disallowed_private_import = |binding : & NameBinding | {
158- !new_import_semantics && !allow_private_imports && // disallowed
159- binding. vis != ty:: Visibility :: Public && binding. is_import ( ) && // non-`pub` import
160- !binding. is_extern_crate ( ) // not an `extern crate`
161- } ;
162-
163154 if let Some ( span) = record_used {
164155 if let Some ( binding) = resolution. binding {
165- if is_disallowed_private_import ( binding) {
166- return Failed ( None ) ;
167- }
168156 if self . record_use ( name, ns, binding, span) {
169157 return Success ( self . dummy_binding ) ;
170158 }
@@ -177,9 +165,8 @@ impl<'a> Resolver<'a> {
177165 }
178166
179167 let check_usable = |this : & mut Self , binding : & ' a NameBinding < ' a > | {
180- let usable =
181- this. is_accessible ( binding. vis ) && !is_disallowed_private_import ( binding) ||
182- binding. is_extern_crate ( ) ; // c.f. issue #37020
168+ // `extern crate` are always usable for backwards compatability, see issue #37020.
169+ let usable = this. is_accessible ( binding. vis ) || binding. is_extern_crate ( ) ;
183170 if usable { Success ( binding) } else { Failed ( None ) }
184171 } ;
185172
@@ -202,7 +189,7 @@ impl<'a> Resolver<'a> {
202189 SingleImport { source, .. } => source,
203190 _ => unreachable ! ( ) ,
204191 } ;
205- match self . resolve_name_in_module ( module, name, ns, true , false , None ) {
192+ match self . resolve_name_in_module ( module, name, ns, false , None ) {
206193 Failed ( _) => { }
207194 _ => return Indeterminate ,
208195 }
@@ -224,7 +211,7 @@ impl<'a> Resolver<'a> {
224211 for directive in module. globs . borrow ( ) . iter ( ) {
225212 if self . is_accessible ( directive. vis . get ( ) ) {
226213 if let Some ( module) = directive. imported_module . get ( ) {
227- let result = self . resolve_name_in_module ( module, name, ns, true , false , None ) ;
214+ let result = self . resolve_name_in_module ( module, name, ns, false , None ) ;
228215 if let Indeterminate = result {
229216 return Indeterminate ;
230217 }
@@ -311,22 +298,17 @@ impl<'a> Resolver<'a> {
311298 self . update_resolution ( module, name, ns, |this, resolution| {
312299 if let Some ( old_binding) = resolution. binding {
313300 if binding. is_glob_import ( ) {
314- if !this. new_import_semantics {
315- resolution. duplicate_globs . push ( binding) ;
316- } else if !old_binding. is_glob_import ( ) &&
317- !( ns == MacroNS && old_binding. expansion != Mark :: root ( ) ) {
301+ if !old_binding. is_glob_import ( ) &&
302+ !( ns == MacroNS && old_binding. expansion != Mark :: root ( ) ) {
318303 } else if binding. def ( ) != old_binding. def ( ) {
319304 resolution. binding = Some ( this. ambiguity ( old_binding, binding) ) ;
320305 } else if !old_binding. vis . is_at_least ( binding. vis , this) {
321306 // We are glob-importing the same item but with greater visibility.
322307 resolution. binding = Some ( binding) ;
323308 }
324309 } else if old_binding. is_glob_import ( ) {
325- if !this. new_import_semantics {
326- resolution. duplicate_globs . push ( old_binding) ;
327- resolution. binding = Some ( binding) ;
328- } else if ns == MacroNS && binding. expansion != Mark :: root ( ) &&
329- binding. def ( ) != old_binding. def ( ) {
310+ if ns == MacroNS && binding. expansion != Mark :: root ( ) &&
311+ binding. def ( ) != old_binding. def ( ) {
330312 resolution. binding = Some ( this. ambiguity ( binding, old_binding) ) ;
331313 } else {
332314 resolution. binding = Some ( binding) ;
@@ -366,7 +348,7 @@ impl<'a> Resolver<'a> {
366348 let t = f ( self , resolution) ;
367349
368350 match resolution. binding ( ) {
369- _ if ! self . new_import_semantics && old_binding. is_some ( ) => return t,
351+ _ if old_binding. is_some ( ) => return t,
370352 None => return t,
371353 Some ( binding) => match old_binding {
372354 Some ( old_binding) if old_binding as * const _ == binding as * const _ => return t,
@@ -377,10 +359,7 @@ impl<'a> Resolver<'a> {
377359
378360 // Define `binding` in `module`s glob importers.
379361 for directive in module. glob_importers . borrow_mut ( ) . iter ( ) {
380- if match self . new_import_semantics {
381- true => self . is_accessible_from ( binding. vis , directive. parent ) ,
382- false => binding. vis == ty:: Visibility :: Public ,
383- } {
362+ if self . is_accessible_from ( binding. vis , directive. parent ) {
384363 let imported_binding = self . import ( binding, directive) ;
385364 let _ = self . try_define ( directive. parent , name, ns, imported_binding) ;
386365 }
@@ -528,7 +507,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
528507 self . per_ns ( |this, ns| {
529508 if let Err ( Undetermined ) = result[ ns] . get ( ) {
530509 result[ ns] . set ( {
531- match this. resolve_name_in_module ( module, source, ns, false , false , None ) {
510+ match this. resolve_name_in_module ( module, source, ns, false , None ) {
532511 Success ( binding) => Ok ( binding) ,
533512 Indeterminate => Err ( Undetermined ) ,
534513 Failed ( _) => Err ( Determined ) ,
@@ -624,7 +603,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
624603 if all_ns_err {
625604 let mut all_ns_failed = true ;
626605 self . per_ns ( |this, ns| {
627- match this. resolve_name_in_module ( module, name, ns, false , false , Some ( span) ) {
606+ match this. resolve_name_in_module ( module, name, ns, false , Some ( span) ) {
628607 Success ( _) => all_ns_failed = false ,
629608 _ => { }
630609 }
@@ -729,8 +708,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
729708 resolution. borrow ( ) . binding ( ) . map ( |binding| ( * name, binding) )
730709 } ) . collect :: < Vec < _ > > ( ) ;
731710 for ( ( name, ns) , binding) in bindings {
732- if binding. pseudo_vis ( ) == ty:: Visibility :: Public ||
733- self . new_import_semantics && self . is_accessible ( binding. vis ) {
711+ if binding. pseudo_vis ( ) == ty:: Visibility :: Public || self . is_accessible ( binding. vis ) {
734712 let imported_binding = self . import ( binding, directive) ;
735713 let _ = self . try_define ( directive. parent , name, ns, imported_binding) ;
736714 }
@@ -761,20 +739,6 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
761739 None => continue ,
762740 } ;
763741
764- // Report conflicts
765- if !self . new_import_semantics {
766- for duplicate_glob in resolution. duplicate_globs . iter ( ) {
767- // FIXME #31337: We currently allow items to shadow glob-imported re-exports.
768- if !binding. is_import ( ) {
769- if let NameBindingKind :: Import { binding, .. } = duplicate_glob. kind {
770- if binding. is_import ( ) { continue }
771- }
772- }
773-
774- self . report_conflict ( module, name, ns, duplicate_glob, binding) ;
775- }
776- }
777-
778742 if binding. vis == ty:: Visibility :: Public &&
779743 ( binding. is_import ( ) || binding. is_extern_crate ( ) ) {
780744 let def = binding. def ( ) ;
0 commit comments