Closed
Description
As raised here:
...related to the language:
Const contexts that are used as parts of types (array type and repeat length expressions as well as const generic arguments) can only make restricted use of surrounding generic type and lifetime parameters.
We should document what these restrictions are precisely.
Here's an example of what doesn't work:
fn foo<const C: usize>() {
let _ = [(); const { C + 1 }];
//~^ ERROR generic parameters may not be used in const operations
}
Similarly:
trait Tr {
const C: usize;
}
impl Tr for () {
const C: usize = 0;
}
fn foo<T: Tr>() {
let _ = [(); const { T::C }];
//~^ ERROR constant expression depends on a generic parameter
}