-
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
rustc: don't trip an assertion for enums with present but uninhabited variants. #50735
Conversation
Beta-nominated because the assert failure was introduced in the already-backported #50622. |
@bors r+ cc @rust-lang/compiler -- approving for backport |
📌 Commit 29b4c7b has been approved by |
@bors p=80 (added to the backports PR) |
rustc: don't trip an assertion for enums with present but uninhabited variants. Fixes #50731. r? @nikomatsakis
@@ -888,6 +888,11 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { | |||
if x < min { min = x; } | |||
if x > max { max = x; } | |||
} | |||
// We might have no inhabited variants, so pretend there's at least one. | |||
if (min, max) == (i128::max_value(), i128::min_value()) { |
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.
Just to make sure, is (min, max) = max(), min()
correct?
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.
Jup. These are the initial values for both, so that means the loop was empty or all variants uninhabited
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.
(and the loop can't be empty, thanks to a condition much earlier)
☀️ Test successful - status-appveyor, status-travis |
[beta] Process backports Merged on master: * #50648: Fix volatile_store and nontemporal_store * #50735: rustc: don't trip an assertion for enums with present but uninhabited variants. * #50693: typeck: Save the index of private fields * #50748: Update stdsimd module * #50694: Fix self referential impl Trait substitutions r? @alexcrichton
Fixes #50731.
r? @nikomatsakis