Skip to content

Commit

Permalink
Access stable_crate_id directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Jun 9, 2021
1 parent a246751 commit f387cff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
use rustc_session::config::{BorrowckMode, CrateType, OutputFilenames};
use rustc_session::lint::{Level, Lint};
use rustc_session::Session;
use rustc_span::def_id::StableCrateId;
use rustc_span::source_map::MultiSpan;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
use rustc_span::{Span, DUMMY_SP};
Expand Down Expand Up @@ -1264,6 +1265,11 @@ impl<'tcx> TyCtxt<'tcx> {
}
}

#[inline]
pub fn stable_crate_id(self, cnum: CrateNum) -> StableCrateId {
self.def_path_hash(cnum.as_def_id()).stable_crate_id()
}

pub fn def_path_debug_str(self, def_id: DefId) -> String {
// We are explicitly not going through queries here in order to get
// crate name and disambiguator since this code is called from debug!()
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_middle/src/ty/query/on_disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1022,8 +1022,7 @@ where
E: 'a + OpaqueEncoder,
{
fn encode(&self, s: &mut CacheEncoder<'a, 'tcx, E>) -> Result<(), E::Error> {
let def_path_hash = s.tcx.def_path_hash(self.as_def_id());
def_path_hash.stable_crate_id().encode(s)
s.tcx.stable_crate_id(*self).encode(s)
}
}

Expand Down

0 comments on commit f387cff

Please sign in to comment.