Skip to content

Commit

Permalink
Deduplicate match arms
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed May 22, 2018
1 parent 61c58c2 commit 2483c81
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/librustc_mir/transform/qualify_consts.rs
Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2483c81

Please sign in to comment.