@@ -77,8 +77,8 @@ use crate::{
77
77
path:: ModPath ,
78
78
per_ns:: PerNs ,
79
79
visibility:: Visibility ,
80
- AstId , BlockId , BlockLoc , CrateRootModuleId , FunctionId , LocalModuleId , Lookup , MacroExpander ,
81
- MacroId , ModuleId , ProcMacroId ,
80
+ AstId , BlockId , BlockLoc , CrateRootModuleId , ExternCrateId , FunctionId , LocalModuleId , Lookup ,
81
+ MacroExpander , MacroId , ModuleId , ProcMacroId , UseId ,
82
82
} ;
83
83
84
84
/// Contains the results of (early) name resolution.
@@ -105,10 +105,10 @@ pub struct DefMap {
105
105
/// The prelude is empty for non-block DefMaps (unless `#[prelude_import]` was used,
106
106
/// but that attribute is nightly and when used in a block, it affects resolution globally
107
107
/// so we aren't handling this correctly anyways).
108
- prelude : Option < ModuleId > ,
108
+ prelude : Option < ( ModuleId , Option < UseId > ) > ,
109
109
/// `macro_use` prelude that contains macros from `#[macro_use]`'d external crates. Note that
110
110
/// this contains all kinds of macro, not just `macro_rules!` macro.
111
- macro_use_prelude : FxHashMap < Name , MacroId > ,
111
+ macro_use_prelude : FxHashMap < Name , ( MacroId , Option < ExternCrateId > ) > ,
112
112
113
113
/// Tracks which custom derives are in scope for an item, to allow resolution of derive helper
114
114
/// attributes.
@@ -125,7 +125,7 @@ pub struct DefMap {
125
125
#[ derive( Clone , Debug , PartialEq , Eq ) ]
126
126
struct DefMapCrateData {
127
127
/// The extern prelude which contains all root modules of external crates that are in scope.
128
- extern_prelude : FxHashMap < Name , CrateRootModuleId > ,
128
+ extern_prelude : FxHashMap < Name , ( CrateRootModuleId , Option < ExternCrateId > ) > ,
129
129
130
130
/// Side table for resolving derive helpers.
131
131
exported_derives : FxHashMap < MacroDefId , Box < [ Name ] > > ,
@@ -427,15 +427,19 @@ impl DefMap {
427
427
self . block . map ( |block| block. block )
428
428
}
429
429
430
- pub ( crate ) fn prelude ( & self ) -> Option < ModuleId > {
430
+ pub ( crate ) fn prelude ( & self ) -> Option < ( ModuleId , Option < UseId > ) > {
431
431
self . prelude
432
432
}
433
433
434
- pub ( crate ) fn extern_prelude ( & self ) -> impl Iterator < Item = ( & Name , ModuleId ) > + ' _ {
435
- self . data . extern_prelude . iter ( ) . map ( |( name, & def) | ( name, def. into ( ) ) )
434
+ pub ( crate ) fn extern_prelude (
435
+ & self ,
436
+ ) -> impl Iterator < Item = ( & Name , ( CrateRootModuleId , Option < ExternCrateId > ) ) > + ' _ {
437
+ self . data . extern_prelude . iter ( ) . map ( |( name, & def) | ( name, def) )
436
438
}
437
439
438
- pub ( crate ) fn macro_use_prelude ( & self ) -> impl Iterator < Item = ( & Name , MacroId ) > + ' _ {
440
+ pub ( crate ) fn macro_use_prelude (
441
+ & self ,
442
+ ) -> impl Iterator < Item = ( & Name , ( MacroId , Option < ExternCrateId > ) ) > + ' _ {
439
443
self . macro_use_prelude . iter ( ) . map ( |( name, & def) | ( name, def) )
440
444
}
441
445
0 commit comments