rust-lang / rust-lang/rust-analyzer
Invoking the dbg! macro snippet on a negated expression leaves the negation operator outside the dbg!()
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Expected
Calling the postfix dbg completion on a negated expression will wrap the whole expression including the negation operator.
Observed
When the postfix dbg completion is requested, the original negation operator remains outside the freshly inserted dbg!() macro.
Repro
enum NestedStuff {
Variants,
Dont,
Matter,
}
impl NestedStuff {
fn random_method(self) -> bool {
return true;
}
}
fn some_func() {
let my_enum = NestedStuff::Matter;
if !my_enum.random_method().dbg$0 { // choose the dbg snippet and have this line convert to
//`if !dbg!(my_enum.random_method()) {`
println!("Hello");
}
}
Version info
rustc -V
rustc 1.58.0 (02072b482 2022-01-11)
rust-analyzer --version
rust-analyzer ba3305480 2022-02-07 stable
using lsp-mode in doom emacs, if that's relevant.
Contributor 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.
Research direction
Reproduce the issue using the Rust example and the postfix dbg completion described in the report. Trace the completion entry point and its expression handling, then verify that a negated expression becomes !dbg!(my_enum.random_method()) rather than leaving ! outside the inserted macro.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100