Skip to content

Implement unsized unions #47650

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

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update union-specific tests
- 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
  • Loading branch information
mikeyhew committed Mar 13, 2018
commit de2ff7fcacc69425c40df5ffa4aed20edbc00a54
6 changes: 3 additions & 3 deletions src/test/ui/feature-gate-untagged_unions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ impl Drop for U5 {
}

// the non-`Copy` error message has priority
// replace this with unsized error message if
// non-`Copy` unions are stabilized before unsized unions
// replace this with an "unsized unions are unstable" error message
// if non-`Copy` unions are stabilized before unsized unions
union U6<T: ?Sized> { //~ ERROR unions with non-`Copy` fields are unstable
a: T
}

union U7<T: Copy + ?Sized> { // ERROR unsized unions are unstable
union U7<T: Copy + ?Sized> { //~ ERROR unsized unions are unstable
a: T
}

Expand Down
12 changes: 11 additions & 1 deletion src/test/ui/feature-gate-untagged_unions.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ LL | | }
|
= help: add #![feature(untagged_unions)] to the crate attributes to enable

error: aborting due to 3 previous errors
error[E0658]: unions with non-`Copy` fields are unstable (see issue #32836)
--> $DIR/feature-gate-untagged_unions.rs:38:1
|
LL | / union U6<T: ?Sized> { //~ ERROR unions with non-`Copy` fields are unstable
LL | | a: T
LL | | }
| |_^
|
= help: add #![feature(untagged_unions)] to the crate attributes to enable

error: aborting due to 4 previous errors

If you want more information on this error, try using "rustc --explain E0658"
8 changes: 4 additions & 4 deletions src/test/ui/union/union-sized-field.stderr
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
error[E0277]: the trait bound `T: std::marker::Sized` is not satisfied
--> $DIR/union-sized-field.rs:14:5
--> $DIR/union-sized-field.rs:15:5
|
LL | value: T, //~ ERROR the trait bound `T: std::marker::Sized` is not satisfied
| ^^^^^^^^ `T` does not have a constant size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `T`
= help: consider adding a `where T: std::marker::Sized` bound
= note: no field of a union may have a dynamically sized type
= note: only single-field unions may have a dynamically sized type

error[E0277]: the trait bound `T: std::marker::Sized` is not satisfied
--> $DIR/union-sized-field.rs:18:5
--> $DIR/union-sized-field.rs:19:5
|
LL | value: T, //~ ERROR the trait bound `T: std::marker::Sized` is not satisfied
| ^^^^^^^^ `T` does not have a constant size known at compile-time
Expand All @@ -19,7 +19,7 @@ LL | value: T, //~ ERROR the trait bound `T: std::marker::Sized` is not sati
= note: only the last field of a struct may have a dynamically sized type

error[E0277]: the trait bound `T: std::marker::Sized` is not satisfied
--> $DIR/union-sized-field.rs:23:11
--> $DIR/union-sized-field.rs:24:11
|
LL | Value(T), //~ ERROR the trait bound `T: std::marker::Sized` is not satisfied
| ^^ `T` does not have a constant size known at compile-time
Expand Down