Enum rustc_middle::thir::ExprKind [−][src]
pub enum ExprKind<'tcx> {
Show variants
Scope {
region_scope: Scope,
lint_level: LintLevel,
value: ExprId,
},
Box {
value: ExprId,
},
If {
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,
},
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
Scopes are used to explicitely mark destruction scopes,
and to track the HirId of the expressions within the scope.
A box <value> expression.
Show fields
Fields of Box
value: ExprIdAn if expression.
A function call. Method calls and overloaded operators are converted to plain function calls.
Show fields
Fields of Call
ty: Ty<'tcx>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 non-overloaded dereference.
Show fields
Fields of Deref
arg: ExprIdA non-overloaded binary operation.
A logical operation. This is distinct from BinaryOp because
the operands need to be lazily evaluated.
A non-overloaded unary operation. Note that here the deref (*)
operator is represented by ExprKind::Deref.
A cast: <source> as <type>. The type we cast to is the type of
the parent expression.
Show fields
Fields of Cast
source: ExprIdShow fields
Fields of Use
source: ExprIdA coercion from ! to any type.
Show fields
Fields of NeverToAny
source: ExprIdA pointer cast. More information can be found in PointerCast.
Show fields
Fields of Pointer
cast: PointerCastsource: ExprIdA loop expression.
Show fields
Fields of Loop
body: ExprIdA match expression.
A block.
Show fields
Fields of Block
body: BlockAn assignment: lhs = rhs.
A non-overloaded operation assignment, e.g. lhs += rhs.
Access to a struct or tuple field.
A non-overloaded indexing operation.
A local variable.
Show fields
Fields of VarRef
id: HirIdUsed to represent upvars mentioned in a closure/generator
Show fields
A borrow, e.g. &arg.
Show fields
Fields of Borrow
borrow_kind: BorrowKindarg: ExprIdA &raw [const|mut] $place_expr raw borrow resulting in type *[const|mut] T.
Show fields
Fields of AddressOf
mutability: Mutabilityarg: ExprIdA break expression.
A continue expression.
Show fields
Fields of Continue
label: ScopeA return expression.
An inline const block, e.g. const {}.
Show fields
Fields of ConstBlock
value: &'tcx Const<'tcx>An array literal constructed from one repeated element, e.g. [1; 5].
An array, e.g. [a, b, c, d].
A tuple, e.g. (a, b, c, d).
An ADT constructor, e.g. Foo {x: 1, y: 2}.
A type ascription on a place.
Show fields
A type ascription on a value, e.g. 42: i32.
Show fields
A closure definition.
Show fields
Fields of Closure
closure_id: DefIdsubsts: UpvarSubsts<'tcx>upvars: Box<[ExprId]>movability: Option<Movability>fake_reads: Vec<(ExprId, FakeReadCause, HirId)>A literal.
Show fields
A literal containing the address of a static.
This is only distinguished from Literal so that we can register some
info for diagnostics.
Inline assembly, i.e. asm!().
Show fields
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.
Inline LLVM assembly, i.e. llvm_asm!().
Show fields
A yield expression.
Show fields
Fields of Yield
value: ExprIdTrait Implementations
Auto Trait Implementations
impl<'tcx> !RefUnwindSafe for ExprKind<'tcx>impl<'tcx> !UnwindSafe for ExprKind<'tcx>Blanket Implementations
Layout
Note: Most layout information is completely unstable and may be different between compiler versions and platforms. 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