Tracking Issue for inline const patterns (RFC 2920) #76001
Description
This is a tracking issue for the RFC "Inline const
expressions and patterns" (rust-lang/rfcs#2920).
Const expressions have been stabilized, but patterns have not
The feature gate for the issue is #![feature(inline_const_pat)]
.
This was originally a tracking issue for const blocks in both expression and pattern position. Inline const expressions have been stabilized in #104087 while patterns are still unstable.
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also uses as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
- Implement the RFC (Implement const expressions and patterns (RFC 2920) #77124 does most of it, modulo some bugs around range patterns that should be fixed in Make inline const work in range patterns #78116)
- Adjust documentation (see instructions on rustc-dev-guide) [Unstable Book docs in Document inline-const #78250]
- Handle inner attributes. Parse inner attributes on inline const block #94985
- Decide whether Non-terminals, e.g. expr, have diverged between parser and macro matcher #86730 needs to be resolved.
- Lang decided in 2024-04-03 triage that this is not a blocker.
- Parsing bug inside let-else: Let-else not checking for curly brace of inline const before
else
#118859 - Resolve Const-eval errors in dead functions are optimization-dependent #107503
- Decide whether Which functions are "reachable", and therefore subject to monomorphization-time checks, is optimization-dependent #122814 needs to be resolved
- Lang decided in 2024-04-03 triage that this is not a blocker.
- Decide whether Evaluating constants in MIR optimizations introduces const eval errors #122828 needs to be resolved
- Lang decided in 2024-04-03 triage that this is not a blocker.
- Stabilization PR: expressions Stabilise inline_const #104087
- Reference PR: Document inline const/const block expression reference#1295
- Stabilization PR: patterns
Unresolved Questions
- Naming: "inline const", "const block", or "anonymous const"?
- Lint about
&const { 4 }
vsconst { &4 }
? - How should this work for the special has-block syntax rules? https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/const.20blocks.20differ.20from.20normal.20and.20from.20unsafe.20blocks/near/290229453
Implementation history
- Primary implementation PR: Implement const expressions and patterns (RFC 2920) #77124
- Unstable Book documentation: Document inline-const #78250
FnDef
type is disallowed in patterns: DenyFnDef
in patterns #114668
Activity