summaryrefslogtreecommitdiffstats
path: root/tests/ui-toml/array_size_threshold
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
commita4b7ed7a42c716ab9f05e351f003d589124fd55d (patch)
treeb620cd3f223850b28716e474e80c58059dca5dd4 /tests/ui-toml/array_size_threshold
parentAdding upstream version 1.67.1+dfsg1. (diff)
downloadrustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz
rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui-toml/array_size_threshold')
-rw-r--r--tests/ui-toml/array_size_threshold/array_size_threshold.rs10
-rw-r--r--tests/ui-toml/array_size_threshold/array_size_threshold.stderr29
-rw-r--r--tests/ui-toml/array_size_threshold/clippy.toml1
3 files changed, 40 insertions, 0 deletions
diff --git a/tests/ui-toml/array_size_threshold/array_size_threshold.rs b/tests/ui-toml/array_size_threshold/array_size_threshold.rs
new file mode 100644
index 000000000..7f623c7a9
--- /dev/null
+++ b/tests/ui-toml/array_size_threshold/array_size_threshold.rs
@@ -0,0 +1,10 @@
+#![allow(unused)]
+#![warn(clippy::large_const_arrays, clippy::large_stack_arrays)]
+
+const ABOVE: [u8; 11] = [0; 11];
+const BELOW: [u8; 10] = [0; 10];
+
+fn main() {
+ let above = [0u8; 11];
+ let below = [0u8; 10];
+}
diff --git a/tests/ui-toml/array_size_threshold/array_size_threshold.stderr b/tests/ui-toml/array_size_threshold/array_size_threshold.stderr
new file mode 100644
index 000000000..ac017b209
--- /dev/null
+++ b/tests/ui-toml/array_size_threshold/array_size_threshold.stderr
@@ -0,0 +1,29 @@
+error: large array defined as const
+ --> $DIR/array_size_threshold.rs:4:1
+ |
+LL | const ABOVE: [u8; 11] = [0; 11];
+ | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | |
+ | help: make this a static item: `static`
+ |
+ = note: `-D clippy::large-const-arrays` implied by `-D warnings`
+
+error: allocating a local array larger than 10 bytes
+ --> $DIR/array_size_threshold.rs:4:25
+ |
+LL | const ABOVE: [u8; 11] = [0; 11];
+ | ^^^^^^^
+ |
+ = help: consider allocating on the heap with `vec![0; 11].into_boxed_slice()`
+ = note: `-D clippy::large-stack-arrays` implied by `-D warnings`
+
+error: allocating a local array larger than 10 bytes
+ --> $DIR/array_size_threshold.rs:8:17
+ |
+LL | let above = [0u8; 11];
+ | ^^^^^^^^^
+ |
+ = help: consider allocating on the heap with `vec![0u8; 11].into_boxed_slice()`
+
+error: aborting due to 3 previous errors
+
diff --git a/tests/ui-toml/array_size_threshold/clippy.toml b/tests/ui-toml/array_size_threshold/clippy.toml
new file mode 100644
index 000000000..3f1fe9a12
--- /dev/null
+++ b/tests/ui-toml/array_size_threshold/clippy.toml
@@ -0,0 +1 @@
+array-size-threshold = 10