mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 07:00:55 +00:00
186 lines
4.1 KiB
Text
186 lines
4.1 KiB
Text
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
|
--> $DIR/entry.rs:24:5
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
LL | | m.insert(k, v);
|
|
LL | | }
|
|
| |_____^ help: try this: `m.entry(k).or_insert(v);`
|
|
|
|
|
= note: `-D clippy::map-entry` implied by `-D warnings`
|
|
|
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
|
--> $DIR/entry.rs:29:5
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
LL | | if true {
|
|
LL | | m.insert(k, v);
|
|
LL | | } else {
|
|
LL | | m.insert(k, v2);
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
help: try this
|
|
|
|
|
LL | m.entry(k).or_insert_with(|| {
|
|
LL | if true {
|
|
LL | v
|
|
LL | } else {
|
|
LL | v2
|
|
LL | }
|
|
...
|
|
|
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
|
--> $DIR/entry.rs:38:5
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
LL | | if true {
|
|
LL | | m.insert(k, v)
|
|
LL | | } else {
|
|
LL | | m.insert(k, v2)
|
|
LL | | };
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
help: try this
|
|
|
|
|
LL | m.entry(k).or_insert_with(|| {
|
|
LL | if true {
|
|
LL | v
|
|
LL | } else {
|
|
LL | v2
|
|
LL | }
|
|
...
|
|
|
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
|
--> $DIR/entry.rs:47:5
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
LL | | if true {
|
|
LL | | m.insert(k, v);
|
|
LL | | } else {
|
|
... |
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
help: try this
|
|
|
|
|
LL | if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) {
|
|
LL | if true {
|
|
LL | e.insert(v);
|
|
LL | } else {
|
|
LL | e.insert(v2);
|
|
LL | return;
|
|
...
|
|
|
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
|
--> $DIR/entry.rs:57:5
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
LL | | foo();
|
|
LL | | m.insert(k, v);
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
help: try this
|
|
|
|
|
LL | m.entry(k).or_insert_with(|| {
|
|
LL | foo();
|
|
LL | v
|
|
LL | });
|
|
|
|
|
|
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
|
--> $DIR/entry.rs:63:5
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
LL | | match 0 {
|
|
LL | | 1 if true => {
|
|
LL | | m.insert(k, v);
|
|
... |
|
|
LL | | };
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
help: try this
|
|
|
|
|
LL | m.entry(k).or_insert_with(|| {
|
|
LL | match 0 {
|
|
LL | 1 if true => {
|
|
LL | v
|
|
LL | },
|
|
LL | _ => {
|
|
...
|
|
|
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
|
--> $DIR/entry.rs:75:5
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
LL | | match 0 {
|
|
LL | | 0 => foo(),
|
|
LL | | _ => {
|
|
... |
|
|
LL | | };
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
help: try this
|
|
|
|
|
LL | if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) {
|
|
LL | match 0 {
|
|
LL | 0 => foo(),
|
|
LL | _ => {
|
|
LL | e.insert(v2);
|
|
LL | },
|
|
...
|
|
|
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
|
--> $DIR/entry.rs:85:5
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
LL | | foo();
|
|
LL | | match 0 {
|
|
LL | | 0 if false => {
|
|
... |
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
help: try this
|
|
|
|
|
LL | m.entry(k).or_insert_with(|| {
|
|
LL | foo();
|
|
LL | match 0 {
|
|
LL | 0 if false => {
|
|
LL | v
|
|
LL | },
|
|
...
|
|
|
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
|
--> $DIR/entry.rs:119:5
|
|
|
|
|
LL | / if !m.contains_key(&m!(k)) {
|
|
LL | | m.insert(m!(k), m!(v));
|
|
LL | | }
|
|
| |_____^ help: try this: `m.entry(m!(k)).or_insert_with(|| m!(v));`
|
|
|
|
error: usage of `contains_key` followed by `insert` on a `BTreeMap`
|
|
--> $DIR/entry.rs:153:5
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
LL | | m.insert(k, v);
|
|
LL | | foo();
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
help: try this
|
|
|
|
|
LL | if let std::collections::btree_map::Entry::Vacant(e) = m.entry(k) {
|
|
LL | e.insert(v);
|
|
LL | foo();
|
|
LL | }
|
|
|
|
|
|
|
error: aborting due to 10 previous errors
|
|
|