about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNotLebedev <notlebedev@gmail.com>2025-03-01 10:57:17 +0300
committerNotLebedev <notlebedev@gmail.com>2025-03-02 12:11:18 +0300
commit141d2f3f025c649e92e71dc1f22198cb265c435a (patch)
tree666a42f9330102261e3bef1e5cea0029399ac631
parent298fb8af65cdbecd81ed4a51d3602641caaad909 (diff)
downloadrust-141d2f3f025c649e92e71dc1f22198cb265c435a.tar.gz
rust-141d2f3f025c649e92e71dc1f22198cb265c435a.zip
Replace usages of `Context.def_name`
Use `DefId.name` and `DefId.trimmed_name` instead
-rw-r--r--compiler/stable_mir/src/crate_def.rs6
-rw-r--r--compiler/stable_mir/src/lib.rs5
2 files changed, 3 insertions, 8 deletions
diff --git a/compiler/stable_mir/src/crate_def.rs b/compiler/stable_mir/src/crate_def.rs
index 469e8a7cf89..d36426d5a99 100644
--- a/compiler/stable_mir/src/crate_def.rs
+++ b/compiler/stable_mir/src/crate_def.rs
@@ -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.
diff --git a/compiler/stable_mir/src/lib.rs b/compiler/stable_mir/src/lib.rs
index 0b4cebadad1..8df36e23c4a 100644
--- a/compiler/stable_mir/src/lib.rs
+++ b/compiler/stable_mir/src/lib.rs
@@ -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()
     }
 }