]> git.lizzy.rs Git - rust.git/blob - tests/ui/type_complexity.rs
Update tests for type_complexity lint
[rust.git] / tests / ui / type_complexity.rs
1 #![warn(clippy::all)]
2 #![allow(unused, clippy::needless_pass_by_value, clippy::vec_box)]
3 #![feature(associated_type_defaults)]
4
5 type Alias = Vec<Vec<Box<(u32, u32, u32, u32)>>>; // no warning here
6
7 const CST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
8 static ST: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
9
10 struct S {
11     f: Vec<Vec<Box<(u32, u32, u32, u32)>>>,
12 }
13
14 struct Ts(Vec<Vec<Box<(u32, u32, u32, u32)>>>);
15
16 enum E {
17     Tuple(Vec<Vec<Box<(u32, u32, u32, u32)>>>),
18     Struct { f: Vec<Vec<Box<(u32, u32, u32, u32)>>> },
19 }
20
21 impl S {
22     const A: (u32, (u32, (u32, (u32, u32)))) = (0, (0, (0, (0, 0))));
23     fn impl_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
24 }
25
26 trait T {
27     const A: Vec<Vec<Box<(u32, u32, u32, u32)>>>;
28     type B = Vec<Vec<Box<(u32, u32, u32, u32)>>>;
29     fn method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>);
30     fn def_method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
31 }
32
33 impl T for () {
34     const A: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![];
35
36     // Should not warn since there is likely no way to simplify this (#1013)
37     type B = Vec<Vec<Box<(u32, u32, u32, u32)>>>;
38     fn method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
39 }
40
41 fn test1() -> Vec<Vec<Box<(u32, u32, u32, u32)>>> {
42     vec![]
43 }
44
45 fn test2(_x: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
46
47 fn test3() {
48     let _y: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![];
49 }
50
51 #[repr(C)]
52 struct D {
53     // should not warn, since we don't have control over the signature (#3222)
54     test4: extern "C" fn(
55         itself: &D,
56         a: usize,
57         b: usize,
58         c: usize,
59         d: usize,
60         e: usize,
61         f: usize,
62         g: usize,
63         h: usize,
64         i: usize,
65     ),
66 }
67
68 fn main() {}