]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/zero_sized_hashmap_values.rs
Rollup merge of #102625 - Rageking8:fix-backtrace-small-typo, r=m-ou-se
[rust.git] / src / tools / clippy / tests / ui / zero_sized_hashmap_values.rs
1 #![warn(clippy::zero_sized_map_values)]
2 use std::collections::HashMap;
3
4 const CONST_OK: Option<HashMap<String, usize>> = None;
5 const CONST_NOT_OK: Option<HashMap<String, ()>> = None;
6
7 static STATIC_OK: Option<HashMap<String, usize>> = None;
8 static STATIC_NOT_OK: Option<HashMap<String, ()>> = None;
9
10 type OkMap = HashMap<String, usize>;
11 type NotOkMap = HashMap<String, ()>;
12
13 enum TestEnum {
14     Ok(HashMap<String, usize>),
15     NotOk(HashMap<String, ()>),
16 }
17
18 struct Test {
19     ok: HashMap<String, usize>,
20     not_ok: HashMap<String, ()>,
21
22     also_not_ok: Vec<HashMap<usize, ()>>,
23 }
24
25 trait TestTrait {
26     type Output;
27
28     fn produce_output() -> Self::Output;
29
30     fn weird_map(&self, map: HashMap<usize, ()>);
31 }
32
33 impl Test {
34     fn ok(&self) -> HashMap<String, usize> {
35         todo!()
36     }
37
38     fn not_ok(&self) -> HashMap<String, ()> {
39         todo!()
40     }
41 }
42
43 impl TestTrait for Test {
44     type Output = HashMap<String, ()>;
45
46     fn produce_output() -> Self::Output {
47         todo!();
48     }
49
50     fn weird_map(&self, map: HashMap<usize, ()>) {
51         todo!();
52     }
53 }
54
55 fn test(map: HashMap<String, ()>, key: &str) -> HashMap<String, ()> {
56     todo!();
57 }
58
59 fn test2(map: HashMap<String, usize>, key: &str) -> HashMap<String, usize> {
60     todo!();
61 }
62
63 fn main() {
64     let _: HashMap<String, ()> = HashMap::new();
65     let _: HashMap<String, usize> = HashMap::new();
66
67     let _: HashMap<_, _> = std::iter::empty::<(String, ())>().collect();
68 }