diff options
| author | Trevor Gross <t.gross35@gmail.com> | 2025-06-20 23:25:58 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-20 23:25:58 -0400 |
| commit | 432c7d0235a61bc4f54e8be7b072583a769d8b2a (patch) | |
| tree | 1b17d0c6e48d7a5d09afa5fcddf63af774814b02 | |
| parent | c386ffb5ad8e45dbfd9a81c27aebb4dd8d1a2937 (diff) | |
| parent | 867d0016e5199a30630d1ca7e8585c3be883c97e (diff) | |
Rollup merge of #142765 - workingjubilee:more-abimap-docs, r=compiler-errors
rustc_target: document public AbiMap-related fn and variants
| -rw-r--r-- | compiler/rustc_target/src/spec/abi_map.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_target/src/spec/abi_map.rs b/compiler/rustc_target/src/spec/abi_map.rs index 4659bbdb890..42ec10a8e15 100644 --- a/compiler/rustc_target/src/spec/abi_map.rs +++ b/compiler/rustc_target/src/spec/abi_map.rs @@ -12,16 +12,19 @@ pub struct AbiMap { os: OsKind, } +/// result from trying to map an ABI #[derive(Copy, Clone, Debug)] pub enum AbiMapping { /// this ABI is exactly mapped for this platform Direct(CanonAbi), /// we don't yet warn on this, but we will Deprecated(CanonAbi), + /// ABI we do not map for this platform: it must not reach codegen Invalid, } impl AbiMapping { + /// optionally get a [CanonAbi], even if Deprecated pub fn into_option(self) -> Option<CanonAbi> { match self { Self::Direct(abi) | Self::Deprecated(abi) => Some(abi), @@ -29,6 +32,7 @@ impl AbiMapping { } } + /// get a [CanonAbi] even if Deprecated, panicking if Invalid #[track_caller] pub fn unwrap(self) -> CanonAbi { self.into_option().unwrap() @@ -40,6 +44,7 @@ impl AbiMapping { } impl AbiMap { + /// create an AbiMap according to arbitrary fields on the [Target] pub fn from_target(target: &Target) -> Self { // the purpose of this little exercise is to force listing what affects these mappings let arch = match &*target.arch { @@ -59,6 +64,7 @@ impl AbiMap { AbiMap { arch, os } } + /// lower an [ExternAbi] to a [CanonAbi] if this AbiMap allows pub fn canonize_abi(&self, extern_abi: ExternAbi, has_c_varargs: bool) -> AbiMapping { let AbiMap { os, arch } = *self; |
