Skip to content

Commit df6ef60

Browse files
committed
update get_unwrap.rs
1 parent 1a2364e commit df6ef60

File tree

3 files changed

+39
-39
lines changed

3 files changed

+39
-39
lines changed

tests/ui/get_unwrap.fixed

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// run-rustfix
2+
23
#![allow(unused_mut, clippy::from_iter_instead_of_collect)]
3-
#![deny(clippy::get_unwrap, clippy::unwrap_used)]
4+
#![warn(clippy::unwrap_used)]
5+
#![deny(clippy::get_unwrap)]
46

57
use std::collections::BTreeMap;
68
use std::collections::HashMap;

tests/ui/get_unwrap.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// run-rustfix
2+
23
#![allow(unused_mut, clippy::from_iter_instead_of_collect)]
3-
#![deny(clippy::get_unwrap, clippy::unwrap_used)]
4+
#![warn(clippy::unwrap_used)]
5+
#![deny(clippy::get_unwrap)]
46

57
use std::collections::BTreeMap;
68
use std::collections::HashMap;

tests/ui/get_unwrap.stderr

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,222 +1,218 @@
11
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
2-
--> $DIR/get_unwrap.rs:34:17
2+
--> $DIR/get_unwrap.rs:36:17
33
|
44
LL | let _ = boxed_slice.get(1).unwrap();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&boxed_slice[1]`
66
|
77
note: the lint level is defined here
8-
--> $DIR/get_unwrap.rs:3:9
8+
--> $DIR/get_unwrap.rs:5:9
99
|
10-
LL | #![deny(clippy::get_unwrap, clippy::unwrap_used)]
10+
LL | #![deny(clippy::get_unwrap)]
1111
| ^^^^^^^^^^^^^^^^^^
1212

1313
error: used `unwrap()` on `an Option` value
14-
--> $DIR/get_unwrap.rs:34:17
14+
--> $DIR/get_unwrap.rs:36:17
1515
|
1616
LL | let _ = boxed_slice.get(1).unwrap();
1717
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
1818
|
19-
note: the lint level is defined here
20-
--> $DIR/get_unwrap.rs:3:29
21-
|
22-
LL | #![deny(clippy::get_unwrap, clippy::unwrap_used)]
23-
| ^^^^^^^^^^^^^^^^^^^
19+
= note: `-D clippy::unwrap-used` implied by `-D warnings`
2420
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
2521

2622
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
27-
--> $DIR/get_unwrap.rs:35:17
23+
--> $DIR/get_unwrap.rs:37:17
2824
|
2925
LL | let _ = some_slice.get(0).unwrap();
3026
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_slice[0]`
3127

3228
error: used `unwrap()` on `an Option` value
33-
--> $DIR/get_unwrap.rs:35:17
29+
--> $DIR/get_unwrap.rs:37:17
3430
|
3531
LL | let _ = some_slice.get(0).unwrap();
3632
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
3733
|
3834
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
3935

4036
error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise
41-
--> $DIR/get_unwrap.rs:36:17
37+
--> $DIR/get_unwrap.rs:38:17
4238
|
4339
LL | let _ = some_vec.get(0).unwrap();
4440
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_vec[0]`
4541

4642
error: used `unwrap()` on `an Option` value
47-
--> $DIR/get_unwrap.rs:36:17
43+
--> $DIR/get_unwrap.rs:38:17
4844
|
4945
LL | let _ = some_vec.get(0).unwrap();
5046
| ^^^^^^^^^^^^^^^^^^^^^^^^
5147
|
5248
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
5349

5450
error: called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise
55-
--> $DIR/get_unwrap.rs:37:17
51+
--> $DIR/get_unwrap.rs:39:17
5652
|
5753
LL | let _ = some_vecdeque.get(0).unwrap();
5854
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_vecdeque[0]`
5955

6056
error: used `unwrap()` on `an Option` value
61-
--> $DIR/get_unwrap.rs:37:17
57+
--> $DIR/get_unwrap.rs:39:17
6258
|
6359
LL | let _ = some_vecdeque.get(0).unwrap();
6460
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6561
|
6662
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
6763

6864
error: called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise
69-
--> $DIR/get_unwrap.rs:38:17
65+
--> $DIR/get_unwrap.rs:40:17
7066
|
7167
LL | let _ = some_hashmap.get(&1).unwrap();
7268
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_hashmap[&1]`
7369

7470
error: used `unwrap()` on `an Option` value
75-
--> $DIR/get_unwrap.rs:38:17
71+
--> $DIR/get_unwrap.rs:40:17
7672
|
7773
LL | let _ = some_hashmap.get(&1).unwrap();
7874
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7975
|
8076
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
8177

8278
error: called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise
83-
--> $DIR/get_unwrap.rs:39:17
79+
--> $DIR/get_unwrap.rs:41:17
8480
|
8581
LL | let _ = some_btreemap.get(&1).unwrap();
8682
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_btreemap[&1]`
8783

8884
error: used `unwrap()` on `an Option` value
89-
--> $DIR/get_unwrap.rs:39:17
85+
--> $DIR/get_unwrap.rs:41:17
9086
|
9187
LL | let _ = some_btreemap.get(&1).unwrap();
9288
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9389
|
9490
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
9591

