-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #68542
- Loading branch information
Showing
3 changed files
with
30 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
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,10 @@ | ||
// Regression test for issue #68542 | ||
// Tests that we don't ICE when a closure appears | ||
// in the length part of an array. | ||
|
||
struct Bug { | ||
a: [(); (|| { 0 })()] //~ ERROR calls in constants are limited to | ||
//~^ ERROR evaluation of constant value failed | ||
} | ||
|
||
fn main() {} |
16 changes: 16 additions & 0 deletions
16
src/test/ui/consts/issue-68542-closure-in-array-len.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[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants | ||
--> $DIR/issue-68542-closure-in-array-len.rs:6:13 | ||
| | ||
LL | a: [(); (|| { 0 })()] | ||
| ^^^^^^^^^^^^ | ||
|
||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/issue-68542-closure-in-array-len.rs:6:13 | ||
| | ||
LL | a: [(); (|| { 0 })()] | ||
| ^^^^^^^^^^^^ calling non-const function `Bug::a::{{constant}}#0::{{closure}}#0` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0015, E0080. | ||
For more information about an error, try `rustc --explain E0015`. |