Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ba80d45

Browse files
committed
update testsuite
1 parent 8ccd264 commit ba80d45

File tree

3 files changed

+145
-4
lines changed

3 files changed

+145
-4
lines changed

tests/ui/get_unwrap.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-rustfix
22
#![allow(unused_mut, clippy::from_iter_instead_of_collect)]
3-
#![deny(clippy::get_unwrap)]
3+
#![deny(clippy::get_unwrap, clippy::unwrap_used)]
44

55
use std::collections::BTreeMap;
66
use std::collections::HashMap;

tests/ui/get_unwrap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-rustfix
22
#![allow(unused_mut, clippy::from_iter_instead_of_collect)]
3-
#![deny(clippy::get_unwrap)]
3+
#![deny(clippy::get_unwrap, clippy::unwrap_used)]
44

55
use std::collections::BTreeMap;
66
use std::collections::HashMap;

tests/ui/get_unwrap.stderr

Lines changed: 143 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,80 +7,221 @@ LL | let _ = boxed_slice.get(1).unwrap();
77
note: the lint level is defined here
88
--> $DIR/get_unwrap.rs:3:9
99
|
10-
LL | #![deny(clippy::get_unwrap)]
10+
LL | #![deny(clippy::get_unwrap, clippy::unwrap_used)]
1111
| ^^^^^^^^^^^^^^^^^^
1212

13+
error: used `unwrap()` on `an Option` value
14+
--> $DIR/get_unwrap.rs:34:17
15+
|
16+
LL | let _ = boxed_slice.get(1).unwrap();
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
18+
|
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+
| ^^^^^^^^^^^^^^^^^^^
24+
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
25+
1326
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
1427
--> $DIR/get_unwrap.rs:35:17
1528
|
1629
LL | let _ = some_slice.get(0).unwrap();
1730
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_slice[0]`
1831

32+
error: used `unwrap()` on `an Option` value
33+
--> $DIR/get_unwrap.rs:35:17
34+
|
35+
LL | let _ = some_slice.get(0).unwrap();
36+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
37+
|
38+
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
39+
1940
error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise
2041
--> $DIR/get_unwrap.rs:36:17
2142
|
2243
LL | let _ = some_vec.get(0).unwrap();
2344
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_vec[0]`
2445

46+
error: used `unwrap()` on `an Option` value
47+
--> $DIR/get_unwrap.rs:36:17
48+
|
49+
LL | let _ = some_vec.get(0).unwrap();
50+
| ^^^^^^^^^^^^^^^^^^^^^^^^
51+
|
52+
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
53+
2554
error: called `.get().unwrap()` on a VecDeque. Using `[]` is more clear and more concise
2655
--> $DIR/get_unwrap.rs:37:17
2756
|
2857
LL | let _ = some_vecdeque.get(0).unwrap();
2958
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_vecdeque[0]`
3059

60+
error: used `unwrap()` on `an Option` value
61+
--> $DIR/get_unwrap.rs:37:17
62+
|
63+
LL | let _ = some_vecdeque.get(0).unwrap();
64+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
65+
|
66+
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
67+
3168
error: called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise
3269
--> $DIR/get_unwrap.rs:38:17
3370
|
3471
LL | let _ = some_hashmap.get(&1).unwrap();
3572
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_hashmap[&1]`
3673

