@@ -1028,15 +1028,20 @@ impl<'ra> NameBindingData<'ra> {
10281028#[ derive( Default , Clone ) ]
10291029struct ExternPreludeEntry < ' ra > {
10301030 /// Binding from an `extern crate` item.
1031- item_binding : Option < NameBinding < ' ra > > ,
1031+ /// The boolean flag is true is `item_binding` is non-redundant, happens either when
1032+ /// `only_item` is true, or when `extern crate` introducing `item_binding` used renaming.
1033+ item_binding : Option < ( NameBinding < ' ra > , /* introduced by item */ bool ) > ,
10321034 /// Binding from an `--extern` flag, lazily populated on first use.
10331035 flag_binding : Cell < Option < NameBinding < ' ra > > > ,
10341036 /// There was no `--extern` flag introducing this name,
10351037 /// `flag_binding` doesn't need to be populated.
10361038 only_item : bool ,
1037- /// `item_binding` is non-redundant, happens either when `only_item` is true,
1038- /// or when `extern crate` introducing `item_binding` used renaming.
1039- introduced_by_item : bool ,
1039+ }
1040+
1041+ impl ExternPreludeEntry < ' _ > {
1042+ fn introduced_by_item ( & self ) -> bool {
1043+ matches ! ( self . item_binding, Some ( ( _, true ) ) )
1044+ }
10401045}
10411046
10421047struct DeriveData {
@@ -2062,12 +2067,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
20622067 }
20632068 // Avoid marking `extern crate` items that refer to a name from extern prelude,
20642069 // but not introduce it, as used if they are accessed from lexical scope.
2065- if used == Used :: Scope {
2066- if let Some ( entry) = self . extern_prelude . get ( & Macros20NormalizedIdent :: new ( ident) ) {
2067- if !entry. introduced_by_item && entry. item_binding == Some ( used_binding) {
2068- return ;
2069- }
2070- }
2070+ if used == Used :: Scope
2071+ && let Some ( entry) = self . extern_prelude . get ( & Macros20NormalizedIdent :: new ( ident) )
2072+ && entry. item_binding == Some ( ( used_binding, false ) )
2073+ {
2074+ return ;
20712075 }
20722076 let old_used = self . import_use_map . entry ( import) . or_insert ( used) ;
20732077 if * old_used < used {
@@ -2226,7 +2230,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
22262230 finalize : bool ,
22272231 ) -> Option < NameBinding < ' ra > > {
22282232 let entry = self . extern_prelude . get ( & Macros20NormalizedIdent :: new ( ident) ) ;
2229- entry. and_then ( |entry| entry. item_binding ) . map ( |binding| {
2233+ entry. and_then ( |entry| entry. item_binding ) . map ( |( binding, _ ) | {
22302234 if finalize {
22312235 self . get_mut ( ) . record_use ( ident, binding, Used :: Scope ) ;
22322236 }
0 commit comments