1
Fork 0

Add diagnostic width span when '0$' is used as width.

This commit is contained in:
miam-miam100 2022-07-19 22:25:26 +01:00
parent 29c5a028b0
commit 62187b12c2
No known key found for this signature in database
GPG key ID: 0C3730101953F7DD
2 changed files with 19 additions and 1 deletions

View file

@ -572,9 +572,10 @@ impl<'a> Parser<'a> {
// '0' flag and then an ill-formatted format string with just a '$'
// and no count, but this is better if we instead interpret this as
// no '0' flag and '0$' as the width instead.
if self.consume('$') {
if let Some(end) = self.consume_pos('$') {
spec.width = CountIsParam(0);
havewidth = true;
spec.width_span = Some(self.to_span_index(end - 1).to(self.to_span_index(end + 1)));
} else {
spec.flags |= 1 << (FlagSignAwareZeroPad as u32);
}