pub enum StatementKind {
Show 19 variants
Assign(Place, Rvalue),
SetDiscriminant(Place, VariantId),
StorageLive(LocalId),
StorageDead(LocalId),
PlaceMention(Place),
Borrowck(BorrowckStatement),
Drop {
place: Place,
fn_ptr: FnPtr,
kind: DropKind,
on_unwind: Block,
},
Assert {
assert: Assert,
on_failure: AbortKind,
on_unwind: Block,
},
InlineAsm {
asm: String,
targets: Vec<Block>,
on_unwind: Block,
},
Call {
call: Call,
on_unwind: Block,
},
Abort(AbortKind),
Return,
UnwindResume,
Break(usize),
Continue(usize),
Nop,
Switch(Switch),
Loop(Block),
Error(String),
}Expand description
A raw statement: a statement without meta data.
Variants§
Assign(Place, Rvalue)
Assigns an Rvalue to a Place. e.g. let y = x; could become
y := move x which is represented as Assign(y, Rvalue::Use(Operand::Move(x))).
SetDiscriminant(Place, VariantId)
Not used today because we take MIR built.
StorageLive(LocalId)
Indicates that this local should be allocated; if it is already allocated, this frees
the local and re-allocates it. The arguments do not receive a StorageLive. We ensure in
the micro-pass insert_storage_statements that all other locals have a StorageLive
associated with them.
StorageDead(LocalId)
Indicates that this local should be deallocated; if it is already deallocated, this is
a no-op. A local may not have a StorageDead in the function’s body, in which case it
is implicitly deallocated at the end of the function. The return local does not receive a
StorageDead. We ensure in the micro-pass insert_storage_statements that all other locals
have a StorageDead before function exits.
PlaceMention(Place)
A place is mentioned, but not accessed. The place itself must still be valid though, so this statement is not a no-op: it can trigger UB if the place’s projections are not valid (e.g. because they go out of bounds).
Borrowck(BorrowckStatement)
Statements that only affect borrow-checking.
Drop
Drop the value at the given place.
Depending on DropKind, this may be a real call to drop_glue, or a conditional call
that should only happen if the place has not been moved out of. See the docs of DropKind
for more details; to get precise drops use --precise-drops.
Fields
Assert
InlineAsm
An inline assembly block. For now we only preserve the template string.
Call
Abort(AbortKind)
Panic also handles “unreachable”. We keep the name of the panicking function that was called.
Return
UnwindResume
Unwind out of the current function into its caller.
Break(usize)
Break to outer loops.
The usize gives the index of the outer loop to break to:
- 0: break to first outer loop (the current loop)
- 1: break to second outer loop
- …
Continue(usize)
Continue to outer loops.
The usize gives the index of the outer loop to continue to:
- 0: continue to first outer loop (the current loop)
- 1: continue to second outer loop
- …
Nop
No-op.
Switch(Switch)
Loop(Block)
Error(String)
Implementations§
Source§impl StatementKind
impl StatementKind
pub fn is_assign(&self) -> bool
pub fn is_set_discriminant(&self) -> bool
pub fn is_storage_live(&self) -> bool
pub fn is_storage_dead(&self) -> bool
pub fn is_place_mention(&self) -> bool
pub fn is_borrowck(&self) -> bool
pub fn is_drop(&self) -> bool
pub fn is_assert(&self) -> bool
pub fn is_inline_asm(&self) -> bool
pub fn is_call(&self) -> bool
pub fn is_abort(&self) -> bool
pub fn is_return(&self) -> bool
pub fn is_unwind_resume(&self) -> bool
pub fn is_break(&self) -> bool
pub fn is_continue(&self) -> bool
pub fn is_nop(&self) -> bool
pub fn is_switch(&self) -> bool
pub fn is_loop(&self) -> bool
pub fn is_error(&self) -> bool
Source§impl StatementKind
impl StatementKind
pub fn to_assign(self) -> Option<(Place, Rvalue)>
pub fn to_set_discriminant(self) -> Option<(Place, VariantId)>
pub fn to_storage_live(self) -> Option<LocalId>
pub fn to_storage_dead(self) -> Option<LocalId>
pub fn to_place_mention(self) -> Option<Place>
pub fn to_borrowck(self) -> Option<BorrowckStatement>
pub fn to_drop(self) -> Option<(Place, FnPtr, DropKind, Block)>
pub fn to_assert(self) -> Option<(Assert, AbortKind, Block)>
pub fn to_inline_asm(self) -> Option<(String, Vec<Block>, Block)>
pub fn to_call(self) -> Option<(Call, Block)>
pub fn to_abort(self) -> Option<AbortKind>
pub fn to_return(self) -> Option<()>
pub fn to_unwind_resume(self) -> Option<()>
pub fn to_break(self) -> Option<usize>
pub fn to_continue(self) -> Option<usize>
pub fn to_nop(self) -> Option<()>
pub fn to_switch(self) -> Option<Switch>
pub fn to_loop(self) -> Option<Block>
pub fn to_error(self) -> Option<String>
Source§impl StatementKind
impl StatementKind
pub fn as_assign(&self) -> Option<(&Place, &Rvalue)>
pub fn as_set_discriminant(&self) -> Option<(&Place, &VariantId)>
pub fn as_storage_live(&self) -> Option<&LocalId>
pub fn as_storage_dead(&self) -> Option<&LocalId>
pub fn as_place_mention(&self) -> Option<&Place>
pub fn as_borrowck(&self) -> Option<&BorrowckStatement>
pub fn as_drop(&self) -> Option<(&Place, &FnPtr, &DropKind, &Block)>
pub fn as_assert(&self) -> Option<(&Assert, &AbortKind, &Block)>
pub fn as_inline_asm(&self) -> Option<(&String, &Vec<Block>, &Block)>
pub fn as_call(&self) -> Option<(&Call, &Block)>
pub fn as_abort(&self) -> Option<&AbortKind>
pub fn as_return(&self) -> Option<()>
pub fn as_unwind_resume(&self) -> Option<()>
pub fn as_break(&self) -> Option<&usize>
pub fn as_continue(&self) -> Option<&usize>
pub fn as_nop(&self) -> Option<()>
pub fn as_switch(&self) -> Option<&Switch>
pub fn as_loop(&self) -> Option<&Block>
pub fn as_error(&self) -> Option<&String>
Source§impl StatementKind
impl StatementKind
pub fn as_assign_mut(&mut self) -> Option<(&mut Place, &mut Rvalue)>
pub fn as_set_discriminant_mut( &mut self, ) -> Option<(&mut Place, &mut VariantId)>
pub fn as_storage_live_mut(&mut self) -> Option<&mut LocalId>
pub fn as_storage_dead_mut(&mut self) -> Option<&mut LocalId>
pub fn as_place_mention_mut(&mut self) -> Option<&mut Place>
pub fn as_borrowck_mut(&mut self) -> Option<&mut BorrowckStatement>
pub fn as_drop_mut( &mut self, ) -> Option<(&mut Place, &mut FnPtr, &mut DropKind, &mut Block)>
pub fn as_assert_mut( &mut self, ) -> Option<(&mut Assert, &mut AbortKind, &mut Block)>
pub fn as_inline_asm_mut( &mut self, ) -> Option<(&mut String, &mut Vec<Block>, &mut Block)>
pub fn as_call_mut(&mut self) -> Option<(&mut Call, &mut Block)>
pub fn as_abort_mut(&mut self) -> Option<&mut AbortKind>
pub fn as_return_mut(&mut self) -> Option<()>
pub fn as_unwind_resume_mut(&mut self) -> Option<()>
pub fn as_break_mut(&mut self) -> Option<&mut usize>
pub fn as_continue_mut(&mut self) -> Option<&mut usize>
pub fn as_nop_mut(&mut self) -> Option<()>
pub fn as_switch_mut(&mut self) -> Option<&mut Switch>
pub fn as_loop_mut(&mut self) -> Option<&mut Block>
pub fn as_error_mut(&mut self) -> Option<&mut String>
Trait Implementations§
Source§impl AstVisitable for StatementKind
impl AstVisitable for StatementKind
Source§fn drive<V: VisitAst>(&self, v: &mut V) -> ControlFlow<V::Break>
fn drive<V: VisitAst>(&self, v: &mut V) -> ControlFlow<V::Break>
visit_$any
method if it exists, otherwise visit_inner.Source§fn drive_mut<V: VisitAstMut>(&mut self, v: &mut V) -> ControlFlow<V::Break>
fn drive_mut<V: VisitAstMut>(&mut self, v: &mut V) -> ControlFlow<V::Break>
visit_$any
method if it exists, otherwise visit_inner.Source§fn drive_two<V: ZipAst>(&self, other: &Self, v: &mut V) -> ControlFlow<V::Break>
fn drive_two<V: ZipAst>(&self, other: &Self, v: &mut V) -> ControlFlow<V::Break>
visit_$any
method if it exists, otherwise visit_inner.Source§fn dyn_visit<T: AstVisitable>(&self, f: impl FnMut(&T))where
Self: Sized,
fn dyn_visit<T: AstVisitable>(&self, f: impl FnMut(&T))where
Self: Sized,
self, in pre-order traversal.Source§fn dyn_visit_mut<T: AstVisitable>(&mut self, f: impl FnMut(&mut T))where
Self: Sized,
fn dyn_visit_mut<T: AstVisitable>(&mut self, f: impl FnMut(&mut T))where
Self: Sized,
self, in pre-order traversal.Source§impl BodyVisitable for StatementKind
impl BodyVisitable for StatementKind
Source§fn drive_body<V: VisitBody>(&self, v: &mut V) -> ControlFlow<V::Break>
fn drive_body<V: VisitBody>(&self, v: &mut V) -> ControlFlow<V::Break>
visit_$any
method if it exists, otherwise visit_inner.Source§fn drive_body_mut<V: VisitBodyMut>(
&mut self,
v: &mut V,
) -> ControlFlow<V::Break>
fn drive_body_mut<V: VisitBodyMut>( &mut self, v: &mut V, ) -> ControlFlow<V::Break>
visit_$any
method if it exists, otherwise visit_inner.Source§fn dyn_visit_in_body<T: BodyVisitable>(&self, f: impl FnMut(&T))where
Self: Sized,
fn dyn_visit_in_body<T: BodyVisitable>(&self, f: impl FnMut(&T))where
Self: Sized,
self, in pre-order traversal.Source§fn dyn_visit_in_body_mut<T: BodyVisitable>(&mut self, f: impl FnMut(&mut T))where
Self: Sized,
fn dyn_visit_in_body_mut<T: BodyVisitable>(&mut self, f: impl FnMut(&mut T))where
Self: Sized,
self, in pre-order traversal.Source§impl Clone for StatementKind
impl Clone for StatementKind
Source§fn clone(&self) -> StatementKind
fn clone(&self) -> StatementKind
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StatementKind
impl Debug for StatementKind
Source§impl<'de, __State: ?Sized> DeserializeState<'de, __State> for StatementKindwhere
Place: DeserializeState<'de, __State>,
Rvalue: DeserializeState<'de, __State>,
VariantId: DeserializeState<'de, __State>,
LocalId: DeserializeState<'de, __State>,
BorrowckStatement: DeserializeState<'de, __State>,
FnPtr: DeserializeState<'de, __State>,
DropKind: DeserializeState<'de, __State>,
Block: DeserializeState<'de, __State>,
Assert: DeserializeState<'de, __State>,
AbortKind: DeserializeState<'de, __State>,
String: DeserializeState<'de, __State>,
Vec<Block>: DeserializeState<'de, __State>,
Call: DeserializeState<'de, __State>,
usize: DeserializeState<'de, __State>,
Switch: DeserializeState<'de, __State>,
impl<'de, __State: ?Sized> DeserializeState<'de, __State> for StatementKindwhere
Place: DeserializeState<'de, __State>,
Rvalue: DeserializeState<'de, __State>,
VariantId: DeserializeState<'de, __State>,
LocalId: DeserializeState<'de, __State>,
BorrowckStatement: DeserializeState<'de, __State>,
FnPtr: DeserializeState<'de, __State>,
DropKind: DeserializeState<'de, __State>,
Block: DeserializeState<'de, __State>,
Assert: DeserializeState<'de, __State>,
AbortKind: DeserializeState<'de, __State>,
String: DeserializeState<'de, __State>,
Vec<Block>: DeserializeState<'de, __State>,
Call: DeserializeState<'de, __State>,
usize: DeserializeState<'de, __State>,
Switch: DeserializeState<'de, __State>,
fn deserialize_state<__D>(
__state: &__State,
__deserializer: __D,
) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<'s, V> Drive<'s, V> for StatementKind
impl<'s, V> Drive<'s, V> for StatementKind
Source§fn drive_inner(&'s self, visitor: &mut V) -> ControlFlow<V::Break>
fn drive_inner(&'s self, visitor: &mut V) -> ControlFlow<V::Break>
v.visit() on the immediate contents of self.Source§impl<'s, V> DriveMut<'s, V> for StatementKindwhere
V: Visitor + VisitMut<'s, Place> + VisitMut<'s, Rvalue> + VisitMut<'s, VariantId> + VisitMut<'s, LocalId> + VisitMut<'s, BorrowckStatement> + VisitMut<'s, FnPtr> + VisitMut<'s, Block> + VisitMut<'s, Assert> + VisitMut<'s, AbortKind> + VisitMut<'s, String> + VisitMut<'s, Vec<Block>> + VisitMut<'s, Call> + VisitMut<'s, Switch>,
impl<'s, V> DriveMut<'s, V> for StatementKindwhere
V: Visitor + VisitMut<'s, Place> + VisitMut<'s, Rvalue> + VisitMut<'s, VariantId> + VisitMut<'s, LocalId> + VisitMut<'s, BorrowckStatement> + VisitMut<'s, FnPtr> + VisitMut<'s, Block> + VisitMut<'s, Assert> + VisitMut<'s, AbortKind> + VisitMut<'s, String> + VisitMut<'s, Vec<Block>> + VisitMut<'s, Call> + VisitMut<'s, Switch>,
Source§fn drive_inner_mut(&'s mut self, visitor: &mut V) -> ControlFlow<V::Break>
fn drive_inner_mut(&'s mut self, visitor: &mut V) -> ControlFlow<V::Break>
v.visit() on the immediate contents of self.Source§impl<'s, V> DriveTwo<'s, V> for StatementKindwhere
V: Visitor<Break: Default> + VisitTwo<'s, Place> + VisitTwo<'s, Rvalue> + VisitTwo<'s, VariantId> + VisitTwo<'s, LocalId> + VisitTwo<'s, BorrowckStatement> + VisitTwo<'s, FnPtr> + VisitTwo<'s, Block> + VisitTwo<'s, Assert> + VisitTwo<'s, AbortKind> + VisitTwo<'s, String> + VisitTwo<'s, Vec<Block>> + VisitTwo<'s, Call> + VisitTwo<'s, Switch>,
impl<'s, V> DriveTwo<'s, V> for StatementKindwhere
V: Visitor<Break: Default> + VisitTwo<'s, Place> + VisitTwo<'s, Rvalue> + VisitTwo<'s, VariantId> + VisitTwo<'s, LocalId> + VisitTwo<'s, BorrowckStatement> + VisitTwo<'s, FnPtr> + VisitTwo<'s, Block> + VisitTwo<'s, Assert> + VisitTwo<'s, AbortKind> + VisitTwo<'s, String> + VisitTwo<'s, Vec<Block>> + VisitTwo<'s, Call> + VisitTwo<'s, Switch>,
Source§fn drive_two_inner(
&'s self,
other: &'s Self,
visitor: &mut V,
) -> ControlFlow<V::Break>
fn drive_two_inner( &'s self, other: &'s Self, visitor: &mut V, ) -> ControlFlow<V::Break>
v.visit() on the immediate contents of self and other, if they correspond. If
the values don’t match up, this returns Break(Default::default()).Source§impl PartialEq for StatementKind
impl PartialEq for StatementKind
Source§fn eq(&self, other: &StatementKind) -> bool
fn eq(&self, other: &StatementKind) -> bool
self and other values to be equal, and is used by ==.Source§impl<__State: ?Sized> SerializeState<__State> for StatementKindwhere
Place: SerializeState<__State>,
Rvalue: SerializeState<__State>,
VariantId: SerializeState<__State>,
LocalId: SerializeState<__State>,
BorrowckStatement: SerializeState<__State>,
FnPtr: SerializeState<__State>,
DropKind: SerializeState<__State>,
Block: SerializeState<__State>,
Assert: SerializeState<__State>,
AbortKind: SerializeState<__State>,
String: SerializeState<__State>,
Vec<Block>: SerializeState<__State>,
Call: SerializeState<__State>,
usize: SerializeState<__State>,
Switch: SerializeState<__State>,
impl<__State: ?Sized> SerializeState<__State> for StatementKindwhere
Place: SerializeState<__State>,
Rvalue: SerializeState<__State>,
VariantId: SerializeState<__State>,
LocalId: SerializeState<__State>,
BorrowckStatement: SerializeState<__State>,
FnPtr: SerializeState<__State>,
DropKind: SerializeState<__State>,
Block: SerializeState<__State>,
Assert: SerializeState<__State>,
AbortKind: SerializeState<__State>,
String: SerializeState<__State>,
Vec<Block>: SerializeState<__State>,
Call: SerializeState<__State>,
usize: SerializeState<__State>,
Switch: SerializeState<__State>,
fn serialize_state<__S>(
&self,
__state: &__State,
__serializer: __S,
) -> Result<__S::Ok, __S::Error>where
__S: Serializer,
impl Eq for StatementKind
impl StructuralPartialEq for StatementKind
Auto Trait Implementations§
impl Freeze for StatementKind
impl RefUnwindSafe for StatementKind
impl Send for StatementKind
impl Sync for StatementKind
impl Unpin for StatementKind
impl UnsafeUnpin for StatementKind
impl UnwindSafe for StatementKind
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
§fn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<I> RecreateContext<I> for I
impl<I> RecreateContext<I> for I
§fn recreate_context(_original_input: I, tail: I) -> I
fn recreate_context(_original_input: I, tail: I) -> I
Source§impl<T> TyVisitable for Twhere
T: AstVisitable,
impl<T> TyVisitable for Twhere
T: AstVisitable,
Source§fn visit_vars(&mut self, v: &mut impl VarsVisitor)
fn visit_vars(&mut self, v: &mut impl VarsVisitor)
self, as seen from the outside of self. This means
that any variable bound inside self will be skipped, and all the seen De Bruijn indices
will count from the outside of self.Source§fn substitute(self, generics: &GenericArgs) -> Self
fn substitute(self, generics: &GenericArgs) -> Self
self by replacing them with the provided values.
Note: if self is an item that comes from a TraitDecl, you must use
substitute_with_self or substitute_inner_binder, otherwise you’ll get panics.Source§fn substitute_inner_binder(self, generics: &GenericArgs) -> Self
fn substitute_inner_binder(self, generics: &GenericArgs) -> Self
self by replacing them with the provided values.
This is appropriate when substituting an inner binder.Source§fn substitute_explicits(self, generics: &GenericArgs) -> Self
fn substitute_explicits(self, generics: &GenericArgs) -> Self
Source§fn substitute_with_self(
self,
generics: &GenericArgs,
self_ref: &TraitRefKind,
) -> Self
fn substitute_with_self( self, generics: &GenericArgs, self_ref: &TraitRefKind, ) -> Self
TraitRefKind::SelfId trait ref.Source§fn substitute_with_tref(self, tref: &TraitRef) -> Self
fn substitute_with_tref(self, tref: &TraitRef) -> Self
TraitRefKind::SelfId trait ref.Source§fn try_substitute_with_tref(
self,
tref: &TraitRef,
) -> Result<Self, GenericsMismatch>
fn try_substitute_with_tref( self, tref: &TraitRef, ) -> Result<Self, GenericsMismatch>
TraitRefKind::SelfId trait ref.fn try_substitute( self, generics: &GenericArgs, ) -> Result<Self, GenericsMismatch>
fn try_substitute_with_self( self, generics: &GenericArgs, self_ref: &TraitRefKind, ) -> Result<Self, GenericsMismatch>
Source§fn move_under_binder(self) -> Self
fn move_under_binder(self) -> Self
Source§fn move_under_binders(self, depth: DeBruijnId) -> Self
fn move_under_binders(self, depth: DeBruijnId) -> Self
depth binders.Source§fn move_from_under_binder(self) -> Option<Self>
fn move_from_under_binder(self) -> Option<Self>
Source§fn move_from_under_binders(self, depth: DeBruijnId) -> Option<Self>
fn move_from_under_binders(self, depth: DeBruijnId) -> Option<Self>
depth binders. Returns None if it contains a variable bound in
one of these depth binders.Source§fn visit_db_id<B>(
&mut self,
f: impl FnMut(&mut DeBruijnId) -> ControlFlow<B>,
) -> ControlFlow<B>
fn visit_db_id<B>( &mut self, f: impl FnMut(&mut DeBruijnId) -> ControlFlow<B>, ) -> ControlFlow<B>
self, as seen from the outside of self. This means
that any variable bound inside self will be skipped, and all the seen indices will count
from the outside of self.