Replace usages of Context.def_name

Use `DefId.name` and `DefId.trimmed_name` instead
This commit is contained in:
NotLebedev 2025-03-01 10:57:17 +03:00
parent 298fb8af65
commit 141d2f3f02
No known key found for this signature in database
GPG key ID: 4AC94C2E52F6E5F4
2 changed files with 3 additions and 8 deletions

View file

@ -41,8 +41,7 @@ pub trait CrateDef {
/// Return the fully qualified name of the current definition.
fn name(&self) -> Symbol {
let def_id = self.def_id();
with(|cx| cx.def_name(def_id, false))
self.def_id().name()
}
/// Return a trimmed name of this definition.
@ -56,8 +55,7 @@ pub trait CrateDef {
/// For example, this function may shorten `std::vec::Vec` to just `Vec`,
/// as long as there is no other `Vec` importable anywhere.
fn trimmed_name(&self) -> Symbol {
let def_id = self.def_id();
with(|cx| cx.def_name(def_id, true))
self.def_id().trimmed_name()
}
/// Return information about the crate where this definition is declared.

View file

@ -48,10 +48,7 @@ pub type CrateNum = usize;
impl Debug for DefId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DefId")
.field("id", &self.0)
.field("name", &with(|cx| cx.def_name(*self, false)))
.finish()
f.debug_struct("DefId").field("id", &self.0).field("name", &self.name()).finish()
}
}