[][src]Enum rustc_ap_rustc_ast::ast::ExprKind

pub enum ExprKind {
    Box(P<Expr>),
    Array(Vec<P<Expr>>),
    Call(P<Expr>, Vec<P<Expr>>),
    MethodCall(PathSegmentVec<P<Expr>>, Span),
    Tup(Vec<P<Expr>>),
    Binary(BinOpP<Expr>, P<Expr>),
    Unary(UnOpP<Expr>),
    Lit(Lit),
    Cast(P<Expr>, P<Ty>),
    Type(P<Expr>, P<Ty>),
    Let(P<Pat>, P<Expr>),
    If(P<Expr>, P<Block>, Option<P<Expr>>),
    While(P<Expr>, P<Block>, Option<Label>),
    ForLoop(P<Pat>, P<Expr>, P<Block>, Option<Label>),
    Loop(P<Block>, Option<Label>),
    Match(P<Expr>, Vec<Arm>),
    Closure(CaptureByAsyncMovabilityP<FnDecl>, P<Expr>, Span),
    Block(P<Block>, Option<Label>),
    Async(CaptureByNodeIdP<Block>),
    Await(P<Expr>),
    TryBlock(P<Block>),
    Assign(P<Expr>, P<Expr>, Span),
    AssignOp(BinOpP<Expr>, P<Expr>),
    Field(P<Expr>, Ident),
    Index(P<Expr>, P<Expr>),
    Range(Option<P<Expr>>, Option<P<Expr>>, RangeLimits),
    Path(Option<QSelf>, Path),
    AddrOf(BorrowKindMutabilityP<Expr>),
    Break(Option<Label>, Option<P<Expr>>),
    Continue(Option<Label>),
    Ret(Option<P<Expr>>),
    InlineAsm(P<InlineAsm>),
    LlvmInlineAsm(P<LlvmInlineAsm>),
    MacCall(MacCall),
    Struct(PathVec<Field>, Option<P<Expr>>),
    Repeat(P<Expr>, AnonConst),
    Paren(P<Expr>),
    Try(P<Expr>),
    Yield(Option<P<Expr>>),
    Err,
}

Variants

Box(P<Expr>)

A box x expression.

Array(Vec<P<Expr>>)

An array ([a, b, c, d])

Call(P<Expr>, Vec<P<Expr>>)

A function call

The first field resolves to the function itself, and the second field is the list of arguments. This also represents calling the constructor of tuple-like ADTs such as tuple structs and enum variants.

MethodCall(PathSegmentVec<P<Expr>>, Span)

A method call (x.foo::<'static, Bar, Baz>(a, b, c, d))

The PathSegment represents the method name and its generic arguments (within the angle brackets). The first element of the vector of an Expr is the expression that evaluates to the object on which the method is being called on (the receiver), and the remaining elements are the rest of the arguments. Thus, x.foo::<Bar, Baz>(a, b, c, d) is represented as ExprKind::MethodCall(PathSegment { foo, [Bar, Baz] }, [x, a, b, c, d]). This Span is the span of the function, without the dot and receiver (e.g. foo(a, b) in x.foo(a, b)

Tup(Vec<P<Expr>>)

A tuple (e.g., (a, b, c, d)).

Binary(BinOpP<Expr>, P<Expr>)

A binary operation (e.g., a + b, a * b).

Unary(UnOpP<Expr>)

A unary operation (e.g., !x, *x).

Lit(Lit)

A literal (e.g., 1, "foo").

Cast(P<Expr>, P<Ty>)

A cast (e.g., foo as f64).

Type(P<Expr>, P<Ty>)

A type ascription (e.g., 42: usize).

Let(P<Pat>, P<Expr>)

A let pat = expr expression that is only semantically allowed in the condition of if / while expressions. (e.g., if let 0 = x { .. }).

If(P<Expr>, P<Block>, Option<P<Expr>>)

An if block, with an optional else block.

if expr { block } else { expr }

While(P<Expr>, P<Block>, Option<Label>)

A while loop, with an optional label.

'label: while expr { block }

ForLoop(P<Pat>, P<Expr>, P<Block>, Option<Label>)

A for loop, with an optional label.

'label: for pat in expr { block }

This is desugared to a combination of loop and match expressions.

Loop(P<Block>, Option<Label>)

Conditionless loop (can be exited with break, continue, or return).

'label: loop { block }

Match(P<Expr>, Vec<Arm>)

A match block.

Closure(CaptureByAsyncMovabilityP<FnDecl>, P<Expr>, Span)

A closure (e.g., move |a, b, c| a + b + c).

The final span is the span of the argument block |...|.

Block(P<Block>, Option<Label>)

A block ('label: { ... }).

Async(CaptureByNodeIdP<Block>)

An async block (async move { ... }).

The NodeId is the NodeId for the closure that results from desugaring an async block, just like the NodeId field in the Async::Yes variant. This is necessary in order to create a def for the closure which can be used as a parent of any child defs. Defs created during lowering cannot be made the parent of any other preexisting defs.

Await(P<Expr>)

An await expression (my_future.await).

TryBlock(P<Block>)

A try block (try { ... }).

Assign(P<Expr>, P<Expr>, Span)

An assignment (a = foo()). The Span argument is the span of the = token.

AssignOp(BinOpP<Expr>, P<Expr>)

An assignment with an operator.

E.g., a += 1.

Field(P<Expr>, Ident)

Access of a named (e.g., obj.foo) or unnamed (e.g., obj.0) struct field.

Index(P<Expr>, P<Expr>)

An indexing operation (e.g., foo[2]).

A range (e.g., 1..2, 1.., ..2, 1..=2, ..=2).

Path(Option<QSelf>, Path)

Variable reference, possibly containing :: and/or type parameters (e.g., foo::bar::<baz>).

Optionally "qualified" (e.g., <Vec<T> as SomeTrait>::SomeType).

A referencing operation (&a, &mut a, &raw const a or &raw mut a).

Break(Option<Label>, Option<P<Expr>>)

A break, with an optional label to break, and an optional expression.

Continue(Option<Label>)

A continue, with an optional label.

Ret(Option<P<Expr>>)

A return, with an optional value to be returned.

InlineAsm(P<InlineAsm>)

Output of the asm!() macro.

LlvmInlineAsm(P<LlvmInlineAsm>)

Output of the llvm_asm!() macro.

MacCall(MacCall)

A macro invocation; pre-expansion.

Struct(PathVec<Field>, Option<P<Expr>>)

A struct literal expression.

E.g., Foo {x: 1, y: 2}, or Foo {x: 1, .. base}, where base is the Option<Expr>.

Repeat(P<Expr>, AnonConst)

An array literal constructed from one repeated element.

E.g., [1; 5]. The expression is the element to be repeated; the constant is the number of times to repeat it.

Paren(P<Expr>)

No-op: used solely so we can pretty-print faithfully.

Try(P<Expr>)

A try expression (expr?).

Yield(Option<P<Expr>>)

A yield, with an optional value to be yielded.

Err

Placeholder for an expression that wasn't syntactically well formed in some way.

Trait Implementations

impl Clone for ExprKind[src]

impl Debug for ExprKind[src]

impl<__D: Decoder> Decodable<__D> for ExprKind[src]

impl<__E: Encoder> Encodable<__E> for ExprKind[src]

Auto Trait Implementations

impl !RefUnwindSafe for ExprKind

impl !Send for ExprKind

impl !Sync for ExprKind

impl Unpin for ExprKind

impl !UnwindSafe for ExprKind

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<'a, T> Captures<'a> for T where
    T: ?Sized
[src]

impl<T> Erased for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,