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:
commit
dbd090c655
25 changed files with 333 additions and 136 deletions
|
@ -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).+)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue