review comments
This commit is contained in:
parent
86f4f68b70
commit
762f6452b9
@ -514,10 +514,6 @@ fn format(&mut self) -> FormatSpec<'a> {
|
||||
// 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 '$'
|
||||
@ -531,11 +527,11 @@ fn format(&mut self) -> FormatSpec<'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;
|
||||
|
@ -586,7 +586,7 @@ fn build_piece(
|
||||
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;
|
||||
|
@ -1402,6 +1402,7 @@ pub struct MalformedSourceMapPositions {
|
||||
pub end_pos: BytePos
|
||||
}
|
||||
|
||||
/// Range inside of a `Span` used for diagnostics when we only have access to relative positions.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
pub struct InnerSpan {
|
||||
pub start: usize,
|
||||
|
@ -235,10 +235,10 @@ error: 4 positional arguments in format string, but there are 3 arguments
|
||||
--> $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
|
||||
@ -247,9 +247,9 @@ error: invalid reference to positional argument 7 (there are 3 arguments)
|
||||
--> $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
|
||||
|
Loading…
Reference in New Issue
Block a user