2 #![warn(clippy::box_default)]
5 struct ImplementsDefault;
10 fn default() -> Self {
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());
38 fn ret_ty_fn() -> Box<bool> {
39 Box::<bool>::default()
42 #[allow(clippy::boxed_local)]
43 fn call_ty_fn(_b: Box<u8>) {
44 issue_9621_dyn_trait();
47 use std::io::{Read, Result};
49 impl Read for ImplementsDefault {
50 fn read(&mut self, _: &mut [u8]) -> Result<usize> {
55 fn issue_9621_dyn_trait() {
56 let _: Box<dyn Read> = Box::<ImplementsDefault>::default();