Skip to content

Commit 81c64b3

Browse files
authored
Rollup merge of #81671 - jackh726:atb-tests, r=estebank
Add more associated type tests Closes #24159 Closes #37808 Closes #39532 Closes #37883 r? ``@estebank``
2 parents 70d16d5 + f0a3de6 commit 81c64b3

File tree

4 files changed

+95
-0
lines changed

4 files changed

+95
-0
lines changed

Diff for: src/test/ui/associated-types/issue-24159.rs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// check-pass
2+
3+
#![allow(unused)]
4+
5+
trait Bar<T> {
6+
fn dummy(&self);
7+
}
8+
9+
trait Foo {
10+
type A;
11+
type B: Bar<Self::A>;
12+
13+
fn get_b(&self) -> &Self::B;
14+
}
15+
16+
fn test_bar<A, B: Bar<A>>(_: &B) {}
17+
18+
fn test<A, F: Foo<A = A>>(f: &F) {
19+
test_bar(f.get_b());
20+
}
21+
22+
trait Bar1<T> {}
23+
trait Caz1 {
24+
type A;
25+
type B: Bar1<Self::A>;
26+
}
27+
28+
fn test1<T, U>() where T: Caz1, U: Caz1<A = T::A> {}
29+
30+
trait Bar2<T> {}
31+
trait Caz2 {
32+
type A;
33+
type B: Bar2<Self::A>;
34+
}
35+
fn test2<T: Caz2<A = ()>>() {}
36+
37+
fn main() {}

Diff for: src/test/ui/associated-types/issue-37808.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// check-pass
2+
3+
trait Parent {
4+
type Ty;
5+
type Assoc: Child<Self::Ty>;
6+
}
7+
8+
trait Child<T> {}
9+
10+
struct ChildWrapper<T>(T);
11+
impl<A, T> Child<A> for ChildWrapper<T> where T: Child<A> {}
12+
13+
struct ParentWrapper<T>(T);
14+
impl<A, T: Parent<Ty = A>> Parent for ParentWrapper<T> {
15+
type Ty = A;
16+
type Assoc = ChildWrapper<T::Assoc>;
17+
}
18+
19+
fn main() {}

Diff for: src/test/ui/associated-types/issue-37883.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// check-pass
2+
3+
use std::ops::Mul;
4+
5+
fn main() {}
6+
7+
trait Ring {}
8+
trait Real: Ring {}
9+
10+
trait Module: Sized + Mul<<Self as Module>::Ring, Output = Self> {
11+
type Ring: Ring;
12+
}
13+
14+
trait EuclideanSpace {
15+
type Coordinates: Module<Ring = Self::Real>;
16+
type Real: Real;
17+
}
18+
19+
trait Translation<E: EuclideanSpace> {
20+
fn to_vector(&self) -> E::Coordinates;
21+
22+
fn powf(&self, n: <E::Coordinates as Module>::Ring) -> E::Coordinates {
23+
self.to_vector() * n
24+
}
25+
}

Diff for: src/test/ui/associated-types/issue-39532.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// check-pass
2+
3+
#![allow(unused)]
4+
5+
trait Foo {
6+
type Bar;
7+
type Baz: Bar<Self::Bar>;
8+
}
9+
10+
trait Bar<T> {}
11+
12+
fn x<T: Foo<Bar = U>, U>(t: &T) {}
13+
14+
fn main() {}

0 commit comments

Comments
 (0)