Skip to content

Commit b95392d

Browse files
committed
[resolution tests]
1 parent 2fe50cd commit b95392d

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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() {}
Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
// Regression test for issue #112560.
22
// Respect the fact that (associated) types and constants live in different namespaces and
33
// 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.
85

96
// check-pass
107

118
#![feature(associated_const_equality)]
129

13-
trait Trait {
10+
trait Trait: SuperTrait {
1411
type N;
12+
type Q;
1513

1614
const N: usize;
1715
}
1816

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 = [()]>) {}
2024

2125
fn main() {}

tests/ui/generic-const-items/associated-const-equality.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@
66
trait Owner {
77
const C<const N: u32>: u32;
88
const K<const N: u32>: u32;
9+
const Q<T>: Option<T>;
910
}
1011

1112
impl Owner for () {
1213
const C<const N: u32>: u32 = N;
1314
const K<const N: u32>: u32 = N + 1;
15+
const Q<T>: Option<T> = None;
1416
}
1517

1618
fn take0<const N: u32>(_: impl Owner<C<N> = { N }>) {}
1719
fn take1(_: impl Owner<K<99> = 100>) {}
20+
fn take2(_: impl Owner<Q<()> = { Some(()) }>) {}
1821

1922
fn main() {
2023
take0::<128>(());

0 commit comments

Comments
 (0)