rust-lang / rust-lang/rust-analyzer
"Generate constant" assist creates constant with function's type when invoked on a const generic argument.
Open
Nobody has claimed this yet.
A-assists
A-ty
C-bug
S-unactionable
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
- serverVersion: '0.3.859'
- nightlyReleaseId: 55412114
Example:
fn main() {
fn foo<const X: usize>() { }
foo::<BAR>();
}
Invoking the "Generate constant" assist on BAR results in:
fn main() {
fn foo<const X: usize>() { }
const BAR: fn foo() = ;
foo::<BAR>();
}
It should instead use the argument's type and generate const BAR: usize = .
https://user-images.githubusercontent.com/1352092/146385585-7e7151f2-a287-4b99-9c50-6b43a216c99f.mp4
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
Start at the rust-analyzer “Generate constant” assist entry point and reproduce the issue with the const-generic Rust snippet in the report. Trace how the selected argument’s type is determined, then verify that invoking the assist on BAR produces const BAR: usize = rather than using the function type.
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
- Clearly specified
- Newbie friendliness
- 48/100