rust-lang / rust-lang/rust-analyzer
Structural Search and Replace (SSR): nothing happens when replacement includes macro
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
rust-analyzer version: rust-analyzer version: 0.3.1885-standalone (b6d1887bc 2024-03-17)
rustc version: rustc 1.75.0 (82e1608df 2023-12-21)
IDE: VSCode
NOT A CONTRIBUTION
Code
// println!($a, $b) ==>> eprintln!($a, $b)
fn main() {
println!("foo: {}", 123);
}
Steps to reproduce
cargo new foo- Open new project with IDE and paste the code snippet to
src/main.rs - Run code action for commented line with an SSR request
Expected behavior
The println!(…) should become an eprintln!(…)
Observed behavior
Nothing happens
Additional context
If I trace the language server, it responds to the SSR request saying that there are no document changes. No errors are printed anywhere.
If I use a different replacement pattern, such as ($a, $b), it works just fine, so it's handling the match, it only fails on the replacement.
If I use a code snippet where I'm replacing a non-macro with a macro, that also fails:
fn foo(s: &str, x: isize) {}
// foo($a, $b) ==>> println!($a, $b)
fn main() {
foo("foo: {}", 123);
}
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
No source file or test is named. Start by reproducing the SSR request in rust-analyzer with the provided macro replacement examples, then trace replacement handling after the match is found. Done means replacing println! with eprintln! and supporting the non-macro-to-macro example without returning an empty document change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100