Closed
Description
While trait inheritance works with user defined traits, it doesn't appear to work with special traits like Copy
. This code compiles fine:
trait Foo { fn f(&self); }
trait Bar: Foo { fn g(&self); }
trait Baz: Copy { fn h(&self); }
struct A;
impl Foo for A { fn f(&self) { } }
impl Bar for A { fn g(&self) { } }
impl Baz for A { fn h(&self) { } }
fn f<T: Bar>(t: &T) {
t.f();
t.g();
}
fn g<T: Baz+Copy>(t: T) -> T {
t.h();
copy t
}
/*
fn h<T: Baz>(t: T) -> T {
t.h();
copy t
}
*/
fn main() { }
However, if you uncomment function h
, it errors with:
foo.rs:23:9: 23:10 error: copying a value of non-copyable type `'a`
foo.rs:23 copy t
^
foo.rs:23:9: 23:10 note: explicit copy requires a copyable argument
foo.rs:23 copy t
^
error: aborting due to previous error
Metadata
Metadata
Assignees
Labels
No labels