Skip to content

Commit 7258c89

Browse files
Warn on unused offset_of!() result
1 parent 8a78f58 commit 7258c89

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

core/src/mem/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,8 @@ impl<T> SizedTypeProperties for T {}
13171317
/// assert_eq!(mem::offset_of!(NestedA, b.0), 0);
13181318
/// ```
13191319
#[unstable(feature = "offset_of", issue = "106655")]
1320-
#[allow_internal_unstable(builtin_syntax)]
1320+
#[allow_internal_unstable(builtin_syntax, hint_must_use)]
13211321
pub macro offset_of($Container:ty, $($fields:tt).+ $(,)?) {
1322-
builtin # offset_of($Container, $($fields).+)
1322+
// The `{}` is for better error messages
1323+
crate::hint::must_use({builtin # offset_of($Container, $($fields).+)})
13231324
}

0 commit comments

Comments
 (0)