1
1
use crate :: base:: * ;
2
2
use crate :: config:: StripUnconfigured ;
3
3
use crate :: errors:: {
4
- IncompleteParse , RecursionLimitReached , RemoveExprNotSupported , RemoveNodeNotSupported ,
5
- UnsupportedKeyValue , WrongFragmentKind ,
4
+ ExpansionGrowthLimitReached , IncompleteParse , RecursionLimitReached , RemoveExprNotSupported ,
5
+ RemoveNodeNotSupported , UnsupportedKeyValue , WrongFragmentKind ,
6
6
} ;
7
7
use crate :: hygiene:: SyntaxContext ;
8
8
use crate :: mbe:: diagnostics:: annotate_err_with_kind;
@@ -628,20 +628,12 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
628
628
limit => limit * 2 ,
629
629
} ;
630
630
631
- self . cx
632
- . struct_span_err (
633
- expn_data. call_site ,
634
- & format ! (
635
- "expansion grow limit reached while expanding `{}`" ,
636
- expn_data. kind. descr( )
637
- ) ,
638
- )
639
- . help ( & format ! (
640
- "consider increasing the expansion grow limit by adding a \
641
- `#![expansion_growth_limit = \" {}\" ]` attribute to your crate (`{}`)",
642
- suggested_limit, self . cx. ecfg. crate_name,
643
- ) )
644
- . emit ( ) ;
631
+ self . cx . emit_err ( ExpansionGrowthLimitReached {
632
+ span : expn_data. call_site ,
633
+ descr : expn_data. kind . descr ( ) ,
634
+ suggested_limit,
635
+ crate_name : & self . cx . ecfg . crate_name ,
636
+ } ) ;
645
637
self . cx . trace_macros_diag ( ) ;
646
638
}
647
639
@@ -663,7 +655,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
663
655
664
656
// Reduce the recursion limit by half each time it triggers.
665
657
self . cx . reduced_recursion_limit = Some ( expansion_limit / 2 ) ;
666
-
667
658
return Err ( ( ) ) ;
668
659
}
669
660
Ok ( ( ) )
@@ -698,11 +689,9 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
698
689
self . parse_ast_fragment ( tok_result, fragment_kind, & mac. path , span)
699
690
}
700
691
SyntaxExtensionKind :: LegacyBang ( expander) => {
701
- if self . reduce_expansion_growth_limit ( mac. args . inner_tokens ( ) . len ( ) ) . is_err ( ) {
692
+ if self . reduce_expansion_growth_limit ( mac. args . tokens . len ( ) ) . is_err ( ) {
702
693
return ExpandResult :: Ready ( fragment_kind. dummy ( span) ) ;
703
694
}
704
- let prev = self . cx . current_expansion . prior_type_ascription ;
705
- self . cx . current_expansion . prior_type_ascription = mac. prior_type_ascription ;
706
695
let tok_result = expander. expand ( self . cx , span, mac. args . tokens . clone ( ) ) ;
707
696
let result = if let Some ( result) = fragment_kind. make_from ( tok_result) {
708
697
result
@@ -2040,7 +2029,7 @@ impl ExpansionConfig<'_> {
2040
2029
crate_name,
2041
2030
features,
2042
2031
recursion_limit : Limit :: new ( 1024 ) ,
2043
- expansion_growth_limit : Limit :: new ( 6000 ) ,
2032
+ expansion_growth_limit : Limit :: new ( 1000000 ) ,
2044
2033
trace_mac : false ,
2045
2034
should_test : false ,
2046
2035
span_debug : false ,
0 commit comments