]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/vec_box_sized.rs
Rollup merge of #100076 - tspiteri:const_slice_split_at, r=oli-obk
[rust.git] / src / tools / clippy / tests / ui / vec_box_sized.rs
1 // run-rustfix
2
3 #![allow(dead_code)]
4
5 struct SizedStruct(i32);
6 struct UnsizedStruct([i32]);
7 struct BigStruct([i32; 10000]);
8
9 /// The following should trigger the lint
10 mod should_trigger {
11     use super::SizedStruct;
12     const C: Vec<Box<i32>> = Vec::new();
13     static S: Vec<Box<i32>> = Vec::new();
14
15     struct StructWithVecBox {
16         sized_type: Vec<Box<SizedStruct>>,
17     }
18
19     struct A(Vec<Box<SizedStruct>>);
20     struct B(Vec<Vec<Box<(u32)>>>);
21 }
22
23 /// The following should not trigger the lint
24 mod should_not_trigger {
25     use super::{BigStruct, UnsizedStruct};
26
27     struct C(Vec<Box<UnsizedStruct>>);
28     struct D(Vec<Box<BigStruct>>);
29
30     struct StructWithVecBoxButItsUnsized {
31         unsized_type: Vec<Box<UnsizedStruct>>,
32     }
33
34     struct TraitVec<T: ?Sized> {
35         // Regression test for #3720. This was causing an ICE.
36         inner: Vec<Box<T>>,
37     }
38 }
39
40 mod inner_mod {
41     mod inner {
42         pub struct S;
43     }
44
45     mod inner2 {
46         use super::inner::S;
47
48         pub fn f() -> Vec<Box<S>> {
49             vec![]
50         }
51     }
52 }
53
54 fn main() {}