-
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
ICE in object_safety.rs due to method receiver not having a layout #57276
Comments
There is also the straightforward solution of not doing the layout checks if the layout is un-computable. But it seems like |
Triage: This is no longer ICE with the latest nightly, seems #78422 fixed it. |
It's ICE'd again (https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=dcac74ce4f9ee21c114a7659c5e86783), too late to add a regression test :(, removing the label.
|
Bug rust-lang#57276 (and several duplicates) is an ICE which occurs when a generic type is used as a receiver which implements both Receiver and DispatchFromDyn. This change proposes to detect this error condition and turn it into a regular error rather than an ICE. Future changes could liberalise things here. As this same code path currently produces an ICE, this seems to be strictly better, and it seems defensible to inform the user that their excessively generic type is not dyn-safe. This is somewhat related to the stabilization of arbitrary self types in PR rust-lang#135881, tracked in rust-lang#44874.
I'd like to fix this as we're on the way to stabilizing arbitrary self types in #135881. As a first proposal, a simple "fix" would be to switch from an ICE to an error message: PR #136195. I feel that's a legitimate and defensible thing to tell the user about; but if not, at least I'm hoping that this PR provokes some discussion about the "correct" fix. |
The following code causes an ICE,
Error: the type `T` has an unknown layout
:Similar to #56806,
receiver_is_dispatchable
succeeds, and then there is an ICE during the layout sanity checks. In this case, it is because the method receiver is a type parameter and has no layout.receiver_is_dispatchable
checks that the following predicate holds:In this case, it reduces to
T: DispatchFromDyn<T>
, which is provided by a where clause. In #56806, it reduced toBox<dyn Trait>: DispatchFromDyn<Box<dyn Trait>>
. The check passes in both cases, and then there is an ICE during the layout sanity checks.One way to fix both of these cases would be to add an extra requirement to
receiver_is_dispatchable
: thatReceiver
andReceiver[Self => U]
are not the same type. I'm not sure if there are any edge cases that that doesn't cover.cc @varkor #57229
The text was updated successfully, but these errors were encountered: