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
2 changed files with 3 additions and 8 deletions
+2 -4
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 @@ fn name(&self) -> Symbol {
/// 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.
+1 -4
View File
@@ -48,10 +48,7 @@
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()
}
}