Refactor dyn-compatibility error and suggestions

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
This commit is contained in:
Taylor Cramer 2024-11-20 14:19:36 -08:00
parent b2728d5426
commit d00d4dfe0d
175 changed files with 1338 additions and 1102 deletions

View file

@ -264,15 +264,15 @@ trait Foo {
### Trait contains associated constants
Just like static functions, associated constants aren't stored on the method
table. If the trait or any subtrait contain an associated constant, they cannot
be made into an object.
table. If the trait or any subtrait contain an associated constant, they are not
dyn compatible.
```compile_fail,E0038
trait Foo {
const X: i32;
}
impl Foo {}
impl dyn Foo {}
```
A simple workaround is to use a helper method instead: