Skip to content

Commit d9f28b7

Browse files
committed
fix ICE in Definitions::create_def
1 parent e5a7d8f commit d9f28b7

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

compiler/rustc_hir/src/definitions.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,12 @@ impl Definitions {
338338

339339
/// Adds a definition with a parent definition.
340340
pub fn create_def(&mut self, parent: LocalDefId, data: DefPathData) -> LocalDefId {
341-
debug!("create_def(parent={:?}, data={:?})", parent, data);
341+
// We can't use `Debug` implementation for `LocalDefId` here, since it tries to acquire a
342+
// reference to `Definitions` and we're already holding a mutable reference.
343+
debug!(
344+
"create_def(parent={}, data={data:?})",
345+
self.def_path(parent).to_string_no_crate_verbose(),
346+
);
342347

343348
// The root node must be created with `create_root_def()`.
344349
assert!(data != DefPathData::CrateRoot);

compiler/rustc_middle/src/ty/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,11 +1459,11 @@ impl<'tcx> TyCtxt<'tcx> {
14591459
};
14601460

14611461
format!(
1462-
"{}[{}]{}",
1462+
"{}[{:04x}]{}",
14631463
crate_name,
14641464
// Don't print the whole stable crate id. That's just
14651465
// annoying in debug output.
1466-
&(format!("{:08x}", stable_crate_id.to_u64()))[..4],
1466+
stable_crate_id.to_u64() >> 8 * 6,
14671467
self.def_path(def_id).to_string_no_crate_verbose()
14681468
)
14691469
}

0 commit comments

Comments
 (0)