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",
|
||||
Applicability::MachineApplicable,
|
||||
)
|
||||
.span_suggestion_verbose(
|
||||
init_span,
|
||||
.multipart_suggestion(
|
||||
"consider explicitly droping with `std::mem::drop`",
|
||||
"drop(...)",
|
||||
Applicability::HasPlaceholders,
|
||||
vec![
|
||||
(init_span.shrink_to_lo(), "drop(".to_string()),
|
||||
(init_span.shrink_to_hi(), ")".to_string()),
|
||||
],
|
||||
Applicability::MachineApplicable,
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@ LL | let _unused = NontrivialDrop;
|
|||
| ~~~~~~~
|
||||
help: consider explicitly droping with `std::mem::drop`
|
||||
|
|
||||
LL | let _ = drop(...);
|
||||
| ~~~~~~~~~
|
||||
LL | let _ = drop(NontrivialDrop);
|
||||
| +++++ +
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ LL | let _unused = data.lock().unwrap();
|
|||
| ~~~~~~~
|
||||
help: consider explicitly droping with `std::mem::drop`
|
||||
|
|
||||
LL | let _ = drop(...);
|
||||
| ~~~~~~~~~
|
||||
LL | let _ = drop(data.lock().unwrap());
|
||||
| +++++ +
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue