@@ -26,12 +26,11 @@ use syntax::ast;
26
26
use triomphe:: Arc ;
27
27
28
28
use crate :: {
29
- AdtId , AstId , AstIdWithPath , ConstLoc , CrateRootModuleId , EnumLoc , EnumVariantLoc ,
30
- ExternBlockLoc , ExternCrateId , ExternCrateLoc , FunctionId , FunctionLoc , ImplLoc , Intern ,
31
- ItemContainerId , LocalModuleId , Lookup , Macro2Id , Macro2Loc , MacroExpander , MacroId ,
32
- MacroRulesId , MacroRulesLoc , MacroRulesLocFlags , ModuleDefId , ModuleId , ProcMacroId ,
33
- ProcMacroLoc , StaticLoc , StructLoc , TraitAliasLoc , TraitLoc , TypeAliasLoc , UnionLoc ,
34
- UnresolvedMacro , UseId , UseLoc ,
29
+ AdtId , AstId , AstIdWithPath , ConstLoc , CrateRootModuleId , EnumLoc , ExternBlockLoc ,
30
+ ExternCrateId , ExternCrateLoc , FunctionId , FunctionLoc , ImplLoc , Intern , ItemContainerId ,
31
+ LocalModuleId , Lookup , Macro2Id , Macro2Loc , MacroExpander , MacroId , MacroRulesId ,
32
+ MacroRulesLoc , MacroRulesLocFlags , ModuleDefId , ModuleId , ProcMacroId , ProcMacroLoc , StaticLoc ,
33
+ StructLoc , TraitAliasLoc , TraitLoc , TypeAliasLoc , UnionLoc , UnresolvedMacro , UseId , UseLoc ,
35
34
attr:: Attrs ,
36
35
db:: DefDatabase ,
37
36
item_scope:: { GlobId , ImportId , ImportOrExternCrate , PerNsGlobImports } ,
@@ -971,27 +970,16 @@ impl DefCollector<'_> {
971
970
Some ( ModuleDefId :: AdtId ( AdtId :: EnumId ( e) ) ) => {
972
971
cov_mark:: hit!( glob_enum) ;
973
972
// glob import from enum => just import all the variants
974
-
975
- // We need to check if the def map the enum is from is us, if it is we can't
976
- // call the def-map query since we are currently constructing it!
977
- let loc = e. lookup ( self . db ) ;
978
- let tree = loc. id . item_tree ( self . db ) ;
979
- let current_def_map = self . def_map . krate == loc. container . krate
980
- && self . def_map . block_id ( ) == loc. container . block ;
981
- let def_map;
982
- let resolutions = if current_def_map {
983
- & self . def_map . enum_definitions [ & e]
984
- } else {
985
- def_map = loc. container . def_map ( self . db ) ;
986
- & def_map. enum_definitions [ & e]
987
- }
988
- . iter ( )
989
- . map ( |& variant| {
990
- let name = tree[ variant. lookup ( self . db ) . id . value ] . name . clone ( ) ;
991
- let res = PerNs :: both ( variant. into ( ) , variant. into ( ) , vis, None ) ;
992
- ( Some ( name) , res)
993
- } )
994
- . collect :: < Vec < _ > > ( ) ;
973
+ let resolutions = self
974
+ . db
975
+ . enum_variants ( e)
976
+ . variants
977
+ . iter ( )
978
+ . map ( |& ( variant, ref name) | {
979
+ let res = PerNs :: both ( variant. into ( ) , variant. into ( ) , vis, None ) ;
980
+ ( Some ( name. clone ( ) ) , res)
981
+ } )
982
+ . collect :: < Vec < _ > > ( ) ;
995
983
self . update (
996
984
module_id,
997
985
& resolutions,
@@ -1894,39 +1882,6 @@ impl ModCollector<'_, '_> {
1894
1882
1895
1883
let vis = resolve_vis ( def_map, local_def_map, & self . item_tree [ it. visibility ] ) ;
1896
1884
update_def ( self . def_collector , enum_. into ( ) , & it. name , vis, false ) ;
1897
-
1898
- let mut index = 0 ;
1899
- let variants = FileItemTreeId :: range_iter ( it. variants . clone ( ) )
1900
- . filter_map ( |variant| {
1901
- let is_enabled = self
1902
- . item_tree
1903
- . attrs ( db, krate, variant. into ( ) )
1904
- . cfg ( )
1905
- . and_then ( |cfg| self . is_cfg_enabled ( & cfg) . not ( ) . then_some ( cfg) )
1906
- . map_or ( Ok ( ( ) ) , Err ) ;
1907
- match is_enabled {
1908
- Err ( cfg) => {
1909
- self . emit_unconfigured_diagnostic (
1910
- self . tree_id ,
1911
- variant. into ( ) ,
1912
- & cfg,
1913
- ) ;
1914
- None
1915
- }
1916
- Ok ( ( ) ) => Some ( {
1917
- let loc = EnumVariantLoc {
1918
- id : ItemTreeId :: new ( self . tree_id , variant) ,
1919
- parent : enum_,
1920
- index,
1921
- }
1922
- . intern ( db) ;
1923
- index += 1 ;
1924
- loc
1925
- } ) ,
1926
- }
1927
- } )
1928
- . collect ( ) ;
1929
- self . def_collector . def_map . enum_definitions . insert ( enum_, variants) ;
1930
1885
}
1931
1886
ModItem :: Const ( id) => {
1932
1887
let it = & self . item_tree [ id] ;
0 commit comments