Skip to main content

Stmt

Enum Stmt 

Source
pub enum Stmt {
Show 18 variants Error, Empty, Expr(ExprId), Block(StmtList), Decls(DeclList), If { cond: ExprId, then: StmtId, otherwise: Option<StmtId>, }, While { cond: ExprId, body: StmtId, }, DoWhile { body: StmtId, cond: ExprId, }, For { init: Option<StmtId>, cond: Option<ExprId>, step: Option<ExprId>, body: StmtId, }, Switch { cond: ExprId, body: StmtId, cases: CaseList, default: Option<StmtId>, }, Case { case: CaseId, body: StmtId, }, Default { body: StmtId, }, Label { label: LabelId, body: StmtId, }, Goto(LabelId), IndirectGoto(ExprId), Break, Continue, Return(Option<ExprId>),
}
Expand description

A statement.

Variants§

§

Error

A statement that was already the subject of a diagnostic.

§

Empty

;, which is a statement and does nothing.

§

Expr(ExprId)

An expression evaluated for its effects, whose value is discarded.

§

Block(StmtList)

{ ... }, which is also a scope, though the scope has been resolved by now.

§

Decls(DeclList)

The declarations of one declaration statement, which introduce objects into the block.

§

If

if (cond) then else otherwise.

Fields

§cond: ExprId

The condition, converted to bool.

§then: StmtId

The statement taken when it is true.

§otherwise: Option<StmtId>

The statement taken when it is false, if there is one.

§

While

while (cond) body.

Fields

§cond: ExprId

The condition, converted to bool.

§body: StmtId

The body.

§

DoWhile

do body while (cond);.

Fields

§body: StmtId

The body, which runs before the condition is first evaluated.

§cond: ExprId

The condition, converted to bool.

§

For

for (init; cond; step) body.

Fields

§init: Option<StmtId>

The initial clause, which is a declaration or an expression or nothing.

§cond: Option<ExprId>

The condition, converted to bool, or nothing for for (;;).

§step: Option<ExprId>

The step, evaluated for its effects.

§body: StmtId

The body.

§

Switch

switch (cond) body.

Fields

§cond: ExprId

The controlling expression, after its integer promotion.

§body: StmtId

The body, which holds the labelled statements themselves.

§cases: CaseList

Where each value goes, collected here so that the walk to the IR builds a jump table from a table rather than by searching the body for labels.

§default: Option<StmtId>

Where a value that matches nothing goes, absent when there is no default, which is the same statement the Stmt::Default in the body labels.

§

Case

case value:, which is a label on the statement it precedes.

The value is in the case table rather than here, because two i128 bounds would make every statement in the arena the size of the widest one.

Fields

§case: CaseId

Which entry of the enclosing switch’s table, so that reaching a case gives its value without searching the table for the statement that is already in hand.

§body: StmtId

The statement it labels.

§

Default

default:, which is a label and not a case, since it has no value to be in a table.

It is here as well as in the enclosing switch because the two say different things: this says where in the body it was written, and the field on the switch is the entry of the jump table. A reader that only had the field could not say where default: went.

Fields

§body: StmtId

The statement it labels.

§

Label

name: body, with the label resolved.

Fields

§label: LabelId

Which label.

§body: StmtId

The statement it labels.

§

Goto(LabelId)

goto name;, with the label resolved.

§

IndirectGoto(ExprId)

goto *expr;, GNU’s computed goto, whose target is a label address.

§

Break

break;, which leaves the innermost loop or switch.

§

Continue

continue;, which starts the next iteration of the innermost loop.

§

Return(Option<ExprId>)

return; or return expr;, with the value already converted to the return type.

Trait Implementations§

Source§

impl Clone for Stmt

Source§

fn clone(&self) -> Stmt

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Stmt

Source§

impl Debug for Stmt

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Stmt

Source§

impl PartialEq for Stmt

Source§

fn eq(&self, other: &Stmt) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Stmt

Auto Trait Implementations§

§

impl Freeze for Stmt

§

impl RefUnwindSafe for Stmt

§

impl Send for Stmt

§

impl Sync for Stmt

§

impl Unpin for Stmt

§

impl UnsafeUnpin for Stmt

§

impl UnwindSafe for Stmt

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.