-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Poor error message for attempt to make doubly-fat pointers #46375
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
Triage: no change. |
Current output, little change:
|
Using:
yields:
which is a totally different set of error messages. However after following the recommended fixes to give:
Produces:
which is essentially the same as in the issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Compiling the following code yields the given error:
This is confusing when the intent is to create a trait object. I think it's common to internalize the rule that one can coerce
Box<T>
toBox<Trait>
ifT: Trait
, without noticing the side requirement thatBox<T>
must not be a fat pointer, lest we create a doubly-fat pointer.I would speculate that what's going on in the compiler is that the coercion code declines to perform any coercion, leaving Rust to report the mismatch. It would be helpful to issue a note to the effect that trait object creation was considered, but rejected because the incoming pointer was already fat.
The text was updated successfully, but these errors were encountered: