]> git.lizzy.rs Git - rust.git/blob - tests/ui/box_collection.rs
Auto merge of #8359 - flip1995:rustup, r=flip1995
[rust.git] / tests / ui / box_collection.rs
1 #![warn(clippy::all)]
2 #![allow(
3     clippy::boxed_local,
4     clippy::needless_pass_by_value,
5     clippy::blacklisted_name,
6     unused
7 )]
8
9 use std::collections::HashMap;
10
11 macro_rules! boxit {
12     ($init:expr, $x:ty) => {
13         let _: Box<$x> = Box::new($init);
14     };
15 }
16
17 fn test_macro() {
18     boxit!(Vec::new(), Vec<u8>);
19 }
20
21 fn test(foo: Box<Vec<bool>>) {}
22
23 fn test2(foo: Box<dyn Fn(Vec<u32>)>) {
24     // pass if #31 is fixed
25     foo(vec![1, 2, 3])
26 }
27
28 fn test3(foo: Box<String>) {}
29
30 fn test4(foo: Box<HashMap<String, String>>) {}
31
32 fn test_local_not_linted() {
33     let _: Box<Vec<bool>>;
34 }
35
36 // All of these test should be allowed because they are part of the
37 // public api and `avoid_breaking_exported_api` is `false` by default.
38 pub fn pub_test(foo: Box<Vec<bool>>) {}
39
40 pub fn pub_test_ret() -> Box<Vec<bool>> {
41     Box::new(Vec::new())
42 }
43
44 fn main() {}