]> git.proxmox.com Git - rustc.git/blame - src/tools/clippy/tests/ui/large_const_arrays.fixed
Update upstream source from tag 'upstream/1.52.1+dfsg1'
[rustc.git] / src / tools / clippy / tests / ui / large_const_arrays.fixed
CommitLineData
f20569fa
XL
1// run-rustfix
2
3#![warn(clippy::large_const_arrays)]
4#![allow(dead_code)]
5
6#[derive(Clone, Copy)]
7pub struct S {
8 pub data: [u64; 32],
9}
10
11// Should lint
12pub(crate) static FOO_PUB_CRATE: [u32; 1_000_000] = [0u32; 1_000_000];
13pub static FOO_PUB: [u32; 1_000_000] = [0u32; 1_000_000];
14static FOO: [u32; 1_000_000] = [0u32; 1_000_000];
15
16// Good
17pub(crate) const G_FOO_PUB_CRATE: [u32; 1_000] = [0u32; 1_000];
18pub const G_FOO_PUB: [u32; 1_000] = [0u32; 1_000];
19const G_FOO: [u32; 1_000] = [0u32; 1_000];
20
21fn main() {
22 // Should lint
23 pub static BAR_PUB: [u32; 1_000_000] = [0u32; 1_000_000];
24 static BAR: [u32; 1_000_000] = [0u32; 1_000_000];
25 pub static BAR_STRUCT_PUB: [S; 5_000] = [S { data: [0; 32] }; 5_000];
26 static BAR_STRUCT: [S; 5_000] = [S { data: [0; 32] }; 5_000];
27 pub static BAR_S_PUB: [Option<&str>; 200_000] = [Some("str"); 200_000];
28 static BAR_S: [Option<&str>; 200_000] = [Some("str"); 200_000];
29
30 // Good
31 pub const G_BAR_PUB: [u32; 1_000] = [0u32; 1_000];
32 const G_BAR: [u32; 1_000] = [0u32; 1_000];
33 pub const G_BAR_STRUCT_PUB: [S; 500] = [S { data: [0; 32] }; 500];
34 const G_BAR_STRUCT: [S; 500] = [S { data: [0; 32] }; 500];
35 pub const G_BAR_S_PUB: [Option<&str>; 200] = [Some("str"); 200];
36 const G_BAR_S: [Option<&str>; 200] = [Some("str"); 200];
37}