1
Fork 0

Warn on unused offset_of!() result

This commit is contained in:
Chayim Refael Friedman 2023-06-08 15:11:31 +03:00
parent d7dcadc597
commit 592844cf88
13 changed files with 333 additions and 135 deletions

View file

@ -1317,7 +1317,8 @@ impl<T> SizedTypeProperties for T {}
/// assert_eq!(mem::offset_of!(NestedA, b.0), 0);
/// ```
#[unstable(feature = "offset_of", issue = "106655")]
#[allow_internal_unstable(builtin_syntax)]
#[allow_internal_unstable(builtin_syntax, hint_must_use)]
pub macro offset_of($Container:ty, $($fields:tt).+ $(,)?) {
builtin # offset_of($Container, $($fields).+)
// The `{}` is for better error messages
crate::hint::must_use({builtin # offset_of($Container, $($fields).+)})
}