-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #121470 - clubby789:anon-struct-in-enum, r=fmease
Don't ICE on anonymous struct in enum variant Fixes #121446 Computing `adt_def` for the anon struct calls `adt_def` on the parent to find its repr. If the parent is a non-item (e.g. an enum variant) we should have already emitted at least one error, so we just use the repr of the anonymous struct to avoid an ICE. cc ``@frank-king``
- Loading branch information
Showing
4 changed files
with
41 additions
and
1 deletion.
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
11 changes: 11 additions & 0 deletions
11
tests/ui/union/unnamed-fields/anon-struct-in-enum-issue-121446.rs
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,11 @@ | ||
#![crate_type = "lib"] | ||
#![feature(unnamed_fields)] | ||
#![allow(unused, incomplete_features)] | ||
|
||
enum K { | ||
M { | ||
_ : struct { field: u8 }, | ||
//~^ error: unnamed fields are not allowed outside of structs or unions | ||
//~| error: anonymous structs are not allowed outside of unnamed struct or union fields | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
tests/ui/union/unnamed-fields/anon-struct-in-enum-issue-121446.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,16 @@ | ||
error: unnamed fields are not allowed outside of structs or unions | ||
--> $DIR/anon-struct-in-enum-issue-121446.rs:7:9 | ||
| | ||
LL | _ : struct { field: u8 }, | ||
| -^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| unnamed field declared here | ||
|
||
error: anonymous structs are not allowed outside of unnamed struct or union fields | ||
--> $DIR/anon-struct-in-enum-issue-121446.rs:7:13 | ||
| | ||
LL | _ : struct { field: u8 }, | ||
| ^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here | ||
|
||
error: aborting due to 2 previous errors | ||
|