]>
Commit | Line | Data |
---|---|---|
c295e0f8 XL |
1 | #![warn(clippy::all)] |
2 | #![allow( | |
3 | clippy::boxed_local, | |
4 | clippy::needless_pass_by_value, | |
f2b60f7d | 5 | clippy::disallowed_names, |
c295e0f8 XL |
6 | unused |
7 | )] | |
8 | ||
064997fb | 9 | use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque}; |
c295e0f8 XL |
10 | |
11 | macro_rules! boxit { | |
12 | ($init:expr, $x:ty) => { | |
13 | let _: Box<$x> = Box::new($init); | |
14 | }; | |
15 | } | |
16 | ||
17 | fn test_macro() { | |
2b03887a | 18 | boxit!(vec![1], Vec<u8>); |
c295e0f8 XL |
19 | } |
20 | ||
064997fb | 21 | fn test1(foo: Box<Vec<bool>>) {} |
781aab86 | 22 | //~^ ERROR: you seem to be trying to use `Box<Vec<..>>`. Consider using just `Vec<..>` |
c295e0f8 XL |
23 | |
24 | fn test2(foo: Box<dyn Fn(Vec<u32>)>) { | |
25 | // pass if #31 is fixed | |
26 | foo(vec![1, 2, 3]) | |
27 | } | |
28 | ||
29 | fn test3(foo: Box<String>) {} | |
781aab86 | 30 | //~^ ERROR: you seem to be trying to use `Box<String>`. Consider using just `String` |
c295e0f8 XL |
31 | |
32 | fn test4(foo: Box<HashMap<String, String>>) {} | |
781aab86 | 33 | //~^ ERROR: you seem to be trying to use `Box<HashMap<..>>`. Consider using just `HashMap< |
c295e0f8 | 34 | |
064997fb | 35 | fn test5(foo: Box<HashSet<i64>>) {} |
781aab86 | 36 | //~^ ERROR: you seem to be trying to use `Box<HashSet<..>>`. Consider using just `HashSet< |
064997fb FG |
37 | |
38 | fn test6(foo: Box<VecDeque<i32>>) {} | |
781aab86 | 39 | //~^ ERROR: you seem to be trying to use `Box<VecDeque<..>>`. Consider using just `VecDequ |
064997fb FG |
40 | |
41 | fn test7(foo: Box<LinkedList<i16>>) {} | |
781aab86 | 42 | //~^ ERROR: you seem to be trying to use `Box<LinkedList<..>>`. Consider using just `Linke |
064997fb FG |
43 | |
44 | fn test8(foo: Box<BTreeMap<i8, String>>) {} | |
781aab86 | 45 | //~^ ERROR: you seem to be trying to use `Box<BTreeMap<..>>`. Consider using just `BTreeMa |
064997fb FG |
46 | |
47 | fn test9(foo: Box<BTreeSet<u64>>) {} | |
781aab86 | 48 | //~^ ERROR: you seem to be trying to use `Box<BTreeSet<..>>`. Consider using just `BTreeSe |
064997fb FG |
49 | |
50 | fn test10(foo: Box<BinaryHeap<u32>>) {} | |
781aab86 | 51 | //~^ ERROR: you seem to be trying to use `Box<BinaryHeap<..>>`. Consider using just `Binar |
064997fb | 52 | |
c295e0f8 XL |
53 | fn test_local_not_linted() { |
54 | let _: Box<Vec<bool>>; | |
55 | } | |
56 | ||
57 | // All of these test should be allowed because they are part of the | |
58 | // public api and `avoid_breaking_exported_api` is `false` by default. | |
59 | pub fn pub_test(foo: Box<Vec<bool>>) {} | |
60 | ||
61 | pub fn pub_test_ret() -> Box<Vec<bool>> { | |
2b03887a | 62 | Box::default() |
c295e0f8 XL |
63 | } |
64 | ||
65 | fn main() {} |