@@ -14,8 +14,7 @@ use self::Position::*;
1414use fmt_macros as parse;
1515
1616use syntax:: ast;
17- use syntax:: ext:: base;
18- use syntax:: ext:: base:: * ;
17+ use syntax:: ext:: base:: { self , * } ;
1918use syntax:: ext:: build:: AstBuilder ;
2019use syntax:: feature_gate;
2120use syntax:: parse:: token;
@@ -24,6 +23,7 @@ use syntax::symbol::Symbol;
2423use syntax:: tokenstream;
2524use syntax_pos:: { MultiSpan , Span , DUMMY_SP } ;
2625
26+ use std:: borrow:: Cow ;
2727use std:: collections:: hash_map:: Entry ;
2828use std:: collections:: { HashMap , HashSet } ;
2929
@@ -143,8 +143,10 @@ fn parse_args(ecx: &mut ExtCtxt,
143143 ecx. span_err ( sp, "requires at least a format string argument" ) ;
144144 return None ;
145145 }
146+
146147 let fmtstr = panictry ! ( p. parse_expr( ) ) ;
147148 let mut named = false ;
149+
148150 while p. token != token:: Eof {
149151 if !p. eat ( & token:: Comma ) {
150152 ecx. span_err ( p. span , "expected token: `,`" ) ;
@@ -264,11 +266,11 @@ impl<'a, 'b> Context<'a, 'b> {
264266 }
265267 }
266268
267- fn describe_num_args ( & self ) -> String {
269+ fn describe_num_args ( & self ) -> Cow < str > {
268270 match self . args . len ( ) {
269- 0 => "no arguments were given" . to_string ( ) ,
270- 1 => "there is 1 argument" . to_string ( ) ,
271- x => format ! ( "there are {} arguments" , x) ,
271+ 0 => "no arguments were given" . into ( ) ,
272+ 1 => "there is 1 argument" . into ( ) ,
273+ x => format ! ( "there are {} arguments" , x) . into ( ) ,
272274 }
273275 }
274276
0 commit comments