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
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
block: BlockIdA block.
Assign
An assignment: lhs = rhs.
AssignOp
A non-overloaded operation assignment, e.g. lhs += rhs.
Field
Fields
lhs: ExprIdvariant_index: VariantIdxVariant containing the field.
name: FieldThis can be a named (.foo) or unnamed (.0) field.
Access to a field of a struct, a tuple, an union, or an enum.
Index
A non-overloaded indexing operation.
VarRef
Fields
id: LocalVarIdA local variable.
UpvarRef
Fields
closure_def_id: DefIdDefId of the closure/generator
var_hir_id: LocalVarIdHirId 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
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
source: ExprIduser_ty: Option<Box<CanonicalUserType<'tcx>>>Type that the user gave to this expression
A type ascription on a place.
ValueTypeAscription
Fields
source: ExprIduser_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
Fields
value: ExprIdA yield expression.
Trait Implementations
sourceimpl<'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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<Ctxt, T> DepNodeParams<Ctxt> for Twhere
Ctxt: DepContext,
T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
impl<Ctxt, T> DepNodeParams<Ctxt> for Twhere
Ctxt: DepContext,
T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
default fn fingerprint_style() -> FingerprintStyle
sourcedefault fn to_fingerprint(&self, tcx: Ctxt) -> Fingerprint
default fn to_fingerprint(&self, tcx: Ctxt) -> Fingerprint
default fn to_debug_str(&self, Ctxt) -> String
sourcedefault fn recover(Ctxt, &DepNode<<Ctxt as DepContext>::DepKind>) -> Option<T>
default fn recover(Ctxt, &DepNode<<Ctxt as DepContext>::DepKind>) -> Option<T>
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 moresourceimpl<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,
sourceimpl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
sourceimpl<CTX, T> Value<CTX> for Twhere
CTX: DepContext,
impl<CTX, T> Value<CTX> for Twhere
CTX: DepContext,
default fn from_cycle_error(tcx: CTX) -> T
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
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