rust-lang / rust-lang/rust-analyzer
"extract into function" inserts dereference for macro call
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
I'm not knowledgeable enough to explain what's going on here, but here's an example which reproduces this:
let v = vec![1];
for _ in 0..1 {
println!("len is {}", v.len());
}
highlight the println! statement, Extract into function...
fn fun_name(v: &Vec<i32>) {
*println!("len is {}", v.len());
}
note the dereference, which prevents this from compiling (type () cannot be dereferenced)
rust-analyzer version: 0.3.1524-standalone (7ac161ce7 2023-05-21)
rustc version: (eg. output of rustc -V) 1.69.0
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 in rust-analyzer using the Rust snippet and the Extract into function action, then trace how extraction handles the println! macro call. Done means the generated function no longer inserts a dereference and the resulting Rust code compiles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100