1
1
error: usage of `contains_key` followed by `insert` on a `HashMap`
2
- --> tests/ui/entry_unfixable.rs:46 :13
2
+ --> tests/ui/entry_unfixable.rs:47 :13
3
3
|
4
4
LL | / if self.globals.contains_key(&name) {
5
5
LL | |
@@ -15,7 +15,7 @@ LL | | }
15
15
= help: to override `-D warnings` add `#[allow(clippy::map_entry)]`
16
16
17
17
error: usage of `contains_key` followed by `insert` on a `HashMap`
18
- --> tests/ui/entry_unfixable.rs:61 :5
18
+ --> tests/ui/entry_unfixable.rs:62 :5
19
19
|
20
20
LL | / if hm.contains_key(&key) {
21
21
LL | |
@@ -29,7 +29,7 @@ LL | | }
29
29
= help: consider using the `Entry` API: https://doc.rust-lang.org/std/collections/struct.HashMap.html#entry-api
30
30
31
31
error: usage of `contains_key` followed by `insert` on a `HashMap`
32
- --> tests/ui/entry_unfixable.rs:80 :13
32
+ --> tests/ui/entry_unfixable.rs:81 :13
33
33
|
34
34
LL | / if !self.values.contains_key(&name) {
35
35
LL | |
@@ -42,5 +42,22 @@ LL | | }
42
42
|
43
43
= help: consider using the `Entry` API: https://doc.rust-lang.org/std/collections/struct.HashMap.html#entry-api
44
44
45
- error: aborting due to 3 previous errors
45
+ error: usage of `contains_key` followed by `insert` on a `HashMap`
46
+ --> tests/ui/entry_unfixable.rs:95:5
47
+ |
48
+ LL | / if !m.contains_key(&k) {
49
+ LL | |
50
+ LL | | assert!(m.insert(k, v).is_none());
51
+ LL | | }
52
+ | |_____^
53
+ |
54
+ help: try
55
+ |
56
+ LL ~ if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) {
57
+ LL +
58
+ LL + assert!({ e.insert(v); None }.is_none());
59
+ LL + }
60
+ |
61
+
62
+ error: aborting due to 4 previous errors
46
63
0 commit comments