Skip to content

Commit ca935dd

Browse files
committed
Make tcx.stable_crate_id() faster
1 parent e95bd03 commit ca935dd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

compiler/rustc_middle/src/ty/context.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1299,8 +1299,12 @@ impl<'tcx> TyCtxt<'tcx> {
12991299
}
13001300

13011301
#[inline]
1302-
pub fn stable_crate_id(self, cnum: CrateNum) -> StableCrateId {
1303-
self.def_path_hash(cnum.as_def_id()).stable_crate_id()
1302+
pub fn stable_crate_id(self, crate_num: CrateNum) -> StableCrateId {
1303+
if crate_num == LOCAL_CRATE {
1304+
self.sess.local_stable_crate_id()
1305+
} else {
1306+
self.cstore.stable_crate_id_untracked(crate_num)
1307+
}
13041308
}
13051309

13061310
pub fn def_path_debug_str(self, def_id: DefId) -> String {

0 commit comments

Comments
 (0)