about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2019-09-14 11:21:18 +0200
committerbjorn3 <bjorn3@users.noreply.github.com>2019-09-14 11:21:18 +0200
commit6ea4cbdf1bbe0a7db018f4acd0258e13734b0338 (patch)
treeef8b995e0c8eac14738cb2c95e14383c919c9b97
parent1558bf94e59e7c5e5bc4e278561e9587af7b729a (diff)
downloadrust-6ea4cbdf1bbe0a7db018f4acd0258e13734b0338.tar.gz
rust-6ea4cbdf1bbe0a7db018f4acd0258e13734b0338.zip
Rustup to rustc 1.39.0-nightly (a6946a817 2019-09-13)
-rw-r--r--src/analyze.rs6
-rw-r--r--src/base.rs136
-rw-r--r--src/constant.rs2
3 files changed, 70 insertions, 74 deletions
diff --git a/src/analyze.rs b/src/analyze.rs
index 2adaa0b7182..63b268597fe 100644
--- a/src/analyze.rs
+++ b/src/analyze.rs
@@ -24,8 +24,10 @@ pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> HashMap<Local, Flags> {
     for bb in fx.mir.basic_blocks().iter() {
         for stmt in bb.statements.iter() {
             match &stmt.kind {
-                Assign(_, rval) => match &**rval {
-                    Rvalue::Ref(_, _, place) => analyze_non_ssa_place(&mut flag_map, place),
+                Assign(place_and_rval) => match &place_and_rval.1 {
+                    Rvalue::Ref(_, _, place) => {
+                        analyze_non_ssa_place(&mut flag_map, place);
+                    }
                     _ => {}
                 },
                 _ => {}
diff --git a/src/base.rs b/src/base.rs
index 81735ef7a62..f1840f20125 100644
--- a/src/base.rs
+++ b/src/base.rs
@@ -267,10 +267,10 @@ fn trans_stmt<'tcx>(
             let place = trans_place(fx, place);
             crate::discriminant::codegen_set_discriminant(fx, place, *variant_index);
         }
-        StatementKind::Assign(to_place, rval) => {
-            let lval = trans_place(fx, to_place);
+        StatementKind::Assign(to_place_and_rval) => {
+            let lval = trans_place(fx, &to_place_and_rval.0);
             let dest_layout = lval.layout();
-            match &**rval {
+            match &to_place_and_rval.1 {
                 Rvalue::Use(operand) => {
                     let val = trans_operand(fx, operand);
                     lval.write_cvalue(fx, val);
@@ -506,7 +506,7 @@ fn trans_stmt<'tcx>(
                             to.write_cvalue(fx, operand);
                         }
                     }
-                    _ => unimpl!("shouldn't exist at trans {:?}", rval),
+                    _ => unimpl!("shouldn't exist at trans {:?}", to_place_and_rval.1),
                 },
             }
         }
@@ -606,7 +606,7 @@ pub fn trans_place<'tcx>(
     fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
     place: &Place<'tcx>,
 ) -> CPlace<'tcx> {
-    let base = match &place.base {
+    let mut cplace = match &place.base {
         PlaceBase::Local(local) => fx.get_local_place(*local),
         PlaceBase::Static(static_) => match static_.kind {
             StaticKind::Static => {
@@ -619,76 +619,70 @@ pub fn trans_place<'tcx>(
         },
     };
 
-    trans_place_projection(fx, base, &place.projection)
-}
-
-pub fn trans_place_projection<'tcx>(
-    fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
-    base: CPlace<'tcx>,
-    projection: &Option<Box<Projection<'tcx>>>,
-) -> CPlace<'tcx> {
-    let projection = if let Some(projection) = projection {
-        projection
-    } else {
-        return base;
-    };
-
-    let base = trans_place_projection(fx, base, &projection.base);
-
-    match projection.elem {
-        ProjectionElem::Deref => base.place_deref(fx),
-        ProjectionElem::Field(field, _ty) => base.place_field(fx, field),
-        ProjectionElem::Index(local) => {
-            let index = fx.get_local_place(local).to_cvalue(fx).load_scalar(fx);
-            base.place_index(fx, index)
-        }
-        ProjectionElem::ConstantIndex {
-            offset,
-            min_length: _,
-            from_end,
-        } => {
-            let index = if !from_end {
-                fx.bcx.ins().iconst(fx.pointer_type, offset as i64)
-            } else {
-                let len = codegen_array_len(fx, base);
-                fx.bcx.ins().iadd_imm(len, -(offset as i64))
-            };
-            base.place_index(fx, index)
-        }
-        ProjectionElem::Subslice { from, to } => {
-            // These indices are generated by slice patterns.
-            // slice[from:-to] in Python terms.
-
-            match base.layout().ty.sty {
-                ty::Array(elem_ty, len) => {
-                    let elem_layout = fx.layout_of(elem_ty);
-                    let ptr = base.to_addr(fx);
-                    let len = crate::constant::force_eval_const(fx, len)
-                        .eval_usize(fx.tcx, ParamEnv::reveal_all());
-                    CPlace::for_addr(
-                        fx.bcx
-                            .ins()
-                            .iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64),
-                        fx.layout_of(fx.tcx.mk_array(elem_ty, len - from as u64 - to as u64)),
-                    )
-                }
-                ty::Slice(elem_ty) => {
-                    let elem_layout = fx.layout_of(elem_ty);
-                    let (ptr, len) = base.to_addr_maybe_unsized(fx);
-                    let len = len.unwrap();
-                    CPlace::for_addr_with_extra(
-                        fx.bcx
-                            .ins()
-                            .iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64),
-                        fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)),
-                        base.layout(),
-                    )
+    for elem in &*place.projection {
+        match *elem {
+            PlaceElem::Deref => {
+                cplace = cplace.place_deref(fx);
+            }
+            PlaceElem::Field(field, _ty) => {
+                cplace = cplace.place_field(fx, field);
+            }
+            PlaceElem::Index(local) => {
+                let index = fx.get_local_place(local).to_cvalue(fx).load_scalar(fx);
+                cplace = cplace.place_index(fx, index);
+            }
+            PlaceElem::ConstantIndex {
+                offset,
+                min_length: _,
+                from_end,
+            } => {
+                let index = if !from_end {
+                    fx.bcx.ins().iconst(fx.pointer_type, offset as i64)
+                } else {
+                    let len = codegen_array_len(fx, cplace);
+                    fx.bcx.ins().iadd_imm(len, -(offset as i64))
+                };
+                cplace = cplace.place_index(fx, index);
+            }
+            PlaceElem::Subslice { from, to } => {
+                // These indices are generated by slice patterns.
+                // slice[from:-to] in Python terms.
+
+                match cplace.layout().ty.sty {
+                    ty::Array(elem_ty, len) => {
+                        let elem_layout = fx.layout_of(elem_ty);
+                        let ptr = cplace.to_addr(fx);
+                        let len = crate::constant::force_eval_const(fx, len)
+                            .eval_usize(fx.tcx, ParamEnv::reveal_all());
+                        cplace = CPlace::for_addr(
+                            fx.bcx
+                                .ins()
+                                .iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64),
+                            fx.layout_of(fx.tcx.mk_array(elem_ty, len - from as u64 - to as u64)),
+                        );
+                    }
+                    ty::Slice(elem_ty) => {
+                        let elem_layout = fx.layout_of(elem_ty);
+                        let (ptr, len) = cplace.to_addr_maybe_unsized(fx);
+                        let len = len.unwrap();
+                        cplace = CPlace::for_addr_with_extra(
+                            fx.bcx
+                                .ins()
+                                .iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64),
+                            fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)),
+                            cplace.layout(),
+                        );
+                    }
+                    _ => unreachable!(),
                 }
-                _ => unreachable!(),
+            }
+            PlaceElem::Downcast(_adt_def, variant) => {
+                cplace = cplace.downcast_variant(fx, variant);
             }
         }
-        ProjectionElem::Downcast(_adt_def, variant) => base.downcast_variant(fx, variant),
     }
+
+    cplace
 }
 
 pub fn trans_operand<'tcx>(
diff --git a/src/constant.rs b/src/constant.rs
index 639bb9e5ade..f064a2c0a3d 100644
--- a/src/constant.rs
+++ b/src/constant.rs
@@ -482,7 +482,7 @@ pub fn mir_operand_get_const_val<'tcx>(
         Operand::Constant(const_) => return Some(force_eval_const(fx, const_.literal)),
     };
 
-    assert!(place.projection.is_none());
+    assert!(place.projection.is_empty());
     let static_ = match &place.base {
         PlaceBase::Static(static_) => static_,
         PlaceBase::Local(_) => return None,