Rollup merge of #127354 - nicholasbishop:bishop-sized-doc, r=Nilstrieb · model-checking/verify-rust-std@9f7100d

Original file line numberDiff line numberDiff line change

@@ -1266,6 +1266,20 @@ impl<T> SizedTypeProperties for T {}

12661266

/// // ^^^ error[E0616]: field `private` of struct `Struct` is private

12671267

/// ```

12681268

///

1269+

/// Only [`Sized`] fields are supported, but the container may be unsized:

1270+

/// ```

1271+

/// # use core::mem;

1272+

/// #[repr(C)]

1273+

/// pub struct Struct {

1274+

/// a: u8,

1275+

/// b: [u8],

1276+

/// }

1277+

///

1278+

/// assert_eq!(mem::offset_of!(Struct, a), 0); // OK

1279+

/// // assert_eq!(mem::offset_of!(Struct, b), 1);

1280+

/// // ^^^ error[E0277]: doesn't have a size known at compile-time

1281+

/// ```

1282+

///

12691283

/// Note that type layout is, in general, [subject to change and

12701284

/// platform-specific](https://doc.rust-lang.org/reference/type-layout.html). If

12711285

/// layout stability is required, consider using an [explicit `repr` attribute].