Skip to content

Commit fdfa24e

Browse files
committed
Add a test for BTreeMap with zero-sized value type
1 parent 6fa0fdc commit fdfa24e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

tests/ui/zero_sized_map_values.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![warn(clippy::zero_sized_map_values)]
2-
use std::collections::HashMap;
2+
use std::collections::{BTreeMap, HashMap};
33

44
const CONST_OK: Option<HashMap<String, usize>> = None;
55
const CONST_NOT_OK: Option<HashMap<String, ()>> = None;
@@ -66,4 +66,5 @@ fn main() {
6666
let _: HashMap<String, usize> = HashMap::new();
6767

6868
let _: HashMap<_, _> = std::iter::empty::<(String, ())>().collect();
69+
let _: BTreeMap<_, _> = std::iter::empty::<(String, ())>().collect();
6970
}

tests/ui/zero_sized_map_values.stderr

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,13 @@ LL | let _: HashMap<_, _> = std::iter::empty::<(String, ())>().collect();
103103
|
104104
= help: consider using a set instead
105105

106-
error: aborting due to 13 previous errors
106+
error: map with zero-sized value type
107+
--> $DIR/zero_sized_map_values.rs:69:12
108+
|
109+
LL | let _: BTreeMap<_, _> = std::iter::empty::<(String, ())>().collect();
110+
| ^^^^^^^^^^^^^^
111+
|
112+
= help: consider using a set instead
113+
114+
error: aborting due to 14 previous errors
107115

0 commit comments

Comments
 (0)