]> git.lizzy.rs Git - rust.git/blob - tests/ui/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs
Rollup merge of #106470 - ehuss:tidy-no-wasm, r=Mark-Simulacrum
[rust.git] / tests / ui / rfc-2632-const-trait-impl / tilde-const-and-const-params.rs
1 #![feature(const_trait_impl)]
2 #![feature(generic_arg_infer)]
3 #![feature(generic_const_exprs)]
4 #![allow(incomplete_features)]
5
6 struct Foo<const N: usize>;
7
8 impl<const N: usize> Foo<N> {
9    fn add<A: ~const Add42>(self) -> Foo<{ A::add(N) }> {
10       Foo
11    }
12 }
13
14 #[const_trait]
15 trait Add42 {
16     fn add(a: usize) -> usize;
17 }
18
19 impl const Add42 for () {
20     fn add(a: usize) -> usize {
21         a + 42
22     }
23 }
24
25 fn bar<A: ~const Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> {
26     //~^ ERROR `~const` is not allowed here
27     Foo
28 }
29
30 fn main() {
31    let foo = Foo::<0>;
32    let foo = bar::<(), _>(foo);
33    let _foo = bar::<(), _>(foo);
34 }