Using a bare trait as a field type in a struct gives subpar suggestion #135759
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
Rationale and extra context
Currently this just suggests using
dyn
which also works if the field is the last field int the struct so can be unsized. However the suggestion is also given when the field is not in the last position, so applying the fix fails.For most cases I think it makes more sense to either add a generic or Box the value.
Other cases
Rust Version
Anything else?
No response
The text was updated successfully, but these errors were encountered: