-
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.
Handle index out of bound errors during const eval without panic
- Loading branch information
Showing
3 changed files
with
36 additions
and
2 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,6 @@ | ||
fn main() { | ||
&{[1, 2, 3][4]}; | ||
//~^ ERROR index out of bounds | ||
//~| ERROR reaching this expression at runtime will panic or abort | ||
//~| ERROR this expression will panic at runtime | ||
} |
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,24 @@ | ||
error: index out of bounds: the len is 3 but the index is 4 | ||
--> $DIR/array-literal-index-oob.rs:2:7 | ||
| | ||
LL | &{[1, 2, 3][4]}; | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: #[deny(const_err)] on by default | ||
|
||
error: this expression will panic at runtime | ||
--> $DIR/array-literal-index-oob.rs:2:5 | ||
| | ||
LL | &{[1, 2, 3][4]}; | ||
| ^^^^^^^^^^^^^^^ index out of bounds: the len is 3 but the index is 4 | ||
|
||
error: reaching this expression at runtime will panic or abort | ||
--> $DIR/array-literal-index-oob.rs:2:7 | ||
| | ||
LL | &{[1, 2, 3][4]}; | ||
| --^^^^^^^^^^^^- | ||
| | | ||
| index out of bounds: the len is 3 but the index is 4 | ||
|
||
error: aborting due to 3 previous errors | ||
|