@@ -12,6 +12,7 @@ use triomphe::Arc;
12
12
use crate :: {
13
13
body:: scope:: { ExprScopes , ScopeId } ,
14
14
builtin_type:: BuiltinType ,
15
+ data:: ExternCrateDeclData ,
15
16
db:: DefDatabase ,
16
17
generics:: { GenericParams , TypeOrConstParamData } ,
17
18
hir:: { BindingId , ExprId , LabelId } ,
@@ -451,6 +452,7 @@ impl Resolver {
451
452
def_map[ module_id] . scope . entries ( ) . for_each ( |( name, def) | {
452
453
res. add_per_ns ( name, def) ;
453
454
} ) ;
455
+
454
456
def_map[ module_id] . scope . legacy_macros ( ) . for_each ( |( name, macs) | {
455
457
macs. iter ( ) . for_each ( |& mac| {
456
458
res. add ( name, ScopeDef :: ModuleDef ( ModuleDefId :: MacroId ( mac) ) ) ;
@@ -474,6 +476,23 @@ impl Resolver {
474
476
res. map
475
477
}
476
478
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
+
477
496
pub fn traits_in_scope ( & self , db : & dyn DefDatabase ) -> FxHashSet < TraitId > {
478
497
// FIXME(trait_alias): Trait alias brings aliased traits in scope! Note that supertraits of
479
498
// aliased traits are NOT brought in scope (unless also aliased).
0 commit comments