about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkadmin <julianknodt@gmail.com>2021-01-23 00:23:13 +0000
committerkadmin <julianknodt@gmail.com>2021-03-09 16:54:14 +0000
commit049045b100f2b7f5fbc36ecd36418dec1f6853cb (patch)
treef1a1fd79c0909d3cc5ae061cc88e98c25476c3df
parent982382dc0361aa19e2f7e1e2b02003320d34b502 (diff)
downloadrust-049045b100f2b7f5fbc36ecd36418dec1f6853cb.tar.gz
rust-049045b100f2b7f5fbc36ecd36418dec1f6853cb.zip
Replace todos with impls
Changed to various implementations, copying the style of prior function calls in places I was
unsure of.

Also one minor style nit.
-rw-r--r--compiler/rustc_codegen_ssa/src/mir/statement.rs3
-rw-r--r--compiler/rustc_mir/src/borrow_check/invalidation.rs6
-rw-r--r--compiler/rustc_mir/src/borrow_check/mod.rs10
-rw-r--r--compiler/rustc_mir/src/borrow_check/type_check/mod.rs36
4 files changed, 45 insertions, 10 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/statement.rs b/compiler/rustc_codegen_ssa/src/mir/statement.rs
index 774c920ee96..054273262f7 100644
--- a/compiler/rustc_codegen_ssa/src/mir/statement.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/statement.rs
@@ -126,8 +126,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
                 let count = count_val.immediate_or_packed_pair(&mut bx);
                 let dst = dst_val.immediate_or_packed_pair(&mut bx);
                 let src = src_val.immediate_or_packed_pair(&mut bx);
-                use crate::MemFlags;
-                let flags = MemFlags::empty();
+                let flags = crate::MemFlags::empty();
                 bx.memcpy(
                     dst,
                     dst_val.layout.layout.align.pref,
diff --git a/compiler/rustc_mir/src/borrow_check/invalidation.rs b/compiler/rustc_mir/src/borrow_check/invalidation.rs
index 1f3dfc251e1..17c4f3c6494 100644
--- a/compiler/rustc_mir/src/borrow_check/invalidation.rs
+++ b/compiler/rustc_mir/src/borrow_check/invalidation.rs
@@ -100,12 +100,6 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
                 self.consume_operand(location, src);
                 self.consume_operand(location, dst);
                 self.consume_operand(location, count);
-                match dst {
-                    Operand::Move(ref place) | Operand::Copy(ref place) => {
-                        self.mutate_place(location, *place, Deep, JustWrite);
-                    }
-                    _ => {}
-                }
             }
             StatementKind::Nop
             | StatementKind::Coverage(..)
diff --git a/compiler/rustc_mir/src/borrow_check/mod.rs b/compiler/rustc_mir/src/borrow_check/mod.rs
index 539319ab9f2..037abb04f56 100644
--- a/compiler/rustc_mir/src/borrow_check/mod.rs
+++ b/compiler/rustc_mir/src/borrow_check/mod.rs
@@ -627,7 +627,15 @@ impl<'cx, 'tcx> dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tc
                 }
             }
 
-            StatementKind::CopyNonOverlapping(..) => todo!(),
+            StatementKind::CopyNonOverlapping(box rustc_middle::mir::CopyNonOverlapping {
+                src,
+                dst,
+                count,
+            }) => {
+                self.consume_operand(location, (src, span), flow_state);
+                self.consume_operand(location, (dst, span), flow_state);
+                self.consume_operand(location, (count, span), flow_state);
+            }
             StatementKind::Nop
             | StatementKind::Coverage(..)
             | StatementKind::AscribeUserType(..)
diff --git a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs
index 74d7fd84c9e..58db2752c98 100644
--- a/compiler/rustc_mir/src/borrow_check/type_check/mod.rs
+++ b/compiler/rustc_mir/src/borrow_check/type_check/mod.rs
@@ -1520,7 +1520,41 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
                     );
                 }
             }
-            StatementKind::CopyNonOverlapping(..) => todo!(),
+            StatementKind::CopyNonOverlapping(box rustc_middle::mir::CopyNonOverlapping {
+                ref src,
+                ref dst,
+                ref count,
+            }) => {
+                let op_src_ty = self.normalize(src.ty(body, self.tcx()), location);
+                let op_dst_ty = self.normalize(dst.ty(body, self.tcx()), location);
+                // since CopyNonOverlapping is parametrized by 1 type,
+                // we only need to check that they are equal and not keep an extra parameter.
+                if let Err(terr) = self.eq_types(
+                    op_src_ty,
+                    op_dst_ty,
+                    location.to_locations(),
+                    ConstraintCategory::Internal,
+                ) {
+                    span_mirbug!(
+                        self,
+                        stmt,
+                        "bad arg ({:?} != {:?}): {:?}",
+                        op_src_ty,
+                        op_dst_ty,
+                        terr
+                    );
+                }
+
+                let op_cnt_ty = self.normalize(count.ty(body, self.tcx()), location);
+                if let Err(terr) = self.eq_types(
+                    op_cnt_ty,
+                    tcx.types.usize,
+                    location.to_locations(),
+                    ConstraintCategory::Internal,
+                ) {
+                    span_mirbug!(self, stmt, "bad arg ({:?} != usize): {:?}", op_cnt_ty, terr);
+                }
+            }
             StatementKind::FakeRead(..)
             | StatementKind::StorageLive(..)
             | StatementKind::StorageDead(..)