diff options
| author | Jack Huey <jack.huey@umassmed.edu> | 2021-02-02 12:54:32 -0500 |
|---|---|---|
| committer | Jack Huey <jack.huey@umassmed.edu> | 2021-02-02 13:19:52 -0500 |
| commit | f0a3de6aa23fee50614eff0a3121fd0e3afd5382 (patch) | |
| tree | 5fab998ab18e580328db32fcc4fe9c5c03a43be8 | |
| parent | b81f5811f96fe750ab28c15219d1b0dba6b1dc90 (diff) | |
| download | rust-f0a3de6aa23fee50614eff0a3121fd0e3afd5382.tar.gz rust-f0a3de6aa23fee50614eff0a3121fd0e3afd5382.zip | |
More associated type tests
| -rw-r--r-- | src/test/ui/associated-types/issue-24159.rs | 37 | ||||
| -rw-r--r-- | src/test/ui/associated-types/issue-37808.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/associated-types/issue-37883.rs | 25 | ||||
| -rw-r--r-- | src/test/ui/associated-types/issue-39532.rs | 14 |
4 files changed, 95 insertions, 0 deletions
diff --git a/src/test/ui/associated-types/issue-24159.rs b/src/test/ui/associated-types/issue-24159.rs new file mode 100644 index 00000000000..49753e7bf16 --- /dev/null +++ b/src/test/ui/associated-types/issue-24159.rs @@ -0,0 +1,37 @@ +// check-pass + +#![allow(unused)] + +trait Bar<T> { + fn dummy(&self); +} + +trait Foo { + type A; + type B: Bar<Self::A>; + + fn get_b(&self) -> &Self::B; +} + +fn test_bar<A, B: Bar<A>>(_: &B) {} + +fn test<A, F: Foo<A = A>>(f: &F) { + test_bar(f.get_b()); +} + +trait Bar1<T> {} +trait Caz1 { + type A; + type B: Bar1<Self::A>; +} + +fn test1<T, U>() where T: Caz1, U: Caz1<A = T::A> {} + +trait Bar2<T> {} +trait Caz2 { + type A; + type B: Bar2<Self::A>; +} +fn test2<T: Caz2<A = ()>>() {} + +fn main() {} diff --git a/src/test/ui/associated-types/issue-37808.rs b/src/test/ui/associated-types/issue-37808.rs new file mode 100644 index 00000000000..3701c37d0c8 --- /dev/null +++ b/src/test/ui/associated-types/issue-37808.rs @@ -0,0 +1,19 @@ +// check-pass + +trait Parent { + type Ty; + type Assoc: Child<Self::Ty>; +} + +trait Child<T> {} + +struct ChildWrapper<T>(T); +impl<A, T> Child<A> for ChildWrapper<T> where T: Child<A> {} + +struct ParentWrapper<T>(T); +impl<A, T: Parent<Ty = A>> Parent for ParentWrapper<T> { + type Ty = A; + type Assoc = ChildWrapper<T::Assoc>; +} + +fn main() {} diff --git a/src/test/ui/associated-types/issue-37883.rs b/src/test/ui/associated-types/issue-37883.rs new file mode 100644 index 00000000000..d854f6af3ea --- /dev/null +++ b/src/test/ui/associated-types/issue-37883.rs @@ -0,0 +1,25 @@ +// check-pass + +use std::ops::Mul; + +fn main() {} + +trait Ring {} +trait Real: Ring {} + +trait Module: Sized + Mul<<Self as Module>::Ring, Output = Self> { + type Ring: Ring; +} + +trait EuclideanSpace { + type Coordinates: Module<Ring = Self::Real>; + type Real: Real; +} + +trait Translation<E: EuclideanSpace> { + fn to_vector(&self) -> E::Coordinates; + + fn powf(&self, n: <E::Coordinates as Module>::Ring) -> E::Coordinates { + self.to_vector() * n + } +} diff --git a/src/test/ui/associated-types/issue-39532.rs b/src/test/ui/associated-types/issue-39532.rs new file mode 100644 index 00000000000..52652cedec9 --- /dev/null +++ b/src/test/ui/associated-types/issue-39532.rs @@ -0,0 +1,14 @@ +// check-pass + +#![allow(unused)] + +trait Foo { + type Bar; + type Baz: Bar<Self::Bar>; +} + +trait Bar<T> {} + +fn x<T: Foo<Bar = U>, U>(t: &T) {} + +fn main() {} |
