-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Fix several ICEs related to malformed #[repr(...)]
attributes
#87013
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Regression test for various ICEs inspired by | ||
// https://github.com/rust-lang/rust/issues/83921#issuecomment-814640734 | ||
|
||
// compile-flags: -Zdeduplicate-diagnostics=yes | ||
|
||
#[repr(packed())] | ||
//~^ ERROR: incorrect `repr(packed)` attribute format | ||
struct S1; | ||
|
||
#[repr(align)] | ||
//~^ ERROR: invalid `repr(align)` attribute | ||
struct S2; | ||
|
||
#[repr(align(2, 4))] | ||
//~^ ERROR: incorrect `repr(align)` attribute format | ||
struct S3; | ||
|
||
#[repr(align())] | ||
//~^ ERROR: incorrect `repr(align)` attribute format | ||
struct S4; | ||
|
||
#[repr(i8())] | ||
//~^ ERROR: invalid representation hint | ||
enum E1 { A, B } | ||
|
||
#[repr(u32(42))] | ||
//~^ ERROR: invalid representation hint | ||
enum E2 { A, B } | ||
|
||
#[repr(i64 = 2)] | ||
//~^ ERROR: invalid representation hint | ||
enum E3 { A, B } | ||
|
||
fn main() {} |
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,46 @@ | ||
error[E0552]: incorrect `repr(packed)` attribute format: `packed` takes exactly one parenthesized argument, or no parentheses at all | ||
--> $DIR/issue-83921-ice.rs:6:8 | ||
| | ||
LL | #[repr(packed())] | ||
| ^^^^^^^^ | ||
|
||
error[E0589]: invalid `repr(align)` attribute: `align` needs an argument | ||
--> $DIR/issue-83921-ice.rs:10:8 | ||
| | ||
LL | #[repr(align)] | ||
| ^^^^^ help: supply an argument here: `align(...)` | ||
|
||
error[E0693]: incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses | ||
--> $DIR/issue-83921-ice.rs:14:8 | ||
| | ||
LL | #[repr(align(2, 4))] | ||
| ^^^^^^^^^^^ | ||
|
||
error[E0693]: incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses | ||
--> $DIR/issue-83921-ice.rs:18:8 | ||
| | ||
LL | #[repr(align())] | ||
| ^^^^^^^ | ||
|
||
error[E0552]: invalid representation hint: `i8` does not take a parenthesized argument list | ||
--> $DIR/issue-83921-ice.rs:22:8 | ||
| | ||
LL | #[repr(i8())] | ||
| ^^^^ | ||
|
||
error[E0552]: invalid representation hint: `u32` does not take a parenthesized argument list | ||
--> $DIR/issue-83921-ice.rs:26:8 | ||
| | ||
LL | #[repr(u32(42))] | ||
| ^^^^^^^ | ||
|
||
error[E0552]: invalid representation hint: `i64` does not take a value | ||
--> $DIR/issue-83921-ice.rs:30:8 | ||
| | ||
LL | #[repr(i64 = 2)] | ||
| ^^^^^^^ | ||
|
||
error: aborting due to 7 previous errors | ||
|
||
Some errors have detailed explanations: E0552, E0589, E0693. | ||
For more information about an error, try `rustc --explain E0552`. |
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,9 @@ | ||
error[E0565]: meta item in `repr` must be an identifier | ||
--> $DIR/issue-83921-pretty.rs:10:8 | ||
| | ||
LL | #[repr("C")] | ||
| ^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0565`. |
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,19 @@ | ||
#![feature(prelude_import)] | ||
#![no_std] | ||
#[prelude_import] | ||
use ::std::prelude::rust_2015::*; | ||
#[macro_use] | ||
extern crate std; | ||
// Regression test for #83921. A `delay_span_bug()` call was issued, but the | ||
// error was never reported because the pass responsible for detecting and | ||
// reporting the error does not run in certain modes of pretty-printing. | ||
|
||
// Make sure the error is reported if we do not just pretty-print: | ||
// revisions: pretty normal | ||
// [pretty]compile-flags: -Zunpretty=everybody_loops | ||
// [pretty]check-pass | ||
#[repr("C")] | ||
struct A { | ||
} | ||
|
||
fn main() { loop { } } |
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,14 @@ | ||
// Regression test for #83921. A `delay_span_bug()` call was issued, but the | ||
// error was never reported because the pass responsible for detecting and | ||
// reporting the error does not run in certain modes of pretty-printing. | ||
|
||
// Make sure the error is reported if we do not just pretty-print: | ||
// revisions: pretty normal | ||
// [pretty]compile-flags: -Zunpretty=everybody_loops | ||
// [pretty]check-pass | ||
|
||
#[repr("C")] | ||
//[normal]~^ ERROR: meta item in `repr` must be an identifier [E0565] | ||
struct A {} | ||
|
||
fn main() {} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because you have no conditional changes on the diagnostic, you can rely on chaining instead:
(Might need to run
./x.py fmt
to fix the formatting here)