]> git.lizzy.rs Git - rust.git/blob - tests/ui/box_default.fixed
Auto merge of #9684 - kraktus:ref_option_ref, r=xFrednet
[rust.git] / tests / ui / box_default.fixed
1 // run-rustfix
2 #![warn(clippy::box_default)]
3
4 #[derive(Default)]
5 struct ImplementsDefault;
6
7 struct OwnDefault;
8
9 impl OwnDefault {
10     fn default() -> Self {
11         Self
12     }
13 }
14
15 macro_rules! outer {
16     ($e: expr) => {
17         $e
18     };
19 }
20
21 fn main() {
22     let _string: Box<String> = Box::default();
23     let _byte = Box::<u8>::default();
24     let _vec = Box::<std::vec::Vec<u8>>::default();
25     let _impl = Box::<ImplementsDefault>::default();
26     let _impl2 = Box::<ImplementsDefault>::default();
27     let _impl3: Box<ImplementsDefault> = Box::default();
28     let _own = Box::new(OwnDefault::default()); // should not lint
29     let _in_macro = outer!(Box::<std::string::String>::default());
30     let _string_default = outer!(Box::<std::string::String>::default());
31     let _vec2: Box<Vec<ImplementsDefault>> = Box::default();
32     let _vec3: Box<Vec<bool>> = Box::default();
33     let _vec4: Box<_> = Box::<std::vec::Vec<bool>>::default();
34     let _more = ret_ty_fn();
35     call_ty_fn(Box::default());
36 }
37
38 fn ret_ty_fn() -> Box<bool> {
39     Box::<bool>::default()
40 }
41
42 #[allow(clippy::boxed_local)]
43 fn call_ty_fn(_b: Box<u8>) {}