Skip to content

Commit 141d2f3

Browse files
committed
Replace usages of Context.def_name
Use `DefId.name` and `DefId.trimmed_name` instead
1 parent 298fb8a commit 141d2f3

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

compiler/stable_mir/src/crate_def.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ pub trait CrateDef {
4141

4242
/// Return the fully qualified name of the current definition.
4343
fn name(&self) -> Symbol {
44-
let def_id = self.def_id();
45-
with(|cx| cx.def_name(def_id, false))
44+
self.def_id().name()
4645
}
4746

4847
/// Return a trimmed name of this definition.
@@ -56,8 +55,7 @@ pub trait CrateDef {
5655
/// For example, this function may shorten `std::vec::Vec` to just `Vec`,
5756
/// as long as there is no other `Vec` importable anywhere.
5857
fn trimmed_name(&self) -> Symbol {
59-
let def_id = self.def_id();
60-
with(|cx| cx.def_name(def_id, true))
58+
self.def_id().trimmed_name()
6159
}
6260

6361
/// Return information about the crate where this definition is declared.

compiler/stable_mir/src/lib.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ pub type CrateNum = usize;
4848

4949
impl Debug for DefId {
5050
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
51-
f.debug_struct("DefId")
52-
.field("id", &self.0)
53-
.field("name", &with(|cx| cx.def_name(*self, false)))
54-
.finish()
51+
f.debug_struct("DefId").field("id", &self.0).field("name", &self.name()).finish()
5552
}
5653
}
5754

0 commit comments

Comments
 (0)