]> git.lizzy.rs Git - rust.git/commitdiff
repairing broken error message and rustfix application for the new test
authorAurélien Deharbe <aurelien.deharbe@ssi.gouv.fr>
Fri, 11 Sep 2020 15:31:52 +0000 (17:31 +0200)
committerAurélien Deharbe <aurelien.deharbe@ssi.gouv.fr>
Fri, 11 Sep 2020 15:31:52 +0000 (17:31 +0200)
case

compiler/rustc_parse/src/parser/mod.rs
src/test/ui/issue-76597.fixed [new file with mode: 0644]
src/test/ui/issue-76597.rs
src/test/ui/issue-76597.stderr

index 5eefae3af60e9b9d47819b713764f1d497589c22..7340c5744808c4325c93a3e6469a5a98f5617345 100644 (file)
@@ -694,9 +694,13 @@ fn parse_seq_to_before_tokens<T>(
                                 Ok(t) => {
                                     // Parsed successfully, therefore most probably the code only
                                     // misses a separator.
+                                    let mut exp_span = self.sess.source_map().next_point(sp);
+                                    if self.sess.source_map().is_multiline(exp_span) {
+                                        exp_span = sp;
+                                    }
                                     expect_err
                                         .span_suggestion_short(
-                                            self.sess.source_map().next_point(sp),
+                                            exp_span,
                                             &format!("missing `{}`", token_str),
                                             token_str,
                                             Applicability::MaybeIncorrect,
diff --git a/src/test/ui/issue-76597.fixed b/src/test/ui/issue-76597.fixed
new file mode 100644 (file)
index 0000000..2d7a30b
--- /dev/null
@@ -0,0 +1,11 @@
+// run-rustfix
+
+#![allow(dead_code)]
+#![allow(unused_variables)]
+fn f(
+                                     x: u8,
+                                     y: u8,
+) {}
+//~^^ ERROR: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `y`
+
+fn main() {}
index 879e6b49e9b771201f5b779d2e1cc404cefa18c7..521b9c64b1c5714bcf8bdf84f629bb1163f5c3bf 100644 (file)
@@ -1,3 +1,7 @@
+// run-rustfix
+
+#![allow(dead_code)]
+#![allow(unused_variables)]
 fn f(
                                      x: u8
                                      y: u8,
index 163ce61cb18e39f0dfbe9192e8d44fcb7218ac99..50b23329f0cebd2f8400354675514ba9fd844d0f 100644 (file)
@@ -1,14 +1,13 @@
 error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `y`
-  --> $DIR/issue-76597.rs:3:38
+  --> $DIR/issue-76597.rs:7:38
    |
-LL |   ...                   x: u8
-   |                              - expected one of 7 possible tokens
-   |  ____________________________|
-   | |
-LL | | ...                   y: u8,
-|  | |                       ^ unexpected token
-|  | |
-   |   help: missing `,`
+LL | ...                   x: u8
+   |                            -
+   |                            |
+   |                            expected one of 7 possible tokens
+   |                            help: missing `,`
+LL | ...                   y: u8,
+   |                       ^ unexpected token
 
 error: aborting due to previous error