forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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 rust-lang#69903 - estebank:icemation, r=oli-obk
Do not ICE in the face of invalid enum discriminant Fix rust-lang#67377. r? @pnkfelix
- Loading branch information
Showing
4 changed files
with
181 additions
and
5 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
36 changes: 36 additions & 0 deletions
36
src/test/ui/parser/issue-67377-invalid-syntax-in-enum-discriminant.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,36 @@ | ||
mod a { | ||
use std::marker::PhantomData; | ||
|
||
enum Bug { | ||
V = [PhantomData; { [ () ].len() ].len() as isize, | ||
//~^ ERROR mismatched closing delimiter: `]` | ||
//~| ERROR mismatched closing delimiter: `]` | ||
//~| ERROR mismatched closing delimiter: `]` | ||
//~| ERROR mismatched closing delimiter: `]` | ||
//~| ERROR destructors cannot be evaluated at compile-time | ||
} | ||
} | ||
|
||
mod b { | ||
enum Bug { | ||
V = [Vec::new; { [].len() ].len() as isize, | ||
//~^ ERROR mismatched closing delimiter: `]` | ||
//~| ERROR mismatched closing delimiter: `]` | ||
//~| ERROR mismatched closing delimiter: `]` | ||
//~| ERROR mismatched closing delimiter: `]` | ||
//~| ERROR type annotations needed | ||
} | ||
} | ||
|
||
mod c { | ||
enum Bug { | ||
V = [Vec::new; { [0].len() ].len() as isize, | ||
//~^ ERROR mismatched closing delimiter: `]` | ||
//~| ERROR mismatched closing delimiter: `]` | ||
//~| ERROR mismatched closing delimiter: `]` | ||
//~| ERROR mismatched closing delimiter: `]` | ||
//~| ERROR type annotations needed | ||
} | ||
} | ||
|
||
fn main() {} |
130 changes: 130 additions & 0 deletions
130
src/test/ui/parser/issue-67377-invalid-syntax-in-enum-discriminant.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,130 @@ | ||
error: mismatched closing delimiter: `]` | ||
--> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:42 | ||
| | ||
LL | V = [PhantomData; { [ () ].len() ].len() as isize, | ||
| - - ^ mismatched closing delimiter | ||
| | | | ||
| | unclosed delimiter | ||
| closing delimiter possibly meant for this | ||
|
||
error: mismatched closing delimiter: `]` | ||
--> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:16:36 | ||
| | ||
LL | V = [Vec::new; { [].len() ].len() as isize, | ||
| - - ^ mismatched closing delimiter | ||
| | | | ||
| | unclosed delimiter | ||
| closing delimiter possibly meant for this | ||
|
||
error: mismatched closing delimiter: `]` | ||
--> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:27:36 | ||
| | ||
LL | V = [Vec::new; { [0].len() ].len() as isize, | ||
| - - ^ mismatched closing delimiter | ||
| | | | ||
| | unclosed delimiter | ||
| closing delimiter possibly meant for this | ||
|
||
error: mismatched closing delimiter: `]` | ||
--> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:42 | ||
| | ||
LL | V = [PhantomData; { [ () ].len() ].len() as isize, | ||
| - - ^ mismatched closing delimiter | ||
| | | | ||
| | unclosed delimiter | ||
| closing delimiter possibly meant for this | ||
|
||
error: mismatched closing delimiter: `]` | ||
--> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:16:36 | ||
| | ||
LL | V = [Vec::new; { [].len() ].len() as isize, | ||
| - - ^ mismatched closing delimiter | ||
| | | | ||
| | unclosed delimiter | ||
| closing delimiter possibly meant for this | ||
|
||
error: mismatched closing delimiter: `]` | ||
--> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:27:36 | ||
| | ||
LL | V = [Vec::new; { [0].len() ].len() as isize, | ||
| - - ^ mismatched closing delimiter | ||
| | | | ||
| | unclosed delimiter | ||
| closing delimiter possibly meant for this | ||
|
||
error: mismatched closing delimiter: `]` | ||
--> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:42 | ||
| | ||
LL | V = [PhantomData; { [ () ].len() ].len() as isize, | ||
| - - ^ mismatched closing delimiter | ||
| | | | ||
| | unclosed delimiter | ||
| closing delimiter possibly meant for this | ||
|
||
error: mismatched closing delimiter: `]` | ||
--> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:16:36 | ||
| | ||
LL | V = [Vec::new; { [].len() ].len() as isize, | ||
| - - ^ mismatched closing delimiter | ||
| | | | ||
| | unclosed delimiter | ||
| closing delimiter possibly meant for this | ||
|
||
error: mismatched closing delimiter: `]` | ||
--> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:27:36 | ||
| | ||
LL | V = [Vec::new; { [0].len() ].len() as isize, | ||
| - - ^ mismatched closing delimiter | ||
| | | | ||
| | unclosed delimiter | ||
| closing delimiter possibly meant for this | ||
|
||
error: mismatched closing delimiter: `]` | ||
--> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:42 | ||
| | ||
LL | V = [PhantomData; { [ () ].len() ].len() as isize, | ||
| - - ^ mismatched closing delimiter | ||
| | | | ||
| | unclosed delimiter | ||
| closing delimiter possibly meant for this | ||
|
||
error: mismatched closing delimiter: `]` | ||
--> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:16:36 | ||
| | ||
LL | V = [Vec::new; { [].len() ].len() as isize, | ||
| - - ^ mismatched closing delimiter | ||
| | | | ||
| | unclosed delimiter | ||
| closing delimiter possibly meant for this | ||
|
||
error: mismatched closing delimiter: `]` | ||
--> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:27:36 | ||
| | ||
LL | V = [Vec::new; { [0].len() ].len() as isize, | ||
| - - ^ mismatched closing delimiter | ||
| | | | ||
| | unclosed delimiter | ||
| closing delimiter possibly meant for this | ||
|
||
error[E0493]: destructors cannot be evaluated at compile-time | ||
--> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:5:13 | ||
| | ||
LL | V = [PhantomData; { [ () ].len() ].len() as isize, | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constants cannot evaluate destructors | ||
|
||
error[E0282]: type annotations needed | ||
--> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:16:29 | ||
| | ||
LL | V = [Vec::new; { [].len() ].len() as isize, | ||
| ^^^ cannot infer type for type parameter `T` | ||
|
||
error[E0282]: type annotations needed | ||
--> $DIR/issue-67377-invalid-syntax-in-enum-discriminant.rs:27:14 | ||
| | ||
LL | V = [Vec::new; { [0].len() ].len() as isize, | ||
| ^^^^^^^^ cannot infer type for type parameter `T` | ||
|
||
error: aborting due to 15 previous errors | ||
|
||
Some errors have detailed explanations: E0282, E0493. | ||
For more information about an error, try `rustc --explain E0282`. |