fix ICE in Definitions::create_def

This commit is contained in:
Goldstein 2022-07-16 21:30:17 +03:00
parent e5a7d8f945
commit d9f28b7b70
No known key found for this signature in database
GPG Key ID: DE6031ABA0BB269A
2 changed files with 8 additions and 3 deletions

View File

@ -338,7 +338,12 @@ pub fn new(stable_crate_id: StableCrateId) -> Definitions {
/// Adds a definition with a parent definition. /// Adds a definition with a parent definition.
pub fn create_def(&mut self, parent: LocalDefId, data: DefPathData) -> LocalDefId { 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()`. // The root node must be created with `create_root_def()`.
assert!(data != DefPathData::CrateRoot); assert!(data != DefPathData::CrateRoot);

View File

@ -1459,11 +1459,11 @@ pub fn def_path_debug_str(self, def_id: DefId) -> String {
}; };
format!( format!(
"{}[{}]{}", "{}[{:04x}]{}",
crate_name, crate_name,
// Don't print the whole stable crate id. That's just // Don't print the whole stable crate id. That's just
// annoying in debug output. // 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() self.def_path(def_id).to_string_no_crate_verbose()
) )
} }