Skip to content

Commit aef2c4b

Browse files
committed
Fix rust-lang#124478 - offset_of! returns a temporary
This was due to the must_use() call. Adding HIR's OffsetOf to the must_use checking within the compiler avoids this issue.
1 parent 00ddbee commit aef2c4b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: core/src/mem/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1340,8 +1340,8 @@ impl<T> SizedTypeProperties for T {}
13401340
/// assert_eq!(mem::offset_of!(Option<&u8>, Some.0), 0);
13411341
/// ```
13421342
#[stable(feature = "offset_of", since = "1.77.0")]
1343-
#[allow_internal_unstable(builtin_syntax, hint_must_use)]
1343+
#[allow_internal_unstable(builtin_syntax)]
13441344
pub macro offset_of($Container:ty, $($fields:expr)+ $(,)?) {
13451345
// The `{}` is for better error messages
1346-
crate::hint::must_use({builtin # offset_of($Container, $($fields)+)})
1346+
{builtin # offset_of($Container, $($fields)+)}
13471347
}

0 commit comments

Comments
 (0)