about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-08-03 13:37:44 -0700
committerEsteban Küber <esteban@kuber.com.ar>2019-08-03 13:37:44 -0700
commit2c5684208c6f951b2cbe90df26a6691a95099e93 (patch)
tree0cb8651efd4bee50f596107f57b532f979e7180d
parentd3da411a080fb19c9cba2b812a48fb0a57c03013 (diff)
downloadrust-2c5684208c6f951b2cbe90df26a6691a95099e93.tar.gz
rust-2c5684208c6f951b2cbe90df26a6691a95099e93.zip
avoid mutable state and override main message
-rw-r--r--src/librustc/mir/interpret/error.rs11
-rw-r--r--src/test/ui/consts/issue-55878.rs2
-rw-r--r--src/test/ui/consts/issue-55878.stderr2
-rw-r--r--src/test/ui/issues/issue-56762.rs4
-rw-r--r--src/test/ui/issues/issue-56762.stderr4
5 files changed, 12 insertions, 11 deletions
diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs
index 05978ae3c6f..fb6f74397fc 100644
--- a/src/librustc/mir/interpret/error.rs
+++ b/src/librustc/mir/interpret/error.rs
@@ -137,16 +137,15 @@ impl<'tcx> ConstEvalErr<'tcx> {
         message: &str,
         lint_root: Option<hir::HirId>,
     ) -> Result<DiagnosticBuilder<'tcx>, ErrorHandled> {
-        let mut must_error = false;
-        match self.error {
+        let must_error = match self.error {
             err_inval!(Layout(LayoutError::Unknown(_))) |
             err_inval!(TooGeneric) =>
                 return Err(ErrorHandled::TooGeneric),
             err_inval!(TypeckError) =>
                 return Err(ErrorHandled::Reported),
-            err_inval!(Layout(LayoutError::SizeOverflow(_))) => must_error = true,
-            _ => {},
-        }
+            err_inval!(Layout(LayoutError::SizeOverflow(_))) => true,
+            _ => false,
+        };
         trace!("reporting const eval failure at {:?}", self.span);
         let mut err = if let (Some(lint_root), false) = (lint_root, must_error) {
             let hir_id = self.stacktrace
@@ -161,6 +160,8 @@ impl<'tcx> ConstEvalErr<'tcx> {
                 tcx.span,
                 message,
             )
+        } else if must_error {
+            struct_error(tcx, &self.error.to_string())
         } else {
             struct_error(tcx, message)
         };
diff --git a/src/test/ui/consts/issue-55878.rs b/src/test/ui/consts/issue-55878.rs
index ce6c2574287..6d8159e2fcd 100644
--- a/src/test/ui/consts/issue-55878.rs
+++ b/src/test/ui/consts/issue-55878.rs
@@ -1,4 +1,4 @@
-// error-pattern: reaching this expression at runtime will panic or abort
+// error-pattern: the type `[u8; 18446744073709551615]` is too big for the current architecture
 fn main() {
     println!("Size: {}", std::mem::size_of::<[u8; std::u64::MAX as usize]>());
 }
diff --git a/src/test/ui/consts/issue-55878.stderr b/src/test/ui/consts/issue-55878.stderr
index adb272f4bed..184c6d0e292 100644
--- a/src/test/ui/consts/issue-55878.stderr
+++ b/src/test/ui/consts/issue-55878.stderr
@@ -1,4 +1,4 @@
-error[E0080]: reaching this expression at runtime will panic or abort
+error[E0080]: the type `[u8; 18446744073709551615]` is too big for the current architecture
   --> $SRC_DIR/libcore/mem/mod.rs:LL:COL
    |
 LL |     intrinsics::size_of::<T>()
diff --git a/src/test/ui/issues/issue-56762.rs b/src/test/ui/issues/issue-56762.rs
index f12d0121a8f..5ba5b9847d0 100644
--- a/src/test/ui/issues/issue-56762.rs
+++ b/src/test/ui/issues/issue-56762.rs
@@ -17,8 +17,8 @@ impl TooBigArray {
 }
 
 static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new();
-//~^ ERROR could not evaluate static initializer
+//~^ ERROR the type `[u8; 2305843009213693951]` is too big for the current architecture
 static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE];
-//~^ ERROR could not evaluate static initializer
+//~^ ERROR the type `[u8; 2305843009213693951]` is too big for the current architecture
 
 fn main() { }
diff --git a/src/test/ui/issues/issue-56762.stderr b/src/test/ui/issues/issue-56762.stderr
index bce95087c5c..e74904f1f68 100644
--- a/src/test/ui/issues/issue-56762.stderr
+++ b/src/test/ui/issues/issue-56762.stderr
@@ -1,10 +1,10 @@
-error[E0080]: could not evaluate static initializer
+error[E0080]: the type `[u8; 2305843009213693951]` is too big for the current architecture
   --> $DIR/issue-56762.rs:19:1
    |
 LL | static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new();
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the type `[u8; 2305843009213693951]` is too big for the current architecture
 
-error[E0080]: could not evaluate static initializer
+error[E0080]: the type `[u8; 2305843009213693951]` is too big for the current architecture
   --> $DIR/issue-56762.rs:21:1
    |
 LL | static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE];