diff options
| author | Maybe Waffle <waffle.lapkin@gmail.com> | 2023-05-29 15:43:15 +0000 |
|---|---|---|
| committer | Maybe Waffle <waffle.lapkin@gmail.com> | 2023-06-05 16:09:46 +0000 |
| commit | 9d3482c403f781a0d1c81508a7fa5bda5e56ceee (patch) | |
| tree | 68f868316a1ac1c9fbc90b72f329a40df37d2155 /tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs | |
| parent | 7452822843cf461b56742f0fc648af35889a3070 (diff) | |
| download | rust-9d3482c403f781a0d1c81508a7fa5bda5e56ceee.tar.gz rust-9d3482c403f781a0d1c81508a7fa5bda5e56ceee.zip | |
Better group RFC ui tests together
Diffstat (limited to 'tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs')
| -rw-r--r-- | tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs new file mode 100644 index 00000000000..78a64b9018a --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/tilde-const-and-const-params.rs @@ -0,0 +1,34 @@ +#![feature(const_trait_impl)] +#![feature(generic_arg_infer)] +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +struct Foo<const N: usize>; + +impl<const N: usize> Foo<N> { + fn add<A: ~const Add42>(self) -> Foo<{ A::add(N) }> { + Foo + } +} + +#[const_trait] +trait Add42 { + fn add(a: usize) -> usize; +} + +impl const Add42 for () { + fn add(a: usize) -> usize { + a + 42 + } +} + +fn bar<A: ~const Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> { + //~^ ERROR `~const` is not allowed here + Foo +} + +fn main() { + let foo = Foo::<0>; + let foo = bar::<(), _>(foo); + let _foo = bar::<(), _>(foo); +} |
