]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/entry.stderr
Auto merge of #9684 - kraktus:ref_option_ref, r=xFrednet
[rust.git] / tests / ui / entry.stderr
index 9a4e0ba31eeead46ef59286501e6b02bdea9af87..2ef9966525cefbfaca089233e71a9c8f3a6a1ca4 100644 (file)
 error: usage of `contains_key` followed by `insert` on a `HashMap`
-  --> $DIR/entry.rs:19:5
+  --> $DIR/entry.rs:24:5
    |
-19 | /     if !m.contains_key(&k) {
-20 | |         m.insert(k, v);
-21 | |     }
-   | |_____^ help: consider using: `m.entry(k).or_insert(v)`
+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:25:5
+  --> $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 +         }
+LL +     });
    |
-25 | /     if !m.contains_key(&k) {
-26 | |         foo();
-27 | |         m.insert(k, v);
-28 | |     }
-   | |_____^ help: consider using: `m.entry(k)`
 
 error: usage of `contains_key` followed by `insert` on a `HashMap`
-  --> $DIR/entry.rs:32:5
-   |
-32 | /     if !m.contains_key(&k) {
-33 | |         m.insert(k, v)
-34 | |     } else {
-35 | |         None
-36 | |     };
-   | |_____^ help: consider using: `m.entry(k)`
+  --> $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 +         }
+LL +     });
+   |
 
 error: usage of `contains_key` followed by `insert` on a `HashMap`
-  --> $DIR/entry.rs:40:5
-   |
-40 | /     if m.contains_key(&k) {
-41 | |         None
-42 | |     } else {
-43 | |         m.insert(k, v)
-44 | |     };
-   | |_____^ help: consider using: `m.entry(k)`
+  --> $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;
+LL +         }
+LL +     }
+   |
 
 error: usage of `contains_key` followed by `insert` on a `HashMap`
-  --> $DIR/entry.rs:48:5
-   |
-48 | /     if !m.contains_key(&k) {
-49 | |         foo();
-50 | |         m.insert(k, v)
-51 | |     } else {
-52 | |         None
-53 | |     };
-   | |_____^ help: consider using: `m.entry(k)`
+  --> $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:57:5
+  --> $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 +             _ => {
+LL +                 v2
+LL +             },
+LL +         }
+LL +     });
    |
-57 | /     if m.contains_key(&k) {
-58 | |         None
-59 | |     } else {
-60 | |         foo();
-61 | |         m.insert(k, v)
-62 | |     };
-   | |_____^ help: consider using: `m.entry(k)`
 
-error: usage of `contains_key` followed by `insert` on a `BTreeMap`
-  --> $DIR/entry.rs:66:5
-   |
-66 | /     if !m.contains_key(&k) {
-67 | |         foo();
-68 | |         m.insert(k, v)
-69 | |     } else {
-70 | |         None
-71 | |     };
-   | |_____^ help: consider using: `m.entry(k)`
+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 +             },
+LL +         };
+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 +             },
+LL +             1 => {
+LL +                 foo();
+LL +                 v
+LL +             },
+LL +             2 | 3 => {
+LL +                 for _ in 0..2 {
+LL +                     foo();
+LL +                 }
+LL +                 if true {
+LL +                     v
+LL +                 } else {
+LL +                     v2
+LL +                 }
+LL +             },
+LL +             _ => {
+LL +                 v2
+LL +             },
+LL +         }
+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 `HashMap`
+  --> $DIR/entry.rs:151:5
+   |
+LL | /     if !m.contains_key(&k) {
+LL | |         let x = (String::new(), String::new());
+LL | |         let _ = x.0;
+LL | |         m.insert(k, v);
+LL | |     }
+   | |_____^
+   |
+help: try this
+   |
+LL ~     m.entry(k).or_insert_with(|| {
+LL +         let x = (String::new(), String::new());
+LL +         let _ = x.0;
+LL +         v
+LL +     });
+   |
 
-error: aborting due to 7 previous errors
+error: aborting due to 10 previous errors