@@ -8,17 +8,17 @@ use std::path::Path;
8
8
use std:: str;
9
9
use std:: sync:: Arc ;
10
10
11
- use parser:: node:: Whitespace ;
11
+ use parser:: node:: { Macro , Whitespace } ;
12
12
use parser:: {
13
13
CharLit , Expr , FloatKind , IntKind , MAX_RUST_KEYWORD_LEN , Num , RUST_KEYWORDS , StrLit , WithSpan ,
14
14
} ;
15
15
use rustc_hash:: FxBuildHasher ;
16
16
17
- use crate :: CompileError ;
18
17
use crate :: heritage:: { Context , Heritage } ;
19
18
use crate :: html:: write_escaped_str;
20
19
use crate :: input:: { Source , TemplateInput } ;
21
20
use crate :: integration:: { Buffer , impl_everything, write_header} ;
21
+ use crate :: { CompileError , FileInfo } ;
22
22
23
23
pub ( crate ) fn template_to_string (
24
24
buf : & mut Buffer ,
@@ -46,27 +46,29 @@ pub(crate) fn template_to_string(
46
46
}
47
47
48
48
struct Generator < ' a , ' h > {
49
- // The template input state: original struct AST and attributes
49
+ /// The template input state: original struct AST and attributes
50
50
input : & ' a TemplateInput < ' a > ,
51
- // All contexts, keyed by the package-relative template path
51
+ /// All contexts, keyed by the package-relative template path
52
52
contexts : & ' a HashMap < & ' a Arc < Path > , Context < ' a > , FxBuildHasher > ,
53
- // The heritage contains references to blocks and their ancestry
53
+ /// The heritage contains references to blocks and their ancestry
54
54
heritage : Option < & ' h Heritage < ' a , ' h > > ,
55
- // Variables accessible directly from the current scope (not redirected to context)
55
+ /// Variables accessible directly from the current scope (not redirected to context)
56
56
locals : MapChain < ' a > ,
57
- // Suffix whitespace from the previous literal. Will be flushed to the
58
- // output buffer unless suppressed by whitespace suppression on the next
59
- // non-literal.
57
+ /// Suffix whitespace from the previous literal. Will be flushed to the
58
+ /// output buffer unless suppressed by whitespace suppression on the next
59
+ /// non-literal.
60
60
next_ws : Option < & ' a str > ,
61
- // Whitespace suppression from the previous non-literal. Will be used to
62
- // determine whether to flush prefix whitespace from the next literal.
61
+ /// Whitespace suppression from the previous non-literal. Will be used to
62
+ /// determine whether to flush prefix whitespace from the next literal.
63
63
skip_ws : Whitespace ,
64
- // If currently in a block, this will contain the name of a potential parent block
64
+ /// If currently in a block, this will contain the name of a potential parent block
65
65
super_block : Option < ( & ' a str , usize ) > ,
66
- // Buffer for writable
66
+ /// Buffer for writable
67
67
buf_writable : WritableBuffer < ' a > ,
68
- // Used in blocks to check if we are inside a filter block.
68
+ /// Used in blocks to check if we are inside a filter block.
69
69
is_in_filter_block : usize ,
70
+ /// Set of called macros we are currently in. Used to prevent (indirect) recursions.
71
+ seen_macros : Vec < ( & ' a Macro < ' a > , Option < FileInfo < ' a > > ) > ,
70
72
}
71
73
72
74
impl < ' a , ' h > Generator < ' a , ' h > {
@@ -91,6 +93,7 @@ impl<'a, 'h> Generator<'a, 'h> {
91
93
..Default :: default ( )
92
94
} ,
93
95
is_in_filter_block,
96
+ seen_macros : Vec :: new ( ) ,
94
97
}
95
98
}
96
99
0 commit comments