Skip to content

Commit 762f645

Browse files
committed
review comments
1 parent 86f4f68 commit 762f645

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

Diff for: src/libfmt_macros/lib.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -514,10 +514,6 @@ impl<'a> Parser<'a> {
514514
// Width and precision
515515
let mut havewidth = false;
516516

517-
let mut width_span_start = 0;
518-
if let Some((pos, '0')) = self.cur.peek() {
519-
width_span_start = *pos;
520-
}
521517
if self.consume('0') {
522518
// small ambiguity with '0$' as a format string. In theory this is a
523519
// '0' flag and then an ill-formatted format string with just a '$'
@@ -531,11 +527,11 @@ impl<'a> Parser<'a> {
531527
}
532528
}
533529
if !havewidth {
534-
if width_span_start == 0 {
535-
if let Some((pos, _)) = self.cur.peek() {
536-
width_span_start = *pos;
537-
}
538-
}
530+
let width_span_start = if let Some((pos, _)) = self.cur.peek() {
531+
*pos
532+
} else {
533+
0
534+
};
539535
let (w, sp) = self.count(width_span_start);
540536
spec.width = w;
541537
spec.width_span = sp;

Diff for: src/libsyntax_ext/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ impl<'a, 'b> Context<'a, 'b> {
586586
arg.position.index() == simple_arg.position.index();
587587

588588
if arg.format.precision_span.is_some() || arg.format.width_span.is_some() {
589-
self.arg_with_formatting.push(arg.format); //'liself.fmtsp.from_inner(span));
589+
self.arg_with_formatting.push(arg.format);
590590
}
591591
if !pos_simple || arg.format != simple_arg.format || fill != ' ' {
592592
self.all_pieces_simple = false;

Diff for: src/libsyntax_pos/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1402,6 +1402,7 @@ pub struct MalformedSourceMapPositions {
14021402
pub end_pos: BytePos
14031403
}
14041404

1405+
/// Range inside of a `Span` used for diagnostics when we only have access to relative positions.
14051406
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
14061407
pub struct InnerSpan {
14071408
pub start: usize,

Diff for: src/test/ui/if/ifmt-bad-arg.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@ error: 4 positional arguments in format string, but there are 3 arguments
235235
--> $DIR/ifmt-bad-arg.rs:81:15
236236
|
237237
LL | println!("{} {:07$.*} {}", 1, 3.2, 4);
238-
| ^^ ^^-----^ ^^ --- this parameter corresponds to the precision flag
239-
| | |
240-
| | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
241-
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
238+
| ^^ ^^^----^ ^^ --- this parameter corresponds to the precision flag
239+
| | |
240+
| | this precision flag adds an extra required argument at position 1, which is why there are 4 arguments expected
241+
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
242242
|
243243
= note: positional arguments are zero-based
244244
= 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)
247247
--> $DIR/ifmt-bad-arg.rs:84:18
248248
|
249249
LL | println!("{} {:07$} {}", 1, 3.2, 4);
250-
| ^^---^
251-
| |
252-
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
250+
| ^^^--^
251+
| |
252+
| this width flag expects an `usize` argument at position 7, but there are 3 arguments
253253
|
254254
= note: positional arguments are zero-based
255255
= note: for information about formatting flags, visit https://doc.rust-lang.org/std/fmt/index.html

0 commit comments

Comments
 (0)