This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
compiler/rustc_parse_format/src Expand file tree Collapse file tree 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> {
572572 // '0' flag and then an ill-formatted format string with just a '$'
573573 // and no count, but this is better if we instead interpret this as
574574 // no '0' flag and '0$' as the width instead.
575- if self . consume ( '$' ) {
575+ if let Some ( end ) = self . consume_pos ( '$' ) {
576576 spec. width = CountIsParam ( 0 ) ;
577577 havewidth = true ;
578+ spec. width_span = Some ( self . to_span_index ( end - 1 ) . to ( self . to_span_index ( end + 1 ) ) ) ;
578579 } else {
579580 spec. flags |= 1 << ( FlagSignAwareZeroPad as u32 ) ;
580581 }
Original file line number Diff line number Diff line change @@ -178,6 +178,23 @@ fn format_counts() {
178178 } ,
179179 } ) ] ,
180180 ) ;
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+ ) ;
181198 same (
182199 "{:.*x}" ,
183200 & [ NextArgument ( Argument {
You can’t perform that action at this time.
0 commit comments