diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-06-06 00:58:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-06 00:58:47 +0200 |
| commit | 2f7de4fca48a04240548484df8936f35e85758af (patch) | |
| tree | 4af0e9bd438140f39691590e89100484bf5ce34a | |
| parent | 7420ae82a7ee4d7480616d3a6f7691e8c78ac352 (diff) | |
| parent | 51acc5778df121adb1e4a8eea7467400dd7fda5b (diff) | |
| download | rust-2f7de4fca48a04240548484df8936f35e85758af.tar.gz rust-2f7de4fca48a04240548484df8936f35e85758af.zip | |
Rollup merge of #142067 - RalfJung:abi-map-to-str, r=workingjubilee
canon_abi: make to_erased_extern_abi just a detail in formatting I think ideally we'd avoid ever printing `CanonAbi` to users, but that needs further changes. Personally I think it's fine for Miri to use the debug printing of `CanonAbi` until we figure that out, but I think others disagree. ;) r? ``@workingjubilee``
| -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) } } |
