about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCameron Steffen <cam.steffen94@gmail.com>2021-07-11 20:30:19 -0500
committerCameron Steffen <cam.steffen94@gmail.com>2021-07-13 08:57:16 -0500
commit306f9e843d5474eb2de6907b3ca6941dc918ea23 (patch)
tree80cbc9e7e0e242d8253cd00a9428aab0d6cce902
parent73ffae6ea1b8639050ca19db9732a7a25daae482 (diff)
downloadrust-306f9e843d5474eb2de6907b3ca6941dc918ea23.tar.gz
rust-306f9e843d5474eb2de6907b3ca6941dc918ea23.zip
Split a lint message into help
-rw-r--r--clippy_lints/src/explicit_write.rs6
-rw-r--r--tests/ui/explicit_write_non_rustfix.stderr3
2 files changed, 5 insertions, 4 deletions
diff --git a/clippy_lints/src/explicit_write.rs b/clippy_lints/src/explicit_write.rs
index 9a07d422b63..66724294804 100644
--- a/clippy_lints/src/explicit_write.rs
+++ b/clippy_lints/src/explicit_write.rs
@@ -1,4 +1,4 @@
-use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg};
+use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_sugg};
 use clippy_utils::higher::FormatArgsExpn;
 use clippy_utils::{is_expn_of, match_function_call, paths};
 use if_chain::if_chain;
@@ -97,8 +97,8 @@ impl<'tcx> LateLintPass<'tcx> for ExplicitWrite {
                     );
                 } else {
                     // We don't have a proper suggestion
-                    let msg = format!("{}. Consider using `{}{}!` instead", msg, prefix, sugg_mac);
-                    span_lint(cx, EXPLICIT_WRITE, expr.span, &msg);
+                    let help = format!("consider using `{}{}!` instead", prefix, sugg_mac);
+                    span_lint_and_help(cx, EXPLICIT_WRITE, expr.span, &msg, None, &help);
                 }
             }
         }
diff --git a/tests/ui/explicit_write_non_rustfix.stderr b/tests/ui/explicit_write_non_rustfix.stderr
index 77cadb99bb5..b94ec6403dd 100644
--- a/tests/ui/explicit_write_non_rustfix.stderr
+++ b/tests/ui/explicit_write_non_rustfix.stderr
@@ -1,10 +1,11 @@
-error: use of `writeln!(stderr(), ...).unwrap()`. Consider using `eprintln!` instead
+error: use of `writeln!(stderr(), ...).unwrap()`
   --> $DIR/explicit_write_non_rustfix.rs:7:5
    |
 LL |     writeln!(std::io::stderr(), "foo {}", bar).unwrap();
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `-D clippy::explicit-write` implied by `-D warnings`
+   = help: consider using `eprintln!` instead
 
 error: aborting due to previous error