Confusing diagnostic for invalid casts of pointers to trait objects #130030
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-raw-pointers
Area: raw pointers, MaybeUninit, NonNull
A-trait-objects
Area: trait objects, vtable layout
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
D-terse
Diagnostics: An error or lint that doesn't give enough information about the problem at hand.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
Code
Current output
Desired output
Rationale and extra context
In #120248 I made checks for casting pointers to trait objects more strict: now they need to have the same generic arguments (this is due to the fact that for the cast to be safe, we need vtables to match).
The check is however made in a bit of a crude way, which results in this "mismatched types" diagnostic.
We should modify it so that the intent of the error is clear.
Rust Version
Reproduces on both stable 1.81.0 and 1.83.0-nightly (2024-09-05 9c01301).
The text was updated successfully, but these errors were encountered: