File tree Expand file tree Collapse file tree 3 files changed +29
-6
lines changed Expand file tree Collapse file tree 3 files changed +29
-6
lines changed Original file line number Diff line number Diff line change
1
+ // Regression test for issue #118040.
2
+ // Ensure that we support assoc const eq bounds where the assoc const comes from a supertrait.
3
+
4
+ // check-pass
5
+
6
+ #![ feature( associated_const_equality) ]
7
+
8
+ trait Trait : SuperTrait { }
9
+ trait SuperTrait : SuperSuperTrait < i32 > { }
10
+ trait SuperSuperTrait < T > {
11
+ const K : T ;
12
+ }
13
+
14
+ fn take ( _: impl Trait < K = 0 > ) { }
15
+
16
+ fn main ( ) { }
Original file line number Diff line number Diff line change 1
1
// Regression test for issue #112560.
2
2
// Respect the fact that (associated) types and constants live in different namespaces and
3
3
// therefore equality bounds involving identically named associated items don't conflict if
4
- // their kind (type vs. const) differs.
5
-
6
- // FIXME(fmease): Extend this test to cover supertraits again
7
- // once #118040 is fixed. See initial version of PR #118360.
4
+ // their kind (type vs. const) differs. This obviously extends to supertraits.
8
5
9
6
// check-pass
10
7
11
8
#![ feature( associated_const_equality) ]
12
9
13
- trait Trait {
10
+ trait Trait : SuperTrait {
14
11
type N ;
12
+ type Q ;
15
13
16
14
const N : usize ;
17
15
}
18
16
19
- fn take ( _: impl Trait < N = 0 , N = ( ) > ) { }
17
+ trait SuperTrait {
18
+ const Q : & ' static str ;
19
+ }
20
+
21
+ fn take0 ( _: impl Trait < N = 0 , N = ( ) > ) { }
22
+
23
+ fn take1 ( _: impl Trait < Q = "..." , Q = [ ( ) ] > ) { }
20
24
21
25
fn main ( ) { }
Original file line number Diff line number Diff line change 6
6
trait Owner {
7
7
const C <const N : u32 >: u32 ;
8
8
const K <const N : u32 >: u32 ;
9
+ const Q <T >: Option <T >;
9
10
}
10
11
11
12
impl Owner for ( ) {
12
13
const C <const N : u32 >: u32 = N ;
13
14
const K <const N : u32 >: u32 = N + 1 ;
15
+ const Q <T >: Option <T > = None ;
14
16
}
15
17
16
18
fn take0 < const N : u32 > ( _: impl Owner < C < N > = { N } > ) { }
17
19
fn take1 ( _: impl Owner < K < 99 > = 100 > ) { }
20
+ fn take2 ( _: impl Owner < Q < ( ) > = { Some ( ( ) ) } > ) { }
18
21
19
22
fn main ( ) {
20
23
take0 :: < 128 > ( ( ) ) ;
You can’t perform that action at this time.
0 commit comments