Question/request: const generic dependencies
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
(the adt_const_params tracking issue said to create an issue for questions and/or requests, so I'm doing that)
Under #![feature(adt_const_params)], I would expect the following to be allowed:
pub struct Array<const N: usize, const D: [usize; N]> {
// ...
}
However, this gives an error:
error[E0770]: the type of const parameters must not depend on other generic parameters
--> src/lib.rs:18:51
|
18 | pub struct Array<const N: usize, const D: [usize; N]> {
| ^ the type must not depend on the parameter `N`
This feels like a reasonably-common use of const type parameters; it would be nice for this to be supported.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the adt_const_params example with const D: [usize; N] and inspect the reported E0770 diagnostic. Determine the language and compiler changes needed to permit const-parameter types that depend on earlier generic parameters; done means the example is accepted under the feature without regressing existing restrictions.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100