Skip to content

Commit 0f83753

Browse files
committed
feat: change error message
1 parent 20c352a commit 0f83753

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

clippy_lints/src/methods/or_then_unwrap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ pub(super) fn check<'tcx>(
2121
let or_arg_content: Span;
2222

2323
if is_type_diagnostic_item(cx, ty, sym::Option) {
24-
title = ".or(Some(…)).unwrap() found";
24+
title = "found `.or(Some(…)).unwrap()`";
2525
if let Some(content) = get_content_if_is(or_arg, "Some") {
2626
or_arg_content = content;
2727
} else {
2828
return;
2929
}
3030
} else if is_type_diagnostic_item(cx, ty, sym::Result) {
31-
title = ".or(Ok(…)).unwrap() found";
31+
title = "found `.or(Ok(…)).unwrap()`";
3232
if let Some(content) = get_content_if_is(or_arg, "Ok") {
3333
or_arg_content = content;
3434
} else {

tests/ui/or_then_unwrap.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
error: .or(Some(…)).unwrap() found
1+
error: found `.or(Some(…)).unwrap()`
22
--> $DIR/or_then_unwrap.rs:24:20
33
|
44
LL | let _ = option.or(Some("fallback")).unwrap(); // should trigger lint
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or("fallback")`
66
|
77
= note: `-D clippy::or-then-unwrap` implied by `-D warnings`
88

9-
error: .or(Ok(…)).unwrap() found
9+
error: found `.or(Ok(…)).unwrap()`
1010
--> $DIR/or_then_unwrap.rs:27:20
1111
|
1212
LL | let _ = result.or::<&str>(Ok("fallback")).unwrap(); // should trigger lint
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or("fallback")`
1414

15-
error: .or(Some(…)).unwrap() found
15+
error: found `.or(Some(…)).unwrap()`
1616
--> $DIR/or_then_unwrap.rs:31:31
1717
|
1818
LL | let _ = option.map(|v| v).or(Some("fallback")).unwrap().to_string().chars(); // should trigger lint

0 commit comments

Comments
 (0)