Closed
Description
The following code fails to compile since it exceeds the default recursion limit. Using 2056
as the recursion limit works as expected.
#![recursion_limit = "99999999999999999999999999999999999999999999999999999"]
//#![recursion_limit = "2056"]
macro_rules! explode {
(recurse; $head:tt $($tail:tt)*) => { explode!(recurse; $($tail)*); };
(recurse;) => {};
(0; $($tt:tt)*) => { explode!(1; $($tt)* $($tt)* $($tt)*); };
(1; $($tt:tt)*) => { explode!(2; $($tt)* $($tt)* $($tt)*); };
(2; $($tt:tt)*) => { explode!(3; $($tt)* $($tt)* $($tt)*); };
(3; $($tt:tt)*) => { explode!(recurse; $($tt)* $($tt)* $($tt)*); };
}
explode!(0; a b c);
This is because we don't check for integer overflow errors when parsing limits:
rust/src/librustc/middle/recursion_limit.rs
Lines 19 to 33 in e9469a6
There's a few options here. My preference would be to silently default to usize::MAX
when overflow occurs.
This issue has been assigned to @fisherdarling via this comment.