@@ -12,6 +12,7 @@ use triomphe::Arc;
1212use crate :: {
1313 body:: scope:: { ExprScopes , ScopeId } ,
1414 builtin_type:: BuiltinType ,
15+ data:: ExternCrateDeclData ,
1516 db:: DefDatabase ,
1617 generics:: { GenericParams , TypeOrConstParamData } ,
1718 hir:: { BindingId , ExprId , LabelId } ,
@@ -451,6 +452,7 @@ impl Resolver {
451452 def_map[ module_id] . scope . entries ( ) . for_each ( |( name, def) | {
452453 res. add_per_ns ( name, def) ;
453454 } ) ;
455+
454456 def_map[ module_id] . scope . legacy_macros ( ) . for_each ( |( name, macs) | {
455457 macs. iter ( ) . for_each ( |& mac| {
456458 res. add ( name, ScopeDef :: ModuleDef ( ModuleDefId :: MacroId ( mac) ) ) ;
@@ -474,6 +476,23 @@ impl Resolver {
474476 res. map
475477 }
476478
479+ pub fn extern_crate_decls_in_scope < ' a > (
480+ & ' a self ,
481+ db : & ' a dyn DefDatabase ,
482+ ) -> impl Iterator < Item = Name > + ' a {
483+ self . module_scope . def_map [ self . module_scope . module_id ]
484+ . scope
485+ . extern_crate_decls ( )
486+ . map ( |id| ExternCrateDeclData :: extern_crate_decl_data_query ( db, id) . name . clone ( ) )
487+ }
488+
489+ pub fn extern_crates_in_scope < ' a > ( & ' a self ) -> impl Iterator < Item = ( Name , ModuleId ) > + ' a {
490+ self . module_scope
491+ . def_map
492+ . extern_prelude ( )
493+ . map ( |( name, module_id) | ( name. clone ( ) , module_id. 0 . into ( ) ) )
494+ }
495+
477496 pub fn traits_in_scope ( & self , db : & dyn DefDatabase ) -> FxHashSet < TraitId > {
478497 // FIXME(trait_alias): Trait alias brings aliased traits in scope! Note that supertraits of
479498 // aliased traits are NOT brought in scope (unless also aliased).
0 commit comments