@@ -14,7 +14,7 @@ use ext::base::{ExtCtxt, MacResult, SyntaxExtension};
14
14
use ext:: base:: { NormalTT , TTMacroExpander } ;
15
15
use ext:: tt:: macro_parser:: { Success , Error , Failure } ;
16
16
use ext:: tt:: macro_parser:: { NamedMatch , MatchedSeq , MatchedNonterminal } ;
17
- use ext:: tt:: macro_parser:: { parse, parse_or_else } ;
17
+ use ext:: tt:: macro_parser:: parse;
18
18
use parse:: lexer:: new_tt_reader;
19
19
use parse:: parser:: Parser ;
20
20
use parse:: token:: { self , special_idents, gensym_ident, NtTT , Token } ;
@@ -211,13 +211,16 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt,
211
211
best_fail_spot = sp;
212
212
best_fail_msg = ( * msg) . clone ( ) ;
213
213
} ,
214
- Error ( sp, ref msg) => panic ! ( cx. span_fatal( sp, & msg[ ..] ) )
214
+ Error ( err_sp, ref msg) => {
215
+ panic ! ( cx. span_fatal( err_sp. substitute_dummy( sp) , & msg[ ..] ) )
216
+ }
215
217
}
216
218
}
217
219
_ => cx. bug ( "non-matcher found in parsed lhses" )
218
220
}
219
221
}
220
- panic ! ( cx. span_fatal( best_fail_spot, & best_fail_msg[ ..] ) ) ;
222
+
223
+ panic ! ( cx. span_fatal( best_fail_spot. substitute_dummy( sp) , & best_fail_msg[ ..] ) ) ;
221
224
}
222
225
223
226
// Note that macro-by-example's input is also matched against a token tree:
@@ -266,10 +269,17 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt,
266
269
None ,
267
270
None ,
268
271
def. body . clone ( ) ) ;
269
- let argument_map = parse_or_else ( cx. parse_sess ( ) ,
270
- cx. cfg ( ) ,
271
- arg_reader,
272
- argument_gram) ;
272
+
273
+ let argument_map = match parse ( cx. parse_sess ( ) ,
274
+ cx. cfg ( ) ,
275
+ arg_reader,
276
+ & argument_gram) {
277
+ Success ( m) => m,
278
+ Failure ( sp, str) | Error ( sp, str) => {
279
+ panic ! ( cx. parse_sess( ) . span_diagnostic
280
+ . span_fatal( sp. substitute_dummy( def. span) , & str [ ..] ) ) ;
281
+ }
282
+ } ;
273
283
274
284
// Extract the arguments:
275
285
let lhses = match * * argument_map. get ( & lhs_nm) . unwrap ( ) {
0 commit comments