Deduplicate match arms

This commit is contained in:
Oliver Schneider 2018-05-22 13:56:37 +02:00
parent 61c58c2f67
commit 2483c81217
No known key found for this signature in database
GPG Key ID: 1D5CB4FC597C3004

View File

@ -293,14 +293,11 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
debug!("store to var {:?}", index);
self.local_qualif[index] = Some(self.qualif);
}
Place::Local(index) if self.mir.local_kind(index) == LocalKind::Temp => {
debug!("store to temp {:?}", index);
Place::Local(index) if self.mir.local_kind(index) == LocalKind::Temp ||
self.mir.local_kind(index) == LocalKind::ReturnPointer => {
debug!("store to {:?} (temp or return pointer)", index);
store(&mut self.local_qualif[index])
}
Place::Local(index) if self.mir.local_kind(index) == LocalKind::ReturnPointer => {
debug!("store to return place {:?}", index);
store(&mut self.local_qualif[RETURN_PLACE])
}
Place::Projection(box Projection {
base: Place::Local(index),
@ -772,7 +769,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
}
if let Place::Local(local) = *place {
if self.mir.local_kind(local) == LocalKind::Temp {
if let Some(qualif) = self.temp_qualif[local] {
if let Some(qualif) = self.local_qualif[local] {
// `forbidden_mut` is false, so we can safely ignore
// `MUTABLE_INTERIOR` from the local's qualifications.
// This allows borrowing fields which don't have