-
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
Futures involving uninhabited variables are incorrectly considered uninhabited. #59972
Comments
cc @tmandry |
This is actually already fixed in #59897 (currently a WIP), around here. I'll make sure to add this as a test to that PR! |
@tmandry does that mean that generators will no longer "cheat" in their layout, and rust/src/librustc/ty/layout.rs Line 1813 in a7cef0b
I'd also have to adjust rust/src/librustc_mir/interpret/visitor.rs Line 315 in a7cef0b
|
@RalfJung I don't think it's that simple, we'd likely still need to keep uninitialized variables for now. |
We could do that, yes, with some further changes to my PR. I would like to get there, and then we can have UB checking for our generators as well :) |
triage: P-high. removing nominated tag. |
Multi-variant layouts for generators This allows generators to overlap fields using variants, but doesn't do any such overlapping yet. It creates one variant for every state of the generator (unresumed, returned, panicked, plus one for every yield), and puts every stored local in each of the yield-point variants. Required for optimizing generator layouts (#52924). There was quite a lot of refactoring needed for this change. I've done my best in later commits to eliminate assumptions in the code that only certain kinds of types are multi-variant, and to centralize knowledge of the inner mechanics of generators in as few places as possible. This change also emits debuginfo about the fields contained in each variant, as well as preserving debuginfo about stored locals while running in the generator. Also, fixes #59972. Future work: - Use this change for an optimization pass that actually overlaps locals within the generator struct (#52924) - In the type layout fields, don't include locals that are uninitialized for a particular variant, so miri and UB sanitizers can check our memory (see #59972 (comment)) - Preserve debuginfo scopes across generator yield points
…-obk Add test for rust-lang#59972 This PR adds a test for rust-lang#59972, which was fixed in rust-lang#59897. Closes rust-lang#59972. r? @eddyb
…-obk Add test for rust-lang#59972 This PR adds a test for rust-lang#59972, which was fixed in rust-lang#59897. Closes rust-lang#59972. r? @eddyb
…-obk Add test for rust-lang#59972 This PR adds a test for rust-lang#59972, which was fixed in rust-lang#59897. Closes rust-lang#59972. r? @eddyb
…-obk Add test for rust-lang#59972 This PR adds a test for rust-lang#59972, which was fixed in rust-lang#59897. Closes rust-lang#59972. r? @eddyb
Rollup of 8 pull requests Successful merges: - #59979 (to_xe_bytes for isize and usize returns an array of different size) - #60491 (std: Update compiler-builtins crate) - #60550 (Add tests for concrete const types) - #60572 (Add test for #59972) - #60627 (test for #50518) - #60634 (Document + Cleanup lang_items.rs) - #60641 (Instead of ICEing on incorrect pattern, use delay_span_bug) - #60644 (Use `delay_span_bug` for "Failed to unify obligation") Failed merges: r? @ghost
The following code crashes with an illegal instruction, presumably because all the code after
contains_never
is considered unreachable:It seems the root cause is that the struct representing the future contains a field of type
Uninhabited
as it is preserved across the (unreachable) yield point and thus is considered uninhabited itself, despite being perfectly constructible.The text was updated successfully, but these errors were encountered: