11//! Describes items defined or visible (ie, imported) in a certain scope.
22//! This is shared between modules and blocks.
33
4- use std:: collections:: hash_map:: Entry ;
5-
64use base_db:: CrateId ;
75use hir_expand:: { attrs:: AttrId , db:: ExpandDatabase , name:: Name , AstId , MacroCallId } ;
6+ use indexmap:: map:: Entry ;
87use itertools:: Itertools ;
98use la_arena:: Idx ;
109use once_cell:: sync:: Lazy ;
@@ -17,8 +16,8 @@ use crate::{
1716 db:: DefDatabase ,
1817 per_ns:: PerNs ,
1918 visibility:: { Visibility , VisibilityExplicitness } ,
20- AdtId , BuiltinType , ConstId , ExternCrateId , HasModule , ImplId , LocalModuleId , Lookup , MacroId ,
21- ModuleDefId , ModuleId , TraitId , UseId ,
19+ AdtId , BuiltinType , ConstId , ExternCrateId , FxIndexMap , HasModule , ImplId , LocalModuleId ,
20+ Lookup , MacroId , ModuleDefId , ModuleId , TraitId , UseId ,
2221} ;
2322
2423#[ derive( Debug , Default ) ]
@@ -67,9 +66,9 @@ pub struct ItemScope {
6766 /// Defs visible in this scope. This includes `declarations`, but also
6867 /// imports. The imports belong to this module and can be resolved by using them on
6968 /// the `use_imports_*` fields.
70- types : FxHashMap < Name , ( ModuleDefId , Visibility , Option < ImportOrExternCrate > ) > ,
71- values : FxHashMap < Name , ( ModuleDefId , Visibility , Option < ImportId > ) > ,
72- macros : FxHashMap < Name , ( MacroId , Visibility , Option < ImportId > ) > ,
69+ types : FxIndexMap < Name , ( ModuleDefId , Visibility , Option < ImportOrExternCrate > ) > ,
70+ values : FxIndexMap < Name , ( ModuleDefId , Visibility , Option < ImportId > ) > ,
71+ macros : FxIndexMap < Name , ( MacroId , Visibility , Option < ImportId > ) > ,
7372 unresolved : FxHashSet < Name > ,
7473
7574 /// The defs declared in this scope. Each def has a single scope where it is
@@ -118,7 +117,7 @@ struct DeriveMacroInvocation {
118117 derive_call_ids : SmallVec < [ Option < MacroCallId > ; 1 ] > ,
119118}
120119
121- pub ( crate ) static BUILTIN_SCOPE : Lazy < FxHashMap < Name , PerNs > > = Lazy :: new ( || {
120+ pub ( crate ) static BUILTIN_SCOPE : Lazy < FxIndexMap < Name , PerNs > > = Lazy :: new ( || {
122121 BuiltinType :: all_builtin_types ( )
123122 . iter ( )
124123 . map ( |( name, ty) | ( name. clone ( ) , PerNs :: types ( ( * ty) . into ( ) , Visibility :: Public , None ) ) )
0 commit comments