forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Anonymous{Struct, Union} in the AST
Add unnamed_fields feature gate and gate unnamed fields on parsing
- Loading branch information
Showing
13 changed files
with
232 additions
and
31 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
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -1269,6 +1269,7 @@ symbols! { | |
unix, | ||
unlikely, | ||
unmarked_api, | ||
unnamed_fields, | ||
unpin, | ||
unreachable, | ||
unreachable_code, | ||
|
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,27 @@ | ||
struct Foo { | ||
foo: u8, | ||
_: union { //~ ERROR unnamed fields are not yet fully implemented [E0658] | ||
//~^ ERROR unnamed fields are not yet fully implemented [E0658] | ||
//~| ERROR anonymous unions are unimplemented | ||
bar: u8, | ||
baz: u16 | ||
} | ||
} | ||
|
||
union Bar { | ||
foobar: u8, | ||
_: struct { //~ ERROR unnamed fields are not yet fully implemented [E0658] | ||
//~^ ERROR unnamed fields are not yet fully implemented [E0658] | ||
//~| ERROR anonymous structs are unimplemented | ||
//~| ERROR unions may not contain fields that need dropping [E0740] | ||
foobaz: u8, | ||
barbaz: u16 | ||
} | ||
} | ||
|
||
struct S; | ||
struct Baz { | ||
_: S //~ ERROR unnamed fields are not yet fully implemented [E0658] | ||
} | ||
|
||
fn main(){} |
111 changes: 111 additions & 0 deletions
111
src/test/ui/feature-gates/feature-gate-unnamed_fields.stderr
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,111 @@ | ||
error[E0658]: unnamed fields are not yet fully implemented | ||
--> $DIR/feature-gate-unnamed_fields.rs:3:5 | ||
| | ||
LL | _: union { | ||
| ^ | ||
| | ||
= note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information | ||
= help: add `#![feature(unnamed_fields)]` to the crate attributes to enable | ||
|
||
error[E0658]: unnamed fields are not yet fully implemented | ||
--> $DIR/feature-gate-unnamed_fields.rs:3:8 | ||
| | ||
LL | _: union { | ||
| ________^ | ||
LL | | | ||
LL | | | ||
LL | | bar: u8, | ||
LL | | baz: u16 | ||
LL | | } | ||
| |_____^ | ||
| | ||
= note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information | ||
= help: add `#![feature(unnamed_fields)]` to the crate attributes to enable | ||
|
||
error[E0658]: unnamed fields are not yet fully implemented | ||
--> $DIR/feature-gate-unnamed_fields.rs:13:5 | ||
| | ||
LL | _: struct { | ||
| ^ | ||
| | ||
= note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information | ||
= help: add `#![feature(unnamed_fields)]` to the crate attributes to enable | ||
|
||
error[E0658]: unnamed fields are not yet fully implemented | ||
--> $DIR/feature-gate-unnamed_fields.rs:13:8 | ||
| | ||
LL | _: struct { | ||
| ________^ | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | foobaz: u8, | ||
LL | | barbaz: u16 | ||
LL | | } | ||
| |_____^ | ||
| | ||
= note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information | ||
= help: add `#![feature(unnamed_fields)]` to the crate attributes to enable | ||
|
||
error[E0658]: unnamed fields are not yet fully implemented | ||
--> $DIR/feature-gate-unnamed_fields.rs:24:5 | ||
| | ||
LL | _: S | ||
| ^ | ||
| | ||
= note: see issue #49804 <https://github.com/rust-lang/rust/issues/49804> for more information | ||
= help: add `#![feature(unnamed_fields)]` to the crate attributes to enable | ||
|
||
error: anonymous unions are unimplemented | ||
--> $DIR/feature-gate-unnamed_fields.rs:3:8 | ||
| | ||
LL | _: union { | ||
| ________^ | ||
LL | | | ||
LL | | | ||
LL | | bar: u8, | ||
LL | | baz: u16 | ||
LL | | } | ||
| |_____^ | ||
|
||
error: anonymous structs are unimplemented | ||
--> $DIR/feature-gate-unnamed_fields.rs:13:8 | ||
| | ||
LL | _: struct { | ||
| ________^ | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | foobaz: u8, | ||
LL | | barbaz: u16 | ||
LL | | } | ||
| |_____^ | ||
|
||
error[E0740]: unions may not contain fields that need dropping | ||
--> $DIR/feature-gate-unnamed_fields.rs:13:5 | ||
| | ||
LL | / _: struct { | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | foobaz: u8, | ||
LL | | barbaz: u16 | ||
LL | | } | ||
| |_____^ | ||
| | ||
note: `std::mem::ManuallyDrop` can be used to wrap the type | ||
--> $DIR/feature-gate-unnamed_fields.rs:13:5 | ||
| | ||
LL | / _: struct { | ||
LL | | | ||
LL | | | ||
LL | | | ||
LL | | foobaz: u8, | ||
LL | | barbaz: u16 | ||
LL | | } | ||
| |_____^ | ||
|
||
error: aborting due to 8 previous errors | ||
|
||
Some errors have detailed explanations: E0658, E0740. | ||
For more information about an error, try `rustc --explain E0658`. |