offset_of
This commit is contained in:
parent
b92a41c676
commit
511e457c4b
71 changed files with 841 additions and 38 deletions
|
@ -1271,6 +1271,7 @@ impl Expr {
|
|||
ExprKind::Continue(..) => ExprPrecedence::Continue,
|
||||
ExprKind::Ret(..) => ExprPrecedence::Ret,
|
||||
ExprKind::InlineAsm(..) => ExprPrecedence::InlineAsm,
|
||||
ExprKind::OffsetOf(..) => ExprPrecedence::OffsetOf,
|
||||
ExprKind::MacCall(..) => ExprPrecedence::Mac,
|
||||
ExprKind::Struct(..) => ExprPrecedence::Struct,
|
||||
ExprKind::Repeat(..) => ExprPrecedence::Repeat,
|
||||
|
@ -1469,6 +1470,9 @@ pub enum ExprKind {
|
|||
/// Output of the `asm!()` macro.
|
||||
InlineAsm(P<InlineAsm>),
|
||||
|
||||
/// Output of the `offset_of!()` macro.
|
||||
OffsetOf(P<Ty>, Vec<Ident>),
|
||||
|
||||
/// A macro invocation; pre-expansion.
|
||||
MacCall(P<MacCall>),
|
||||
|
||||
|
|
|
@ -1456,6 +1456,12 @@ pub fn noop_visit_expr<T: MutVisitor>(
|
|||
}
|
||||
ExprKind::InlineAsm(asm) => vis.visit_inline_asm(asm),
|
||||
ExprKind::FormatArgs(fmt) => vis.visit_format_args(fmt),
|
||||
ExprKind::OffsetOf(container, fields) => {
|
||||
vis.visit_ty(container);
|
||||
for field in fields {
|
||||
vis.visit_ident(field);
|
||||
}
|
||||
}
|
||||
ExprKind::MacCall(mac) => vis.visit_mac_call(mac),
|
||||
ExprKind::Struct(se) => {
|
||||
let StructExpr { qself, path, fields, rest } = se.deref_mut();
|
||||
|
|
|
@ -269,6 +269,7 @@ pub enum ExprPrecedence {
|
|||
Index,
|
||||
Try,
|
||||
InlineAsm,
|
||||
OffsetOf,
|
||||
Mac,
|
||||
FormatArgs,
|
||||
|
||||
|
@ -335,7 +336,8 @@ impl ExprPrecedence {
|
|||
| ExprPrecedence::Try
|
||||
| ExprPrecedence::InlineAsm
|
||||
| ExprPrecedence::Mac
|
||||
| ExprPrecedence::FormatArgs => PREC_POSTFIX,
|
||||
| ExprPrecedence::FormatArgs
|
||||
| ExprPrecedence::OffsetOf => PREC_POSTFIX,
|
||||
|
||||
// Never need parens
|
||||
ExprPrecedence::Array
|
||||
|
|
|
@ -909,6 +909,12 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
|
|||
ExprKind::Paren(subexpression) => visitor.visit_expr(subexpression),
|
||||
ExprKind::InlineAsm(asm) => visitor.visit_inline_asm(asm),
|
||||
ExprKind::FormatArgs(f) => visitor.visit_format_args(f),
|
||||
ExprKind::OffsetOf(container, fields) => {
|
||||
visitor.visit_ty(container);
|
||||
for &field in fields {
|
||||
visitor.visit_ident(field);
|
||||
}
|
||||
}
|
||||
ExprKind::Yield(optional_expression) => {
|
||||
walk_list!(visitor, visit_expr, optional_expression);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue