blob: b147c246bdac8546c963e37d116253884607b445 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
trait Trait<const N: usize> {
const Assoc: usize;
}
impl<const N: usize> Trait<N> for () {
const Assoc: usize = 1;
}
pub const fn foo<const N: usize>() where (): Trait<N> {
let bar = [(); <()>::Assoc];
//~^ error: constant expression depends on a generic parameter
}
trait Trait2<const N: usize> {
const Assoc2: usize;
}
impl<const N: usize> Trait2<N> for () {
const Assoc2: usize = N - 1;
}
pub const fn foo2<const N: usize>() where (): Trait2<N> {
let bar2 = [(); <()>::Assoc2];
//~^ error: constant expression depends on a generic parameter
}
fn main() {
foo::<0>();
foo2::<0>();
}
|