-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add failing test for projections used as union field type
- Loading branch information
1 parent
4a04f25
commit 829cf09
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// This is currently not possible to use projections as union field's type. | ||
|
||
#![crate_type = "lib"] | ||
|
||
pub trait Identity { | ||
type Identity; | ||
} | ||
|
||
impl<T> Identity for T { | ||
type Identity = Self; | ||
} | ||
|
||
pub type Foo = u8; | ||
|
||
pub union Bar { | ||
a: <Foo as Identity>::Identity, //~ ERROR | ||
b: u8, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error[E0740]: unions cannot contain fields that may need dropping | ||
--> $DIR/projection-as-union-type.rs:16:5 | ||
| | ||
LL | a: <Foo as Identity>::Identity, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: a type is guaranteed not to need dropping when it implements `Copy`, or when it is the special `ManuallyDrop<_>` type | ||
help: when the type does not implement `Copy`, wrap it inside a `ManuallyDrop<_>` and ensure it is manually dropped | ||
| | ||
LL | a: std::mem::ManuallyDrop<<Foo as Identity>::Identity>, | ||
| +++++++++++++++++++++++ + | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0740`. |