diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2023-11-23 13:30:36 +0100 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2023-11-23 13:32:41 +0100 |
| commit | 6c84b968862ef605eca33ec9770009be5e1f0adf (patch) | |
| tree | 22ad241648be1999ec4decd88271c1e357870fa2 /clippy_lints | |
| parent | 840e227bb6eadb2a01f2344e41ef57bcde6cfa6f (diff) | |
Improve error messages format
Diffstat (limited to 'clippy_lints')
| -rw-r--r-- | clippy_lints/src/methods/map_unwrap_or.rs | 6 | ||||
| -rw-r--r-- | clippy_lints/src/methods/option_as_ref_deref.rs | 5 | ||||
| -rw-r--r-- | clippy_lints/src/methods/option_map_or_none.rs | 9 | ||||
| -rw-r--r-- | clippy_lints/src/methods/option_map_unwrap_or.rs | 5 |
4 files changed, 7 insertions, 18 deletions
diff --git a/clippy_lints/src/methods/map_unwrap_or.rs b/clippy_lints/src/methods/map_unwrap_or.rs index cb81b3919bf..52ea584a2c8 100644 --- a/clippy_lints/src/methods/map_unwrap_or.rs +++ b/clippy_lints/src/methods/map_unwrap_or.rs @@ -44,11 +44,9 @@ pub(super) fn check<'tcx>( // lint message let msg = if is_option { - "called `map(<f>).unwrap_or_else(<g>)` on an `Option` value. This can be done more directly by calling \ - `map_or_else(<g>, <f>)` instead" + "called `map(<f>).unwrap_or_else(<g>)` on an `Option` value" } else { - "called `map(<f>).unwrap_or_else(<g>)` on a `Result` value. This can be done more directly by calling \ - `.map_or_else(<g>, <f>)` instead" + "called `map(<f>).unwrap_or_else(<g>)` on a `Result` value" }; // get snippets for args to map() and unwrap_or_else() let map_snippet = snippet(cx, map_arg.span, ".."); diff --git a/clippy_lints/src/methods/option_as_ref_deref.rs b/clippy_lints/src/methods/option_as_ref_deref.rs index 15111006133..756dbe62d84 100644 --- a/clippy_lints/src/methods/option_as_ref_deref.rs +++ b/clippy_lints/src/methods/option_as_ref_deref.rs @@ -99,10 +99,7 @@ pub(super) fn check( let hint = format!("{}.{method_hint}()", snippet(cx, as_ref_recv.span, "..")); let suggestion = format!("try using {method_hint} instead"); - let msg = format!( - "called `{current_method}` on an Option value. This can be done more directly \ - by calling `{hint}` instead" - ); + let msg = format!("called `{current_method}` on an `Option` value"); span_lint_and_sugg( cx, OPTION_AS_REF_DEREF, diff --git a/clippy_lints/src/methods/option_map_or_none.rs b/clippy_lints/src/methods/option_map_or_none.rs index 418e6a7d6a0..ff4d8cc9e3e 100644 --- a/clippy_lints/src/methods/option_map_or_none.rs +++ b/clippy_lints/src/methods/option_map_or_none.rs @@ -66,8 +66,7 @@ pub(super) fn check<'tcx>( && Some(id) == cx.tcx.lang_items().option_some_variant() { let func_snippet = snippet(cx, arg_char.span, ".."); - let msg = "called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling \ - `map(..)` instead"; + let msg = "called `map_or(None, ..)` on an `Option` value"; return span_lint_and_sugg( cx, OPTION_MAP_OR_NONE, @@ -80,8 +79,7 @@ pub(super) fn check<'tcx>( } let func_snippet = snippet(cx, map_arg.span, ".."); - let msg = "called `map_or(None, ..)` on an `Option` value. This can be done more directly by calling \ - `and_then(..)` instead"; + let msg = "called `map_or(None, ..)` on an `Option` value"; span_lint_and_sugg( cx, OPTION_MAP_OR_NONE, @@ -92,8 +90,7 @@ pub(super) fn check<'tcx>( Applicability::MachineApplicable, ); } else if f_arg_is_some { - let msg = "called `map_or(None, Some)` on a `Result` value. This can be done more directly by calling \ - `ok()` instead"; + let msg = "called `map_or(None, Some)` on a `Result` value"; let self_snippet = snippet(cx, recv.span, ".."); span_lint_and_sugg( cx, diff --git a/clippy_lints/src/methods/option_map_unwrap_or.rs b/clippy_lints/src/methods/option_map_unwrap_or.rs index c78f8b71c78..575c2d8f157 100644 --- a/clippy_lints/src/methods/option_map_unwrap_or.rs +++ b/clippy_lints/src/methods/option_map_unwrap_or.rs @@ -97,10 +97,7 @@ pub(super) fn check<'tcx>( } else { "map_or(<a>, <f>)" }; - let msg = &format!( - "called `map(<f>).unwrap_or({arg})` on an `Option` value. \ - This can be done more directly by calling `{suggest}` instead" - ); + let msg = &format!("called `map(<f>).unwrap_or({arg})` on an `Option` value"); span_lint_and_then(cx, MAP_UNWRAP_OR, expr.span, msg, |diag| { let map_arg_span = map_arg.span; |
