Enum rustc_middle::thir::ExprKind[][src]

pub enum ExprKind<'tcx> {
Show 41 variants Scope { region_scope: Scope, lint_level: LintLevel, value: ExprId, }, Box { value: ExprId, }, If { if_then_scope: Scope, cond: ExprId, then: ExprId, else_opt: Option<ExprId>, }, Call { ty: Ty<'tcx>, fun: ExprId, args: Box<[ExprId]>, from_hir_call: bool, fn_span: Span, }, Deref { arg: ExprId, }, Binary { op: BinOp, lhs: ExprId, rhs: ExprId, }, LogicalOp { op: LogicalOp, lhs: ExprId, rhs: ExprId, }, Unary { op: UnOp, arg: ExprId, }, Cast { source: ExprId, }, Use { source: ExprId, }, NeverToAny { source: ExprId, }, Pointer { cast: PointerCast, source: ExprId, }, Loop { body: ExprId, }, Let { expr: ExprId, pat: Pat<'tcx>, }, Match { scrutinee: ExprId, arms: Box<[ArmId]>, }, Block { body: Block, }, Assign { lhs: ExprId, rhs: ExprId, }, AssignOp { op: BinOp, lhs: ExprId, rhs: ExprId, }, Field { lhs: ExprId, name: Field, }, Index { lhs: ExprId, index: ExprId, }, VarRef { id: HirId, }, UpvarRef { closure_def_id: DefId, var_hir_id: HirId, }, Borrow { borrow_kind: BorrowKind, arg: ExprId, }, AddressOf { mutability: Mutability, arg: ExprId, }, Break { label: Scope, value: Option<ExprId>, }, Continue { label: Scope, }, Return { value: Option<ExprId>, }, ConstBlock { value: &'tcx Const<'tcx>, }, Repeat { value: ExprId, count: &'tcx Const<'tcx>, }, Array { fields: Box<[ExprId]>, }, Tuple { fields: Box<[ExprId]>, }, Adt(Box<Adt<'tcx>>), PlaceTypeAscription { source: ExprId, user_ty: Option<Canonical<'tcx, UserType<'tcx>>>, }, ValueTypeAscription { source: ExprId, user_ty: Option<Canonical<'tcx, UserType<'tcx>>>, }, Closure { closure_id: DefId, substs: UpvarSubsts<'tcx>, upvars: Box<[ExprId]>, movability: Option<Movability>, fake_reads: Vec<(ExprId, FakeReadCause, HirId)>, }, Literal { literal: &'tcx Const<'tcx>, user_ty: Option<Canonical<'tcx, UserType<'tcx>>>, const_id: Option<DefId>, }, StaticRef { literal: &'tcx Const<'tcx>, def_id: DefId, }, InlineAsm { template: &'tcx [InlineAsmTemplatePiece], operands: Box<[InlineAsmOperand<'tcx>]>, options: InlineAsmOptions, line_spans: &'tcx [Span], }, ThreadLocalRef(DefId), LlvmInlineAsm { asm: &'tcx LlvmInlineAsmInner, outputs: Box<[ExprId]>, inputs: Box<[ExprId]>, }, Yield { value: ExprId, },
}

Variants

Scope

Scopes are used to explicitely mark destruction scopes, and to track the HirId of the expressions within the scope.

Fields of Scope

region_scope: Scopelint_level: LintLevelvalue: ExprId
Box

A box <value> expression.

Fields of Box

value: ExprId
If

An if expression.

Fields of If

if_then_scope: Scopecond: ExprIdthen: ExprIdelse_opt: Option<ExprId>
Call

A function call. Method calls and overloaded operators are converted to plain function calls.

Fields of Call

ty: Ty<'tcx>

The type of the function. This is often a FnDef or a FnPtr.

fun: ExprId

The function itself.

args: Box<[ExprId]>

The arguments passed to the function.

Note: in some cases (like calling a closure), the function call f(...args) gets rewritten as a call to a function trait method (e.g. FnOnce::call_once(f, (...args))).

from_hir_call: bool

Whether this is from an overloaded operator rather than a function call from HIR. true for overloaded function call.

fn_span: Span

The span of the function, without the dot and receiver (e.g. foo(a, b) in x.foo(a, b)).

Deref

A non-overloaded dereference.

Fields of Deref

arg: ExprId
Binary

A non-overloaded binary operation.

Fields of Binary

op: BinOplhs: ExprIdrhs: ExprId
LogicalOp

A logical operation. This is distinct from BinaryOp because the operands need to be lazily evaluated.

Fields of LogicalOp

op: LogicalOplhs: ExprIdrhs: ExprId
Unary

A non-overloaded unary operation. Note that here the deref (*) operator is represented by ExprKind::Deref.

Fields of Unary

op: UnOparg: ExprId
Cast

A cast: <source> as <type>. The type we cast to is the type of the parent expression.

Fields of Cast

source: ExprId
Use

Fields of Use

