File tree 2 files changed +19
-1
lines changed
compiler/rustc_parse_format/src
2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -572,9 +572,10 @@ impl<'a> Parser<'a> {
572
572
// '0' flag and then an ill-formatted format string with just a '$'
573
573
// and no count, but this is better if we instead interpret this as
574
574
// no '0' flag and '0$' as the width instead.
575
- if self . consume ( '$' ) {
575
+ if let Some ( end ) = self . consume_pos ( '$' ) {
576
576
spec. width = CountIsParam ( 0 ) ;
577
577
havewidth = true ;
578
+ spec. width_span = Some ( self . to_span_index ( end - 1 ) . to ( self . to_span_index ( end + 1 ) ) ) ;
578
579
} else {
579
580
spec. flags |= 1 << ( FlagSignAwareZeroPad as u32 ) ;
580
581
}
Original file line number Diff line number Diff line change @@ -178,6 +178,23 @@ fn format_counts() {
178
178
} ,
179
179
} ) ] ,
180
180
) ;
181
+ same (
182
+ "{1:0$.10x}" ,
183
+ & [ NextArgument ( Argument {
184
+ position : ArgumentIs ( 1 ) ,
185
+ format : FormatSpec {
186
+ fill : None ,
187
+ align : AlignUnknown ,
188
+ flags : 0 ,
189
+ precision : CountIs ( 10 ) ,
190
+ width : CountIsParam ( 0 ) ,
191
+ precision_span : None ,
192
+ width_span : Some ( InnerSpan :: new ( 4 , 6 ) ) ,
193
+ ty : "x" ,
194
+ ty_span : None ,
195
+ } ,
196
+ } ) ] ,
197
+ ) ;
181
198
same (
182
199
"{:.*x}" ,
183
200
& [ NextArgument ( Argument {
You can’t perform that action at this time.
0 commit comments