rust-lang / rust-lang/rust-analyzer
Feature request: Generate type definition from struct or enum literal
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
It would be really nice for quick prototyping if there was an assist that could generate a struct or enum definition given a corresponding literal with an undefined type name at the front.
Record struct:
let foo = Foo$0 { field: "hello".to_owned() };
// generate type definition
struct Foo {
field: String,
}
Tuple struct:
let foo = Foo$0("world");
// generate type definition
struct Foo<'a>(&'a str);
Enum:
let bar = Foo$0::Bar;
let baz = Foo::Baz;
// generate type definition
enum Foo {
Bar,
Baz,
}
(and equivalent for enums with tuple or record fields)
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
The issue names no files, tests, or entry points. Start by locating rust-analyzer's assist handling for undefined types and use the record, tuple-struct, and enum examples as acceptance cases. Done means generating struct or enum definitions, including tuple or record fields and required lifetimes, from the literals shown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100