@@ -6,7 +6,7 @@ use rustc_data_structures::fx::FxHashMap;
6
6
use rustc_data_structures:: sso:: SsoHashSet ;
7
7
use rustc_hir as hir;
8
8
use rustc_hir:: def:: { self , CtorKind , DefKind , Namespace } ;
9
- use rustc_hir:: def_id:: { DefId , DefIdSet , CRATE_DEF_INDEX , LOCAL_CRATE } ;
9
+ use rustc_hir:: def_id:: { DefId , DefIdSet , CRATE_DEF_ID , LOCAL_CRATE } ;
10
10
use rustc_hir:: definitions:: { DefPathData , DefPathDataName , DisambiguatedDefPathData } ;
11
11
use rustc_hir:: ItemKind ;
12
12
use rustc_session:: config:: TrimmedDefPaths ;
@@ -336,9 +336,7 @@ pub trait PrettyPrinter<'tcx>:
336
336
337
337
// If `def_id` is a direct or injected extern crate, return the
338
338
// path to the crate followed by the path to the item within the crate.
339
- if def_id. index == CRATE_DEF_INDEX {
340
- let cnum = def_id. krate ;
341
-
339
+ if let Some ( cnum) = def_id. as_crate_root ( ) {
342
340
if cnum == LOCAL_CRATE {
343
341
return Ok ( ( self . path_crate ( cnum) ?, true ) ) ;
344
342
}
@@ -2228,11 +2226,11 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
2228
2226
ty:: BrNamed ( _, _) => br. kind ,
2229
2227
ty:: BrAnon ( i) => {
2230
2228
let name = region_map[ & ( i + 1 ) ] ;
2231
- ty:: BrNamed ( DefId :: local ( CRATE_DEF_INDEX ) , name)
2229
+ ty:: BrNamed ( CRATE_DEF_ID . to_def_id ( ) , name)
2232
2230
}
2233
2231
ty:: BrEnv => {
2234
2232
let name = region_map[ & 0 ] ;
2235
- ty:: BrNamed ( DefId :: local ( CRATE_DEF_INDEX ) , name)
2233
+ ty:: BrNamed ( CRATE_DEF_ID . to_def_id ( ) , name)
2236
2234
}
2237
2235
} ;
2238
2236
self . tcx . mk_region ( ty:: ReLateBound (
@@ -2258,7 +2256,7 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
2258
2256
}
2259
2257
} ;
2260
2258
do_continue ( & mut self , name) ;
2261
- ty:: BrNamed ( DefId :: local ( CRATE_DEF_INDEX ) , name)
2259
+ ty:: BrNamed ( CRATE_DEF_ID . to_def_id ( ) , name)
2262
2260
}
2263
2261
} ;
2264
2262
tcx. mk_region ( ty:: ReLateBound ( ty:: INNERMOST , ty:: BoundRegion { var : br. var , kind } ) )
@@ -2693,7 +2691,7 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N
2693
2691
let mut seen_defs: DefIdSet = Default :: default ( ) ;
2694
2692
2695
2693
for & cnum in tcx. crates ( ( ) ) . iter ( ) {
2696
- let def_id = DefId { krate : cnum, index : CRATE_DEF_INDEX } ;
2694
+ let def_id = cnum. as_def_id ( ) ;
2697
2695
2698
2696
// Ignore crates that are not direct dependencies.
2699
2697
match tcx. extern_crate ( def_id) {
0 commit comments