Repository: rust
Issue: Tracking issue for generic const items
Labels: T-lang,B-unstable,C-tracking-issue,S-tracking-needs-to-bake,F-generic_const_items,B-experimental

This is a tracking issue for the experimental feature *generic const items* (RFC pending).
The feature gate for the issue is `#![feature(generic_const_items)]`.

It enables generic parameters and where-clauses on free and associated const items.
See also rust-lang/lang-team#214.

### About experimental features

An experimental feature is one that has not yet had an RFC. The idea is to allow implementation work to proceed to better inform an upcoming RFC. Experimental features cannot be stabilized without first having an RFC. The existence of an experimental feature does not indicate lang team consensus that the feature is desirable, only that there is a problem that is worthy of being solved and that the idea has enough merit to consider exploring. See [the lang team process page][experimental] for more details.

[experimental]: https://lang-team.rust-lang.org/how_to/experiment.html

### 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.

### Steps

- [x] Implement the experiment: #113522
- [ ] Write an RFC
- [ ] Adjust documentation ([see instructions on rustc-dev-guide][doc-guide])
- [ ] Formatting for new syntax has been added to the [Style Guide] ([nightly-style-procedure])
- [ ] Formatting has been implemented in rustfmt according to the Style Guide
- [ ] Rustdoc JSON support has been added
- [ ] Stabilization PR ([see instructions on rustc-dev-guide][stabilization-guide])

[stabilization-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#stabilization-pr
[doc-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#documentation-prs
[nightly-style-procedure]: https://github.com/rust-lang/style-team/blob/master/nightly-style-procedure.md 
[Style Guide]: https://github.com/rust-lang/rust/tree/master/src/doc/style-guide

### Experimental results

Part of the goal of the experimental process is to identify benefits but also concerns that need to be addressed in the RFC. This section catalogues notable findings thus far.

1. Do we want to require “`where Self: 'a`” bounds on GACs like we do on GATs (#87479)?
  Unresolved, not implemented.
2. Should `#![feature(trivial_bounds)] const _UNUSED: () = () where String: Copy;` successfully compile?
  [Ideally yes](https://github.com/rust-lang/rust/pull/113522#issuecomment-1628634092), not implemented.
3. Should we forbid underscore identifiers for const items with generic parameters (e.g., `const _<T>: () = ();`)?
  Unresolved, not implemented.
4. Should we imply some outlives-bounds? E.g., should the presence of `&'a &'b ()` in `const K<'a, 'b>: &'a &'b () = &&();` imply the bound `'b: 'a` (similarly, `const K<'a, T>: &'a T = loop {};` and `T: 'a`)?
  Probably yes, not implemented.

### Implementation history

* #113522
* #114758
* #115744
* #119099
  * Among other things, this PR makes it possible to use const trait bounds in GCIs under CTI/effects
* #119385
  * Among other things, this PR makes it possible to use GACs[^1] in [ACEs](rust-lang/rust#92827)
* #123898
* #125457
* #136168

[^1]: Generic associated constants, i.e., associated constants with generics and/or a where clause.