The feature gate for the issue is #![feature(gca_macroless_items)]. Using it requires #![feature(gca_min_const_items)] to be enabled as well.
Note: this tracking issue was largely copied from #159006 which was originally written by @khyperia
Background
On stable, there are two kinds of const arguments for generics at the moment:
- "anon consts", which cannot be generic, and support arbitrary expressions. These are opaque to the type system, and are blindly handed off to CTFE to get a concrete value for.
min_const_generics arguments, which are plain paths to const parameters, used in e.g. array lengths (e.g. fn foo<const N: usize>(x: [u32; N]) {}). These are visible to, and reasoned about, by the type system.
The second category, things that can be reasoned about by the type system, have the (bikesheddable) name of a "directly represented" const argument. The generic_const_args family of features is about expanding and reasoning about these directly represented const arguments in various ways.
#![feature(gca_min_const_items)] extends the set of directly represented const arguments with:
- the
gca!() macro allows a significantly expanded set of expressions within it, e.g. paths to const items with a gca! RHS, paths to regular const items, struct expressions, array expressions, so on and so forth. (Informational note: each of these can be and likely will be under various feature flags, e.g. paths to gca!-rhs const items are supported under gca_min_const_items, but paths to regular const items are only supported under gca_const_items)
Finally, we come to this feature, #![feature(gca_macroless_items)]. This feature extends the set of directly represented const arguments with:
- Anything that used to be supported within the
gca!() macro as the right hand side of a const item, is now supported without the macro. Const item RHS expressions will be attempted to be lowered "directly", and if they cannot be represented directly, it will automatically fall back to being represented as a regular const item.
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
Unresolved Questions
Implementation history
The feature gate for the issue is
#![feature(gca_macroless_items)]. Using it requires#![feature(gca_min_const_items)]to be enabled as well.Note: this tracking issue was largely copied from #159006 which was originally written by @khyperia
Background
On stable, there are two kinds of const arguments for generics at the moment:
min_const_genericsarguments, which are plain paths to const parameters, used in e.g. array lengths (e.g.fn foo<const N: usize>(x: [u32; N]) {}). These are visible to, and reasoned about, by the type system.The second category, things that can be reasoned about by the type system, have the (bikesheddable) name of a "directly represented" const argument. The generic_const_args family of features is about expanding and reasoning about these directly represented const arguments in various ways.
#![feature(gca_min_const_items)]extends the set of directly represented const arguments with:gca!()macro allows a significantly expanded set of expressions within it, e.g. paths to const items with agca!RHS, paths to regularconstitems, struct expressions, array expressions, so on and so forth. (Informational note: each of these can be and likely will be under various feature flags, e.g. paths togca!-rhs const items are supported undergca_min_const_items, but paths to regularconstitems are only supported undergca_const_items)Finally, we come to this feature,
#![feature(gca_macroless_items)]. This feature extends the set of directly represented const arguments with:gca!()macro as the right hand side of a const item, is now supported without the macro. Const item RHS expressions will be attempted to be lowered "directly", and if they cannot be represented directly, it will automatically fall back to being represented as a regular const item.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
rustfmtUnresolved Questions
Implementation history