suggest doubling recursion limit in more situations

This commit is contained in:
Alex Burka
2017-01-05 23:17:12 +00:00
committed by Alex Burka
parent c14f87e3b0
commit b4993ec863
9 changed files with 202 additions and 61 deletions

View File

@@ -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;