Skip to content

Commit 593f414

Browse files
committed
test: Add a test for trait inheritance with self as a type parameter. rs=test-only
1 parent 53b181d commit 593f414

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
trait Foo<T> {
2+
fn f(&self, x: &T);
3+
}
4+
5+
trait Bar : Foo<self> {
6+
fn g(&self);
7+
}
8+
9+
struct S {
10+
x: int
11+
}
12+
13+
impl S : Foo<S> {
14+
fn f(&self, x: &S) {
15+
io::println(x.x.to_str());
16+
}
17+
}
18+
19+
impl S : Bar {
20+
fn g(&self) {
21+
self.f(self);
22+
}
23+
}
24+
25+
fn main() {
26+
let s = S { x: 1 };
27+
s.g();
28+
}
29+

0 commit comments

Comments
 (0)