about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_mir/transform/const_prop.rs10
-rw-r--r--src/test/ui/const-eval/index_out_of_bound.stderr9
-rw-r--r--src/test/ui/const-eval/index_out_of_bounds.rs (renamed from src/test/ui/const-eval/index_out_of_bound.rs)5
-rw-r--r--src/test/ui/const-eval/index_out_of_bounds.stderr17
4 files changed, 21 insertions, 20 deletions
diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs
index 40a6610c417..d39042ceba9 100644
--- a/src/librustc_mir/transform/const_prop.rs
+++ b/src/librustc_mir/transform/const_prop.rs
@@ -240,16 +240,6 @@ impl<'b, 'a, 'tcx:'b> ConstPropagator<'b, 'a, 'tcx> {
     ) -> Option<Const<'tcx>> {
         let span = source_info.span;
         match *rvalue {
-            // No need to overwrite an already evaluated constant
-            Rvalue::Use(Operand::Constant(box Constant {
-                literal: Literal::Value {
-                    value: &ty::Const {
-                        val: ConstVal::Value(_),
-                        ..
-                    },
-                },
-                ..
-            })) => None,
             // This branch exists for the sanity type check
             Rvalue::Use(Operand::Constant(ref c)) => {
                 assert_eq!(c.ty, place_ty);
diff --git a/src/test/ui/const-eval/index_out_of_bound.stderr b/src/test/ui/const-eval/index_out_of_bound.stderr
deleted file mode 100644
index d16231c72b9..00000000000
--- a/src/test/ui/const-eval/index_out_of_bound.stderr
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0080]: constant evaluation error
-  --> $DIR/index_out_of_bound.rs:11:19
-   |
-LL | static FOO: i32 = [][0];
-   |                   ^^^^^ index out of bounds: the len is 0 but the index is 0
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0080`.
diff --git a/src/test/ui/const-eval/index_out_of_bound.rs b/src/test/ui/const-eval/index_out_of_bounds.rs
index e7ffbe81b9a..9624b2924ba 100644
--- a/src/test/ui/const-eval/index_out_of_bound.rs
+++ b/src/test/ui/const-eval/index_out_of_bounds.rs
@@ -11,4 +11,7 @@
 static FOO: i32 = [][0];
 //~^ ERROR E0080
 
-fn main() {}
+fn main() {
+    let array = [std::env::args().len()];
+    array[1]; //~ ERROR index out of bounds
+}
\ No newline at end of file
diff --git a/src/test/ui/const-eval/index_out_of_bounds.stderr b/src/test/ui/const-eval/index_out_of_bounds.stderr
new file mode 100644
index 00000000000..96e592dc209
--- /dev/null
+++ b/src/test/ui/const-eval/index_out_of_bounds.stderr
@@ -0,0 +1,17 @@
+error[E0080]: constant evaluation error
+  --> $DIR/index_out_of_bounds.rs:11:19
+   |
+LL | static FOO: i32 = [][0];
+   |                   ^^^^^ index out of bounds: the len is 0 but the index is 0
+
+error: index out of bounds: the len is 1 but the index is 1
+  --> $DIR/index_out_of_bounds.rs:16:5
+   |
+LL |     array[1]; //~ ERROR index out of bounds
+   |     ^^^^^^^^
+   |
+   = note: #[deny(const_err)] on by default
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0080`.