1
Fork 0

Rollup merge of #110694 - est31:builtin, r=petrochenkov

Implement builtin # syntax and use it for offset_of!(...)

Add `builtin #` syntax to the parser, as well as a generic infrastructure to support both item and expression position builtin syntaxes. The PR also uses this infrastructure for the implementation of the `offset_of!` macro, added by #106934.

cc `@petrochenkov` `@DrMeepster`

cc #110680 `builtin #` tracking issue
cc #106655 `offset_of!` tracking issue
This commit is contained in:
Dylan DPC 2023-05-09 12:33:45 +05:30 committed by GitHub
commit dbd090c655
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 333 additions and 136 deletions

View file

@ -1315,9 +1315,9 @@ impl<T> SizedTypeProperties for T {}
///
/// assert_eq!(mem::offset_of!(NestedA, b.0), 0);
/// ```
#[unstable(feature = "offset_of", issue = "106655")]
#[rustc_builtin_macro]
#[cfg(not(bootstrap))]
#[unstable(feature = "offset_of", issue = "106655")]
#[allow_internal_unstable(builtin_syntax)]
pub macro offset_of($Container:ty, $($fields:tt).+ $(,)?) {
/* compiler built-in */
builtin # offset_of($Container, $($fields).+)
}