about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-10-28 03:02:17 +0000
committerbors <bors@rust-lang.org>2017-10-28 03:02:17 +0000
commitc1a0b6d9eb888ded9a7204db0d67d62b1cdc9944 (patch)
tree0e5481df011f16a6a64164344cdd089227f6dab6 /src/test
parentd9f124965551e8fb9403def6a715e13dfd5e9c95 (diff)
parentae6a9e6fd2a7138d04c03e2a30458d7ebcc68627 (diff)
downloadrust-c1a0b6d9eb888ded9a7204db0d67d62b1cdc9944.tar.gz
rust-c1a0b6d9eb888ded9a7204db0d67d62b1cdc9944.zip
Auto merge of #45503 - thombles:tk/i44339-v5, r=petrochenkov
Improve diagnostics when list of tokens has incorrect separators

Make `parse_seq_to_before_tokens` more resilient to error conditions. Where possible it is better if it can consume up to the final bracket before returning. This change improves the diagnostics in a couple of situations:

```
struct S(pub () ()); // omitted separator
use std::{foo. bar}; // used a similar but wrong separator
```

Fixes #44339
r? @petrochenkov
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/privacy/restricted/tuple-struct-fields/test.rs2
-rw-r--r--src/test/compile-fail/privacy/restricted/tuple-struct-fields/test2.rs1
-rw-r--r--src/test/compile-fail/privacy/restricted/tuple-struct-fields/test3.rs1
-rw-r--r--src/test/ui/similar-tokens.rs19
-rw-r--r--src/test/ui/similar-tokens.stderr8
5 files changed, 28 insertions, 3 deletions
diff --git a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test.rs b/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test.rs
index d17b604717e..d4ea76d6c26 100644
--- a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test.rs
+++ b/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test.rs
@@ -13,5 +13,5 @@ mod foo {
     struct S1(pub(in foo) (), pub(T), pub(crate) (), pub(((), T)));
     struct S2(pub((foo)) ());
     //~^ ERROR expected `,`, found `(`
-    //~| ERROR expected one of `;` or `where`, found `(`
+    //~| ERROR cannot find type `foo` in this scope
 }
diff --git a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test2.rs b/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test2.rs
index 166d5e27e8d..fed9432c6a0 100644
--- a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test2.rs
+++ b/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test2.rs
@@ -14,7 +14,6 @@ macro_rules! define_struct {
         struct S2(pub (in foo) ());
         struct S3(pub $t ());
         //~^ ERROR expected `,`, found `(`
-        //~| ERROR expected one of `;` or `where`, found `(`
     }
 }
 
diff --git a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test3.rs b/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test3.rs
index edab175f4cd..dd2cb0e2184 100644
--- a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test3.rs
+++ b/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test3.rs
@@ -14,7 +14,6 @@ macro_rules! define_struct {
         struct S2(pub (in foo) ());
         struct S3(pub($t) ());
         //~^ ERROR expected `,`, found `(`
-        //~| ERROR expected one of `;` or `where`, found `(`
     }
 }
 
diff --git a/src/test/ui/similar-tokens.rs b/src/test/ui/similar-tokens.rs
new file mode 100644
index 00000000000..986382bc8ee
--- /dev/null
+++ b/src/test/ui/similar-tokens.rs
@@ -0,0 +1,19 @@
+// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+mod x {
+    pub struct A;
+    pub struct B;
+}
+
+// `.` is similar to `,` so list parsing should continue to closing `}`
+use x::{A. B};
+
+fn main() {}
diff --git a/src/test/ui/similar-tokens.stderr b/src/test/ui/similar-tokens.stderr
new file mode 100644
index 00000000000..cf0ed646db7
--- /dev/null
+++ b/src/test/ui/similar-tokens.stderr
@@ -0,0 +1,8 @@
+error: expected one of `,` or `as`, found `.`
+  --> $DIR/similar-tokens.rs:17:10
+   |
+17 | use x::{A. B};
+   |          ^ expected one of `,` or `as` here
+
+error: aborting due to previous error
+