Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b040666

Browse files
committed
Have the drop code suggestion not include let _ =
1 parent 7237e86 commit b040666

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

compiler/rustc_lint/src/let_underscore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ fn build_and_emit_lint(
157157
.multipart_suggestion(
158158
"consider immediately dropping the value",
159159
vec![
160-
(init_span.shrink_to_lo(), "drop(".to_string()),
160+
(local.span.until(init_span), "drop(".to_string()),
161161
(init_span.shrink_to_hi(), ")".to_string()),
162162
],
163163
Applicability::MachineApplicable,

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 immediately dropping the value
1313
|
14-
LL | let _ = drop(NontrivialDrop);
15-
| +++++ +
14+
LL | 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 immediately dropping the value
1313
|
14-
LL | let _ = drop(data.lock().unwrap());
15-
| +++++ +
14+
LL | drop(data.lock().unwrap());
15+
| ~~~~~ +
1616

1717
error: aborting due to previous error
1818

0 commit comments

Comments
 (0)