Skip to content

Commit cdf6606

Browse files
committed
Use multipart_suggestion to create an applicable suggestion.
The "consider explicitly droping" can now suggest a machine applicable suggestion now.
1 parent 211feb1 commit cdf6606

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

compiler/rustc_lint/src/let_underscore.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,13 @@ fn build_and_emit_lint(
154154
"_unused",
155155
Applicability::MachineApplicable,
156156
)
157-
.span_suggestion_verbose(
158-
init_span,
157+
.multipart_suggestion(
159158
"consider explicitly droping with `std::mem::drop`",
160-
"drop(...)",
161-
Applicability::HasPlaceholders,
159+
vec![
160+
(init_span.shrink_to_lo(), "drop(".to_string()),
161+
(init_span.shrink_to_hi(), ")".to_string()),
162+
],
163+
Applicability::MachineApplicable,
162164
)
163165
.emit();
164166
}

src/test/ui/lint/let_underscore/let_underscore_drop.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ LL | let _unused = NontrivialDrop;
1111
| ~~~~~~~
1212
help: consider explicitly droping with `std::mem::drop`
1313
|
14-
LL | let _ = drop(...);
15-
| ~~~~~~~~~
14+
LL | let _ = drop(NontrivialDrop);
15+
| +++++ +
1616

1717
warning: 1 warning emitted
1818

src/test/ui/lint/let_underscore/let_underscore_lock.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ LL | let _unused = data.lock().unwrap();
1111
| ~~~~~~~
1212
help: consider explicitly droping with `std::mem::drop`
1313
|
14-
LL | let _ = drop(...);
15-
| ~~~~~~~~~
14+
LL | let _ = drop(data.lock().unwrap());
15+
| +++++ +
1616

1717
error: aborting due to previous error
1818

0 commit comments

Comments
 (0)