File tree 1 file changed +14
-0
lines changed
1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -1266,6 +1266,20 @@ impl<T> SizedTypeProperties for T {}
1266
1266
/// // ^^^ error[E0616]: field `private` of struct `Struct` is private
1267
1267
/// ```
1268
1268
///
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
+ ///
1269
1283
/// Note that type layout is, in general, [subject to change and
1270
1284
/// platform-specific](https://doc.rust-lang.org/reference/type-layout.html). If
1271
1285
/// layout stability is required, consider using an [explicit `repr` attribute].
You can’t perform that action at this time.
0 commit comments