]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/type_complexity.rs
Rollup merge of #93080 - SkiFire13:itermut-as_mut_slice, r=m-ou-se
[rust.git] / src / tools / clippy / 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 // Should not warn since there is likely no way to simplify this (#1013)
34 impl T for () {
35     const A: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![];
36
37     type B = Vec<Vec<Box<(u32, u32, u32, u32)>>>;
38
39     fn method(&self, p: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
40 }
41
42 fn test1() -> Vec<Vec<Box<(u32, u32, u32, u32)>>> {
43     vec![]
44 }
45
46 fn test2(_x: Vec<Vec<Box<(u32, u32, u32, u32)>>>) {}
47
48 fn test3() {
49     let _y: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![];
50 }
51
52 #[repr(C)]
53 struct D {
54     // should not warn, since we don't have control over the signature (#3222)
55     test4: extern "C" fn(
56         itself: &D,
57         a: usize,
58         b: usize,
59         c: usize,
60         d: usize,
61         e: usize,
62         f: usize,
63         g: usize,
64         h: usize,
65         i: usize,
66     ),
67 }
68
69 fn main() {}