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

Fields

§region_scope: Scope
§lint_level: LintLevel
§value: ExprId

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

§

Box

Fields

§value: ExprId

A box <value> expression.

§

If

Fields

§if_then_scope: Scope
§cond: ExprId
§then: ExprId
§else_opt: Option<ExprId>

An if expression.

§

Call

Fields

§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)).

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

§

Deref

Fields

§arg: ExprId

A non-overloaded dereference.

§

Binary

Fields

§op: BinOp
§lhs: ExprId
§rhs: ExprId

A non-overloaded binary operation.

§

LogicalOp

Fields

§lhs: ExprId
§rhs: ExprId

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

§

Unary

Fields

§op: UnOp
§arg: ExprId

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

§

Cast

Fields

§source: ExprId

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

§

Use

Fields

§source: ExprId
§

NeverToAny

Fields

§source: ExprId

A coercion from ! to any type.

§

Pointer

Fields

§source: ExprId

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

§

Loop

Fields

§body: ExprId

A loop expression.

§

Let

Fields

§expr: ExprId
§pat: Box<Pat<'tcx>>
§

Match

Fields

§scrutinee: ExprId
§arms: Box<[ArmId]>

A match expression.

§

Block

Fields

§block: BlockId

A block.

§

Assign

Fields

§lhs: ExprId
§rhs: ExprId

An assignment: lhs = rhs.

§

AssignOp

Fields

§op: BinOp
§lhs: ExprId
§rhs: ExprId

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

§

Field

Fields

§lhs: ExprId
§variant_index: VariantIdx

Variant containing the field.

§name: Field

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

Access to a field of a struct, a tuple, an union, or an enum.

§

Index

Fields

§lhs: ExprId
§index: ExprId

A non-overloaded indexing operation.

§

VarRef

Fields

A local variable.

§

UpvarRef

Fields

§closure_def_id: DefId

DefId of the closure/generator

§var_hir_id: LocalVarId

HirId of the root variable

Used to represent upvars mentioned in a closure/generator

§

Borrow

Fields

§borrow_kind: BorrowKind
§arg: ExprId

A borrow, e.g. &arg.

§

AddressOf

Fields

§mutability: Mutability
§arg: ExprId

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

§

Break

Fields

§label: Scope
§value: Option<ExprId>

A break expression.

§

Continue

Fields

§label: Scope

A continue expression.

§

Return

Fields

§value: Option<ExprId>

A return expression.

§

ConstBlock

Fields

§did: DefId
§substs: SubstsRef<'tcx>

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

§

Repeat

Fields

§value: ExprId
§count: Const<'tcx>

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

§

Array

Fields

§fields: Box<[ExprId]>

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

§

Tuple

Fields

§fields: Box<[ExprId]>

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: ExprId
§user_ty: Option<Box<CanonicalUserType<'tcx>>>

Type that the user gave to this expression

A type ascription on a place.

§

ValueTypeAscription

Fields

§source: ExprId
§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

Fields

§lit: &'tcx Lit
§neg: bool

A literal.

§

NonHirLiteral

Fields

§user_ty: Option<Box<CanonicalUserType<'tcx>>>

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

Fields

§def_id: DefId
§substs: SubstsRef<'tcx>
§user_ty: Option<Box<CanonicalUserType<'tcx>>>

Associated constants and named constants

§

ConstParam

Fields

§param: ParamConst
§def_id: DefId
§

StaticRef

Fields

§alloc_id: AllocId
§ty: Ty<'tcx>
§def_id: DefId

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: ExprId

A yield expression.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
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

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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: 40 bytes

Size for each variant:

  • Scope: 23 bytes
  • Box: 7 bytes
  • If: 23 bytes
  • Call: 39 bytes
  • Deref: 7 bytes
  • Binary: 11 bytes
  • LogicalOp: 11 bytes
  • Unary: 7 bytes
  • Cast: 7 bytes
  • Use: 7 bytes
  • NeverToAny: 7 bytes
  • Pointer: 7 bytes
  • Loop: 7 bytes
  • Let: 15 bytes
  • Match: 23 bytes
  • Block: 7 bytes
  • Assign: 11 bytes
  • AssignOp: 11 bytes
  • Field: 15 bytes
  • Index: 11 bytes
  • VarRef: 11 bytes
  • UpvarRef: 19 bytes
  • Borrow: 7 bytes
  • AddressOf: 7 bytes
  • Break: 15 bytes
  • Continue: 11 bytes
  • Return: 7 bytes
  • ConstBlock: 23 bytes
  • Repeat: 15 bytes
  • Array: 23 bytes
  • Tuple: 23 bytes
  • Adt: 15 bytes
  • PlaceTypeAscription: 15 bytes
  • ValueTypeAscription: 15 bytes
  • Closure: 15 bytes
  • Literal: 15 bytes
  • NonHirLiteral: 31 bytes
  • ZstLiteral: 15 bytes
  • NamedConst: 31 bytes
  • ConstParam: 19 bytes
  • StaticRef: 31 bytes
  • InlineAsm: 15 bytes
  • ThreadLocalRef: 11 bytes
  • Yield: 7 bytes