]> git.lizzy.rs Git - rust.git/blob - tests/ui/entry.stderr
Improve `map_entry` lint
[rust.git] / tests / ui / entry.stderr
1 error: usage of `contains_key` followed by `insert` on a `HashMap`
2   --> $DIR/entry.rs:16:5
3    |
4 LL | /     if !m.contains_key(&k) {
5 LL | |         m.insert(k, v);
6 LL | |     }
7    | |_____^ help: try this: `m.entry(k).or_insert(v);`
8    |
9    = note: `-D clippy::map-entry` implied by `-D warnings`
10
11 error: usage of `contains_key` followed by `insert` on a `HashMap`
12   --> $DIR/entry.rs:20:5
13    |
14 LL | /     if !m.contains_key(&k) {
15 LL | |         if true {
16 LL | |             m.insert(k, v);
17 LL | |         } else {
18 LL | |             m.insert(k, v2);
19 LL | |         }
20 LL | |     }
21    | |_____^
22    |
23 help: try this
24    |
25 LL |     if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) {
26 LL |         if true {
27 LL |             e.insert(v);
28 LL |         } else {
29 LL |             e.insert(v2);
30 LL |         }
31  ...
32
33 error: usage of `contains_key` followed by `insert` on a `HashMap`
34   --> $DIR/entry.rs:28:5
35    |
36 LL | /     if !m.contains_key(&k) {
37 LL | |         if true {
38 LL | |             m.insert(k, v);
39 LL | |         } else {
40 ...  |
41 LL | |         }
42 LL | |     }
43    | |_____^
44    |
45 help: try this
46    |
47 LL |     if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) {
48 LL |         if true {
49 LL |             e.insert(v);
50 LL |         } else {
51 LL |             e.insert(v2);
52 LL |             return;
53  ...
54
55 error: usage of `contains_key` followed by `insert` on a `HashMap`
56   --> $DIR/entry.rs:37:5
57    |
58 LL | /     if !m.contains_key(&k) {
59 LL | |         foo();
60 LL | |         m.insert(k, v);
61 LL | |     }
62    | |_____^
63    |
64 help: try this
65    |
66 LL |     if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) {
67 LL |         foo();
68 LL |         e.insert(v);
69 LL |     }
70    |
71
72 error: usage of `contains_key` followed by `insert` on a `HashMap`
73   --> $DIR/entry.rs:42:5
74    |
75 LL | /     if !m.contains_key(&k) {
76 LL | |         match 0 {
77 LL | |             1 if true => {
78 LL | |                 m.insert(k, v);
79 ...  |
80 LL | |         };
81 LL | |     }
82    | |_____^
83    |
84 help: try this
85    |
86 LL |     if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) {
87 LL |         match 0 {
88 LL |             1 if true => {
89 LL |                 e.insert(v);
90 LL |             },
91 LL |             _ => {
92  ...
93
94 error: usage of `contains_key` followed by `insert` on a `HashMap`
95   --> $DIR/entry.rs:53:5
96    |
97 LL | /     if !m.contains_key(&k) {
98 LL | |         match 0 {
99 LL | |             0 => {},
100 LL | |             1 => {
101 ...  |
102 LL | |         };
103 LL | |     }
104    | |_____^
105    |
106 help: try this
107    |
108 LL |     if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) {
109 LL |         match 0 {
110 LL |             0 => {},
111 LL |             1 => {
112 LL |                 e.insert(v);
113 LL |             },
114  ...
115
116 error: usage of `contains_key` followed by `insert` on a `HashMap`
117   --> $DIR/entry.rs:65:5
118    |
119 LL | /     if !m.contains_key(&k) {
120 LL | |         foo();
121 LL | |         match 0 {
122 LL | |             0 if false => {
123 ...  |
124 LL | |         }
125 LL | |     }
126    | |_____^
127    |
128 help: try this
129    |
130 LL |     if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) {
131 LL |         foo();
132 LL |         match 0 {
133 LL |             0 if false => {
134 LL |                 e.insert(v);
135 LL |             },
136  ...
137
138 error: usage of `contains_key` followed by `insert` on a `HashMap`
139   --> $DIR/entry.rs:91:5
140    |
141 LL | /     if !m.contains_key(&m!(k)) {
142 LL | |         m.insert(m!(k), m!(v));
143 LL | |     }
144    | |_____^
145    |
146 help: try this
147    |
148 LL |     if let std::collections::hash_map::Entry::Vacant(e) = m.entry(m!(k)) {
149 LL |         e.insert(m!(v));
150 LL |     }
151    |
152
153 error: usage of `contains_key` followed by `insert` on a `BTreeMap`
154   --> $DIR/entry.rs:97:5
155    |
156 LL | /     if !m.contains_key(&k) {
157 LL | |         m.insert(k, v);
158 LL | |         foo();
159 LL | |     }
160    | |_____^
161    |
162 help: try this
163    |
164 LL |     if let std::collections::btree_map::Entry::Vacant(e) = m.entry(k) {
165 LL |         e.insert(v);
166 LL |         foo();
167 LL |     }
168    |
169
170 error: aborting due to 9 previous errors
171