Closed
Description
trait Foo: Clone {
fn clone_as_obj(&self) -> ~Foo {
~(self.clone()) as ~Foo
}
}
impl Clone for ~Foo {
fn clone(&self) -> ~Foo {
self.clone_as_obj();
}
}
fn test(x: ~Foo) {
x.clone();
}
clone-abort-3.rs:14:4: 14:14 error: cannot call a method whose type contains a self-type through an object
clone-abort-3.rs:14 x.clone();
^~~~~~~~~~
error: aborting due to previous error
task 'rustc' failed at 'explicit failure', /home/huon/rust/src/libsyntax/diagnostic.rs:102
task '<main>' failed at 'explicit failure', /home/huon/rust/src/librustc/lib.rs:395
It seems like that should prefer the (~Foo).clone()
method rather than trying to call the .clone
that the compiler knows that the inner type must have.