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:
Auto Trait Implementations§
impl Freeze for FakeBorrowKind
impl RefUnwindSafe for FakeBorrowKind
impl Send for FakeBorrowKind
impl Sync for FakeBorrowKind
impl Unpin 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,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§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.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