| error: usage of `contains_key` followed by `insert` on a `HashMap` |
| --> tests/ui/entry_with_else.rs:14:5 |
| | |
| LL | / if !m.contains_key(&k) { |
| LL | | |
| LL | | m.insert(k, v); |
| LL | | } else { |
| LL | | m.insert(k, v2); |
| LL | | } |
| | |_____^ |
| | |
| = note: `-D clippy::map-entry` implied by `-D warnings` |
| = help: to override `-D warnings` add `#[allow(clippy::map_entry)]` |
| help: try |
| | |
| LL ~ match m.entry(k) { |
| LL + std::collections::hash_map::Entry::Vacant(e) => { |
| LL + |
| LL + e.insert(v); |
| LL + } |
| LL + std::collections::hash_map::Entry::Occupied(mut e) => { |
| LL + e.insert(v2); |
| LL + } |
| LL + } |
| | |
| |
| error: usage of `contains_key` followed by `insert` on a `HashMap` |
| --> tests/ui/entry_with_else.rs:21:5 |
| | |
| LL | / if m.contains_key(&k) { |
| LL | | |
| LL | | m.insert(k, v); |
| LL | | } else { |
| LL | | m.insert(k, v2); |
| LL | | } |
| | |_____^ |
| | |
| help: try |
| | |
| LL ~ match m.entry(k) { |
| LL + std::collections::hash_map::Entry::Occupied(mut e) => { |
| LL + |
| LL + e.insert(v); |
| LL + } |
| LL + std::collections::hash_map::Entry::Vacant(e) => { |
| LL + e.insert(v2); |
| LL + } |
| LL + } |
| | |
| |
| error: usage of `contains_key` followed by `insert` on a `HashMap` |
| --> tests/ui/entry_with_else.rs:28:5 |
| | |
| LL | / if !m.contains_key(&k) { |
| LL | | |
| LL | | m.insert(k, v); |
| LL | | } else { |
| LL | | foo(); |
| LL | | } |
| | |_____^ |
| | |
| help: try |
| | |
| LL ~ if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) { |
| LL + |
| LL + e.insert(v); |
| LL + } else { |
| LL + foo(); |
| LL + } |
| | |
| |
| error: usage of `contains_key` followed by `insert` on a `HashMap` |
| --> tests/ui/entry_with_else.rs:35:5 |
| | |
| LL | / if !m.contains_key(&k) { |
| LL | | |
| LL | | foo(); |
| LL | | } else { |
| LL | | m.insert(k, v); |
| LL | | } |
| | |_____^ |
| | |
| help: try |
| | |
| LL ~ if let std::collections::hash_map::Entry::Occupied(mut e) = m.entry(k) { |
| LL + e.insert(v); |
| LL + } else { |
| LL + |
| LL + foo(); |
| LL + } |
| | |
| |
| error: usage of `contains_key` followed by `insert` on a `HashMap` |
| --> tests/ui/entry_with_else.rs:42:5 |
| | |
| LL | / if !m.contains_key(&k) { |
| LL | | |
| LL | | m.insert(k, v); |
| LL | | } else { |
| LL | | m.insert(k, v2); |
| LL | | } |
| | |_____^ |
| | |
| help: try |
| | |
| LL ~ match m.entry(k) { |
| LL + std::collections::hash_map::Entry::Vacant(e) => { |
| LL + |
| LL + e.insert(v); |
| LL + } |
| LL + std::collections::hash_map::Entry::Occupied(mut e) => { |
| LL + e.insert(v2); |
| LL + } |
| LL + } |
| | |
| |
| error: usage of `contains_key` followed by `insert` on a `HashMap` |
| --> tests/ui/entry_with_else.rs:49:5 |
| | |
| LL | / if m.contains_key(&k) { |
| LL | | |
| LL | | if true { m.insert(k, v) } else { m.insert(k, v2) } |
| LL | | } else { |
| LL | | m.insert(k, v) |
| LL | | }; |
| | |_____^ |
| | |
| help: try |
| | |
| LL ~ match m.entry(k) { |
| LL + std::collections::hash_map::Entry::Occupied(mut e) => { |
| LL + |
| LL + if true { Some(e.insert(v)) } else { Some(e.insert(v2)) } |
| LL + } |
| LL + std::collections::hash_map::Entry::Vacant(e) => { |
| LL + e.insert(v); |
| LL + None |
| LL + } |
| LL ~ }; |
| | |
| |
| error: usage of `contains_key` followed by `insert` on a `HashMap` |
| --> tests/ui/entry_with_else.rs:56:5 |
| | |
| LL | / if m.contains_key(&k) { |
| LL | | |
| LL | | foo(); |
| LL | | m.insert(k, v) |
| LL | | } else { |
| LL | | None |
| LL | | }; |
| | |_____^ |
| | |
| help: try |
| | |
| LL ~ if let std::collections::hash_map::Entry::Occupied(mut e) = m.entry(k) { |
| LL + |
| LL + foo(); |
| LL + Some(e.insert(v)) |
| LL + } else { |
| LL + None |
| LL ~ }; |
| | |
| |
| error: aborting due to 7 previous errors |
| |