Closed
Description
Here's an example:
https://gist.github.com/3907509
It seems that even if I produce a proper boxed type @T
, rust 0.4 cannot coerce that type to a &T
.
Felix is putting the contents of the above linked gist so that people using ghi can see them readily:
test.rs:
trait T {
fn print(&self);
}
struct S {
s: int,
}
impl S: T {
fn print(&self) {
io::println(fmt!("%?", self));
}
}
fn print_t(t: &T) {
t.print();
}
fn print_s(s: &S) {
s.print();
}
fn main() {
let s: @S = @S { s: 5 };
print_s(s);
let t: @T = s as @T;
print_t(t);
}
output:
test.rs:27:12: 27:13 error: mismatched types: expected `&/T` but found `@T` (trait storage differs: expected & but found @)
test.rs:27 print_t(t);
^
error: aborting due to previous error