Skip to content

Commit 9e60f45

Browse files
committed
Add const generics tests for supertraits + dyn traits.
1 parent 2eb4fc8 commit 9e60f45

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// check-pass
2+
// revisions: full min
3+
4+
#![cfg_attr(full, feature(const_generics))]
5+
#![cfg_attr(full, allow(incomplete_features))]
6+
#![cfg_attr(min, feature(min_const_generics))]
7+
8+
trait Foo<const N: usize> {}
9+
trait Bar<const N: usize> : Foo<N> {}
10+
trait Baz: Foo<3> {}
11+
12+
struct FooType<const N: usize> {}
13+
struct BarType<const N: usize> {}
14+
struct BazType {}
15+
16+
impl<const N: usize> Foo<N> for FooType<N> {}
17+
impl<const N: usize> Foo<N> for BarType<N> {}
18+
impl<const N: usize> Bar<N> for BarType<N> {}
19+
impl Foo<3> for BazType {}
20+
impl Baz for BazType {}
21+
22+
trait Foz {}
23+
trait Boz: Foo<3> + Foz {}
24+
trait Bok<const N: usize>: Foo<N> + Foz {}
25+
26+
struct FozType {}
27+
struct BozType {}
28+
struct BokType<const N: usize> {}
29+
30+
impl Foz for FozType {}
31+
32+
impl Foz for BozType {}
33+
impl Foo<3> for BozType {}
34+
impl Boz for BozType {}
35+
36+
impl<const N: usize> Foz for BokType<N> {}
37+
impl<const N: usize> Foo<N> for BokType<N> {}
38+
impl<const N: usize> Bok<N> for BokType<N> {}
39+
40+
fn a<const N: usize>(x: &dyn Foo<N>) {}
41+
fn b(x: &dyn Foo<3>) {}
42+
43+
fn main() {
44+
let foo = FooType::<3> {};
45+
a(&foo); b(&foo);
46+
47+
let bar = BarType::<3> {};
48+
a(&bar); b(&bar);
49+
50+
let baz = BazType {};
51+
a(&baz); b(&baz);
52+
53+
let boz = BozType {};
54+
a(&boz); b(&boz);
55+
56+
let bok = BokType::<3> {};
57+
a(&bok); b(&bok);
58+
}

0 commit comments

Comments
 (0)