summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/zero_sized_hashmap_values.rs
blob: a1608d863fb52cb4c05e336ed40d323387554784 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#![warn(clippy::zero_sized_map_values)]
use std::collections::HashMap;

const CONST_OK: Option<HashMap<String, usize>> = None;
const CONST_NOT_OK: Option<HashMap<String, ()>> = None;

static STATIC_OK: Option<HashMap<String, usize>> = None;
static STATIC_NOT_OK: Option<HashMap<String, ()>> = None;

type OkMap = HashMap<String, usize>;
type NotOkMap = HashMap<String, ()>;

enum TestEnum {
    Ok(HashMap<String, usize>),
    NotOk(HashMap<String, ()>),
}

struct Test {
    ok: HashMap<String, usize>,
    not_ok: HashMap<String, ()>,

    also_not_ok: Vec<HashMap<usize, ()>>,
}

trait TestTrait {
    type Output;

    fn produce_output() -> Self::Output;

    fn weird_map(&self, map: HashMap<usize, ()>);
}

impl Test {
    fn ok(&self) -> HashMap<String, usize> {
        todo!()
    }

    fn not_ok(&self) -> HashMap<String, ()> {
        todo!()
    }
}

impl TestTrait for Test {
    type Output = HashMap<String, ()>;

    fn produce_output() -> Self::Output {
        todo!();
    }

    fn weird_map(&self, map: HashMap<usize, ()>) {
        todo!();
    }
}

fn test(map: HashMap<String, ()>, key: &str) -> HashMap<String, ()> {
    todo!();
}

fn test2(map: HashMap<String, usize>, key: &str) -> HashMap<String, usize> {
    todo!();
}

fn main() {
    let _: HashMap<String, ()> = HashMap::new();
    let _: HashMap<String, usize> = HashMap::new();

    let _: HashMap<_, _> = std::iter::empty::<(String, ())>().collect();
}