3 // There are various parts of the compiler that must impose arbitrary limits
4 // on how deeply they recurse to prevent stack overflow. Users can override
5 // this via an attribute on the crate like `#![recursion_limit="22"]`. This pass
6 // just peeks and looks for that attribute.
8 use crate::session::Session;
11 use rustc_data_structures::sync::Once;
13 pub fn update_limits(sess: &Session, krate: &ast::Crate) {
14 update_limit(krate, &sess.recursion_limit, "recursion_limit", 64);
15 update_limit(krate, &sess.type_length_limit, "type_length_limit", 1048576);
18 fn update_limit(krate: &ast::Crate, limit: &Once<usize>, name: &str, default: usize) {
19 for attr in &krate.attrs {
20 if !attr.check_name(name) {
24 if let Some(s) = attr.value_str() {
25 if let Some(n) = s.as_str().parse().ok() {