mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 13:43:17 +00:00
feat: change error message
This commit is contained in:
parent
20c352a4f6
commit
0f83753934
2 changed files with 5 additions and 5 deletions
|
@ -21,14 +21,14 @@ pub(super) fn check<'tcx>(
|
||||||
let or_arg_content: Span;
|
let or_arg_content: Span;
|
||||||
|
|
||||||
if is_type_diagnostic_item(cx, ty, sym::Option) {
|
if is_type_diagnostic_item(cx, ty, sym::Option) {
|
||||||
title = ".or(Some(…)).unwrap() found";
|
title = "found `.or(Some(…)).unwrap()`";
|
||||||
if let Some(content) = get_content_if_is(or_arg, "Some") {
|
if let Some(content) = get_content_if_is(or_arg, "Some") {
|
||||||
or_arg_content = content;
|
or_arg_content = content;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if is_type_diagnostic_item(cx, ty, sym::Result) {
|
} else if is_type_diagnostic_item(cx, ty, sym::Result) {
|
||||||
title = ".or(Ok(…)).unwrap() found";
|
title = "found `.or(Ok(…)).unwrap()`";
|
||||||
if let Some(content) = get_content_if_is(or_arg, "Ok") {
|
if let Some(content) = get_content_if_is(or_arg, "Ok") {
|
||||||
or_arg_content = content;
|
or_arg_content = content;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error: .or(Some(…)).unwrap() found
|
error: found `.or(Some(…)).unwrap()`
|
||||||
--> $DIR/or_then_unwrap.rs:24:20
|
--> $DIR/or_then_unwrap.rs:24:20
|
||||||
|
|
|
|
||||||
LL | let _ = option.or(Some("fallback")).unwrap(); // should trigger lint
|
LL | let _ = option.or(Some("fallback")).unwrap(); // should trigger lint
|
||||||
|
@ -6,13 +6,13 @@ LL | let _ = option.or(Some("fallback")).unwrap(); // should trigger lint
|
||||||
|
|
|
|
||||||
= note: `-D clippy::or-then-unwrap` implied by `-D warnings`
|
= note: `-D clippy::or-then-unwrap` implied by `-D warnings`
|
||||||
|
|
||||||
error: .or(Ok(…)).unwrap() found
|
error: found `.or(Ok(…)).unwrap()`
|
||||||
--> $DIR/or_then_unwrap.rs:27:20
|
--> $DIR/or_then_unwrap.rs:27:20
|
||||||
|
|
|
|
||||||
LL | let _ = result.or::<&str>(Ok("fallback")).unwrap(); // should trigger lint
|
LL | let _ = result.or::<&str>(Ok("fallback")).unwrap(); // should trigger lint
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or("fallback")`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or("fallback")`
|
||||||
|
|
||||||
error: .or(Some(…)).unwrap() found
|
error: found `.or(Some(…)).unwrap()`
|
||||||
--> $DIR/or_then_unwrap.rs:31:31
|
--> $DIR/or_then_unwrap.rs:31:31
|
||||||
|
|
|
|
||||||
LL | let _ = option.map(|v| v).or(Some("fallback")).unwrap().to_string().chars(); // should trigger lint
|
LL | let _ = option.map(|v| v).or(Some("fallback")).unwrap().to_string().chars(); // should trigger lint
|
||||||
|
|
Loading…
Reference in a new issue