]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_codegen_ssa/mir/operand.rs
Remove PlaceBase enum and make Place base field be local: Local
[rust.git] / src / librustc_codegen_ssa / mir / operand.rs
index d53069654372043656f83d1a8e0662df2330e6b6..a155a6e78f7c3e3e6dd708501256b3460011b495 100644 (file)
@@ -373,44 +373,40 @@ fn maybe_codegen_consume_direct(
     ) -> Option<OperandRef<'tcx, Bx::Value>> {
         debug!("maybe_codegen_consume_direct(place_ref={:?})", place_ref);
 
-        if let mir::PlaceBase::Local(index) = place_ref.base {
-            match self.locals[*index] {
-                LocalRef::Operand(Some(mut o)) => {
-                    // Moves out of scalar and scalar pair fields are trivial.
-                    for elem in place_ref.projection.iter() {
-                        match elem {
-                            mir::ProjectionElem::Field(ref f, _) => {
-                                o = o.extract_field(bx, f.index());
-                            }
-                            mir::ProjectionElem::Index(_)
-                            | mir::ProjectionElem::ConstantIndex { .. } => {
-                                // ZSTs don't require any actual memory access.
-                                // FIXME(eddyb) deduplicate this with the identical
-                                // checks in `codegen_consume` and `extract_field`.
-                                let elem = o.layout.field(bx.cx(), 0);
-                                if elem.is_zst() {
-                                    o = OperandRef::new_zst(bx, elem);
-                                } else {
-                                    return None;
-                                }
+        match self.locals[*place_ref.local] {
+            LocalRef::Operand(Some(mut o)) => {
+                // Moves out of scalar and scalar pair fields are trivial.
+                for elem in place_ref.projection.iter() {
+                    match elem {
+                        mir::ProjectionElem::Field(ref f, _) => {
+                            o = o.extract_field(bx, f.index());
+                        }
+                        mir::ProjectionElem::Index(_)
+                        | mir::ProjectionElem::ConstantIndex { .. } => {
+                            // ZSTs don't require any actual memory access.
+                            // FIXME(eddyb) deduplicate this with the identical
+                            // checks in `codegen_consume` and `extract_field`.
+                            let elem = o.layout.field(bx.cx(), 0);
+                            if elem.is_zst() {
+                                o = OperandRef::new_zst(bx, elem);
+                            } else {
+                                return None;
                             }
-                            _ => return None,
                         }
+                        _ => return None,
                     }
-
-                    Some(o)
-                }
-                LocalRef::Operand(None) => {
-                    bug!("use of {:?} before def", place_ref);
-                }
-                LocalRef::Place(..) | LocalRef::UnsizedPlace(..) => {
-                    // watch out for locals that do not have an
-                    // alloca; they are handled somewhat differently
-                    None
                 }
+
+                Some(o)
+            }
+            LocalRef::Operand(None) => {
+                bug!("use of {:?} before def", place_ref);
+            }
+            LocalRef::Place(..) | LocalRef::UnsizedPlace(..) => {
+                // watch out for locals that do not have an
+                // alloca; they are handled somewhat differently
+                None
             }
-        } else {
-            None
         }
     }