rust-lang / rust-lang/rust

Tracking Issue for Generic Constant Arguments MVP

Open
#132,980 0 comments 65 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-const-generics C-tracking-issue F-min_generic_const_args PG-const-generics T-compiler T-lang T-types
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

This is a tracking issue for the prototype described in rust-lang/rust-project-goals#100. Background reading as to the design/justification for this feature.
The feature gate for the issue is #![feature(min_generic_const_args)].

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used 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.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.

Steps
  • Add ConstArgKind::Path (https://github.com/rust-lang/rust/pull/125915)
  • Use ConstArgKind::Path for all single-segment paths (https://github.com/rust-lang/rust/pull/131081)
  • Use ConstArgKind::Path for all paths
    • most paths #135186
    • #132986
  • Support "simple" exprs necessary for constructing adt_const_params types:
    • Struct construction exprs, e.g. Adt { field: N }
      • Core impl #149114
      • Rest patterns #150622
    • Tuple constructor calls, e.g. Some(N) #150610
    • Const constructs, e.g. None #132985
    • Array exprs, e.g. [M; N], [1, 2, N] #150612
    • Tuple exprs, (10, N) #150613
  • reject impls not using #[type_const] on their assoc consts if the trait used it #148716
  • enforce type_const marked const items have a type that implements ConstParamTy #148716
  • forbid generic parameters from being used in the types of const parameters #150614
  • lower uses of type_consts to mir::Const::Ty so they can be normalized in the MIR correctly #150615
  • Make inherent associated constants behave correctly #15200
  • Implement type system normalization that makes use of associated_const_equality bounds #139558
  • Merge feature(associated_const_equality) into min_generic_const_args #150617
  • Experiment with adding some kind of ConstArgKind::Literal #150618
  • Traits are dyn compatible if all associated consts are type safe #130300
  • Find a way to avoid code duplication between HIR ty lowering and typechecking for struct expressions #150621
  • Make HIR ty lowering lower uses of generic parameters to errors if in an item with no generics
    • ish, #150519
    • #150620
  • Find better names for ConstKind::Value and ValTree now that they're not fully evaluated #150624
  • Do something about CTFE returning ValTrees with erased lifetimes. Likely means adding a ValTree which doesn't recurse through ty::Const like how it used to be #150624
  • Typecheck that const arguments outside of paths have the correct type #150623
  • Adjust documentation (see instructions on rustc-dev-guide)
  • Stabilization PR (see instructions on rustc-dev-guide)
Unresolved Questions
  • Can we get rid of needing an annotation on const items for them being type consts?
    • If no we need t-style to decide on rustfmt stuff
Implementation history
Implementation history

  • Initial document proposing the design/feature hackmd link
  • #125915
  • #129137
  • #131081
  • #134873
  • #135186
  • #140549
  • #139558
  • #148716
  • #149136
  • #150025
  • #149114
  • #150380
  • #150411
  • #150519
  • #150589
  • #150603
  • #150650
  • #150675
  • #150640
    • This tracking issue now inherits the impl history of ACE's tracking issue #92827
    • #87648[^1]
    • #93285[^2]
    • #113028
    • #118668
    • #119385
    • #121258
    • #142092
    • #150844
    • rust-lang/rustc-demangle#87
    • #150843
  • #150699
  • #150704
  • #150695
  • #150713
  • #150799
  • #151085
  • #151296
  • #150886
  • #151055
  • #150786
  • #151288
  • #151275
  • #150962
  • #150869
  • #151219
  • #151947
  • #151754
  • #152000
  • #152001
  • #152040
  • #152129
  • #152136
  • #152139
  • #152146
  • #152278
  • #152324
  • #152385
  • #152492 #152458
  • #152565
  • #152794
  • #152906
  • #152952
  • #153050
  • #153075
  • #155198

[^1]: Initial effort to implement which includes parsing and use of term throughout the codebase, but still lacking a complete implementation.
[^2]: More thorough implementation which works for basic cases. This allowed for consts to actually be bound, more than just parsing them.

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

Start with rust-lang/rust-project-goals#100 and the linked design document, then review the unchecked items in this tracking issue for the min_generic_const_args feature gate. Use the referenced issues and rustc-dev-guide stabilization and documentation instructions to identify a focused task. Done means the selected checklist item is resolved and the feature is ready for documentation and stabilization.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.