// Width and precision
let mut havewidth = false;
- let mut width_span_start = 0;
- if let Some((pos, '0')) = self.cur.peek() {
- width_span_start = *pos;
- }
if self.consume('0') {
// small ambiguity with '0$' as a format string. In theory this is a
// '0' flag and then an ill-formatted format string with just a '$'
}
}
if !havewidth {
- if width_span_start == 0 {
- if let Some((pos, _)) = self.cur.peek() {
- width_span_start = *pos;
- }
- }
+ let width_span_start = if let Some((pos, _)) = self.cur.peek() {
+ *pos
+ } else {
+ 0
+ };
let (w, sp) = self.count(width_span_start);
spec.width = w;
spec.width_span = sp;
arg.position.index() == simple_arg.position.index();
if arg.format.precision_span.is_some() || arg.format.width_span.is_some() {
- self.arg_with_formatting.push(arg.format); //'liself.fmtsp.from_inner(span));
+ self.arg_with_formatting.push(arg.format);
}
if !pos_simple || arg.format != simple_arg.format || fill != ' ' {
self.all_pieces_simple = false;
--> $DIR/ifmt-bad-arg.rs:81:15
|
LL | println!("{} {:07$.*} {}", 1, 3.2, 4);
- | ^^ ^^-----^ ^^ --- this parameter corresponds to the precision flag
- | | |
- | | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
- | this width flag expects an `usize` argument at position 7, but there are 3 arguments
+ | ^^ ^^^----^ ^^ --- this parameter corresponds to the precision flag
+ | | |
+ | | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
+ | this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html
--> $DIR/ifmt-bad-arg.rs:84:18
|
LL | println!("{} {:07$} {}", 1, 3.2, 4);
- | ^^---^
- | |
- | this width flag expects an `usize` argument at position 7, but there are 3 arguments
+ | ^^^--^
+ | |
+ | this width flag expects an `usize` argument at position 7, but there are 3 arguments
|
= note: positional arguments are zero-based
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html