From a9f1b7bd2a25e34de29eb88f81550690f4fec5dc Mon Sep 17 00:00:00 2001 From: Aaron Kofsky Date: Thu, 4 Aug 2022 17:00:48 -0400 Subject: Explain why let-underscoring a lock guard is incorrect. Currently, the let_underscore_lock lint simply tells what is wrong, but not why it is wrong. We fix this by using a `MultiSpan` to explain specifically that doing `let _ = ` immediately drops the lock guard because it does not assign the lock guard to a binding. --- src/test/ui/lint/let_underscore/let_underscore_lock.stderr | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/test') 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 7aa119003b4..fb58af0a42f 100644 --- a/src/test/ui/lint/let_underscore/let_underscore_lock.stderr +++ b/src/test/ui/lint/let_underscore/let_underscore_lock.stderr @@ -1,8 +1,10 @@ error: non-binding let on a synchronization lock - --> $DIR/let_underscore_lock.rs:6:5 + --> $DIR/let_underscore_lock.rs:6:9 | LL | let _ = data.lock().unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ ^^^^^^^^^^^^^^^^^^^^ this binding will immediately drop the value assigned to it + | | + | this lock is not assigned to a binding and is immediately dropped | = note: `#[deny(let_underscore_lock)]` on by default help: consider binding to an unused variable to avoid immediately dropping the value -- cgit 1.4.1-3-g733a5