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.,
|
/// Returns `true` is the local is from a compiler desugaring, e.g.,
|
||||||
/// `__next` from a `for` loop.
|
/// `__next` from a `for` loop.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -180,9 +180,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||||||
&including_downcast,
|
&including_downcast,
|
||||||
)?;
|
)?;
|
||||||
} else if let Place::Base(PlaceBase::Local(local)) = proj.base {
|
} else if let Place::Base(PlaceBase::Local(local)) = proj.base {
|
||||||
if let Some(ClearCrossCrate::Set(BindingForm::RefForGuard)) =
|
if self.mir.local_decls[local].is_ref_for_guard() {
|
||||||
self.mir.local_decls[local].is_user_variable
|
|
||||||
{
|
|
||||||
self.append_place_to_string(
|
self.append_place_to_string(
|
||||||
&proj.base,
|
&proj.base,
|
||||||
buf,
|
buf,
|
||||||
|
@ -95,12 +95,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
} else if {
|
} else if {
|
||||||
if let Place::Base(PlaceBase::Local(local)) = *base {
|
if let Place::Base(PlaceBase::Local(local)) = *base {
|
||||||
if let Some(ClearCrossCrate::Set(BindingForm::RefForGuard))
|
self.mir.local_decls[local].is_ref_for_guard()
|
||||||
= self.mir.local_decls[local].is_user_variable {
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
@ -503,13 +503,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||||||
elem: ProjectionElem::Deref,
|
elem: ProjectionElem::Deref,
|
||||||
}) => {
|
}) => {
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
if let Some(ClearCrossCrate::Set(BindingForm::RefForGuard)) =
|
this.local_decls[local].is_ref_for_guard(),
|
||||||
this.local_decls[local].is_user_variable
|
|
||||||
{
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
},
|
|
||||||
"Unexpected capture place",
|
"Unexpected capture place",
|
||||||
);
|
);
|
||||||
this.local_decls[local].mutability
|
this.local_decls[local].mutability
|
||||||
|
Loading…
x
Reference in New Issue
Block a user