Enum rustc_middle::mir::FakeReadCause[][src]

pub enum FakeReadCause {
    ForMatchGuard,
    ForMatchedPlace(Option<DefId>),
    ForGuardBinding,
    ForLet(Option<DefId>),
    ForIndex,
}

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<DefId>)

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 DefId will be None.

ForGuardBinding

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

ForLet(Option<DefId>)

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.

Trait Implementations

impl Clone for FakeReadCause[src]

impl Copy for FakeReadCause[src]

impl Debug for FakeReadCause[src]

impl<'tcx, __D: TyDecoder<'tcx>> Decodable<__D> for FakeReadCause[src]

impl<'tcx, __E: TyEncoder<'tcx>> Encodable<__E> for FakeReadCause[src]

impl Hash for FakeReadCause[src]

impl<'__ctx> HashStable<StableHashingContext<'__ctx>> for FakeReadCause[src]

impl<'tcx> Lift<'tcx> for FakeReadCause[src]

type Lifted = Self

impl PartialEq<FakeReadCause> for FakeReadCause[src]

impl StructuralPartialEq for FakeReadCause[src]

impl<'tcx> TypeFoldable<'tcx> for FakeReadCause[src]

Auto Trait Implementations

impl RefUnwindSafe for FakeReadCause

impl Send for FakeReadCause

impl Sync for FakeReadCause

impl Unpin for FakeReadCause

impl UnwindSafe for FakeReadCause

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<'tcx, T> ArenaAllocatable<'tcx, ()> for T where
    T: Copy
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<'a, T> Captures<'a> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> MaybeResult<T> for T[src]

type Error = !

impl<'tcx, T> Subst<'tcx> for T where
    T: TypeFoldable<'tcx>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> WithConstness for T[src]