Use multipart_suggestion
to create an applicable suggestion.
The "consider explicitly droping" can now suggest a machine applicable suggestion now.
This commit is contained in:
parent
211feb106a
commit
cdf6606066
3 changed files with 10 additions and 8 deletions
|
@ -154,11 +154,13 @@ fn build_and_emit_lint(
|
||||||
"_unused",
|
"_unused",
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.span_suggestion_verbose(
|
.multipart_suggestion(
|
||||||
init_span,
|
|
||||||
"consider explicitly droping with `std::mem::drop`",
|
"consider explicitly droping with `std::mem::drop`",
|
||||||
"drop(...)",
|
vec![
|
||||||
Applicability::HasPlaceholders,
|
(init_span.shrink_to_lo(), "drop(".to_string()),
|
||||||
|
(init_span.shrink_to_hi(), ")".to_string()),
|
||||||
|
],
|
||||||
|
Applicability::MachineApplicable,
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@ LL | let _unused = NontrivialDrop;
|
||||||
| ~~~~~~~
|
| ~~~~~~~
|
||||||
help: consider explicitly droping with `std::mem::drop`
|
help: consider explicitly droping with `std::mem::drop`
|
||||||
|
|
|
|
||||||
LL | let _ = drop(...);
|
LL | let _ = drop(NontrivialDrop);
|
||||||
| ~~~~~~~~~
|
| +++++ +
|
||||||
|
|
||||||
warning: 1 warning emitted
|
warning: 1 warning emitted
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ LL | let _unused = data.lock().unwrap();
|
||||||
| ~~~~~~~
|
| ~~~~~~~
|
||||||
help: consider explicitly droping with `std::mem::drop`
|
help: consider explicitly droping with `std::mem::drop`
|
||||||
|
|
|
|
||||||
LL | let _ = drop(...);
|
LL | let _ = drop(data.lock().unwrap());
|
||||||
| ~~~~~~~~~
|
| +++++ +
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue