about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorAlex Burka <durka42@gmail.com>2017-01-05 23:17:12 +0000
committerAlex Burka <alex@alexburka.com>2017-02-09 06:40:23 +0000
commitb4993ec8635a48d4467a69482f77c6370a9709df (patch)
tree0f8bb145f0d65b4f8794281e4bc51a2f2fb948d4 /src/libsyntax
parentc14f87e3b0823407a91a283796bf78ef83d5fe99 (diff)
downloadrust-b4993ec8635a48d4467a69482f77c6370a9709df.tar.gz
rust-b4993ec8635a48d4467a69482f77c6370a9709df.zip
suggest doubling recursion limit in more situations
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ext/base.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index 9a717b86d09..e7f794328b8 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -14,7 +14,7 @@ use ast::{self, Attribute, Name, PatKind, MetaItem};
 use attr::HasAttrs;
 use codemap::{self, CodeMap, ExpnInfo, Spanned, respan};
 use syntax_pos::{Span, ExpnId, NO_EXPANSION};
-use errors::DiagnosticBuilder;
+use errors::{DiagnosticBuilder, FatalError};
 use ext::expand::{self, Expansion};
 use ext::hygiene::Mark;
 use fold::{self, Folder};
@@ -674,9 +674,15 @@ impl<'a> ExtCtxt<'a> {
 
     pub fn bt_push(&mut self, ei: ExpnInfo) {
         if self.current_expansion.depth > self.ecfg.recursion_limit {
-            self.span_fatal(ei.call_site,
-                            &format!("recursion limit reached while expanding the macro `{}`",
-                                    ei.callee.name()));
+            let suggested_limit = self.ecfg.recursion_limit * 2;
+            let mut err = self.struct_span_fatal(ei.call_site,
+                &format!("recursion limit reached while expanding the macro `{}`",
+                         ei.callee.name()));
+            err.note(&format!(
+                "consider adding a `#![recursion_limit=\"{}\"]` attribute to your crate",
+                suggested_limit));
+            err.emit();
+            panic!(FatalError);
         }
 
         let mut call_site = ei.call_site;