diff options
| author | Ralf Jung <post@ralfj.de> | 2025-06-05 10:03:22 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2025-06-05 10:05:36 +0200 |
| commit | 51acc5778df121adb1e4a8eea7467400dd7fda5b (patch) | |
| tree | d8687c30550fea3c1fa3f3bf390fbbbec9e09721 /compiler/rustc_abi/src | |
| parent | 81a964c23ea4fe9ab52b4449bb166bf280035797 (diff) | |
| download | rust-51acc5778df121adb1e4a8eea7467400dd7fda5b.tar.gz rust-51acc5778df121adb1e4a8eea7467400dd7fda5b.zip | |
canon_abi: make to_erased_extern_abi just a detail in formatting
Diffstat (limited to 'compiler/rustc_abi/src')
| -rw-r--r-- | compiler/rustc_abi/src/canon_abi.rs | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/compiler/rustc_abi/src/canon_abi.rs b/compiler/rustc_abi/src/canon_abi.rs index 2cf7648a859..03eeb645489 100644 --- a/compiler/rustc_abi/src/canon_abi.rs +++ b/compiler/rustc_abi/src/canon_abi.rs @@ -50,18 +50,10 @@ pub enum CanonAbi { impl fmt::Display for CanonAbi { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - self.to_erased_extern_abi().as_str().fmt(f) - } -} - -impl CanonAbi { - /// convert to the ExternAbi that *shares a string* with this CanonAbi - /// - /// A target-insensitive mapping of CanonAbi to ExternAbi, convenient for "forwarding" impls. - /// Importantly, the set of CanonAbi values is a logical *subset* of ExternAbi values, - /// so this is injective: if you take an ExternAbi to a CanonAbi and back, you have lost data. - const fn to_erased_extern_abi(self) -> ExternAbi { - match self { + // convert to the ExternAbi that *shares a string* with this CanonAbi. + // FIXME: ideally we'd avoid printing `CanonAbi`, and preserve `ExternAbi` everywhere + // that we need to generate error messages. + let erased_abi = match self { CanonAbi::C => ExternAbi::C { unwind: false }, CanonAbi::Rust => ExternAbi::Rust, CanonAbi::RustCold => ExternAbi::RustCold, @@ -87,7 +79,8 @@ impl CanonAbi { X86Call::Vectorcall => ExternAbi::Vectorcall { unwind: false }, X86Call::Win64 => ExternAbi::Win64 { unwind: false }, }, - } + }; + erased_abi.as_str().fmt(f) } } |
