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