about summary refs log tree commit diff
diff options
context:
space:
mode:
authory21 <30553356+y21@users.noreply.github.com>2023-05-21 15:07:53 +0200
committery21 <30553356+y21@users.noreply.github.com>2023-05-21 15:07:53 +0200
commite9a98d925f8fa3a95e62034954d090e7d142022a (patch)
tree1a823ad545488e7ee249fffeb88d656fe72cc956
parent191a901a8d29d292aa20b1161e703f76a4690595 (diff)
downloadrust-e9a98d925f8fa3a95e62034954d090e7d142022a.tar.gz
rust-e9a98d925f8fa3a95e62034954d090e7d142022a.zip
add test case for #10741
-rw-r--r--tests/ui/large_stack_arrays.rs13
-rw-r--r--tests/ui/large_stack_arrays.stderr30
2 files changed, 36 insertions, 7 deletions
diff --git a/tests/ui/large_stack_arrays.rs b/tests/ui/large_stack_arrays.rs
index 99787ffd3d3..3e9d5e6a4ca 100644
--- a/tests/ui/large_stack_arrays.rs
+++ b/tests/ui/large_stack_arrays.rs
@@ -18,6 +18,19 @@ pub static DOESNOTLINT2: [u8; 512_001] = {
     [x; 512_001]
 };
 
+fn issue_10741() {
+    #[derive(Copy, Clone)]
+    struct Large([u32; 100_000]);
+
+    fn build() -> Large {
+        Large([0; 100_000])
+    }
+
+    let _x = [build(); 3];
+
+    let _y = [build(), build(), build()];
+}
+
 fn main() {
     let bad = (
         [0u32; 20_000_000],
diff --git a/tests/ui/large_stack_arrays.stderr b/tests/ui/large_stack_arrays.stderr
index 24e90094982..118d39566ab 100644
--- a/tests/ui/large_stack_arrays.stderr
+++ b/tests/ui/large_stack_arrays.stderr
@@ -1,14 +1,30 @@
 error: allocating a local array larger than 512000 bytes
-  --> $DIR/large_stack_arrays.rs:23:9
+  --> $DIR/large_stack_arrays.rs:29:14
+   |
+LL |     let _x = [build(); 3];
+   |              ^^^^^^^^^^^^
+   |
+   = help: consider allocating on the heap with `vec![build(); 3].into_boxed_slice()`
+   = note: `-D clippy::large-stack-arrays` implied by `-D warnings`
+
+error: allocating a local array larger than 512000 bytes
+  --> $DIR/large_stack_arrays.rs:31:14
+   |
+LL |     let _y = [build(), build(), build()];
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: consider allocating on the heap with `vec![build(), build(), build()].into_boxed_slice()`
+
+error: allocating a local array larger than 512000 bytes
+  --> $DIR/large_stack_arrays.rs:36:9
    |
 LL |         [0u32; 20_000_000],
    |         ^^^^^^^^^^^^^^^^^^
    |
    = help: consider allocating on the heap with `vec![0u32; 20_000_000].into_boxed_slice()`
-   = note: `-D clippy::large-stack-arrays` implied by `-D warnings`
 
 error: allocating a local array larger than 512000 bytes
-  --> $DIR/large_stack_arrays.rs:24:9
+  --> $DIR/large_stack_arrays.rs:37:9
    |
 LL |         [S { data: [0; 32] }; 5000],
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -16,7 +32,7 @@ LL |         [S { data: [0; 32] }; 5000],
    = help: consider allocating on the heap with `vec![S { data: [0; 32] }; 5000].into_boxed_slice()`
 
 error: allocating a local array larger than 512000 bytes
-  --> $DIR/large_stack_arrays.rs:25:9
+  --> $DIR/large_stack_arrays.rs:38:9
    |
 LL |         [Some(""); 20_000_000],
    |         ^^^^^^^^^^^^^^^^^^^^^^
@@ -24,7 +40,7 @@ LL |         [Some(""); 20_000_000],
    = help: consider allocating on the heap with `vec![Some(""); 20_000_000].into_boxed_slice()`
 
 error: allocating a local array larger than 512000 bytes
-  --> $DIR/large_stack_arrays.rs:26:9
+  --> $DIR/large_stack_arrays.rs:39:9
    |
 LL |         [E::T(0); 5000],
    |         ^^^^^^^^^^^^^^^
@@ -32,12 +48,12 @@ LL |         [E::T(0); 5000],
    = help: consider allocating on the heap with `vec![E::T(0); 5000].into_boxed_slice()`
 
 error: allocating a local array larger than 512000 bytes
-  --> $DIR/large_stack_arrays.rs:27:9
+  --> $DIR/large_stack_arrays.rs:40:9
    |
 LL |         [0u8; usize::MAX],
    |         ^^^^^^^^^^^^^^^^^
    |
    = help: consider allocating on the heap with `vec![0u8; usize::MAX].into_boxed_slice()`
 
-error: aborting due to 5 previous errors
+error: aborting due to 7 previous errors