74+
error: used `unwrap()` on `an Option` value
75+
--> $DIR/get_unwrap.rs:38:17
76+
|
77+
LL | let _ = some_hashmap.get(&1).unwrap();
78+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
79+
|
80+
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
81+
3782
error: called `.get().unwrap()` on a BTreeMap. Using `[]` is more clear and more concise
3883
--> $DIR/get_unwrap.rs:39:17
3984
|
4085
LL | let _ = some_btreemap.get(&1).unwrap();
4186
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&some_btreemap[&1]`
4287

88+
error: used `unwrap()` on `an Option` value
89+
--> $DIR/get_unwrap.rs:39:17
90+
|
91+
LL | let _ = some_btreemap.get(&1).unwrap();
92+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
93+
|
94+
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
95+
96+
error: used `unwrap()` on `an Option` value
97+
--> $DIR/get_unwrap.rs:40:17
98+
|
99+
LL | let _ = false_positive.get(0).unwrap();
100+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
101+
|
102+
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
103+
43104
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
44105
--> $DIR/get_unwrap.rs:42:21
45106
|
46107
LL | let _: u8 = *boxed_slice.get(1).unwrap();
47108
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `boxed_slice[1]`
48109

110+
error: used `unwrap()` on `an Option` value
111+
--> $DIR/get_unwrap.rs:42:22
112+
|
113+
LL | let _: u8 = *boxed_slice.get(1).unwrap();
114+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
115+
|
116+
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
117+
49118
error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise
50119
--> $DIR/get_unwrap.rs:47:9
51120
|
52121
LL | *boxed_slice.get_mut(0).unwrap() = 1;
53122
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `boxed_slice[0]`
54123

124+
error: used `unwrap()` on `an Option` value
125+
--> $DIR/get_unwrap.rs:47:10
126+
|
127+
LL | *boxed_slice.get_mut(0).unwrap() = 1;
128+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
129+
|
130+
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
131+
55132
error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise
56133
--> $DIR/get_unwrap.rs:48:9
57134
|
58135
LL | *some_slice.get_mut(0).unwrap() = 1;
59136
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_slice[0]`
60137

138+
error: used `unwrap()` on `an Option` value
139+
--> $DIR/get_unwrap.rs:48:10
140+
|
141+
LL | *some_slice.get_mut(0).unwrap() = 1;
142+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
143+
|
144+
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
145+
61146
error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise
62147
--> $DIR/get_unwrap.rs:49:9
63148
|
64149
LL | *some_vec.get_mut(0).unwrap() = 1;
65150
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0]`
66151

152+
error: used `unwrap()` on `an Option` value
153+
--> $DIR/get_unwrap.rs:49:10
154+
|
155+
LL | *some_vec.get_mut(0).unwrap() = 1;
156+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
157+
|
158+
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
159+
67160
error: called `.get_mut().unwrap()` on a VecDeque. Using `[]` is more clear and more concise
68161
--> $DIR/get_unwrap.rs:50:9
69162
|
70163
LL | *some_vecdeque.get_mut(0).unwrap() = 1;
71164
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vecdeque[0]`
72165

166+
error: used `unwrap()` on `an Option` value
167+
--> $DIR/get_unwrap.rs:50:10
168+
|
169+
LL | *some_vecdeque.get_mut(0).unwrap() = 1;
170+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
171+
|
172+
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
173+
174+
error: used `unwrap()` on `an Option` value
175+
--> $DIR/get_unwrap.rs:52:10
176+
|
177+
LL | *some_hashmap.get_mut(&1).unwrap() = 'b';
178+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
179+
|
180+
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
181+
182+
error: used `unwrap()` on `an Option` value
183+
--> $DIR/get_unwrap.rs:53:10
184+
|
185+
LL | *some_btreemap.get_mut(&1).unwrap() = 'b';
186+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
187+
|
188+
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
189+
190+
error: used `unwrap()` on `an Option` value
191+
--> $DIR/get_unwrap.rs:54:10
192+
|
193+
LL | *false_positive.get_mut(0).unwrap() = 1;
194+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
195+
|
196+
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
197+
73198
error: called `.get().unwrap()` on a Vec. Using `[]` is more clear and more concise
74199
--> $DIR/get_unwrap.rs:59:17
75200
|
76201
LL | let _ = some_vec.get(0..1).unwrap().to_vec();
77202
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]`
78203

204+
error: used `unwrap()` on `an Option` value
205+
--> $DIR/get_unwrap.rs:59:17
206+
|
207+
LL | let _ = some_vec.get(0..1).unwrap().to_vec();
208+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
209+
|
210+
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
211+
79212
error: called `.get_mut().unwrap()` on a Vec. Using `[]` is more clear and more concise
80213
--> $DIR/get_unwrap.rs:60:17
81214
|
82215
LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec();
83216
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `some_vec[0..1]`
84217

85-
error: aborting due to 13 previous errors
218+
error: used `unwrap()` on `an Option` value
219+
--> $DIR/get_unwrap.rs:60:17
220+
|
221+
LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec();
222+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
223+
|
224+
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
225+
226+
error: aborting due to 30 previous errors
86227

0 commit comments

Comments
 (0)