-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Deref coercions and &-to-* coercions don't compose #32122
Comments
@bluss thanks for walking me through this. |
RFC 401 says that coercions are transitive, but I also realize that it does not consider deref coercions at all. |
While I'm not sure if this should be fixed, we can at least fix the diagnostic to tell to user to use cc @rust-lang/wg-diagnostics |
This should probably be added to rust/src/librustc_typeck/check/demand.rs Lines 581 to 587 in 8ad83af
|
Suggest deref when coercing `ty::Ref` to `ty::RawPtr` Fixes rust-lang#32122 Currently we do autoderef when casting `ty::Ref` ->`ty::Ref`, but we don't autoderef when casting `ty::Ref` -> `ty::RawPtr`. This PR make the compiler suggests deref when coercing `ty::Ref` to `ty::RawPtr`
cc @nikomatsakis Should we close this issue based on only a diagnostics improvement? |
A good question. I do sort of think that coercions "should" compose, but I also suspect there are complications, and am somewhat tempted to say it's "working well enough" and leave it closed. |
Minimal repro:
Compile error:
The text was updated successfully, but these errors were encountered: