@@ -68,7 +68,7 @@ pub fn run_analysis(tcx: TyCtxt, old: DefId, new: DefId) -> ChangeSet {
68
68
}
69
69
70
70
// Get the visibility of the inner item, given the outer item's visibility.
71
- fn get_vis ( outer_vis : Visibility , def : Export < HirId > ) -> Visibility {
71
+ fn get_vis ( outer_vis : Visibility , def : Export ) -> Visibility {
72
72
if outer_vis == Public {
73
73
def. vis
74
74
} else {
@@ -156,7 +156,8 @@ fn diff_structure<'tcx>(
156
156
match items {
157
157
// an item pair is found
158
158
( Some ( o) , Some ( n) ) => {
159
- if let ( Def ( Mod , o_def_id) , Def ( Mod , n_def_id) ) = ( o. res , n. res ) {
159
+ let ( o_res, n_res) = ( o. res . expect_non_local ( ) , n. res . expect_non_local ( ) ) ;
160
+ if let ( Def ( Mod , o_def_id) , Def ( Mod , n_def_id) ) = ( o_res, n_res) {
160
161
if visited. insert ( ( o_def_id, n_def_id) ) {
161
162
let o_vis = get_vis ( old_vis, o) ;
162
163
let n_vis = get_vis ( new_vis, n) ;
@@ -182,16 +183,16 @@ fn diff_structure<'tcx>(
182
183
183
184
mod_queue. push_back ( ( o_def_id, n_def_id, o_vis, n_vis) ) ;
184
185
}
185
- } else if id_mapping. add_export ( o . res , n . res ) {
186
+ } else if id_mapping. add_export ( o_res , n_res ) {
186
187
// struct constructors are weird/hard - let's go shopping!
187
188
if let ( Def ( Ctor ( CtorOf :: Struct , _) , _) , Def ( Ctor ( CtorOf :: Struct , _) , _) ) =
188
- ( o . res , n . res )
189
+ ( o_res , n_res )
189
190
{
190
191
continue ;
191
192
}
192
193
193
- let o_def_id = o . res . def_id ( ) ;
194
- let n_def_id = n . res . def_id ( ) ;
194
+ let o_def_id = o_res . def_id ( ) ;
195
+ let n_def_id = n_res . def_id ( ) ;
195
196
let o_vis = get_vis ( old_vis, o) ;
196
197
let n_vis = get_vis ( new_vis, n) ;
197
198
@@ -211,7 +212,7 @@ fn diff_structure<'tcx>(
211
212
changes. add_change ( ChangeType :: ItemMadePublic , o_def_id, None ) ;
212
213
}
213
214
214
- let ( o_kind, n_kind) = match ( o . res , n . res ) {
215
+ let ( o_kind, n_kind) = match ( o_res , n_res ) {
215
216
( Res :: Def ( o_kind, _) , Res :: Def ( n_kind, _) ) => ( o_kind, n_kind) ,
216
217
_ => {
217
218
// a non-matching item pair (seriously broken though) -
@@ -257,7 +258,7 @@ fn diff_structure<'tcx>(
257
258
// that need to be compared
258
259
( Fn , Fn ) => {
259
260
diff_generics ( changes, id_mapping, tcx, true , o_def_id, n_def_id) ;
260
- diff_fn ( changes, tcx, o . res , n . res ) ;
261
+ diff_fn ( changes, tcx, o_res , n_res ) ;
261
262
}
262
263
// type aliases can declare generics, too
263
264
( TyAlias , TyAlias ) => {
@@ -268,7 +269,7 @@ fn diff_structure<'tcx>(
268
269
// fields
269
270
( Struct , Struct ) | ( Union , Union ) | ( Enum , Enum ) => {
270
271
diff_generics ( changes, id_mapping, tcx, false , o_def_id, n_def_id) ;
271
- diff_adts ( changes, id_mapping, tcx, o . res , n . res ) ;
272
+ diff_adts ( changes, id_mapping, tcx, o_res , n_res ) ;
272
273
}
273
274
// trait definitions can declare generics and require us to check
274
275
// for trait item addition and removal, as well as changes to their
@@ -298,7 +299,7 @@ fn diff_structure<'tcx>(
298
299
// only an old item is found
299
300
( Some ( o) , None ) => {
300
301
// struct constructors are weird/hard - let's go shopping!
301
- if let Def ( Ctor ( CtorOf :: Struct , _) , _) = o. res {
302
+ if let Def ( Ctor ( CtorOf :: Struct , _) , _) = o. res . expect_non_local :: < HirId > ( ) {
302
303
continue ;
303
304
}
304
305
@@ -310,7 +311,7 @@ fn diff_structure<'tcx>(
310
311
// only a new item is found
311
312
( None , Some ( n) ) => {
312
313
// struct constructors are weird/hard - let's go shopping!
313
- if let Def ( Ctor ( CtorOf :: Struct , _) , _) = n. res {
314
+ if let Def ( Ctor ( CtorOf :: Struct , _) , _) = n. res . expect_non_local :: < HirId > ( ) {
314
315
continue ;
315
316
}
316
317
@@ -327,7 +328,7 @@ fn diff_structure<'tcx>(
327
328
328
329
// finally, process item additions and removals
329
330
for n in additions {
330
- let n_def_id = n. res . def_id ( ) ;
331
+ let n_def_id = n. res . expect_non_local :: < HirId > ( ) . def_id ( ) ;
331
332
332
333
if !id_mapping. contains_new_id ( n_def_id) {
333
334
id_mapping. add_non_mapped ( n_def_id) ;
@@ -338,7 +339,7 @@ fn diff_structure<'tcx>(
338
339
}
339
340
340
341
for o in removals {
341
- let o_def_id = o. res . def_id ( ) ;
342
+ let o_def_id = o. res . expect_non_local :: < HirId > ( ) . def_id ( ) ;
342
343
343
344
// reuse an already existing path change entry, if possible
344
345
if id_mapping. contains_old_id ( o_def_id) {
0 commit comments