about summary refs log tree commit diff
path: root/tests/ui/limits
diff options
context:
space:
mode:
authorAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-05 09:13:28 +0100
committerAlbert Larsan <74931857+albertlarsan68@users.noreply.github.com>2023-01-11 09:32:08 +0000
commitcf2dff2b1e3fa55fa5415d524200070d0d7aacfe (patch)
tree40a88d9a46aaf3e8870676eb2538378b75a263eb /tests/ui/limits
parentca855e6e42787ecd062d81d53336fe6788ef51a9 (diff)
downloadrust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.tar.gz
rust-cf2dff2b1e3fa55fa5415d524200070d0d7aacfe.zip
Move /src/test to /tests
Diffstat (limited to 'tests/ui/limits')
-rw-r--r--tests/ui/limits/huge-array-simple-32.rs12
-rw-r--r--tests/ui/limits/huge-array-simple-32.stderr8
-rw-r--r--tests/ui/limits/huge-array-simple-64.rs12
-rw-r--r--tests/ui/limits/huge-array-simple-64.stderr8
-rw-r--r--tests/ui/limits/huge-array.rs15
-rw-r--r--tests/ui/limits/huge-array.stderr8
-rw-r--r--tests/ui/limits/huge-enum.rs18
-rw-r--r--tests/ui/limits/huge-enum.stderr8
-rw-r--r--tests/ui/limits/huge-struct.rs53
-rw-r--r--tests/ui/limits/huge-struct.stderr8
-rw-r--r--tests/ui/limits/issue-15919-32.rs13
-rw-r--r--tests/ui/limits/issue-15919-32.stderr8
-rw-r--r--tests/ui/limits/issue-15919-64.rs13
-rw-r--r--tests/ui/limits/issue-15919-64.stderr8
-rw-r--r--tests/ui/limits/issue-17913.rs21
-rw-r--r--tests/ui/limits/issue-17913.stderr4
-rw-r--r--tests/ui/limits/issue-55878.rs8
-rw-r--r--tests/ui/limits/issue-55878.stderr38
-rw-r--r--tests/ui/limits/issue-56762.rs24
-rw-r--r--tests/ui/limits/issue-56762.stderr15
-rw-r--r--tests/ui/limits/issue-69485-var-size-diffs-too-large.rs11
-rw-r--r--tests/ui/limits/issue-69485-var-size-diffs-too-large.stderr8
-rw-r--r--tests/ui/limits/issue-75158-64.rs16
-rw-r--r--tests/ui/limits/issue-75158-64.stderr4
24 files changed, 341 insertions, 0 deletions
diff --git a/tests/ui/limits/huge-array-simple-32.rs b/tests/ui/limits/huge-array-simple-32.rs
new file mode 100644
index 00000000000..2290e3d5e76
--- /dev/null
+++ b/tests/ui/limits/huge-array-simple-32.rs
@@ -0,0 +1,12 @@
+// ignore-64bit
+// build-fail
+
+// FIXME https://github.com/rust-lang/rust/issues/59774
+// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
+// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
+#![allow(arithmetic_overflow)]
+
+fn main() {
+    let _fat: [u8; (1<<31)+(1<<15)] = //~ ERROR too big for the current architecture
+        [0; (1u32<<31) as usize +(1u32<<15) as usize];
+}
diff --git a/tests/ui/limits/huge-array-simple-32.stderr b/tests/ui/limits/huge-array-simple-32.stderr
new file mode 100644
index 00000000000..31e120df626
--- /dev/null
+++ b/tests/ui/limits/huge-array-simple-32.stderr
@@ -0,0 +1,8 @@
+error: values of the type `[u8; 2147516416]` are too big for the current architecture
+  --> $DIR/huge-array-simple-32.rs:10:9
+   |
+LL |     let _fat: [u8; (1<<31)+(1<<15)] =
+   |         ^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/limits/huge-array-simple-64.rs b/tests/ui/limits/huge-array-simple-64.rs
new file mode 100644
index 00000000000..02c961fc5fa
--- /dev/null
+++ b/tests/ui/limits/huge-array-simple-64.rs
@@ -0,0 +1,12 @@
+// build-fail
+// ignore-32bit
+
+// FIXME https://github.com/rust-lang/rust/issues/59774
+// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
+// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
+#![allow(arithmetic_overflow)]
+
+fn main() {
+    let _fat: [u8; (1<<61)+(1<<31)] = //~ ERROR too big for the current architecture
+        [0; (1u64<<61) as usize +(1u64<<31) as usize];
+}
diff --git a/tests/ui/limits/huge-array-simple-64.stderr b/tests/ui/limits/huge-array-simple-64.stderr
new file mode 100644
index 00000000000..c5d3fe85d0d
--- /dev/null
+++ b/tests/ui/limits/huge-array-simple-64.stderr
@@ -0,0 +1,8 @@
+error: values of the type `[u8; 2305843011361177600]` are too big for the current architecture
+  --> $DIR/huge-array-simple-64.rs:10:9
+   |
+LL |     let _fat: [u8; (1<<61)+(1<<31)] =
+   |         ^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/limits/huge-array.rs b/tests/ui/limits/huge-array.rs
new file mode 100644
index 00000000000..3070801f865
--- /dev/null
+++ b/tests/ui/limits/huge-array.rs
@@ -0,0 +1,15 @@
+// FIXME https://github.com/rust-lang/rust/issues/59774
+
+// build-fail
+// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
+// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
+
+fn generic<T: Copy>(t: T) {
+    let s: [T; 1518600000] = [t; 1518600000];
+    //~^ ERROR values of the type `[[u8; 1518599999]; 1518600000]` are too big
+}
+
+fn main() {
+    let x: [u8; 1518599999] = [0; 1518599999];
+    generic::<[u8; 1518599999]>(x);
+}
diff --git a/tests/ui/limits/huge-array.stderr b/tests/ui/limits/huge-array.stderr
new file mode 100644
index 00000000000..817458b73e4
--- /dev/null
+++ b/tests/ui/limits/huge-array.stderr
@@ -0,0 +1,8 @@
+error: values of the type `[[u8; 1518599999]; 1518600000]` are too big for the current architecture
+  --> $DIR/huge-array.rs:8:9
+   |
+LL |     let s: [T; 1518600000] = [t; 1518600000];
+   |         ^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/limits/huge-enum.rs b/tests/ui/limits/huge-enum.rs
new file mode 100644
index 00000000000..39ea6e11b1f
--- /dev/null
+++ b/tests/ui/limits/huge-enum.rs
@@ -0,0 +1,18 @@
+// build-fail
+// normalize-stderr-test "std::option::Option<\[u32; \d+\]>" -> "TYPE"
+// normalize-stderr-test "\[u32; \d+\]" -> "TYPE"
+
+// FIXME https://github.com/rust-lang/rust/issues/59774
+// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
+// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
+
+#[cfg(target_pointer_width = "32")]
+type BIG = Option<[u32; (1<<29)-1]>;
+
+#[cfg(target_pointer_width = "64")]
+type BIG = Option<[u32; (1<<45)-1]>;
+
+fn main() {
+    let big: BIG = None;
+    //~^ ERROR are too big for the current architecture
+}
diff --git a/tests/ui/limits/huge-enum.stderr b/tests/ui/limits/huge-enum.stderr
new file mode 100644
index 00000000000..a1456e1a8ab
--- /dev/null
+++ b/tests/ui/limits/huge-enum.stderr
@@ -0,0 +1,8 @@
+error: values of the type `Option<TYPE>` are too big for the current architecture
+  --> $DIR/huge-enum.rs:16:9
+   |
+LL |     let big: BIG = None;
+   |         ^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/limits/huge-struct.rs b/tests/ui/limits/huge-struct.rs
new file mode 100644
index 00000000000..02f38d860b4
--- /dev/null
+++ b/tests/ui/limits/huge-struct.rs
@@ -0,0 +1,53 @@
+// build-fail
+// normalize-stderr-test "S32" -> "SXX"
+// normalize-stderr-test "S1M" -> "SXX"
+// error-pattern: too big for the current
+
+// FIXME https://github.com/rust-lang/rust/issues/59774
+// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
+// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
+
+struct S32<T> {
+    v0: T,
+    v1: T,
+    v2: T,
+    v3: T,
+    v4: T,
+    v5: T,
+    v6: T,
+    v7: T,
+    v8: T,
+    u9: T,
+    v10: T,
+    v11: T,
+    v12: T,
+    v13: T,
+    v14: T,
+    v15: T,
+    v16: T,
+    v17: T,
+    v18: T,
+    v19: T,
+    v20: T,
+    v21: T,
+    v22: T,
+    v23: T,
+    v24: T,
+    u25: T,
+    v26: T,
+    v27: T,
+    v28: T,
+    v29: T,
+    v30: T,
+    v31: T,
+}
+
+struct S1k<T> { val: S32<S32<T>> }
+
+struct S1M<T> { val: S1k<S1k<T>> }
+
+fn main() {
+    let fat: Option<S1M<S1M<S1M<u32>>>> = None;
+    //~^ ERROR are too big for the current architecture
+
+}
diff --git a/tests/ui/limits/huge-struct.stderr b/tests/ui/limits/huge-struct.stderr
new file mode 100644
index 00000000000..f0ee88e5955
--- /dev/null
+++ b/tests/ui/limits/huge-struct.stderr
@@ -0,0 +1,8 @@
+error: values of the type `SXX<SXX<SXX<u32>>>` are too big for the current architecture
+  --> $DIR/huge-struct.rs:50:9
+   |
+LL |     let fat: Option<SXX<SXX<SXX<u32>>>> = None;
+   |         ^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/limits/issue-15919-32.rs b/tests/ui/limits/issue-15919-32.rs
new file mode 100644
index 00000000000..3c93f14ccc7
--- /dev/null
+++ b/tests/ui/limits/issue-15919-32.rs
@@ -0,0 +1,13 @@
+// ignore-64bit
+// build-fail
+
+// FIXME https://github.com/rust-lang/rust/issues/59774
+// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
+// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
+
+fn main() {
+    let x = [0usize; 0xffff_ffff]; //~ ERROR too big
+}
+
+// This and the -64 version of this test need to have different literals, as we can't rely on
+// conditional compilation for them while retaining the same spans/lines.
diff --git a/tests/ui/limits/issue-15919-32.stderr b/tests/ui/limits/issue-15919-32.stderr
new file mode 100644
index 00000000000..133637f9a05
--- /dev/null
+++ b/tests/ui/limits/issue-15919-32.stderr
@@ -0,0 +1,8 @@
+error: values of the type `[usize; 4294967295]` are too big for the current architecture
+  --> $DIR/issue-15919-32.rs:9:9
+   |
+LL |     let x = [0usize; 0xffff_ffff];
+   |         ^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/limits/issue-15919-64.rs b/tests/ui/limits/issue-15919-64.rs
new file mode 100644
index 00000000000..3ecbd34eaaa
--- /dev/null
+++ b/tests/ui/limits/issue-15919-64.rs
@@ -0,0 +1,13 @@
+// build-fail
+// ignore-32bit
+
+// FIXME https://github.com/rust-lang/rust/issues/59774
+// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
+// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
+
+fn main() {
+    let x = [0usize; 0xffff_ffff_ffff_ffff]; //~ ERROR too big
+}
+
+// This and the -32 version of this test need to have different literals, as we can't rely on
+// conditional compilation for them while retaining the same spans/lines.
diff --git a/tests/ui/limits/issue-15919-64.stderr b/tests/ui/limits/issue-15919-64.stderr
new file mode 100644
index 00000000000..193b823035c
--- /dev/null
+++ b/tests/ui/limits/issue-15919-64.stderr
@@ -0,0 +1,8 @@
+error: values of the type `[usize; 18446744073709551615]` are too big for the current architecture
+  --> $DIR/issue-15919-64.rs:9:9
+   |
+LL |     let x = [0usize; 0xffff_ffff_ffff_ffff];
+   |         ^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/limits/issue-17913.rs b/tests/ui/limits/issue-17913.rs
new file mode 100644
index 00000000000..8d4cbe20184
--- /dev/null
+++ b/tests/ui/limits/issue-17913.rs
@@ -0,0 +1,21 @@
+// build-fail
+// normalize-stderr-test "\[&usize; \d+\]" -> "[&usize; N]"
+// error-pattern: too big for the current architecture
+
+// FIXME https://github.com/rust-lang/rust/issues/59774
+// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
+// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
+
+#[cfg(target_pointer_width = "64")]
+fn main() {
+    let n = 0_usize;
+    let a: Box<_> = Box::new([&n; 0xF000000000000000_usize]);
+    println!("{}", a[0xFFFFFF_usize]);
+}
+
+#[cfg(target_pointer_width = "32")]
+fn main() {
+    let n = 0_usize;
+    let a: Box<_> = Box::new([&n; 0xFFFFFFFF_usize]);
+    println!("{}", a[0xFFFFFF_usize]);
+}
diff --git a/tests/ui/limits/issue-17913.stderr b/tests/ui/limits/issue-17913.stderr
new file mode 100644
index 00000000000..9a6431d4470
--- /dev/null
+++ b/tests/ui/limits/issue-17913.stderr
@@ -0,0 +1,4 @@
+error: values of the type `[&usize; N]` are too big for the current architecture
+
+error: aborting due to previous error
+
diff --git a/tests/ui/limits/issue-55878.rs b/tests/ui/limits/issue-55878.rs
new file mode 100644
index 00000000000..c1c54646db8
--- /dev/null
+++ b/tests/ui/limits/issue-55878.rs
@@ -0,0 +1,8 @@
+// build-fail
+// normalize-stderr-64bit "18446744073709551615" -> "SIZE"
+// normalize-stderr-32bit "4294967295" -> "SIZE"
+
+// error-pattern: are too big for the current architecture
+fn main() {
+    println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>());
+}
diff --git a/tests/ui/limits/issue-55878.stderr b/tests/ui/limits/issue-55878.stderr
new file mode 100644
index 00000000000..f455dcb06f7
--- /dev/null
+++ b/tests/ui/limits/issue-55878.stderr
@@ -0,0 +1,38 @@
+error[E0080]: values of the type `[u8; SIZE]` are too big for the current architecture
+  --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
+   |
+note: inside `std::mem::size_of::<[u8; SIZE]>`
+  --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
+note: inside `main`
+  --> $DIR/issue-55878.rs:7:26
+   |
+LL |     println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>());
+   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+note: erroneous constant used
+  --> $DIR/issue-55878.rs:7:26
+   |
+LL |     println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>());
+   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+note: erroneous constant used
+  --> $DIR/issue-55878.rs:7:26
+   |
+LL |     println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>());
+   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+note: erroneous constant used
+  --> $DIR/issue-55878.rs:7:26
+   |
+LL |     println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>());
+   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/limits/issue-56762.rs b/tests/ui/limits/issue-56762.rs
new file mode 100644
index 00000000000..fb0a270f18b
--- /dev/null
+++ b/tests/ui/limits/issue-56762.rs
@@ -0,0 +1,24 @@
+// only-x86_64
+
+// FIXME https://github.com/rust-lang/rust/issues/59774
+// normalize-stderr-test "thread.*panicked.*Metadata module not compiled.*\n" -> ""
+// normalize-stderr-test "note:.*RUST_BACKTRACE=1.*\n" -> ""
+const HUGE_SIZE: usize = !0usize / 8;
+
+
+pub struct TooBigArray {
+    arr: [u8; HUGE_SIZE],
+}
+
+impl TooBigArray {
+    pub const fn new() -> Self {
+        TooBigArray { arr: [0x00; HUGE_SIZE], }
+    }
+}
+
+static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new();
+//~^ ERROR values of the type `[u8; 2305843009213693951]` are too big
+static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE];
+//~^ ERROR values of the type `[u8; 2305843009213693951]` are too big
+
+fn main() { }
diff --git a/tests/ui/limits/issue-56762.stderr b/tests/ui/limits/issue-56762.stderr
new file mode 100644
index 00000000000..e6b9c676278
--- /dev/null
+++ b/tests/ui/limits/issue-56762.stderr
@@ -0,0 +1,15 @@
+error[E0080]: values of the type `[u8; 2305843009213693951]` are too big for the current architecture
+  --> $DIR/issue-56762.rs:19:1
+   |
+LL | static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new();
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0080]: values of the type `[u8; 2305843009213693951]` are 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];
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0080`.
diff --git a/tests/ui/limits/issue-69485-var-size-diffs-too-large.rs b/tests/ui/limits/issue-69485-var-size-diffs-too-large.rs
new file mode 100644
index 00000000000..2560ffe168b
--- /dev/null
+++ b/tests/ui/limits/issue-69485-var-size-diffs-too-large.rs
@@ -0,0 +1,11 @@
+// build-fail
+// only-x86_64
+// compile-flags: -Zmir-opt-level=0
+
+fn main() {
+    Bug::V([0; !0]); //~ ERROR are too big for the current
+}
+
+enum Bug {
+    V([u8; !0]),
+}
diff --git a/tests/ui/limits/issue-69485-var-size-diffs-too-large.stderr b/tests/ui/limits/issue-69485-var-size-diffs-too-large.stderr
new file mode 100644
index 00000000000..f7923bd4743
--- /dev/null
+++ b/tests/ui/limits/issue-69485-var-size-diffs-too-large.stderr
@@ -0,0 +1,8 @@
+error: values of the type `[u8; 18446744073709551615]` are too big for the current architecture
+  --> $DIR/issue-69485-var-size-diffs-too-large.rs:6:5
+   |
+LL |     Bug::V([0; !0]);
+   |     ^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/limits/issue-75158-64.rs b/tests/ui/limits/issue-75158-64.rs
new file mode 100644
index 00000000000..06c209c078f
--- /dev/null
+++ b/tests/ui/limits/issue-75158-64.rs
@@ -0,0 +1,16 @@
+//~ ERROR
+
+// build-fail
+// ignore-32bit
+
+struct S<T> {
+    x: [T; !0],
+}
+
+pub fn f() -> usize {
+    std::mem::size_of::<S<u8>>()
+}
+
+fn main() {
+    let x = f();
+}
diff --git a/tests/ui/limits/issue-75158-64.stderr b/tests/ui/limits/issue-75158-64.stderr
new file mode 100644
index 00000000000..dc11d056154
--- /dev/null
+++ b/tests/ui/limits/issue-75158-64.stderr
@@ -0,0 +1,4 @@
+error: values of the type `[u8; 18446744073709551615]` are too big for the current architecture
+
+error: aborting due to previous error
+