flux_rustc_bridge::mir

Enum FakeReadCause

Source
pub enum FakeReadCause {
    ForMatchGuard,
    ForMatchedPlace(Option<LocalDefId>),
    ForGuardBinding,
    ForLet(Option<LocalDefId>),
    ForIndex,
}
Expand description

The FakeReadCause describes the type of pattern why a FakeRead statement exists.

Variants§

§

ForMatchGuard

Inject a fake read of the borrowed input at the end of each guards code.

This should ensure that you cannot change the variant for an enum while you are in the midst of matching on it.

§

ForMatchedPlace(Option<LocalDefId>)

let x: !; match x {} doesn’t generate any read of x so we need to generate a read of x to check that it is initialized and safe.

If a closure pattern matches a Place starting with an Upvar, then we introduce a FakeRead for that Place outside the closure, in such a case this option would be Some(closure_def_id). Otherwise, the value of the optional LocalDefId will be None.

§

ForGuardBinding

A fake read of the RefWithinGuard version of a bind-by-value variable in a match guard to ensure that its value hasn’t change by the time we create the OutsideGuard version.

§

ForLet(Option<LocalDefId>)

Officially, the semantics of

let pattern = <expr>;

is that <expr> is evaluated into a temporary and then this temporary is into the pattern.

However, if we see the simple pattern let var = <expr>, we optimize this to evaluate <expr> directly into the variable var. This is mostly unobservable, but in some cases it can affect the borrow checker, as in #53695. Therefore, we insert a “fake read” here to ensure that we get appropriate errors.

If a closure pattern matches a Place starting with an Upvar, then we introduce a FakeRead for that Place outside the closure, in such a case this option would be Some(closure_def_id). Otherwise, the value of the optional DefId will be None.

§

ForIndex

If we have an index expression like

(*x)[1][{ x = y; 4}]

then the first bounds check is invalidated when we evaluate the second index expression. Thus we create a fake borrow of x across the second indexer, which will cause a borrow check error.

Auto Trait Implementations§

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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 = Infallible

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.