Skip to content

Commit 52a19de

Browse files
Fuss over the comments on CanonAbi some more
1 parent f9f7e75 commit 52a19de

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

compiler/rustc_abi/src/canon_abi.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ impl fmt::Display for CanonAbi {
102102
impl CanonAbi {
103103
/// convert to the ExternAbi that *shares a string* with this CanonAbi
104104
///
105-
/// NOT correct to use if you want to map CanonAbi to an ABI it may have been lowered from,
106-
/// but it is convenient for various "forwarding" implementations. Avoid exposing publicly!
105+
/// A target-insensitive mapping of CanonAbi to ExternAbi, convenient for "forwarding" impls.
106+
/// Importantly, the set of CanonAbi values is a logical *subset* of ExternAbi values,
107+
/// so this is injective: if you take an ExternAbi to a CanonAbi and back, you have lost data.
107108
const fn to_erased_extern_abi(self) -> ExternAbi {
108109
match self {
109110
CanonAbi::C => ExternAbi::C { unwind: false },
@@ -136,8 +137,8 @@ impl CanonAbi {
136137

137138
/// convert an ExternAbi to a CanonAbi if it maps directly
138139
///
139-
/// Like `to_erased_extern_abi`, this is only intended for internal usage by
140-
/// CanonAbi's implementation, as it is not "target-aware".
140+
/// A target-insensitive mapping of ExternAbi to CanonAbi. This is a partial function,
141+
/// and mostly serves as a way to reuse ExternAbi's code.
141142
const fn try_from_extern_abi(extern_abi: ExternAbi) -> Result<Self, AbiConvErr> {
142143
match extern_abi {
143144
ExternAbi::C { unwind: false } => Ok(Self::C),

0 commit comments

Comments
 (0)