@@ -335,16 +335,26 @@ pub trait HasFormatSpecifier: AstToken {
335335 }
336336 c if c == '_' || c. is_alphabetic ( ) => {
337337 read_identifier ( & mut chars, & mut callback) ;
338- if chars. peek ( ) . and_then ( |next| next. 1 . as_ref ( ) . ok ( ) ) . copied ( )
339- != Some ( '$' )
340- {
341- continue ;
342- }
343- skip_char_and_emit (
344- & mut chars,
345- FormatSpecifier :: DollarSign ,
346- & mut callback,
347- ) ;
338+ // can be either width (indicated by dollar sign, or type in which case
339+ // the next sign has to be `}`)
340+ let next =
341+ chars. peek ( ) . and_then ( |next| next. 1 . as_ref ( ) . ok ( ) ) . copied ( ) ;
342+ match next {
343+ Some ( '$' ) => skip_char_and_emit (
344+ & mut chars,
345+ FormatSpecifier :: DollarSign ,
346+ & mut callback,
347+ ) ,
348+ Some ( '}' ) => {
349+ skip_char_and_emit (
350+ & mut chars,
351+ FormatSpecifier :: Close ,
352+ & mut callback,
353+ ) ;
354+ continue ;
355+ }
356+ _ => continue ,
357+ } ;
348358 }
349359 _ => { }
350360 }
@@ -416,12 +426,11 @@ pub trait HasFormatSpecifier: AstToken {
416426 }
417427 }
418428
419- let mut cloned = chars. clone ( ) . take ( 2 ) ;
420- let first = cloned . next ( ) . and_then ( |next| next . 1 . as_ref ( ) . ok ( ) ) . copied ( ) ;
421- if first != Some ( '}' ) {
429+ if let Some ( ( _ , Ok ( '}' ) ) ) = chars. peek ( ) {
430+ skip_char_and_emit ( & mut chars , FormatSpecifier :: Close , & mut callback ) ;
431+ } else {
422432 continue ;
423433 }
424- skip_char_and_emit ( & mut chars, FormatSpecifier :: Close , & mut callback) ;
425434 }
426435 _ => {
427436 while let Some ( ( _, Ok ( next_char) ) ) = chars. peek ( ) {
0 commit comments