You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
…thiaskrgr
Refactor: Use rustc's `match_def_path`
This replaces our match_def_path implementation with the rustc one.
Note that we can't just use it in all call sites because of the
`&[&str]` / `&[Symbol]` difference in Clippy/rustc.
changelog: none
While trait inheritance works with user defined traits, it doesn't appear to work with special traits like
Copy
. This code compiles fine:However, if you uncomment function
h
, it errors with:The text was updated successfully, but these errors were encountered: