@@ -36,7 +36,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
3636use rustc_data_structures:: tagged_ptr:: CopyTaggedPtr ;
3737use rustc_hir as hir;
3838use 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 } ;
4040use rustc_hir:: Node ;
4141use rustc_macros:: HashStable ;
4242use rustc_query_system:: ich:: StableHashingContext ;
@@ -319,7 +319,7 @@ impl Visibility {
319319 pub fn from_hir ( visibility : & hir:: Visibility < ' _ > , id : hir:: HirId , tcx : TyCtxt < ' _ > ) -> Self {
320320 match visibility. node {
321321 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 ( ) ) ,
323323 hir:: VisibilityKind :: Restricted { ref path, .. } => match path. res {
324324 // If there is no resolution, `resolve` will have already reported an error, so
325325 // assume that the visibility is public to avoid reporting more privacy errors.
@@ -1992,8 +1992,8 @@ impl<'tcx> TyCtxt<'tcx> {
19921992 }
19931993
19941994 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 ) )
19971997 } else {
19981998 let def_key = self . def_key ( def_id) ;
19991999 match def_key. disambiguated_data . data {
0 commit comments