Enum rustc_middle::thir::ExprKind
source · [−]pub enum ExprKind<'tcx> {
Show 40 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),
Yield {
value: ExprId,
},
}Variants
Scope
Scopes are used to explicitly mark destruction scopes,
and to track the HirId of the expressions within the scope.
Box
Fields
value: ExprIdA box <value> expression.
If
An if expression.
Call
Fields
fun: ExprIdThe 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: boolWhether this is from an overloaded operator rather than a
function call from HIR. true for overloaded function call.
fn_span: SpanThe span of the function, without the dot and receiver
(e.g. foo(a, b) in x.foo(a, b)).
A function call. Method calls and overloaded operators are converted to plain function calls.
Deref
Fields
arg: ExprIdA non-overloaded dereference.
Binary
A non-overloaded binary operation.
LogicalOp
A logical operation. This is distinct from BinaryOp because
the operands need to be lazily evaluated.
Unary
A non-overloaded unary operation. Note that here the deref (*)
operator is represented by ExprKind::Deref.
Cast
Fields
source: ExprIdA cast: <source> as <type>. The type we cast to is the type of
the parent expression.
Use
Fields
source: ExprIdNeverToAny
Fields
source: ExprIdA coercion from ! to any type.
Pointer
A pointer cast. More information can be found in PointerCast.
Loop
Fields
body: ExprIdA loop expression.
Let
Match
A match expression.
Block
Fields
body: BlockA block.
Assign
An assignment: lhs = rhs.
AssignOp
A non-overloaded operation assignment, e.g. lhs += rhs.
Field
Access to a struct or tuple field.
Index
A non-overloaded indexing operation.
VarRef
Fields
id: HirIdA local variable.
UpvarRef
Fields
closure_def_id: DefIdDefId of the closure/generator
var_hir_id: HirIdHirId of the root variable
Used to represent upvars mentioned in a closure/generator
Borrow
A borrow, e.g. &arg.
AddressOf
A &raw [const|mut] $place_expr raw borrow resulting in type *[const|mut] T.
Break
A break expression.
Continue
Fields
label: ScopeA continue expression.
Return
A return expression.
ConstBlock
Fields
value: &'tcx Const<'tcx>An inline const block, e.g. const {}.
Repeat
An array literal constructed from one repeated element, e.g. [1; 5].
Array
An array, e.g. [a, b, c, d].
Tuple
A tuple, e.g. (a, b, c, d).
Adt(Box<Adt<'tcx>>)
An ADT constructor, e.g. Foo {x: 1, y: 2}.
PlaceTypeAscription
Fields
source: ExprIdA type ascription on a place.
ValueTypeAscription
Fields
source: ExprIdA type ascription on a value, e.g. 42: i32.
Closure
A closure definition.
Literal
Fields
literal: &'tcx Const<'tcx>A literal.
StaticRef
A literal containing the address of a static.
This is only distinguished from Literal so that we can register some
info for diagnostics.
InlineAsm
Fields
template: &'tcx [InlineAsmTemplatePiece]operands: Box<[InlineAsmOperand<'tcx>]>options: InlineAsmOptionsInline assembly, i.e. asm!().
ThreadLocalRef(DefId)
An expression taking a reference to a thread local.
Yield
Fields
value: ExprIdA yield expression.
Trait Implementations
Auto Trait Implementations
impl<'tcx> !RefUnwindSafe for ExprKind
impl<'tcx> !UnwindSafe for ExprKind
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<Ctxt, T> DepNodeParams<Ctxt> for T where
Ctxt: DepContext,
T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
impl<Ctxt, T> DepNodeParams<Ctxt> for T where
Ctxt: DepContext,
T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
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
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:
Scope: 23 bytesBox: 7 bytesIf: 23 bytesCall: 39 bytesDeref: 7 bytesBinary: 11 bytesLogicalOp: 11 bytesUnary: 7 bytesCast: 7 bytesUse: 7 bytesNeverToAny: 7 bytesPointer: 7 bytesLoop: 7 bytesLet: 31 bytesMatch: 23 bytesBlock: 63 bytesAssign: 11 bytesAssignOp: 11 bytesField: 11 bytesIndex: 11 bytesVarRef: 11 bytesUpvarRef: 19 bytesBorrow: 7 bytesAddressOf: 7 bytesBreak: 15 bytesContinue: 11 bytesReturn: 7 bytesConstBlock: 15 bytesRepeat: 15 bytesArray: 23 bytesTuple: 23 bytesAdt: 15 bytesPlaceTypeAscription: 63 bytesValueTypeAscription: 63 bytesClosure: 71 bytesLiteral: 79 bytesStaticRef: 23 bytesInlineAsm: 55 bytesThreadLocalRef: 11 bytesYield: 7 bytes