Skip to content

Commit a74ed3a

Browse files
Improve ABI docs
And defer arrays to later
1 parent c0f5cdd commit a74ed3a

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

compiler/rustc_abi/src/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
196196
size,
197197
max_repr_align: None,
198198
unadjusted_abi_align: element.align.abi,
199-
repr_c: element.repr_c,
199+
repr_c: false,
200200
randomization_seed: element.randomization_seed.wrapping_add(Hash64::new(count)),
201201
})
202202
}

compiler/rustc_abi/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,8 +2142,7 @@ pub struct LayoutData<FieldIdx: Idx, VariantIdx: Idx> {
21422142
/// in some cases.
21432143
pub unadjusted_abi_align: Align,
21442144

2145-
/// Whether this type is `repr(C)`, or a`repr(transparent)` wrapper around such,
2146-
/// or an array of such.
2145+
/// Whether this type is `repr(C)`, or a`repr(transparent)` wrapper around such.
21472146
/// Some C ABIs pass `repr(C)` ZSTs by pointer, but `repr(Rust)` ZSTs should always
21482147
/// be ignored.
21492148
pub repr_c: bool,

library/core/src/primitive_docs.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,10 +1842,14 @@ mod prim_ref {}
18421842
/// call will be valid ABI-wise. The callee receives the result of transmuting the function pointer
18431843
/// from `fn()` to `fn(i32)`; that transmutation is itself a well-defined operation, it's just
18441844
/// almost certainly UB to later call that function pointer.)
1845-
/// - Any two types with size 0 and alignment 1 are ABI-compatible, unless they are `repr(C)`
1846-
/// or a `repr(transparent)` wrapper around `repr(C)`.
1847-
/// - A `repr(transparent)` type `T` is ABI-compatible with its unique non-trivial field, i.e., the
1848-
/// unique field that doesn't have size 0 and alignment 1 (if there is such a field).
1845+
/// - Any two types fulfilling all the following conditions are ABI-compatible;
1846+
/// such types are said to have "trivial ABI":
1847+
/// - Size 0
1848+
/// - Alignment 1
1849+
/// - Not `repr(C)`
1850+
/// - Not a `repr(transparent)` wrapper around a type that fails to satisfy these conditions
1851+
/// - A `repr(transparent)` type is ABI-compatible with its unique field that does not have trivial ABI
1852+
/// (as defined above). If there is no such field, the type has trivial ABI.
18491853
/// - `i32` is ABI-compatible with `NonZero<i32>`, and similar for all other integer types.
18501854
/// - If `T` is guaranteed to be subject to the [null pointer
18511855
/// optimization](option/index.html#representation), and `E` is an enum satisfying the following

0 commit comments

Comments
 (0)