This CL makes a number of small changes to dyn compatibility errors: - "object safety" has been renamed to "dyn-compatibility" throughout - "Convert to enum" suggestions are no longer generated when there exists a type-generic impl of the trait or an impl for `dyn OtherTrait` - Several error messages are reorganized for user readability Additionally, the dyn compatibility error creation code has been split out into functions. cc #132713 cc #133267
28 lines
625 B
Rust
28 lines
625 B
Rust
trait Marker {}
|
|
impl Marker for u32 {}
|
|
|
|
trait MyTrait {
|
|
fn foo(&self) -> impl Marker;
|
|
}
|
|
|
|
struct Outer;
|
|
|
|
impl MyTrait for Outer {
|
|
fn foo(&self) -> impl Marker {
|
|
42
|
|
}
|
|
}
|
|
|
|
impl dyn MyTrait {
|
|
//~^ ERROR the trait `MyTrait` is not dyn compatible
|
|
fn other(&self) -> impl Marker {
|
|
//~^ ERROR the trait `MyTrait` is not dyn compatible
|
|
MyTrait::foo(&self)
|
|
//~^ ERROR the trait bound `&dyn MyTrait: MyTrait` is not satisfied
|
|
//~| ERROR the trait bound `&dyn MyTrait: MyTrait` is not satisfied
|
|
//~| ERROR the trait `MyTrait` is not dyn compatible
|
|
}
|
|
}
|
|
|
|
fn main() {}
|