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;
10 use syntax::symbol::{Symbol, sym};
12 use rustc_data_structures::sync::Once;
14 pub fn update_limits(sess: &Session, krate: &ast::Crate) {
15 update_limit(krate, &sess.recursion_limit, sym::recursion_limit, 64);
16 update_limit(krate, &sess.type_length_limit, sym::type_length_limit, 1048576);
19 fn update_limit(krate: &ast::Crate, limit: &Once<usize>, name: Symbol, default: usize) {
20 for attr in &krate.attrs {
21 if !attr.check_name(name) {
25 if let Some(s) = attr.value_str() {
26 if let Some(n) = s.as_str().parse().ok() {