@@ -16,7 +16,7 @@ use config::{read_config_file, Config};
16
16
use generator:: { Generator , MapChain } ;
17
17
use heritage:: { Context , Heritage } ;
18
18
use input:: { Print , TemplateArgs , TemplateInput } ;
19
- use parser:: { generate_error_info, strip_common, ErrorInfo , ParseError } ;
19
+ use parser:: { generate_error_info, strip_common, ErrorInfo , ParseError , Parsed , WithSpan } ;
20
20
use proc_macro2:: { Span , TokenStream } ;
21
21
22
22
#[ cfg( not( feature = "__standalone" ) ) ]
@@ -138,7 +138,7 @@ struct CompileError {
138
138
}
139
139
140
140
impl CompileError {
141
- fn new < S : fmt:: Display > ( msg : S , file_info : Option < FileInfo < ' _ , ' _ , ' _ > > ) -> Self {
141
+ fn new < S : fmt:: Display > ( msg : S , file_info : Option < FileInfo < ' _ > > ) -> Self {
142
142
let msg = match file_info {
143
143
Some ( file_info) => format ! ( "{msg}{file_info}" ) ,
144
144
None => msg. to_string ( ) ,
@@ -178,23 +178,31 @@ impl From<ParseError> for CompileError {
178
178
}
179
179
}
180
180
181
- struct FileInfo < ' a , ' b , ' c > {
181
+ struct FileInfo < ' a > {
182
182
path : & ' a Path ,
183
- source : Option < & ' b str > ,
184
- node_source : Option < & ' c str > ,
183
+ source : Option < & ' a str > ,
184
+ node_source : Option < & ' a str > ,
185
185
}
186
186
187
- impl < ' a , ' b , ' c > FileInfo < ' a , ' b , ' c > {
188
- fn new ( path : & ' a Path , source : Option < & ' b str > , node_source : Option < & ' c str > ) -> Self {
187
+ impl < ' a > FileInfo < ' a > {
188
+ fn new ( path : & ' a Path , source : Option < & ' a str > , node_source : Option < & ' a str > ) -> Self {
189
189
Self {
190
190
path,
191
191
source,
192
192
node_source,
193
193
}
194
194
}
195
+
196
+ fn of < T > ( node : & WithSpan < ' a , T > , path : & ' a Path , parsed : & ' a Parsed ) -> Self {
197
+ Self {
198
+ path,
199
+ source : Some ( parsed. source ( ) ) ,
200
+ node_source : Some ( node. span ( ) ) ,
201
+ }
202
+ }
195
203
}
196
204
197
- impl < ' a , ' b , ' c > fmt:: Display for FileInfo < ' a , ' b , ' c > {
205
+ impl fmt:: Display for FileInfo < ' _ > {
198
206
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
199
207
match ( self . source , self . node_source ) {
200
208
( Some ( source) , Some ( node_source) ) => {
0 commit comments