Skip to content

Commit f93fb9a

Browse files
committed
Clarify message for unwrap lint
1 parent 377d72a commit f93fb9a

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

clippy_lints/src/unwrap.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ enum UnwrappableKind {
8989
impl UnwrappableKind {
9090
fn success_variant_pattern(self) -> &'static str {
9191
match self {
92-
UnwrappableKind::Option => "Some(..)",
93-
UnwrappableKind::Result => "Ok(..)",
92+
UnwrappableKind::Option => "Some(<item>)",
93+
UnwrappableKind::Result => "Ok(<item>)",
9494
}
9595
}
9696

9797
fn error_variant_pattern(self) -> &'static str {
9898
match self {
9999
UnwrappableKind::Option => "None",
100-
UnwrappableKind::Result => "Err(..)",
100+
UnwrappableKind::Result => "Err(<item>)",
101101
}
102102
}
103103
}

tests/ui/checked_unwrap/complex_conditionals_nested.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: called `unwrap` on `x` after checking its variant with `is_some`
22
--> tests/ui/checked_unwrap/complex_conditionals_nested.rs:13:13
33
|
44
LL | if x.is_some() {
5-
| -------------- help: try: `if let Some(..) = x`
5+
| -------------- help: try: `if let Some(<item>) = x`
66
LL | // unnecessary
77
LL | x.unwrap();
88
| ^^^^^^^^^^

tests/ui/checked_unwrap/simple_conditionals.stderr

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error: called `unwrap` on `x` after checking its variant with `is_some`
22
--> tests/ui/checked_unwrap/simple_conditionals.rs:46:9
33
|
44
LL | if x.is_some() {
5-
| -------------- help: try: `if let Some(..) = x`
5+
| -------------- help: try: `if let Some(<item>) = x`
66
LL | // unnecessary
77
LL | x.unwrap();
88
| ^^^^^^^^^^
@@ -17,7 +17,7 @@ error: called `expect` on `x` after checking its variant with `is_some`
1717
--> tests/ui/checked_unwrap/simple_conditionals.rs:49:9
1818
|
1919
LL | if x.is_some() {
20-
| -------------- help: try: `if let Some(..) = x`
20+
| -------------- help: try: `if let Some(<item>) = x`
2121
...
2222
LL | x.expect("an error message");
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -59,7 +59,7 @@ error: called `unwrap` on `x` after checking its variant with `is_none`
5959
--> tests/ui/checked_unwrap/simple_conditionals.rs:65:9
6060
|
6161
LL | if x.is_none() {
62-
| -------------- help: try: `if let Some(..) = x`
62+
| -------------- help: try: `if let Some(<item>) = x`
6363
...
6464
LL | x.unwrap();
6565
| ^^^^^^^^^^
@@ -68,7 +68,7 @@ error: called `unwrap` on `x` after checking its variant with `is_some`
6868
--> tests/ui/checked_unwrap/simple_conditionals.rs:13:13
6969
|
7070
LL | if $a.is_some() {
71-
| --------------- help: try: `if let Some(..) = x`
71+
| --------------- help: try: `if let Some(<item>) = x`
7272
LL | // unnecessary
7373
LL | $a.unwrap();
7474
| ^^^^^^^^^^^
@@ -82,7 +82,7 @@ error: called `unwrap` on `x` after checking its variant with `is_ok`
8282
--> tests/ui/checked_unwrap/simple_conditionals.rs:78:9
8383
|
8484
LL | if x.is_ok() {
85-
| ------------ help: try: `if let Ok(..) = x`
85+
| ------------ help: try: `if let Ok(<item>) = x`
8686
LL | // unnecessary
8787
LL | x.unwrap();
8888
| ^^^^^^^^^^
@@ -91,7 +91,7 @@ error: called `expect` on `x` after checking its variant with `is_ok`
9191
--> tests/ui/checked_unwrap/simple_conditionals.rs:81:9
9292
|
9393
LL | if x.is_ok() {
94-
| ------------ help: try: `if let Ok(..) = x`
94+
| ------------ help: try: `if let Ok(<item>) = x`
9595
...
9696
LL | x.expect("an error message");
9797
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -127,7 +127,7 @@ error: called `unwrap_err` on `x` after checking its variant with `is_ok`
127127
--> tests/ui/checked_unwrap/simple_conditionals.rs:94:9
128128
|
129129
LL | if x.is_ok() {
130-
| ------------ help: try: `if let Err(..) = x`
130+
| ------------ help: try: `if let Err(<item>) = x`
131131
...
132132
LL | x.unwrap_err();
133133
| ^^^^^^^^^^^^^^
@@ -145,7 +145,7 @@ error: called `unwrap_err` on `x` after checking its variant with `is_err`
145145
--> tests/ui/checked_unwrap/simple_conditionals.rs:102:9
146146
|
147147
LL | if x.is_err() {
148-
| ------------- help: try: `if let Err(..) = x`
148+
| ------------- help: try: `if let Err(<item>) = x`
149149
...
150150
LL | x.unwrap_err();
151151
| ^^^^^^^^^^^^^^
@@ -154,7 +154,7 @@ error: called `unwrap` on `x` after checking its variant with `is_err`
154154
--> tests/ui/checked_unwrap/simple_conditionals.rs:106:9
155155
|
156156
LL | if x.is_err() {
157-
| ------------- help: try: `if let Ok(..) = x`
157+
| ------------- help: try: `if let Ok(<item>) = x`
158158
...
159159
LL | x.unwrap();
160160
| ^^^^^^^^^^
@@ -172,7 +172,7 @@ error: called `unwrap` on `option` after checking its variant with `is_some`
172172
--> tests/ui/checked_unwrap/simple_conditionals.rs:134:9
173173
|
174174
LL | if option.is_some() {
175-
| ------------------- help: try: `if let Some(..) = &option`
175+
| ------------------- help: try: `if let Some(<item>) = &option`
176176
LL | option.as_ref().unwrap();
177177
| ^^^^^^^^^^^^^^^^^^^^^^^^
178178

@@ -189,7 +189,7 @@ error: called `unwrap` on `result` after checking its variant with `is_ok`
189189
--> tests/ui/checked_unwrap/simple_conditionals.rs:144:9
190190
|
191191
LL | if result.is_ok() {
192-
| ----------------- help: try: `if let Ok(..) = &result`
192+
| ----------------- help: try: `if let Ok(<item>) = &result`
193193
LL | result.as_ref().unwrap();
194194
| ^^^^^^^^^^^^^^^^^^^^^^^^
195195

@@ -206,7 +206,7 @@ error: called `unwrap` on `option` after checking its variant with `is_some`
206206
--> tests/ui/checked_unwrap/simple_conditionals.rs:153:9
207207
|
208208
LL | if option.is_some() {
209-
| ------------------- help: try: `if let Some(..) = &mut option`
209+
| ------------------- help: try: `if let Some(<item>) = &mut option`
210210
LL | option.as_mut().unwrap();
211211
| ^^^^^^^^^^^^^^^^^^^^^^^^
212212

@@ -223,7 +223,7 @@ error: called `unwrap` on `result` after checking its variant with `is_ok`
223223
--> tests/ui/checked_unwrap/simple_conditionals.rs:162:9
224224
|
225225
LL | if result.is_ok() {
226-
| ----------------- help: try: `if let Ok(..) = &mut result`
226+
| ----------------- help: try: `if let Ok(<item>) = &mut result`
227227
LL | result.as_mut().unwrap();
228228
| ^^^^^^^^^^^^^^^^^^^^^^^^
229229

0 commit comments

Comments
 (0)