]> git.lizzy.rs Git - rust.git/commitdiff
Always error on `SizeOverflow` during mir evaluation
authorEsteban Küber <esteban@kuber.com.ar>
Wed, 31 Jul 2019 00:46:46 +0000 (17:46 -0700)
committerEsteban Küber <esteban@kuber.com.ar>
Fri, 2 Aug 2019 19:30:46 +0000 (12:30 -0700)
src/librustc/mir/interpret/error.rs
src/test/ui/consts/issue-55878.rs [new file with mode: 0644]
src/test/ui/consts/issue-55878.stderr [new file with mode: 0644]
src/test/ui/issues/issue-56762.rs
src/test/ui/issues/issue-56762.stderr

index 8d41b019c221a4719d578556a47fa74c9398dfcf..7c1941196390a46f402a752749393860303dab03 100644 (file)
@@ -141,7 +141,6 @@ fn struct_generic(
             err_inval!(Layout(LayoutError::Unknown(_))) |
             err_inval!(TooGeneric) =>
                 return Err(ErrorHandled::TooGeneric),
-            err_inval!(Layout(LayoutError::SizeOverflow(_))) |
             err_inval!(TypeckError) =>
                 return Err(ErrorHandled::Reported),
             _ => {},
diff --git a/src/test/ui/consts/issue-55878.rs b/src/test/ui/consts/issue-55878.rs
new file mode 100644 (file)
index 0000000..ce6c257
--- /dev/null
@@ -0,0 +1,4 @@
+// error-pattern: reaching this expression at runtime will panic or abort
+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
new file mode 100644 (file)
index 0000000..03537ff
--- /dev/null
@@ -0,0 +1,15 @@
+error: reaching this expression at runtime will panic or abort
+  --> $SRC_DIR/libcore/mem/mod.rs:LL:COL
+   |
+LL |     intrinsics::size_of::<T>()
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ rustc layout computation failed: SizeOverflow([u8; 18446744073709551615])
+   | 
+  ::: $DIR/issue-55878.rs:3:26
+   |
+LL |     println!("Size: {}", std::mem::size_of::<[u8; std::u64::MAX as usize]>());
+   |                          ---------------------------------------------------
+   |
+   = note: `#[deny(const_err)]` on by default
+
+error: aborting due to previous error
+
index 8bb81b907c9a41dcdbb1595383774c78c5750af3..f12d0121a8f1af5b10badf7d157737b15ea78b6a 100644 (file)
@@ -17,6 +17,8 @@ pub const fn new() -> Self {
 }
 
 static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new();
+//~^ ERROR could not evaluate static initializer
 static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE];
+//~^ ERROR could not evaluate static initializer
 
 fn main() { }
index 83d5dc62e61618ce10a19e370df78706992692f5..fa7b9c71eb4a203c07e0717a6cebf16d87755f43 100644 (file)
@@ -1,4 +1,15 @@
-error: the type `[u8; 2305843009213693951]` is too big for the current architecture
+error[E0080]: could not evaluate static initializer
+  --> $DIR/issue-56762.rs:19:1
+   |
+LL | static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new();
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ rustc layout computation failed: SizeOverflow([u8; 2305843009213693951])
 
-error: aborting due to previous error
+error[E0080]: could not evaluate static initializer
+  --> $DIR/issue-56762.rs:21:1
+   |
+LL | static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE];
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ rustc layout computation failed: SizeOverflow([u8; 2305843009213693951])
 
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0080`.