summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/large_const_arrays.fixed
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/tests/ui/large_const_arrays.fixed')
-rw-r--r--src/tools/clippy/tests/ui/large_const_arrays.fixed37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/large_const_arrays.fixed b/src/tools/clippy/tests/ui/large_const_arrays.fixed
new file mode 100644
index 000000000..c5af07c8a
--- /dev/null
+++ b/src/tools/clippy/tests/ui/large_const_arrays.fixed
@@ -0,0 +1,37 @@
+// run-rustfix
+
+#![warn(clippy::large_const_arrays)]
+#![allow(dead_code)]
+
+#[derive(Clone, Copy)]
+pub struct S {
+ pub data: [u64; 32],
+}
+
+// Should lint
+pub(crate) static FOO_PUB_CRATE: [u32; 1_000_000] = [0u32; 1_000_000];
+pub static FOO_PUB: [u32; 1_000_000] = [0u32; 1_000_000];
+static FOO: [u32; 1_000_000] = [0u32; 1_000_000];
+
+// Good
+pub(crate) const G_FOO_PUB_CRATE: [u32; 1_000] = [0u32; 1_000];
+pub const G_FOO_PUB: [u32; 1_000] = [0u32; 1_000];
+const G_FOO: [u32; 1_000] = [0u32; 1_000];
+
+fn main() {
+ // Should lint
+ pub static BAR_PUB: [u32; 1_000_000] = [0u32; 1_000_000];
+ static BAR: [u32; 1_000_000] = [0u32; 1_000_000];
+ pub static BAR_STRUCT_PUB: [S; 5_000] = [S { data: [0; 32] }; 5_000];
+ static BAR_STRUCT: [S; 5_000] = [S { data: [0; 32] }; 5_000];
+ pub static BAR_S_PUB: [Option<&str>; 200_000] = [Some("str"); 200_000];
+ static BAR_S: [Option<&str>; 200_000] = [Some("str"); 200_000];
+
+ // Good
+ pub const G_BAR_PUB: [u32; 1_000] = [0u32; 1_000];
+ const G_BAR: [u32; 1_000] = [0u32; 1_000];
+ pub const G_BAR_STRUCT_PUB: [S; 500] = [S { data: [0; 32] }; 500];
+ const G_BAR_STRUCT: [S; 500] = [S { data: [0; 32] }; 500];
+ pub const G_BAR_S_PUB: [Option<&str>; 200] = [Some("str"); 200];
+ const G_BAR_S: [Option<&str>; 200] = [Some("str"); 200];
+}