source: ExprId
NeverToAny

A coercion from ! to any type.

Fields of NeverToAny

source: ExprId
Pointer

A pointer cast. More information can be found in PointerCast.

Fields of Pointer

cast: PointerCastsource: ExprId
Loop

A loop expression.

Fields of Loop

body: ExprId
Let

Fields of Let

expr: ExprIdpat: Pat<'tcx>
Match

A match expression.

Fields of Match

scrutinee: ExprIdarms: Box<[ArmId]>
Block

A block.

Fields of Block

body: Block
Assign

An assignment: lhs = rhs.

Fields of Assign

lhs: ExprIdrhs: ExprId
AssignOp

A non-overloaded operation assignment, e.g. lhs += rhs.

Fields of AssignOp

op: BinOplhs: ExprIdrhs: ExprId
Field

Access to a struct or tuple field.

Fields of Field

lhs: ExprIdname: Field

This can be a named (.foo) or unnamed (.0) field.

Index

A non-overloaded indexing operation.

Fields of Index

lhs: ExprIdindex: ExprId
VarRef

A local variable.

Fields of VarRef

id: HirId
UpvarRef

Used to represent upvars mentioned in a closure/generator

Fields of UpvarRef

closure_def_id: DefId

DefId of the closure/generator

var_hir_id: HirId

HirId of the root variable

Borrow

A borrow, e.g. &arg.

Fields of Borrow

borrow_kind: BorrowKindarg: ExprId
AddressOf

A &raw [const|mut] $place_expr raw borrow resulting in type *[const|mut] T.

Fields of AddressOf

mutability: Mutabilityarg: ExprId
Break

A break expression.

Fields of Break

label: Scopevalue: Option<ExprId>
Continue

A continue expression.

Fields of Continue

label: Scope
Return

A return expression.

Fields of Return

value: Option<ExprId>
ConstBlock

An inline const block, e.g. const {}.

Fields of ConstBlock

value: &'tcx Const<'tcx>
Repeat

An array literal constructed from one repeated element, e.g. [1; 5].

Fields of Repeat

value: ExprIdcount: &'tcx Const<'tcx>
Array

An array, e.g. [a, b, c, d].

Fields of Array

fields: Box<[ExprId]>
Tuple

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

Fields of Tuple

fields: Box<[ExprId]>
Adt(Box<Adt<'tcx>>)

An ADT constructor, e.g. Foo {x: 1, y: 2}.

Tuple Fields of Adt

0: Box<Adt<'tcx>>
PlaceTypeAscription

A type ascription on a place.

Fields of PlaceTypeAscription

source: ExprIduser_ty: Option<Canonical<'tcx, UserType<'tcx>>>

Type that the user gave to this expression

ValueTypeAscription

A type ascription on a value, e.g. 42: i32.

Fields of ValueTypeAscription

source: ExprIduser_ty: Option<Canonical<'tcx, UserType<'tcx>>>

Type that the user gave to this expression

Closure

A closure definition.

Fields of Closure

closure_id: DefIdsubsts: UpvarSubsts<'tcx>upvars: Box<[ExprId]>movability: Option<Movability>fake_reads: Vec<(ExprId, FakeReadCause, HirId)>
Literal

A literal.

Fields of Literal

literal: &'tcx Const<'tcx>user_ty: Option<Canonical<'tcx, UserType<'tcx>>>const_id: Option<DefId>

The DefId of the const item this literal was produced from, if this is not a user-written literal value.

StaticRef

A literal containing the address of a static.

This is only distinguished from Literal so that we can register some info for diagnostics.

Fields of StaticRef

literal: &'tcx Const<'tcx>def_id: DefId
InlineAsm

Inline assembly, i.e. asm!().

Fields of InlineAsm

template: &'tcx [InlineAsmTemplatePiece]operands: Box<[InlineAsmOperand<'tcx>]>options: InlineAsmOptionsline_spans: &'tcx [Span]
ThreadLocalRef(DefId)

An expression taking a reference to a thread local.

Tuple Fields of ThreadLocalRef

0: DefId
LlvmInlineAsm

Inline LLVM assembly, i.e. llvm_asm!().

Fields of LlvmInlineAsm

asm: &'tcx LlvmInlineAsmInneroutputs: Box<[ExprId]>inputs: Box<[ExprId]>
Yield

A yield expression.

Fields of Yield

value: ExprId

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

This method turns the parameters of a DepNodeConstructor into an opaque Fingerprint to be used in DepNode. Not all DepNodeParams support being turned into a Fingerprint (they don’t need to if the corresponding DepNode is anonymous). Read more

This method tries to recover the query key from the given DepNode, something which is needed when forcing DepNodes during red-green evaluation. The query system will only call this method if fingerprint_style() is not FingerprintStyle::Opaque. It is always valid to return None here, in which case incremental compilation will treat the query as having changed instead of forcing it. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Layout

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.

Size: 80 bytes

Size for each variant: