Do not underline suggestions for code that is already there
When a suggestion part is for already present code, do not highlight it. If after that there are no highlights left, do not show the suggestion at all. Fix clippy lint suggestion incorrectly treated as `span_help`.
This commit is contained in:
parent
5faea65d4d
commit
5ef38a3bc7
@ -145,7 +145,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 {
|
||||
|
@ -63,7 +63,7 @@ LL | let _val = None::<()>.expect("this always happens");
|
||||
help: remove the `None` and `expect()`
|
||||
|
|
||||
LL | let _val = panic!("this always happens");
|
||||
| ~~~~~~~ ~
|
||||
| ~~~~~~~
|
||||
|
||||
error: used `unwrap_or_default()` on `None` value
|
||||
--> tests/ui/unnecessary_literal_unwrap.rs:22:24
|
||||
@ -134,7 +134,7 @@ LL | None::<()>.expect("this always happens");
|
||||
help: remove the `None` and `expect()`
|
||||
|
|
||||
LL | panic!("this always happens");
|
||||
| ~~~~~~~ ~
|
||||
| ~~~~~~~
|
||||
|
||||
error: used `unwrap_or_default()` on `None` value
|
||||
--> tests/ui/unnecessary_literal_unwrap.rs:30:5
|
||||
|
@ -118,8 +118,8 @@ LL | | }
|
||||
|
|
||||
help: remove the return type...
|
||||
|
|
||||
LL | fn issue_6640_1(a: bool, b: bool) -> Option<()> {
|
||||
| ~~~~~~~~~~
|
||||
LL | fn issue_6640_1(a: bool, b: bool) -> () {
|
||||
| ~~
|
||||
help: ...and then remove returned values
|
||||
|
|
||||
LL ~ return ;
|
||||
@ -145,8 +145,8 @@ LL | | }
|
||||
|
|
||||
help: remove the return type...
|
||||
|
|
||||
LL | fn issue_6640_2(a: bool, b: bool) -> Result<(), i32> {
|
||||
| ~~~~~~~~~~~~~~~
|
||||
LL | fn issue_6640_2(a: bool, b: bool) -> () {
|
||||
| ~~
|
||||
help: ...and then remove returned values
|
||||
|
|
||||
LL ~ return ;
|
||||
|
Loading…
x
Reference in New Issue
Block a user