@@ -144,19 +144,10 @@ impl PartialResolvedImport {
144144 }
145145}
146146
147- // FIXME: `item_tree_id` can be derived from `id`, look into deduplicating this
148147#[ derive( Clone , Debug , Eq , PartialEq ) ]
149148enum ImportSource {
150- Use {
151- item_tree_id : ItemTreeId < item_tree:: Use > ,
152- use_tree : Idx < ast:: UseTree > ,
153- id : UseId ,
154- is_prelude : bool ,
155- } ,
156- ExternCrate {
157- item_tree_id : ItemTreeId < item_tree:: ExternCrate > ,
158- id : ExternCrateId ,
159- } ,
149+ Use { use_tree : Idx < ast:: UseTree > , id : UseId , is_prelude : bool } ,
150+ ExternCrate { id : ExternCrateId } ,
160151}
161152
162153#[ derive( Debug , Eq , PartialEq ) ]
@@ -184,7 +175,7 @@ impl Import {
184175 alias,
185176 visibility : visibility. clone ( ) ,
186177 kind,
187- source : ImportSource :: Use { item_tree_id , use_tree : idx, id, is_prelude } ,
178+ source : ImportSource :: Use { use_tree : idx, id, is_prelude } ,
188179 } ) ;
189180 } ) ;
190181 }
@@ -201,7 +192,7 @@ impl Import {
201192 alias : it. alias . clone ( ) ,
202193 visibility : visibility. clone ( ) ,
203194 kind : ImportKind :: Plain ,
204- source : ImportSource :: ExternCrate { item_tree_id , id } ,
195+ source : ImportSource :: ExternCrate { id } ,
205196 }
206197 }
207198}
@@ -1469,7 +1460,8 @@ impl DefCollector<'_> {
14691460 // heuristic, but it works in practice.
14701461 let mut diagnosed_extern_crates = FxHashSet :: default ( ) ;
14711462 for directive in & self . unresolved_imports {
1472- if let ImportSource :: ExternCrate { item_tree_id, id : _ } = directive. import . source {
1463+ if let ImportSource :: ExternCrate { id } = directive. import . source {
1464+ let item_tree_id = self . db . lookup_intern_extern_crate ( id) . id ;
14731465 let item_tree = item_tree_id. item_tree ( self . db ) ;
14741466 let extern_crate = & item_tree[ item_tree_id. value ] ;
14751467
@@ -1483,16 +1475,14 @@ impl DefCollector<'_> {
14831475 }
14841476
14851477 for directive in & self . unresolved_imports {
1486- if let ImportSource :: Use { item_tree_id, use_tree, id : _, is_prelude : _ } =
1487- directive. import . source
1488- {
1478+ if let ImportSource :: Use { use_tree, id, is_prelude : _ } = directive. import . source {
14891479 if matches ! (
14901480 ( directive. import. path. segments( ) . first( ) , & directive. import. path. kind) ,
14911481 ( Some ( krate) , PathKind :: Plain | PathKind :: Abs ) if diagnosed_extern_crates. contains( krate)
14921482 ) {
14931483 continue ;
14941484 }
1495-
1485+ let item_tree_id = self . db . lookup_intern_use ( id ) . id ;
14961486 self . def_map . diagnostics . push ( DefDiagnostic :: unresolved_import (
14971487 directive. module_id ,
14981488 item_tree_id,
0 commit comments