@@ -36,7 +36,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
36
36
use rustc_data_structures:: tagged_ptr:: CopyTaggedPtr ;
37
37
use rustc_hir as hir;
38
38
use rustc_hir:: def:: { CtorKind , CtorOf , DefKind , Res } ;
39
- use rustc_hir:: def_id:: { CrateNum , DefId , LocalDefId , LocalDefIdMap , CRATE_DEF_INDEX } ;
39
+ use rustc_hir:: def_id:: { CrateNum , DefId , LocalDefId , LocalDefIdMap , CRATE_DEF_ID } ;
40
40
use rustc_hir:: Node ;
41
41
use rustc_macros:: HashStable ;
42
42
use rustc_query_system:: ich:: StableHashingContext ;
@@ -319,7 +319,7 @@ impl Visibility {
319
319
pub fn from_hir ( visibility : & hir:: Visibility < ' _ > , id : hir:: HirId , tcx : TyCtxt < ' _ > ) -> Self {
320
320
match visibility. node {
321
321
hir:: VisibilityKind :: Public => Visibility :: Public ,
322
- hir:: VisibilityKind :: Crate ( _) => Visibility :: Restricted ( DefId :: local ( CRATE_DEF_INDEX ) ) ,
322
+ hir:: VisibilityKind :: Crate ( _) => Visibility :: Restricted ( CRATE_DEF_ID . to_def_id ( ) ) ,
323
323
hir:: VisibilityKind :: Restricted { ref path, .. } => match path. res {
324
324
// If there is no resolution, `resolve` will have already reported an error, so
325
325
// assume that the visibility is public to avoid reporting more privacy errors.
@@ -1992,8 +1992,8 @@ impl<'tcx> TyCtxt<'tcx> {
1992
1992
}
1993
1993
1994
1994
fn opt_item_name ( self , def_id : DefId ) -> Option < Symbol > {
1995
- if def_id . index == CRATE_DEF_INDEX {
1996
- Some ( self . crate_name ( def_id . krate ) )
1995
+ if let Some ( cnum ) = def_id . as_crate_root ( ) {
1996
+ Some ( self . crate_name ( cnum ) )
1997
1997
} else {
1998
1998
let def_key = self . def_key ( def_id) ;
1999
1999
match def_key. disambiguated_data . data {
0 commit comments