-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Do not ICE when trying to get layout of an unexpected type #127803
Conversation
This comment has been minimized.
This comment has been minimized.
@rustbot author |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why didn't you put this check into check_static_inhabited
? Seems like a more specific place to put it, according to the ICE message in the issue you linked.
I felt that it's cleaner to put it in layout because if I put it in |
Well it looks like the test still ICEs anyways 🤔. I would encourage you to try to make this fix more specific if possible, to avoid changing existing assertions which were added as a sanity check. |
Yeah, the test is ICEing in It works fine on my MacBook and I don't have a Linux machine. But I guess the test's ICE is more due to x64 rather than the OS. So I'm going to test it on a Windows machine (which I do have) and see if I can fix it. |
I'll also try to see if I can make it more specific nonetheless. |
This is because of a debug assertion, which you need to enable in your This has nothing to do with operating systems or CPU architectures--it's a type system bug after all. |
Ah, thanks for that. Saved me a lot of time. |
48ae9e6
to
9cf54f0
Compare
I tried to put the fix in If you have any suggestions to make it more specific, please let me know. |
Returning an error instead of triggering a debug_assertion when a normalized type still has infer
9cf54f0
to
9c78fec
Compare
@rustbot review |
The job Click to see the possible cause of the failure (guessed by this bot)
|
Woah! Didn't realise this one stone was gonna hit so many birds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the right fix. This debug assertion exists for a good reason -- because we shouldn't be returning totally unconstrained inference variables from the normalize_after_erasing_regions
query.
In general, when fixing an ICE, I would appreciate if you looker deeper than just the surface. Suppressing a debug assertion from triggering by just removing the debug assertion is not typically the right answer. |
Firstly, it would be useful to understand why #126942 began to ICE in the first place. Specifically, it seems like @oli-obk caused this in #121154. This is a classic case of the types of ICEs introduced with this error refactoring work, so maybe he has some solutions in mind that are less invasive than just removing debug assertions. Perhaps one solution to this would be to project associated types to |
Alternatively, it does seem a bit weird to me that we're checking whether static layouts are inhabited this early in compilation ( |
Awesome. These are all good suggestions. I'll investigate further. Thanks :) |
After this change we're not returning inference variables. We're returning an error. So it's not all bad. But still it's not the best solution. |
Unfortunately, as with most wfcheck logic, we can't invoke it from anywhere else but top-level queries, as it invokes so many other type queries, that we run into cycles left and right. I did assume |
Closing in favour of #127973 |
Fixes #126942
See issue for why the ICE occurs.
In this PR we return an error from layout query instead of raising a bug when we encounter a type that we cannot compute the layout of.
Edit
Put the fix in
try_normalize_erasing_regions
instead oflayout_of_uncached
because we were triggering a debug_assertion in the former.Also fixes #127804