rust-lang / rust-lang/rust-analyzer
fill match arms assist put the code in the wrong place
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: v0.4.1157
rustc version: rustc 1.64.0-nightly (9067d5277 2022-07-28)
fill match arms assist put the code in the wrong place!
Reload the window doesn't solve the problem.
Minimal reproduce:
// crate macro_lab, lab.rs
use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, ItemFn};
#[proc_macro_attribute]
pub fn untouched(_attr: TokenStream, item: TokenStream) -> TokenStream {
let input = parse_macro_input!(item as ItemFn);
let tokens = quote! {
#input
};
tokens.into()
}
// main.rs
use macro_lab::untouched;
#[untouched]
fn f() {
enum E {
A,
B,
}
let e = E::A;
match e {
}
}
However if we define untouched like this:
pub fn untouched(_attr: TokenStream, item: TokenStream) -> TokenStream {
item
}
the bug doesn't occur.
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 proc-macro definitions in lab.rs and the annotated function in main.rs, then invoke the “fill match arms” assist on the empty match. Compare the behavior when the attribute macro expands through quote! versus returning item directly; done means the generated arms are inserted inside the intended match expression.
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
- Mostly clear
- Newbie friendliness
- 45/100