From fcaa2c470c64af9c0002de45e2a4d43a4a2006b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 22 Jun 2024 04:36:42 +0000 Subject: [PATCH] Fix clippy lint suggestion incorrectly treated as `span_help` --- src/tools/clippy/clippy_lints/src/unnecessary_wraps.rs | 4 +++- src/tools/clippy/tests/ui/unnecessary_wraps.stderr | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/tools/clippy/clippy_lints/src/unnecessary_wraps.rs b/src/tools/clippy/clippy_lints/src/unnecessary_wraps.rs index 5c7fbbab988bf..75754994fbac8 100644 --- a/src/tools/clippy/clippy_lints/src/unnecessary_wraps.rs +++ b/src/tools/clippy/clippy_lints/src/unnecessary_wraps.rs @@ -144,7 +144,9 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryWraps { ( "this function's return value is unnecessary".to_string(), "remove the return type...".to_string(), - snippet(cx, fn_decl.output.span(), "..").to_string(), + // FIXME: we should instead get the span including the `->` and suggest an + // empty string for this case. + "()".to_string(), "...and then remove returned values", ) } else { diff --git a/src/tools/clippy/tests/ui/unnecessary_wraps.stderr b/src/tools/clippy/tests/ui/unnecessary_wraps.stderr index 339ac57942efd..59986d895b30e 100644 --- a/src/tools/clippy/tests/ui/unnecessary_wraps.stderr +++ b/src/tools/clippy/tests/ui/unnecessary_wraps.stderr @@ -116,6 +116,10 @@ LL | | } LL | | } | |_^ | +help: remove the return type... + | +LL | fn issue_6640_1(a: bool, b: bool) -> () { + | ~~ help: ...and then remove returned values | LL ~ return ; @@ -139,6 +143,10 @@ LL | | } LL | | } | |_^ | +help: remove the return type... + | +LL | fn issue_6640_2(a: bool, b: bool) -> () { + | ~~ help: ...and then remove returned values | LL ~ return ;