Enum rustc_middle::thir::ExprKind
source · pub enum ExprKind<'tcx> {
Show 44 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: Box<Pat<'tcx>>,
},
Match {
scrutinee: ExprId,
arms: Box<[ArmId]>,
},
Block {
block: BlockId,
},
Assign {
lhs: ExprId,
rhs: ExprId,
},
AssignOp {
op: BinOp,
lhs: ExprId,
rhs: ExprId,
},
Field {
lhs: ExprId,
variant_index: VariantIdx,
name: Field,
},
Index {
lhs: ExprId,
index: ExprId,
},
VarRef {
id: LocalVarId,
},
UpvarRef {
closure_def_id: DefId,
var_hir_id: LocalVarId,
},
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 {
did: DefId,
substs: SubstsRef<'tcx>,
},
Repeat {
value: ExprId,
count: Const<'tcx>,
},
Array {
fields: Box<[ExprId]>,
},
Tuple {
fields: Box<[ExprId]>,
},
Adt(Box<AdtExpr<'tcx>>),
PlaceTypeAscription {
source: ExprId,
user_ty: Option<Box<CanonicalUserType<'tcx>>>,
},
ValueTypeAscription {
source: ExprId,
user_ty: Option<Box<CanonicalUserType<'tcx>>>,
},
Closure(Box<ClosureExpr<'tcx>>),
Literal {
lit: &'tcx Lit,
neg: bool,
},
NonHirLiteral {
lit: ScalarInt,
user_ty: Option<Box<CanonicalUserType<'tcx>>>,
},
ZstLiteral {
user_ty: Option<Box<CanonicalUserType<'tcx>>>,
},
NamedConst {
def_id: DefId,
substs: SubstsRef<'tcx>,
user_ty: Option<Box<CanonicalUserType<'tcx>>>,
},
ConstParam {
param: ParamConst,
def_id: DefId,
},
StaticRef {
alloc_id: AllocId,
ty: Ty<'tcx>,
def_id: DefId,
},
InlineAsm(Box<InlineAsmExpr<'tcx>>),
ThreadLocalRef(DefId),
Yield {
value: ExprId,
},
}
Variants§
Scope
Scope
s are used to explicitly mark destruction scopes,
and to track the HirId
of the expressions within the scope.
Box
A box <value>
expression.
If
An if
expression.
Call
Fields
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))
).
A function call. Method calls and overloaded operators are converted to plain function calls.
Deref
A 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
A cast: <source> as <type>
. The type we cast to is the type of
the parent expression.
Use
NeverToAny
A coercion from !
to any type.
Pointer
A pointer cast. More information can be found in PointerCast
.
Loop
A loop
expression.
Let
Match
A match
expression.
Block
A block.
Assign
An assignment: lhs = rhs
.
AssignOp
A non-overloaded operation assignment, e.g. lhs += rhs
.
Field
Fields
variant_index: VariantIdx
Variant containing the field.
Access to a field of a struct, a tuple, an union, or an enum.
Index
A non-overloaded indexing operation.
VarRef
Fields
id: LocalVarId
A local variable.
UpvarRef
Fields
var_hir_id: LocalVarId
HirId 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
A continue
expression.
Return
A return
expression.
ConstBlock
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<AdtExpr<'tcx>>)
An ADT constructor, e.g. Foo {x: 1, y: 2}
.
PlaceTypeAscription
Fields
user_ty: Option<Box<CanonicalUserType<'tcx>>>
Type that the user gave to this expression
A type ascription on a place.
ValueTypeAscription
Fields
user_ty: Option<Box<CanonicalUserType<'tcx>>>
Type that the user gave to this expression
A type ascription on a value, e.g. 42: i32
.
Closure(Box<ClosureExpr<'tcx>>)
A closure definition.
Literal
A literal.
NonHirLiteral
For literals that don’t correspond to anything in the HIR
ZstLiteral
Fields
user_ty: Option<Box<CanonicalUserType<'tcx>>>
A literal of a ZST type.
NamedConst
Associated constants and named constants
ConstParam
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(Box<InlineAsmExpr<'tcx>>)
Inline assembly, i.e. asm!()
.
ThreadLocalRef(DefId)
An expression taking a reference to a thread local.
Yield
A yield
expression.
Trait Implementations§
source§impl<'tcx, '__ctx> HashStable<StableHashingContext<'__ctx>> for ExprKind<'tcx>
impl<'tcx, '__ctx> HashStable<StableHashingContext<'__ctx>> for ExprKind<'tcx>
fn hash_stable(
&self,
__hcx: &mut StableHashingContext<'__ctx>,
__hasher: &mut StableHasher
)
Auto Trait Implementations§
impl<'tcx> !RefUnwindSafe for ExprKind<'tcx>
impl<'tcx> !Send for ExprKind<'tcx>
impl<'tcx> !Sync for ExprKind<'tcx>
impl<'tcx> Unpin for ExprKind<'tcx>
impl<'tcx> !UnwindSafe for ExprKind<'tcx>
Blanket Implementations§
source§impl<Tcx, T> DepNodeParams<Tcx> for Twhere
Tcx: DepContext,
T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
impl<Tcx, T> DepNodeParams<Tcx> for Twhere
Tcx: DepContext,
T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
default fn fingerprint_style() -> FingerprintStyle
source§default fn to_fingerprint(&self, tcx: Tcx) -> Fingerprint
default fn to_fingerprint(&self, tcx: Tcx) -> Fingerprint
default fn to_debug_str(&self, _: Tcx) -> String
source§default fn recover(
_: Tcx,
_: &DepNode<<Tcx as DepContext>::DepKind>
) -> Option<T>
default fn recover(
_: Tcx,
_: &DepNode<<Tcx as DepContext>::DepKind>
) -> Option<T>
DepNode
,
something which is needed when forcing DepNode
s 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 moresource§impl<T, R> InternIteratorElement<T, R> for T
impl<T, R> InternIteratorElement<T, R> for T
type Output = R
fn intern_with<I, F>(iter: I, f: F) -> <T as InternIteratorElement<T, R>>::Outputwhere
I: Iterator<Item = T>,
F: FnOnce(&[T]) -> R,
source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
source§impl<'tcx, T> ToPredicate<'tcx, T> for T
impl<'tcx, T> ToPredicate<'tcx, T> for T
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> T
source§impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
default fn from_cycle_error(tcx: Tcx, _: &[QueryInfo]) -> T
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: 40 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
: 15 bytesMatch
: 23 bytesBlock
: 7 bytesAssign
: 11 bytesAssignOp
: 11 bytesField
: 15 bytesIndex
: 11 bytesVarRef
: 11 bytesUpvarRef
: 19 bytesBorrow
: 7 bytesAddressOf
: 7 bytesBreak
: 15 bytesContinue
: 11 bytesReturn
: 7 bytesConstBlock
: 23 bytesRepeat
: 15 bytesArray
: 23 bytesTuple
: 23 bytesAdt
: 15 bytesPlaceTypeAscription
: 15 bytesValueTypeAscription
: 15 bytesClosure
: 15 bytesLiteral
: 15 bytesNonHirLiteral
: 31 bytesZstLiteral
: 15 bytesNamedConst
: 31 bytesConstParam
: 19 bytesStaticRef
: 31 bytesInlineAsm
: 15 bytesThreadLocalRef
: 11 bytesYield
: 7 bytes