Enum paralegal_spdg::rustc::mir::BorrowKind
source · pub enum BorrowKind {
Shared,
Shallow,
Mut {
kind: MutBorrowKind,
},
}
Variants§
Data must be immutable and is aliasable.
Shallow
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 prevent if let None = x { ... }
, for example, because the
mutating (*x as Some).0
can’t affect the discriminant of x
.
We can also report errors with this kind of borrow differently.
Mut
Fields
§
kind: MutBorrowKind
Data is mutable and not aliasable.
Auto Trait Implementations§
impl RefUnwindSafe for BorrowKind
impl Send for BorrowKind
impl Sync for BorrowKind
impl Unpin for BorrowKind
impl UnwindSafe for BorrowKind
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
Mutably borrows from an owned value. Read more
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.