diff options
Diffstat (limited to 'tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds.rs')
| -rw-r--r-- | tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds.rs new file mode 100644 index 00000000000..1ebebe632c7 --- /dev/null +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds.rs @@ -0,0 +1,31 @@ +// check-pass + +#![feature(const_trait_impl, effects, generic_const_exprs)] +#![allow(incomplete_features)] + +fn main() { + let _ = process::<()>([()]); + let _ = Struct::<(), 4> { field: [1, 0] }; +} + +fn process<T: const Trait>(input: [(); T::make(2)]) -> [(); T::make(2)] { + input +} + +struct Struct<T: const Trait, const P: usize> +where + [u32; T::make(P)]:, +{ + field: [u32; T::make(P)], +} + +#[const_trait] +trait Trait { + fn make(input: usize) -> usize; +} + +impl const Trait for () { + fn make(input: usize) -> usize { + input / 2 + } +} |
