]> git.lizzy.rs Git - rust.git/blob - tests/ui/box_collection.rs
Rename "blacklisted name" to "disallowed name" throughout
[rust.git] / tests / ui / box_collection.rs
1 #![warn(clippy::all)]
2 #![allow(clippy::boxed_local, clippy::needless_pass_by_value, clippy::disallowed_name, unused)]
3
4 use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
5
6 macro_rules! boxit {
7     ($init:expr, $x:ty) => {
8         let _: Box<$x> = Box::new($init);
9     };
10 }
11
12 fn test_macro() {
13     boxit!(Vec::new(), Vec<u8>);
14 }
15
16 fn test1(foo: Box<Vec<bool>>) {}
17
18 fn test2(foo: Box<dyn Fn(Vec<u32>)>) {
19     // pass if #31 is fixed
20     foo(vec![1, 2, 3])
21 }
22
23 fn test3(foo: Box<String>) {}
24
25 fn test4(foo: Box<HashMap<String, String>>) {}
26
27 fn test5(foo: Box<HashSet<i64>>) {}
28
29 fn test6(foo: Box<VecDeque<i32>>) {}
30
31 fn test7(foo: Box<LinkedList<i16>>) {}
32
33 fn test8(foo: Box<BTreeMap<i8, String>>) {}
34
35 fn test9(foo: Box<BTreeSet<u64>>) {}
36
37 fn test10(foo: Box<BinaryHeap<u32>>) {}
38
39 fn test_local_not_linted() {
40     let _: Box<Vec<bool>>;
41 }
42
43 // All of these test should be allowed because they are part of the
44 // public api and `avoid_breaking_exported_api` is `false` by default.
45 pub fn pub_test(foo: Box<Vec<bool>>) {}
46
47 pub fn pub_test_ret() -> Box<Vec<bool>> {
48     Box::new(Vec::new())
49 }
50
51 fn main() {}