about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2019-07-29 21:43:54 -0700
committerEsteban Küber <esteban@kuber.com.ar>2019-07-29 21:43:54 -0700
commit762f6452b96d93f4f108bf7101189f2688a9dcde (patch)
tree7002fd74130c00b77536b97047c68db9cf1410a2
parent86f4f68b70fb743d05778e88a44bb1259a03e3df (diff)
downloadrust-762f6452b96d93f4f108bf7101189f2688a9dcde.tar.gz
rust-762f6452b96d93f4f108bf7101189f2688a9dcde.zip
review comments
-rw-r--r--src/libfmt_macros/lib.rs14
-rw-r--r--src/libsyntax_ext/format.rs2
-rw-r--r--src/libsyntax_pos/lib.rs1
-rw-r--r--src/test/ui/if/ifmt-bad-arg.stderr14
4 files changed, 14 insertions, 17 deletions
diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs
index b01c3a4aa7f..4e16ad0ba0e 100644
--- a/src/libfmt_macros/lib.rs
+++ b/src/libfmt_macros/lib.rs
@@ -514,10 +514,6 @@ impl<'a> Parser<'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 @@ impl<'a> Parser<'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;
diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs
index 3e0588d03eb..b9337fd9fab 100644
--- a/src/libsyntax_ext/format.rs
+++ b/src/libsyntax_ext/format.rs
@@ -586,7 +586,7 @@ impl<'a, 'b> Context<'a, 'b> {
                     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;
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs
index e5f0892b37b..6a8fca2a28c 100644
--- a/src/libsyntax_pos/lib.rs
+++ b/src/libsyntax_pos/lib.rs
@@ -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,
diff --git a/src/test/ui/if/ifmt-bad-arg.stderr b/src/test/ui/if/ifmt-bad-arg.stderr
index 0de0c53f536..336ea2254bf 100644
--- a/src/test/ui/if/ifmt-bad-arg.stderr
+++ b/src/test/ui/if/ifmt-bad-arg.stderr
@@ -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