rust-lang / rust-lang/rust-analyzer
Support early const eval for inline `const{}` expressions
Open
Nobody has claimed this yet.
C-feature
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
Const eval is not guaranteed to be done at check time, especially with const{} expressions.
For example:
// check error
const X: NonZeroU32 = NonZeroU32::new(0).unwrap();
// check success, build error
let x: NonZeroU32 = const{NonZeroU32::new(0).unwrap()};
rust-analyzer catching such errors would be a great addition.
I hope this is not a duplicate, since it's not easy to search for this.
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 or tests. Start by reproducing the shown const{...} check/build discrepancy and tracing rust-analyzer's const-evaluation path; done means the equivalent invalid NonZeroU32 expression is diagnosed during check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100