1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
13 // There are various parts of the compiler that must impose arbitrary limits
14 // on how deeply they recurse to prevent stack overflow. Users can override
15 // this via an attribute on the crate like `#![recursion_limit="22"]`. This pass
16 // just peeks and looks for that attribute.
20 use syntax::attr::AttrMetaMethods;
21 use std::str::FromStr;
23 pub fn update_recursion_limit(sess: &Session, krate: &ast::Crate) {
24 for attr in krate.attrs.iter() {
25 if !attr.check_name("recursion_limit") {
29 if let Some(s) = attr.value_str() {
30 if let Some(n) = FromStr::from_str(s.get()) {
31 sess.recursion_limit.set(n);
36 span_err!(sess, attr.span, E0296, "malformed recursion limit attribute, \
37 expected #![recursion_limit=\"N\"]");