rust-lang / rust-lang/rust-analyzer

Support early const eval for inline `const{}` expressions

Open
#21,080 1 comment 0 reactions 0 assignees View on GitHub

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

Related:
https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/const.20binding.20vs.2E.20const.7B.7D.20evaluation/near/558550788

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.