]> git.lizzy.rs Git - rust.git/commitdiff
Deduplicate match arms
authorOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>
Tue, 22 May 2018 11:56:37 +0000 (13:56 +0200)
committerOliver Schneider <git-no-reply-9879165716479413131@oli-obk.de>
Tue, 22 May 2018 11:56:37 +0000 (13:56 +0200)
src/librustc_mir/transform/qualify_consts.rs

index bb554b5e806fb102bad276d6a6b730db12237fae..999e3d89fc7e4f3a666fba6f4362c50e9bd6c7eb 100644 (file)
@@ -293,14 +293,11 @@ fn assign(&mut self, dest: &Place<'tcx>, location: Location) {
                 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 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
                     }
                     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