rust-lang / rust-analyzer

A Rust compiler front-end for IDEs
https://rust-analyzer.github.io/
Apache License 2.0
14.17k stars 1.58k forks source link

Provide assistance for writing an impl block #17590

Open RalfJung opened 2 months ago

RalfJung commented 2 months ago

When I am at a type, I can select a "generate impl" assist and it will generate a block right below the type. That's useful, but often I am somewhere else in the project (might not even be the same file), and I want to generate an impl block here. Would be great if there was some way to get the assist there as well. :)

What I usually try is to write impl TypeName, and then my hope would be that (a) I get auto-complete (including auto-import) for the type name, and (b) I can then select an assist to generate an impl block, and it will turn this into

impl<'a, T: Bound> TypeName<'a, T> {
  /* cursor here */
}
lnicola commented 2 months ago

A better UX might be to write impl TypeName and get a completion for the whole thing :slightly_smiling_face:.

ShoyuVanilla commented 2 months ago

I'll give this a try @rustbot claim

ChayimFriedman2 commented 3 weeks ago

@ShoyuVanilla Are you still working on this?

ShoyuVanilla commented 3 weeks ago

No, I was just waiting for #18032 to effectively work on assist things. You could work on this if you like 😄

ChayimFriedman2 commented 3 weeks ago

@rustbot claim

ChayimFriedman2 commented 3 weeks ago

@rustbot release-assignment

I still intend to work on this, but as a diagnostic with quick fix, and this diagnostic requires https://github.com/rust-lang/rust-analyzer/pull/18074 and follow-ups, which is quite big work. So in order to not create false hopes and not block anyone who would like to want on this, I'm unassigning for now.