9692
error: used `unwrap()` on `an Option` value
97-
--> $DIR/get_unwrap.rs:40:17
93+
--> $DIR/get_unwrap.rs:42:17
9894
|
9995
LL | let _ = false_positive.get(0).unwrap();
10096
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10197
|
10298
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
10399

104100
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
105-
--> $DIR/get_unwrap.rs:42:21
101+
--> $DIR/get_unwrap.rs:44:21
106102
|
107103
LL | let _: u8 = *boxed_slice.get(1).unwrap();
108104
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `boxed_slice[1]`
109105

110106
error: used `unwrap()` on `an Option` value
111-
--> $DIR/get_unwrap.rs:42:22
107+
--> $DIR/get_unwrap.rs:44:22
112108
|
113109
LL | let _: u8 = *boxed_slice.get(1).unwrap();
114110
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
115111
|
116112
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
117113

118114
error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise
119-
--> $DIR/get_unwrap.rs:47:9
115+
--> $DIR/get_unwrap.rs:49:9
120116
|
121117
LL | *boxed_slice.get_mut(0).unwrap() = 1;
122118
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `boxed_slice[0]`
123119

124120
error: used `unwrap()` on `an Option` value
125-
--> $DIR/get_unwrap.rs:47:10
121+
--> $DIR/get_unwrap.rs:49:10
126122
|
127123
LL | *boxed_slice.get_mut(0).unwrap() = 1;
128124
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
129125
|
130126
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
131127

132128
error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise
133-
--> $DIR/get_unwrap.rs:48:9
129+
--> $DIR/get_unwrap.rs:50:9
134130
|
135131
LL | *some_slice.get_mut(0).unwrap() = 1;
136132
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_slice[0]`
137133

138134
error: used `unwrap()` on `an Option` value
139-
--> $DIR/get_unwrap.rs:48:10
135+
--> $DIR/get_unwrap.rs:50:10
140136
|
141137
LL | *some_slice.get_mut(0).unwrap() = 1;
142138
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
143139
|
144140
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
145141

146142
error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise
147-
--> $DIR/get_unwrap.rs:49:9
143+
--> $DIR/get_unwrap.rs:51:9
148144
|
149145
LL | *some_vec.get_mut(0).unwrap() = 1;
150146
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0]`
151147

152148
error: used `unwrap()` on `an Option` value
153-
--> $DIR/get_unwrap.rs:49:10
149+
--> $DIR/get_unwrap.rs:51:10
154150
|
155151
LL | *some_vec.get_mut(0).unwrap() = 1;
156152
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
157153
|
158154
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
159155

160156
error: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise
161-
--> $DIR/get_unwrap.rs:50:9
157+
--> $DIR/get_unwrap.rs:52:9
162158
|
163159
LL | *some_vecdeque.get_mut(0).unwrap() = 1;
164160
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vecdeque[0]`
165161

166162
error: used `unwrap()` on `an Option` value
167-
--> $DIR/get_unwrap.rs:50:10
163+
--> $DIR/get_unwrap.rs:52:10
168164
|
169165
LL | *some_vecdeque.get_mut(0).unwrap() = 1;
170166
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
171167
|
172168
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
173169

174170
error: used `unwrap()` on `an Option` value
175-
--> $DIR/get_unwrap.rs:52:10
171+
--> $DIR/get_unwrap.rs:54:10
176172
|
177173
LL | *some_hashmap.get_mut(&1).unwrap() = 'b';
178174
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
179175
|
180176
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
181177

182178
error: used `unwrap()` on `an Option` value
183-
--> $DIR/get_unwrap.rs:53:10
179+
--> $DIR/get_unwrap.rs:55:10
184180
|
185181
LL | *some_btreemap.get_mut(&1).unwrap() = 'b';
186182
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
187183
|
188184
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
189185

190186
error: used `unwrap()` on `an Option` value
191-
--> $DIR/get_unwrap.rs:54:10
187+
--> $DIR/get_unwrap.rs:56:10
192188
|
193189
LL | *false_positive.get_mut(0).unwrap() = 1;
194190
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
195191
|
196192
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
197193

198194
error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise
199-
--> $DIR/get_unwrap.rs:59:17
195+
--> $DIR/get_unwrap.rs:61:17
200196
|
201197
LL | let _ = some_vec.get(0..1).unwrap().to_vec();
202198
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]`
203199

204200
error: used `unwrap()` on `an Option` value
205-
--> $DIR/get_unwrap.rs:59:17
201+
--> $DIR/get_unwrap.rs:61:17
206202
|
207203
LL | let _ = some_vec.get(0..1).unwrap().to_vec();
208204
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
209205
|
210206
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
211207

212208
error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise
213-
--> $DIR/get_unwrap.rs:60:17
209+
--> $DIR/get_unwrap.rs:62:17
214210
|
215211
LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec();
216212
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]`
217213

218214
error: used `unwrap()` on `an Option` value
219-
--> $DIR/get_unwrap.rs:60:17
215+
--> $DIR/get_unwrap.rs:62:17
220216
|
221217
LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec();
222218
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)