@@ -1028,15 +1028,20 @@ impl<'ra> NameBindingData<'ra> {
1028
1028
#[ derive( Default , Clone ) ]
1029
1029
struct ExternPreludeEntry < ' ra > {
1030
1030
/// 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 ) > ,
1032
1034
/// Binding from an `--extern` flag, lazily populated on first use.
1033
1035
flag_binding : Cell < Option < NameBinding < ' ra > > > ,
1034
1036
/// There was no `--extern` flag introducing this name,
1035
1037
/// `flag_binding` doesn't need to be populated.
1036
1038
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
+ }
1040
1045
}
1041
1046
1042
1047
struct DeriveData {
@@ -2062,12 +2067,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2062
2067
}
2063
2068
// Avoid marking `extern crate` items that refer to a name from extern prelude,
2064
2069
// 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 ;
2071
2075
}
2072
2076
let old_used = self . import_use_map . entry ( import) . or_insert ( used) ;
2073
2077
if * old_used < used {
@@ -2226,7 +2230,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2226
2230
finalize : bool ,
2227
2231
) -> Option < NameBinding < ' ra > > {
2228
2232
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, _ ) | {
2230
2234
if finalize {
2231
2235
self . get_mut ( ) . record_use ( ident, binding, Used :: Scope ) ;
2232
2236
}
0 commit comments