Enum FakeBorrowKind
pub enum FakeBorrowKind {
Shallow,
Deep,
}Variants§
Shallow
A shared shallow borrow. The immediately borrowed place must be immutable, but projections
from it don’t need to be. For example, a shallow borrow of a.b doesn’t conflict with a
mutable borrow of a.b.c.
This is used when lowering matches: when matching on a place we want to ensure that place have the same value from the start of the match until an arm is selected. This prevents this code from compiling:
let mut x = &Some(0);
match *x {
None => (),
Some(_) if { x = &None; false } => (),
Some(_) => (),
}This can’t be a shared borrow because mutably borrowing (*x as Some).0 should not checking
the discriminant or accessing other variants, because the mutating (*x as Some).0 can’t
affect the discriminant of x. E.g. the following is allowed:
let mut x = Some(0);
match x {
Some(_)
if {
if let Some(ref mut y) = x {
*y += 1;
};
true
} => {}
_ => {}
}Deep
A shared (deep) borrow. Data must be immutable and is aliasable.
This is used when lowering deref patterns, where shallow borrows wouldn’t prevent something like:
let mut b = Box::new(false);
match b {
deref!(true) => {} // not reached because `*b == false`
_ if { *b = true; false } => {} // not reached because the guard is `false`
deref!(false) => {} // not reached because the guard changed it
// UB because we reached the unreachable.
}Auto Trait Implementations§
impl DynSend for FakeBorrowKind
impl DynSync for FakeBorrowKind
impl Freeze for FakeBorrowKind
impl RefUnwindSafe for FakeBorrowKind
impl Send for FakeBorrowKind
impl Sync for FakeBorrowKind
impl Unpin for FakeBorrowKind
impl UnsafeUnpin for FakeBorrowKind
impl UnwindSafe for FakeBorrowKind
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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