]> git.lizzy.rs Git - rust.git/commitdiff
review comments
authorEsteban Küber <esteban@kuber.com.ar>
Tue, 30 Jul 2019 04:43:54 +0000 (21:43 -0700)
committerEsteban Küber <esteban@kuber.com.ar>
Tue, 30 Jul 2019 04:43:54 +0000 (21:43 -0700)
src/libfmt_macros/lib.rs
src/libsyntax_ext/format.rs
src/libsyntax_pos/lib.rs
src/test/ui/if/ifmt-bad-arg.stderr

index b01c3a4aa7f21114f1c25ad8bf89c407c8bd05f3..4e16ad0ba0e0823f753bde065713c1bca8224629 100644 (file)
@@ -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;
index 3e0588d03eb01573c7bbcbfe1254f55b5d294ae4..b9337fd9fab8890418279f0d4eabe53783a0f29d 100644 (file)
@@ -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;
index e5f0892b37be8dcdd726d10a9fadcb461e2deb0e..6a8fca2a28c546a4afe25598f88b5ebae52dfd4c 100644 (file)
@@ -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,
index 0de0c53f5369a38982c0a0f8f9915334e70e57f7..336ea2254bf5a698e90b843c3e0c8a0a97d829d0 100644 (file)
@@ -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