fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
1.3 KiB35 linesraw
1#![warn(clippy::large_const_arrays)]
2#![allow(dead_code)]
3
4#[derive(Clone, Copy)]
5pub struct S {
6    pub data: [u64; 32],
7}
8
9// Should lint
10pub(crate) static FOO_PUB_CRATE: [u32; 1_000_000] = [0u32; 1_000_000];
11pub static FOO_PUB: [u32; 1_000_000] = [0u32; 1_000_000];
12static FOO: [u32; 1_000_000] = [0u32; 1_000_000];
13
14// Good
15pub(crate) const G_FOO_PUB_CRATE: [u32; 1_000] = [0u32; 1_000];
16pub const G_FOO_PUB: [u32; 1_000] = [0u32; 1_000];
17const G_FOO: [u32; 1_000] = [0u32; 1_000];
18
19fn main() {
20    // Should lint
21    pub static BAR_PUB: [u32; 1_000_000] = [0u32; 1_000_000];
22    static BAR: [u32; 1_000_000] = [0u32; 1_000_000];
23    pub static BAR_STRUCT_PUB: [S; 5_000] = [S { data: [0; 32] }; 5_000];
24    static BAR_STRUCT: [S; 5_000] = [S { data: [0; 32] }; 5_000];
25    pub static BAR_S_PUB: [Option<&str>; 200_000] = [Some("str"); 200_000];
26    static BAR_S: [Option<&str>; 200_000] = [Some("str"); 200_000];
27
28    // Good
29    pub const G_BAR_PUB: [u32; 1_000] = [0u32; 1_000];
30    const G_BAR: [u32; 1_000] = [0u32; 1_000];
31    pub const G_BAR_STRUCT_PUB: [S; 500] = [S { data: [0; 32] }; 500];
32    const G_BAR_STRUCT: [S; 500] = [S { data: [0; 32] }; 500];
33    pub const G_BAR_S_PUB: [Option<&str>; 200] = [Some("str"); 200];
34    const G_BAR_S: [Option<&str>; 200] = [Some("str"); 200];
35}