@@ -144,19 +144,10 @@ impl PartialResolvedImport {
144
144
}
145
145
}
146
146
147
- // FIXME: `item_tree_id` can be derived from `id`, look into deduplicating this
148
147
#[ derive( Clone , Debug , Eq , PartialEq ) ]
149
148
enum 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 } ,
160
151
}
161
152
162
153
#[ derive( Debug , Eq , PartialEq ) ]
@@ -184,7 +175,7 @@ impl Import {
184
175
alias,
185
176
visibility : visibility. clone ( ) ,
186
177
kind,
187
- source : ImportSource :: Use { item_tree_id , use_tree : idx, id, is_prelude } ,
178
+ source : ImportSource :: Use { use_tree : idx, id, is_prelude } ,
188
179
} ) ;
189
180
} ) ;
190
181
}
@@ -201,7 +192,7 @@ impl Import {
201
192
alias : it. alias . clone ( ) ,
202
193
visibility : visibility. clone ( ) ,
203
194
kind : ImportKind :: Plain ,
204
- source : ImportSource :: ExternCrate { item_tree_id , id } ,
195
+ source : ImportSource :: ExternCrate { id } ,
205
196
}
206
197
}
207
198
}
@@ -1469,7 +1460,8 @@ impl DefCollector<'_> {
1469
1460
// heuristic, but it works in practice.
1470
1461
let mut diagnosed_extern_crates = FxHashSet :: default ( ) ;
1471
1462
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 ;
1473
1465
let item_tree = item_tree_id. item_tree ( self . db ) ;
1474
1466
let extern_crate = & item_tree[ item_tree_id. value ] ;
1475
1467
@@ -1483,16 +1475,14 @@ impl DefCollector<'_> {
1483
1475
}
1484
1476
1485
1477
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 {
1489
1479
if matches ! (
1490
1480
( directive. import. path. segments( ) . first( ) , & directive. import. path. kind) ,
1491
1481
( Some ( krate) , PathKind :: Plain | PathKind :: Abs ) if diagnosed_extern_crates. contains( krate)
1492
1482
) {
1493
1483
continue ;
1494
1484
}
1495
-
1485
+ let item_tree_id = self . db . lookup_intern_use ( id ) . id ;
1496
1486
self . def_map . diagnostics . push ( DefDiagnostic :: unresolved_import (
1497
1487
directive. module_id ,
1498
1488
item_tree_id,
0 commit comments