Change method res to try autoref more often. Fixes #3585.
This commit is contained in:
parent
a770d86201
commit
12a0401d84
3 changed files with 48 additions and 53 deletions
20
src/test/run-pass/autoref-intermediate-types-issue-3585.rs
Normal file
20
src/test/run-pass/autoref-intermediate-types-issue-3585.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
trait Foo {
|
||||
fn foo(&self) -> ~str;
|
||||
}
|
||||
|
||||
impl<T: Foo> @T: Foo {
|
||||
fn foo(&self) -> ~str {
|
||||
fmt!("@%s", (**self).foo())
|
||||
}
|
||||
}
|
||||
|
||||
impl uint: Foo {
|
||||
fn foo(&self) -> ~str {
|
||||
fmt!("%u", *self)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = @3u;
|
||||
assert x.foo() == ~"@3";
|
||||
}
|
||||
17
src/test/run-pass/autoref-vec-push.rs
Normal file
17
src/test/run-pass/autoref-vec-push.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
trait VecPush<T> {
|
||||
fn push(&mut self, +t: T);
|
||||
}
|
||||
|
||||
impl<T> ~[T]: VecPush<T> {
|
||||
fn push(&mut self, +t: T) {
|
||||
vec::push(*self, t);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut x = ~[];
|
||||
x.push(1);
|
||||
x.push(2);
|
||||
x.push(3);
|
||||
assert x == ~[1, 2, 3];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue