pub enum Expr {
Show 16 variants
Literal(Literal),
Path(Path),
Call {
callee: Box<Expr>,
args: Vec<Expr>,
},
MethodCall {
receiver: Box<Expr>,
name: Ident,
args: Vec<Expr>,
},
Member {
value: Box<Expr>,
name: Ident,
},
Arrow {
value: Box<Expr>,
name: Ident,
},
Index {
value: Box<Expr>,
index: Box<Expr>,
},
Construct {
type_: Box<Type>,
args: Vec<Expr>,
braced: bool,
},
Unary {
op: &'static str,
value: Box<Expr>,
},
Binary {
op: &'static str,
lhs: Box<Expr>,
rhs: Box<Expr>,
},
Cast {
kind: CastKind,
type_: Box<Type>,
value: Box<Expr>,
},
AddressOf(Box<Expr>),
Deref(Box<Expr>),
InitList(Vec<Expr>),
SizeOf(Box<Type>),
Paren(Box<Expr>),
}Expand description
An expression.
Variants§
Literal(Literal)
A literal.
Path(Path)
A name or qualified name.
Call
f(args)
MethodCall
value.name(args)
Member
a.b
Arrow
a->b
Index
a[i]
Construct
T{args} or T(args).
Unary
op a, written as given — !a, -a, ~a.
The tree carries no precedence, so a caller that needs the
operand bracketed writes Expr::Paren around it.
Added because there was no form for it and the backend faked
one with Binary { op, lhs: 0 }. That reads as 0 - a for a
negation, which is the same number, and as 0 ~ a for a
complement, which is not an expression: 21 corpus cases stopped
compiling on zd_bits & 0 ~ UINT64_C(32897).
Binary
a op b
Cast
static_cast<T>(v) and friends.
AddressOf(Box<Expr>)
&a
Deref(Box<Expr>)
*a
InitList(Vec<Expr>)
{ a, b }
SizeOf(Box<Type>)
sizeof(T)
Paren(Box<Expr>)
(a) — parentheses written on purpose.
The same node the C tree carries and for the same reason: this
tree holds no operator precedence, so a renderer walking it
cannot know where a bracket is needed. A builder that needs one
says so. Binary { op: "<<", lhs: Binary { op: "+", .. }, .. }
renders as a + b << c without it, which is a different number
and compiles without a word — the C column met that shape in a
#define and the same composition is reachable here through a
constexpr initialiser or a case label.