`let_underscore_lock` suggestion crosses macro boundaries
Maintainers usually reply within 1 day
Nobody has claimed this yet.
- #165661 by @2Zest — closed without merging
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by tracing the let_underscore_lock lint’s diagnostic and suggestion code, then inspect compiler UI tests for suggestions involving macro expansions. Reproduce the issue with the provided dbg!(m.lock().unwrap()) example and add a regression test showing the suggestion stays at the call site. Done means the output suggests drop(dbg!(m.lock().unwrap())); without pointing into the standard library macro.
Written by the indexing model from the issue text.
Description
Code
pub fn f(m: std::sync::Mutex<String>) {
let _ = dbg!(m.lock().unwrap());
}
Current output
error: non-binding let on a synchronization lock
--> src/lib.rs:2:9
|
2 | let _ = dbg!(m.lock().unwrap());
| ^ this lock is not assigned to a binding and is immediately dropped
|
= note: `#[deny(let_underscore_lock)]` (part of `#[deny(let_underscore)]`) on by default
help: consider binding to an unused variable to avoid immediately dropping the value
|
2 | let _unused = dbg!(m.lock().unwrap());
| ++++++
help: consider immediately dropping the value
--> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/macros.rs:369:9
|
369 - match $val {
370 - tmp => {
371 - $crate::eprintln!("[{}:{}:{}] {} = {:#?}",
372 - $crate::file!(),
373 - $crate::line!(),
374 - $crate::column!(),
375 - $crate::stringify!($val),
376 - // The `&T: Debug` check happens here (not in the format literal desugaring)
377 - // to avoid format literal related messages and suggestions.
378 - &&tmp as &dyn $crate::fmt::Debug,
379 - );
380 - tmp
381 - }
382 - }
369 + drop()
Desired output
drop(dbg!(m.lock().unwrap()));
Rationale and extra context
Other cases
Rust Version
Build using the Nightly version: 1.102.0-nightly
(2026-11-07 f5cedb83a788ea958109)
Anything else?
No response
- Dominant language
- Rust
- Stars
- 121k
- Forks
- 17.3k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 531
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rust-lang/rust
-
A-run-make relnotes relnotes-needs-review relnotes-tracking-issue T-lang T-libs
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
relnotes relnotes-needs-review relnotes-tracking-issue T-compiler T-libs
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
A-LLVM O-Arm O-UEFI O-x86_64 relnotes relnotes-needs-review relnotes-tracking-issue T-compiler
Difficulty 1/5 Under an hour Newbie friendliness 72/100
rust-lang/rust#165504 · 1 comment ·
Maintainers usually reply within 1 day
-
relnotes relnotes-tracking-issue T-libs
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
unclear wording in vec macroPossibly taken @Suhird claimed this 5 days ago. OpenA-docs A-slice-vec T-libs
Difficulty 1/5 1-3 hours Newbie friendliness 70/100
rust-lang/rust#165360 · 6 comments · 1 assignee ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
bytecodealliance/rustix#1736 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
longbridge/gpui-kit#3871 ·
Maintainers usually reply within 1 day
-
area:models enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
good first issue help wanted
Difficulty 1/5 Under an hour Newbie friendliness 84/100
servo/rust-smallvec#864 ·