Skip to content

Commit 51acc57

Browse files
committed
canon_abi: make to_erased_extern_abi just a detail in formatting
1 parent 81a964c commit 51acc57

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

compiler/rustc_abi/src/canon_abi.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,10 @@ pub enum CanonAbi {
5050

5151
impl fmt::Display for CanonAbi {
5252
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
53-
self.to_erased_extern_abi().as_str().fmt(f)
54-
}
55-
}
56-
57-
impl CanonAbi {
58-
/// convert to the ExternAbi that *shares a string* with this CanonAbi
59-
///
60-
/// A target-insensitive mapping of CanonAbi to ExternAbi, convenient for "forwarding" impls.
61-
/// Importantly, the set of CanonAbi values is a logical *subset* of ExternAbi values,
62-
/// so this is injective: if you take an ExternAbi to a CanonAbi and back, you have lost data.
63-
const fn to_erased_extern_abi(self) -> ExternAbi {
64-
match self {
53+
// convert to the ExternAbi that *shares a string* with this CanonAbi.
54+
// FIXME: ideally we'd avoid printing `CanonAbi`, and preserve `ExternAbi` everywhere
55+
// that we need to generate error messages.
56+
let erased_abi = match self {
6557
CanonAbi::C => ExternAbi::C { unwind: false },
6658
CanonAbi::Rust => ExternAbi::Rust,
6759
CanonAbi::RustCold => ExternAbi::RustCold,
@@ -87,7 +79,8 @@ impl CanonAbi {
8779
X86Call::Vectorcall => ExternAbi::Vectorcall { unwind: false },
8880
X86Call::Win64 => ExternAbi::Win64 { unwind: false },
8981
},
90-
}
82+
};
83+
erased_abi.as_str().fmt(f)
9184
}
9285
}
9386

0 commit comments

Comments
 (0)