From b040666e052a94241d2598b06d5e5dc19c77257b Mon Sep 17 00:00:00 2001 From: Aaron Kofsky Date: Sat, 11 Jun 2022 10:36:48 -0400 Subject: [PATCH] Have the drop code suggestion not include `let _ =` --- compiler/rustc_lint/src/let_underscore.rs | 2 +- src/test/ui/lint/let_underscore/let_underscore_drop.stderr | 4 ++-- src/test/ui/lint/let_underscore/let_underscore_lock.stderr | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_lint/src/let_underscore.rs b/compiler/rustc_lint/src/let_underscore.rs index fe0e0511f6b..2ba79aacace 100644 --- a/compiler/rustc_lint/src/let_underscore.rs +++ b/compiler/rustc_lint/src/let_underscore.rs @@ -157,7 +157,7 @@ fn build_and_emit_lint( .multipart_suggestion( "consider immediately dropping the value", vec![ - (init_span.shrink_to_lo(), "drop(".to_string()), + (local.span.until(init_span), "drop(".to_string()), (init_span.shrink_to_hi(), ")".to_string()), ], Applicability::MachineApplicable, diff --git a/src/test/ui/lint/let_underscore/let_underscore_drop.stderr b/src/test/ui/lint/let_underscore/let_underscore_drop.stderr index b6ff9d1a27c..cf7b882e946 100644 --- a/src/test/ui/lint/let_underscore/let_underscore_drop.stderr +++ b/src/test/ui/lint/let_underscore/let_underscore_drop.stderr @@ -11,8 +11,8 @@ LL | let _unused = NontrivialDrop; | ~~~~~~~ help: consider immediately dropping the value | -LL | let _ = drop(NontrivialDrop); - | +++++ + +LL | drop(NontrivialDrop); + | ~~~~~ + warning: 1 warning emitted diff --git a/src/test/ui/lint/let_underscore/let_underscore_lock.stderr b/src/test/ui/lint/let_underscore/let_underscore_lock.stderr index 1e49b89c5a8..7aa119003b4 100644 --- a/src/test/ui/lint/let_underscore/let_underscore_lock.stderr +++ b/src/test/ui/lint/let_underscore/let_underscore_lock.stderr @@ -11,8 +11,8 @@ LL | let _unused = data.lock().unwrap(); | ~~~~~~~ help: consider immediately dropping the value | -LL | let _ = drop(data.lock().unwrap()); - | +++++ + +LL | drop(data.lock().unwrap()); + | ~~~~~ + error: aborting due to previous error