-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Implement unsized unions #47650
Implement unsized unions #47650
Commits on Mar 2, 2018
-
allow the last field of a union to be ?Sized
- theoretically any single field of the union could be ?Sized, but it's easier to implement this way - still have to allow/implement the unsize cast for unions
Configuration menu - View commit details
-
Copy full SHA for 4d74572 - Browse repository at this point
Copy the full SHA 4d74572View commit details -
this supports unsized unions, where the last field may be unsized. Theoretically, any number of fields of a union could be unsized, as long as the unsized type is the same for all of them, but this is the simplest way to get ManuallyDrop<T: ?Sized> working.
Configuration menu - View commit details
-
Copy full SHA for 74ce9fb - Browse repository at this point
Copy the full SHA 74ce9fbView commit details -
update union-unsized compile-fail test
this now only fails if the unsized field is not the last field
Configuration menu - View commit details
-
Copy full SHA for 06cc03c - Browse repository at this point
Copy the full SHA 06cc03cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 43fa327 - Browse repository at this point
Copy the full SHA 43fa327View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7645490 - Browse repository at this point
Copy the full SHA 7645490View commit details
Commits on Mar 10, 2018
-
Configuration menu - View commit details
-
Copy full SHA for 6d474ae - Browse repository at this point
Copy the full SHA 6d474aeView commit details -
Update union-sized-field ui test
Adds an extra field to the unsized union, so that there will be an error about the union needing to only have a single field
Configuration menu - View commit details
-
Copy full SHA for cedec2b - Browse repository at this point
Copy the full SHA cedec2bView commit details
Commits on Mar 13, 2018
-
Configuration menu - View commit details
-
Copy full SHA for 6cb99d1 - Browse repository at this point
Copy the full SHA 6cb99d1View commit details -
refactor FnCtxt::check_type_defn to handle unsized unions
- the old implementation had an `all_sized: bool` parameter which was true iff the type was a struct, and allowed the last field to be unsized in that case. - Because of unsized unions, things are more complicated, and will become more complicated in the future if we get multiple unsized union fields or enum variants - this implementation gets rid of the `all_sized` parameter, and just checks directly in the function whether the type is a struct, enum or union, handling each case independently
Configuration menu - View commit details
-
Copy full SHA for e2bb126 - Browse repository at this point
Copy the full SHA e2bb126View commit details -
The expression `slice.len()-1` underflows when the slice is empty, which caused an out-of-bounds array access. At least Rust panics in that case! I wish there was a more idiomatic way to get a sub-slice with everything but the last element. This way is evidently pretty bug-prone
Configuration menu - View commit details
-
Copy full SHA for 55f0967 - Browse repository at this point
Copy the full SHA 55f0967View commit details -
upgrade
unreachable!()
to aspan_bug!()
This should output a better error message if check_type_defn ever gets called with something that’s not a struct, enum or union
Configuration menu - View commit details
-
Copy full SHA for 42b84f9 - Browse repository at this point
Copy the full SHA 42b84f9View commit details -
- update the comments on the `U6` test case, to make it more clear what to do when non-`Copy` unions are stabilized - add a crucial `~` that caused a test to pass that wasn’t supposed to - update stderr of some tests to reflect changes in the actual tests and compiler error messages
Configuration menu - View commit details
-
Copy full SHA for de2ff7f - Browse repository at this point
Copy the full SHA de2ff7fView commit details
Commits on Mar 18, 2018
-
eemit a feature-gate error for unsized unions
- unsized unions require the untagged_unions feature - prececedence is given to other error messages for the untagged_unions feature gate. For example, if there is already going to be an error about non-`Copy` unions being unstable, we do not also emit an error about unsized unions being unstable
Configuration menu - View commit details
-
Copy full SHA for d27141c - Browse repository at this point
Copy the full SHA d27141cView commit details