forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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#67272 - fisherdarling:master, r=varkor,hell…
…ow554 recursion_limit parsing handles overflows This PR adds overflow handling to `#![recursion_limit]` attribute parsing. If parsing the given value results in an `IntErrorKind::Overflow`, then the recursion_limit is set to `usize::max_value()`. closes rust-lang#67265
- Loading branch information
Showing
10 changed files
with
112 additions
and
6 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
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 @@ | ||
// Test the parse error for an empty recursion_limit | ||
|
||
#![recursion_limit = ""] //~ ERROR `recursion_limit` must be a non-negative integer | ||
//~| `recursion_limit` must be a non-negative integer | ||
|
||
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,10 @@ | ||
error: `recursion_limit` must be a non-negative integer | ||
--> $DIR/empty.rs:3:1 | ||
| | ||
LL | #![recursion_limit = ""] | ||
| ^^^^^^^^^^^^^^^^^^^^^--^ | ||
| | | ||
| `recursion_limit` must be a non-negative integer | ||
|
||
error: aborting due to previous error | ||
|
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 @@ | ||
// Test the parse error for an invalid digit in recursion_limit | ||
|
||
#![recursion_limit = "-100"] //~ ERROR `recursion_limit` must be a non-negative integer | ||
//~| not a valid integer | ||
|
||
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,10 @@ | ||
error: `recursion_limit` must be a non-negative integer | ||
--> $DIR/invalid_digit.rs:3:1 | ||
| | ||
LL | #![recursion_limit = "-100"] | ||
| ^^^^^^^^^^^^^^^^^^^^^------^ | ||
| | | ||
| not a valid integer | ||
|
||
error: aborting due to previous error | ||
|
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,7 @@ | ||
// Test the parse error for an overflowing recursion_limit | ||
|
||
#![recursion_limit = "999999999999999999999999"] | ||
//~^ ERROR `recursion_limit` must be a non-negative integer | ||
//~| `recursion_limit` is too large | ||
|
||
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,10 @@ | ||
error: `recursion_limit` must be a non-negative integer | ||
--> $DIR/overflow.rs:3:1 | ||
| | ||
LL | #![recursion_limit = "999999999999999999999999"] | ||
| ^^^^^^^^^^^^^^^^^^^^^--------------------------^ | ||
| | | ||
| `recursion_limit` is too large | ||
|
||
error: aborting due to previous error | ||
|
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,12 @@ | ||
// Test that a `recursion_limit` of 0 is valid | ||
|
||
#![recursion_limit = "0"] | ||
|
||
macro_rules! test { | ||
() => {}; | ||
($tt:tt) => { test!(); }; | ||
} | ||
|
||
test!(test); //~ ERROR 10:1: 10:13: recursion limit reached while expanding `test!` | ||
|
||
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,10 @@ | ||
error: recursion limit reached while expanding `test!` | ||
--> $DIR/zero.rs:10:1 | ||
| | ||
LL | test!(test); | ||
| ^^^^^^^^^^^^ | ||
| | ||
= help: consider adding a `#![recursion_limit="0"]` attribute to your crate (`zero`) | ||
|
||
error: aborting due to previous error | ||
|