-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |