@@ -75,7 +75,6 @@ pub struct NameResolution<'a> {
75
75
single_imports : SingleImports < ' a > ,
76
76
/// The least shadowable known binding for this name, or None if there are no known bindings.
77
77
pub binding : Option < & ' a NameBinding < ' a > > ,
78
- duplicate_globs : Vec < & ' a NameBinding < ' a > > ,
79
78
}
80
79
81
80
#[ derive( Clone , Debug ) ]
@@ -141,7 +140,6 @@ impl<'a> Resolver<'a> {
141
140
module : Module < ' a > ,
142
141
name : Name ,
143
142
ns : Namespace ,
144
- allow_private_imports : bool ,
145
143
ignore_unresolved_invocations : bool ,
146
144
record_used : Option < Span > )
147
145
-> ResolveResult < & ' a NameBinding < ' a > > {
@@ -153,18 +151,8 @@ impl<'a> Resolver<'a> {
153
151
_ => return Failed ( None ) , // This happens when there is a cycle of imports
154
152
} ;
155
153
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
-
163
154
if let Some ( span) = record_used {
164
155
if let Some ( binding) = resolution. binding {
165
- if is_disallowed_private_import ( binding) {
166
- return Failed ( None ) ;
167
- }
168
156
if self . record_use ( name, ns, binding, span) {
169
157
return Success ( self . dummy_binding ) ;
170
158
}
@@ -177,9 +165,8 @@ impl<'a> Resolver<'a> {
177
165
}
178
166
179
167
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 ( ) ;
183
170
if usable { Success ( binding) } else { Failed ( None ) }
184
171
} ;
185
172
@@ -202,7 +189,7 @@ impl<'a> Resolver<'a> {
202
189
SingleImport { source, .. } => source,
203
190
_ => unreachable ! ( ) ,
204
191
} ;
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 ) {
206
193
Failed ( _) => { }
207
194
_ => return Indeterminate ,
208
195
}
@@ -224,7 +211,7 @@ impl<'a> Resolver<'a> {
224
211
for directive in module. globs . borrow ( ) . iter ( ) {
225
212
if self . is_accessible ( directive. vis . get ( ) ) {
226
213
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 ) ;
228
215
if let Indeterminate = result {
229
216
return Indeterminate ;
230
217
}
@@ -311,22 +298,17 @@ impl<'a> Resolver<'a> {
311
298
self . update_resolution ( module, name, ns, |this, resolution| {
312
299
if let Some ( old_binding) = resolution. binding {
313
300
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 ( ) ) {
318
303
} else if binding. def ( ) != old_binding. def ( ) {
319
304
resolution. binding = Some ( this. ambiguity ( old_binding, binding) ) ;
320
305
} else if !old_binding. vis . is_at_least ( binding. vis , this) {
321
306
// We are glob-importing the same item but with greater visibility.
322
307
resolution. binding = Some ( binding) ;
323
308
}
324
309
} 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 ( ) {
330
312
resolution. binding = Some ( this. ambiguity ( binding, old_binding) ) ;
331
313
} else {
332
314
resolution. binding = Some ( binding) ;
@@ -366,7 +348,7 @@ impl<'a> Resolver<'a> {
366
348
let t = f ( self , resolution) ;
367
349
368
350
match resolution. binding ( ) {
369
- _ if ! self . new_import_semantics && old_binding. is_some ( ) => return t,
351
+ _ if old_binding. is_some ( ) => return t,
370
352
None => return t,
371
353
Some ( binding) => match old_binding {
372
354
Some ( old_binding) if old_binding as * const _ == binding as * const _ => return t,
@@ -377,10 +359,7 @@ impl<'a> Resolver<'a> {
377
359
378
360
// Define `binding` in `module`s glob importers.
379
361
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 ) {
384
363
let imported_binding = self . import ( binding, directive) ;
385
364
let _ = self . try_define ( directive. parent , name, ns, imported_binding) ;
386
365
}
@@ -528,7 +507,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
528
507
self . per_ns ( |this, ns| {
529
508
if let Err ( Undetermined ) = result[ ns] . get ( ) {
530
509
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 ) {
532
511
Success ( binding) => Ok ( binding) ,
533
512
Indeterminate => Err ( Undetermined ) ,
534
513
Failed ( _) => Err ( Determined ) ,
@@ -624,7 +603,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
624
603
if all_ns_err {
625
604
let mut all_ns_failed = true ;
626
605
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) ) {
628
607
Success ( _) => all_ns_failed = false ,
629
608
_ => { }
630
609
}
@@ -729,8 +708,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
729
708
resolution. borrow ( ) . binding ( ) . map ( |binding| ( * name, binding) )
730
709
} ) . collect :: < Vec < _ > > ( ) ;
731
710
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 ) {
734
712
let imported_binding = self . import ( binding, directive) ;
735
713
let _ = self . try_define ( directive. parent , name, ns, imported_binding) ;
736
714
}
@@ -761,20 +739,6 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
761
739
None => continue ,
762
740
} ;
763
741
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
-
778
742
if binding. vis == ty:: Visibility :: Public &&
779
743
( binding. is_import ( ) || binding. is_extern_crate ( ) ) {
780
744
let def = binding. def ( ) ;
0 commit comments