@@ -16,7 +16,6 @@ use codemap::{Span, respan};
16
16
use ext:: base:: * ;
17
17
use ext:: base;
18
18
use ext:: build:: AstBuilder ;
19
- use fold:: Folder ;
20
19
use fmt_macros as parse;
21
20
use fold:: Folder ;
22
21
use parse:: token:: special_idents;
@@ -636,6 +635,7 @@ pub fn ensure_not_fmt_string_literal<'cx>(cx: &'cx mut ExtCtxt,
636
635
sp : Span ,
637
636
tts : & [ ast:: TokenTree ] )
638
637
-> Box < base:: MacResult +' cx > {
638
+ use fold:: Folder ;
639
639
let takes_two_args = |cx : & ExtCtxt , rest| {
640
640
cx. span_err ( sp, & format ! ( "`ensure_not_fmt_string_literal!` \
641
641
takes 2 arguments, {}", rest) ) ;
@@ -644,8 +644,8 @@ pub fn ensure_not_fmt_string_literal<'cx>(cx: &'cx mut ExtCtxt,
644
644
let mut p = cx. new_parser_from_tts ( tts) ;
645
645
if p. token == token:: Eof { return takes_two_args ( cx, "given 0" ) ; }
646
646
let arg1 = cx. expander ( ) . fold_expr ( p. parse_expr ( ) ) ;
647
- if p. token != token:: Comma { return takes_two_args ( cx, "comma-separated " ) ; }
648
- p . bump ( ) ;
647
+ if p. token == token:: Eof { return takes_two_args ( cx, "given 1 " ) ; }
648
+ if ! panictry ! ( p . eat ( & token :: Comma ) ) { return takes_two_args ( cx , "comma-separated" ) ; }
649
649
if p. token == token:: Eof { return takes_two_args ( cx, "given 1" ) ; }
650
650
let arg2 = cx. expander ( ) . fold_expr ( p. parse_expr ( ) ) ;
651
651
if p. token != token:: Eof {
0 commit comments