2024-10-30 18:03:44 +00:00
|
|
|
#![feature(const_trait_impl)]
|
2022-09-26 05:00:31 +00:00
|
|
|
#![feature(generic_const_exprs)]
|
|
|
|
|
#![allow(incomplete_features)]
|
|
|
|
|
|
|
|
|
|
struct Foo<const N: usize>;
|
|
|
|
|
|
|
|
|
|
impl<const N: usize> Foo<N> {
|
2025-03-11 12:08:45 +00:00
|
|
|
fn add<A: [const] Add42>(self) -> Foo<{ A::add(N) }> {
|
|
|
|
|
//~^ ERROR `[const]` is not allowed here
|
2024-10-22 03:22:57 +00:00
|
|
|
//~| ERROR the trait bound `A: const Add42` is not satisfied
|
2023-08-13 13:59:19 +00:00
|
|
|
Foo
|
|
|
|
|
}
|
2022-09-26 05:00:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[const_trait]
|
|
|
|
|
trait Add42 {
|
|
|
|
|
fn add(a: usize) -> usize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl const Add42 for () {
|
|
|
|
|
fn add(a: usize) -> usize {
|
|
|
|
|
a + 42
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-11 12:08:45 +00:00
|
|
|
fn bar<A: [const] Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> {
|
|
|
|
|
//~^ ERROR `[const]` is not allowed here
|
2024-10-22 03:22:57 +00:00
|
|
|
//~| ERROR the trait bound `A: const Add42` is not satisfied
|
2022-09-26 05:00:31 +00:00
|
|
|
Foo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn main() {
|
2023-09-27 17:25:31 -04:00
|
|
|
let foo = Foo::<0>;
|
|
|
|
|
let foo = bar::<(), _>(foo);
|
|
|
|
|
let _foo = bar::<(), _>(foo);
|
2022-09-26 05:00:31 +00:00
|
|
|
}
|