From d9f28b7b701321d24ff9930b3f7b5d93b6fd671f Mon Sep 17 00:00:00 2001 From: Goldstein Date: Sat, 16 Jul 2022 21:30:17 +0300 Subject: [PATCH] fix ICE in Definitions::create_def --- compiler/rustc_hir/src/definitions.rs | 7 ++++++- compiler/rustc_middle/src/ty/context.rs | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_hir/src/definitions.rs b/compiler/rustc_hir/src/definitions.rs index 5f8801cc4e2..c2c551e78a4 100644 --- a/compiler/rustc_hir/src/definitions.rs +++ b/compiler/rustc_hir/src/definitions.rs @@ -338,7 +338,12 @@ pub fn new(stable_crate_id: StableCrateId) -> Definitions { /// Adds a definition with a parent definition. pub fn create_def(&mut self, parent: LocalDefId, data: DefPathData) -> LocalDefId { - debug!("create_def(parent={:?}, data={:?})", parent, data); + // We can't use `Debug` implementation for `LocalDefId` here, since it tries to acquire a + // reference to `Definitions` and we're already holding a mutable reference. + debug!( + "create_def(parent={}, data={data:?})", + self.def_path(parent).to_string_no_crate_verbose(), + ); // The root node must be created with `create_root_def()`. assert!(data != DefPathData::CrateRoot); diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 2714493b9fc..541763e294f 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1459,11 +1459,11 @@ pub fn def_path_debug_str(self, def_id: DefId) -> String { }; format!( - "{}[{}]{}", + "{}[{:04x}]{}", crate_name, // Don't print the whole stable crate id. That's just // annoying in debug output. - &(format!("{:08x}", stable_crate_id.to_u64()))[..4], + stable_crate_id.to_u64() >> 8 * 6, self.def_path(def_id).to_string_no_crate_verbose() ) }