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:
|
fn update_limit(krate: &ast::Crate, limit: &Once<usize>, name: Symbol, default: usize) { |
|
for attr in &krate.attrs { |
|
if !attr.check_name(name) { |
|
continue; |
|
} |
|
|
|
if let Some(s) = attr.value_str() { |
|
if let Some(n) = s.as_str().parse().ok() { |
|
limit.set(n); |
|
return; |
|
} |
|
} |
|
} |
|
limit.set(default); |
|
} |
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.
The following code fails to compile since it exceeds the default recursion limit. Using
2056as the recursion limit works as expected.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::MAXwhen overflow occurs.This issue has been assigned to @fisherdarling via this comment.