]> git.lizzy.rs Git - rust.git/blob - tests/ui/entry_with_else.stderr
Rollup merge of #87885 - m-ou-se:edition-guide-links, r=rylev
[rust.git] / tests / ui / entry_with_else.stderr
1 error: usage of `contains_key` followed by `insert` on a `HashMap`
2   --> $DIR/entry_with_else.rs:16:5
3    |
4 LL | /     if !m.contains_key(&k) {
5 LL | |         m.insert(k, v);
6 LL | |     } else {
7 LL | |         m.insert(k, v2);
8 LL | |     }
9    | |_____^
10    |
11    = note: `-D clippy::map-entry` implied by `-D warnings`
12 help: try this
13    |
14 LL ~     match m.entry(k) {
15 LL +         std::collections::hash_map::Entry::Vacant(e) => {
16 LL +             e.insert(v);
17 LL +         }
18 LL +         std::collections::hash_map::Entry::Occupied(mut e) => {
19 LL +             e.insert(v2);
20  ...
21
22 error: usage of `contains_key` followed by `insert` on a `HashMap`
23   --> $DIR/entry_with_else.rs:22:5
24    |
25 LL | /     if m.contains_key(&k) {
26 LL | |         m.insert(k, v);
27 LL | |     } else {
28 LL | |         m.insert(k, v2);
29 LL | |     }
30    | |_____^
31    |
32 help: try this
33    |
34 LL ~     match m.entry(k) {
35 LL +         std::collections::hash_map::Entry::Occupied(mut e) => {
36 LL +             e.insert(v);
37 LL +         }
38 LL +         std::collections::hash_map::Entry::Vacant(e) => {
39 LL +             e.insert(v2);
40  ...
41
42 error: usage of `contains_key` followed by `insert` on a `HashMap`
43   --> $DIR/entry_with_else.rs:28:5
44    |
45 LL | /     if !m.contains_key(&k) {
46 LL | |         m.insert(k, v);
47 LL | |     } else {
48 LL | |         foo();
49 LL | |     }
50    | |_____^
51    |
52 help: try this
53    |
54 LL ~     if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) {
55 LL +         e.insert(v);
56 LL +     } else {
57 LL +         foo();
58 LL +     }
59    |
60
61 error: usage of `contains_key` followed by `insert` on a `HashMap`
62   --> $DIR/entry_with_else.rs:34:5
63    |
64 LL | /     if !m.contains_key(&k) {
65 LL | |         foo();
66 LL | |     } else {
67 LL | |         m.insert(k, v);
68 LL | |     }
69    | |_____^
70    |
71 help: try this
72    |
73 LL ~     if let std::collections::hash_map::Entry::Occupied(mut e) = m.entry(k) {
74 LL +         e.insert(v);
75 LL +     } else {
76 LL +         foo();
77 LL +     }
78    |
79
80 error: usage of `contains_key` followed by `insert` on a `HashMap`
81   --> $DIR/entry_with_else.rs:40:5
82    |
83 LL | /     if !m.contains_key(&k) {
84 LL | |         m.insert(k, v);
85 LL | |     } else {
86 LL | |         m.insert(k, v2);
87 LL | |     }
88    | |_____^
89    |
90 help: try this
91    |
92 LL ~     match m.entry(k) {
93 LL +         std::collections::hash_map::Entry::Vacant(e) => {
94 LL +             e.insert(v);
95 LL +         }
96 LL +         std::collections::hash_map::Entry::Occupied(mut e) => {
97 LL +             e.insert(v2);
98  ...
99
100 error: usage of `contains_key` followed by `insert` on a `HashMap`
101   --> $DIR/entry_with_else.rs:46:5
102    |
103 LL | /     if m.contains_key(&k) {
104 LL | |         if true { m.insert(k, v) } else { m.insert(k, v2) }
105 LL | |     } else {
106 LL | |         m.insert(k, v)
107 LL | |     };
108    | |_____^
109    |
110 help: try this
111    |
112 LL ~     match m.entry(k) {
113 LL +         std::collections::hash_map::Entry::Occupied(mut e) => {
114 LL +             if true { Some(e.insert(v)) } else { Some(e.insert(v2)) }
115 LL +         }
116 LL +         std::collections::hash_map::Entry::Vacant(e) => {
117 LL +             e.insert(v);
118  ...
119
120 error: usage of `contains_key` followed by `insert` on a `HashMap`
121   --> $DIR/entry_with_else.rs:52:5
122    |
123 LL | /     if m.contains_key(&k) {
124 LL | |         foo();
125 LL | |         m.insert(k, v)
126 LL | |     } else {
127 LL | |         None
128 LL | |     };
129    | |_____^
130    |
131 help: try this
132    |
133 LL ~     if let std::collections::hash_map::Entry::Occupied(mut e) = m.entry(k) {
134 LL +         foo();
135 LL +         Some(e.insert(v))
136 LL +     } else {
137 LL +         None
138 LL ~     };
139    |
140
141 error: aborting due to 7 previous errors
142