Add is_ref_for_guard
method
This commit is contained in:
parent
da9ebc828c
commit
5cfa70f760
@ -913,6 +913,16 @@ impl<'tcx> LocalDecl<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if this is a reference to a variable bound in a `match`
|
||||
/// expression that is used to access said variable for the guard of the
|
||||
/// match arm.
|
||||
pub fn is_ref_for_guard(&self) -> bool {
|
||||
match self.is_user_variable {
|
||||
Some(ClearCrossCrate::Set(BindingForm::RefForGuard)) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` is the local is from a compiler desugaring, e.g.,
|
||||
/// `__next` from a `for` loop.
|
||||
#[inline]
|
||||
|
@ -180,9 +180,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
||||
&including_downcast,
|
||||
)?;
|
||||
} else if let Place::Base(PlaceBase::Local(local)) = proj.base {
|
||||
if let Some(ClearCrossCrate::Set(BindingForm::RefForGuard)) =
|
||||
self.mir.local_decls[local].is_user_variable
|
||||
{
|
||||
if self.mir.local_decls[local].is_ref_for_guard() {
|
||||
self.append_place_to_string(
|
||||
&proj.base,
|
||||
buf,
|
||||
|
@ -95,12 +95,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
|
||||
}
|
||||
} else if {
|
||||
if let Place::Base(PlaceBase::Local(local)) = *base {
|
||||
if let Some(ClearCrossCrate::Set(BindingForm::RefForGuard))
|
||||
= self.mir.local_decls[local].is_user_variable {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
self.mir.local_decls[local].is_ref_for_guard()
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
@ -503,13 +503,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
elem: ProjectionElem::Deref,
|
||||
}) => {
|
||||
debug_assert!(
|
||||
if let Some(ClearCrossCrate::Set(BindingForm::RefForGuard)) =
|
||||
this.local_decls[local].is_user_variable
|
||||
{
|
||||
true
|
||||
} else {
|
||||
false
|
||||
},
|
||||
this.local_decls[local].is_ref_for_guard(),
|
||||
"Unexpected capture place",
|
||||
);
|
||||
this.local_decls[local].mutability
|
||||
|
Loading…
x
Reference in New Issue
Block a user