diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2018-06-08 17:20:57 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-06-08 17:20:57 -0600 |
| commit | 71865fb94753da6e4eff4de5e5ddc165d87e8ff4 (patch) | |
| tree | e17ecd771f935a3172d562224ea781cb4d47be4d /src | |
| parent | 91b6842dc9b795cdee9bfe552f42cdd463e1a8dd (diff) | |
| parent | df0c6a97b4a7897931c6e4b21b9f4398272d552e (diff) | |
| download | rust-71865fb94753da6e4eff4de5e5ddc165d87e8ff4.tar.gz rust-71865fb94753da6e4eff4de5e5ddc165d87e8ff4.zip | |
Rollup merge of #51099 - Crazycolorz5:expectedcloseparen, r=estebank
Fix Issue 38777 When looking through for a closing bracket in the loop condition, adds them to expecteds. https://github.com/rust-lang/rust/issues/38777
Diffstat (limited to 'src')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 9 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-39616.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/resolve/token-error-correct-3.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/similar-tokens.rs | 2 | ||||
| -rw-r--r-- | src/test/ui/similar-tokens.stderr | 6 | ||||
| -rw-r--r-- | src/test/ui/token/issue-10636-2.stderr | 4 | ||||
| -rw-r--r-- | src/test/ui/tuple-struct-fields/test.rs (renamed from src/test/compile-fail/privacy/restricted/tuple-struct-fields/test.rs) | 2 | ||||
| -rw-r--r-- | src/test/ui/tuple-struct-fields/test.stderr | 20 | ||||
| -rw-r--r-- | src/test/ui/tuple-struct-fields/test2.rs (renamed from src/test/compile-fail/privacy/restricted/tuple-struct-fields/test2.rs) | 2 | ||||
| -rw-r--r-- | src/test/ui/tuple-struct-fields/test2.stderr | 11 | ||||
| -rw-r--r-- | src/test/ui/tuple-struct-fields/test3.rs (renamed from src/test/compile-fail/privacy/restricted/tuple-struct-fields/test3.rs) | 2 | ||||
| -rw-r--r-- | src/test/ui/tuple-struct-fields/test3.stderr | 11 |
12 files changed, 61 insertions, 14 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index ebb53335da3..dd3559798ec 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -652,7 +652,7 @@ impl<'a> Parser<'a> { Err(err) } } else { - self.expect_one_of(unsafe { slice::from_raw_parts(t, 1) }, &[]) + self.expect_one_of(slice::from_ref(t), &[]) } } @@ -1108,7 +1108,12 @@ impl<'a> Parser<'a> { { let mut first: bool = true; let mut v = vec![]; - while !kets.contains(&&self.token) { + while !kets.iter().any(|k| { + match expect { + TokenExpectType::Expect => self.check(k), + TokenExpectType::NoExpect => self.token == **k, + } + }) { match self.token { token::CloseDelim(..) | token::Eof => break, _ => {} diff --git a/src/test/compile-fail/issue-39616.rs b/src/test/compile-fail/issue-39616.rs index d601249c036..13b4c0896e7 100644 --- a/src/test/compile-fail/issue-39616.rs +++ b/src/test/compile-fail/issue-39616.rs @@ -9,7 +9,7 @@ // except according to those terms. fn foo(a: [0; 1]) {} //~ ERROR expected type, found `0` -//~| ERROR expected one of `->`, `where`, or `{`, found `]` +//~| ERROR expected one of `)`, `,`, `->`, `where`, or `{`, found `]` // FIXME(jseyfried): avoid emitting the second error (preexisting) fn main() {} diff --git a/src/test/ui/resolve/token-error-correct-3.stderr b/src/test/ui/resolve/token-error-correct-3.stderr index 284acd20ba5..24186d94acc 100644 --- a/src/test/ui/resolve/token-error-correct-3.stderr +++ b/src/test/ui/resolve/token-error-correct-3.stderr @@ -10,11 +10,11 @@ note: unclosed delimiter LL | callback(path.as_ref(); //~ ERROR expected one of | ^ -error: expected one of `,`, `.`, `?`, or an operator, found `;` +error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;` --> $DIR/token-error-correct-3.rs:24:35 | LL | callback(path.as_ref(); //~ ERROR expected one of - | ^ expected one of `,`, `.`, `?`, or an operator here + | ^ expected one of `)`, `,`, `.`, `?`, or an operator here error: expected one of `.`, `;`, `?`, `}`, or an operator, found `)` --> $DIR/token-error-correct-3.rs:30:9 diff --git a/src/test/ui/similar-tokens.rs b/src/test/ui/similar-tokens.rs index eb7eab9e42d..350a2262391 100644 --- a/src/test/ui/similar-tokens.rs +++ b/src/test/ui/similar-tokens.rs @@ -14,6 +14,6 @@ mod x { } // `.` is similar to `,` so list parsing should continue to closing `}` -use x::{A. B}; //~ ERROR expected one of `,`, `::`, or `as`, found `.` +use x::{A. B}; //~ ERROR expected one of `,`, `::`, `as`, or `}`, found `.` fn main() {} diff --git a/src/test/ui/similar-tokens.stderr b/src/test/ui/similar-tokens.stderr index fe157b99e65..90acc56cbc9 100644 --- a/src/test/ui/similar-tokens.stderr +++ b/src/test/ui/similar-tokens.stderr @@ -1,8 +1,8 @@ -error: expected one of `,`, `::`, or `as`, found `.` +error: expected one of `,`, `::`, `as`, or `}`, found `.` --> $DIR/similar-tokens.rs:17:10 | -LL | use x::{A. B}; //~ ERROR expected one of `,`, `::`, or `as`, found `.` - | ^ expected one of `,`, `::`, or `as` here +LL | use x::{A. B}; //~ ERROR expected one of `,`, `::`, `as`, or `}`, found `.` + | ^ expected one of `,`, `::`, `as`, or `}` here error: aborting due to previous error diff --git a/src/test/ui/token/issue-10636-2.stderr b/src/test/ui/token/issue-10636-2.stderr index 56a30423171..6c0053f2f85 100644 --- a/src/test/ui/token/issue-10636-2.stderr +++ b/src/test/ui/token/issue-10636-2.stderr @@ -10,11 +10,11 @@ note: unclosed delimiter LL | option.map(|some| 42; | ^ -error: expected one of `,`, `.`, `?`, or an operator, found `;` +error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;` --> $DIR/issue-10636-2.rs:15:25 | LL | option.map(|some| 42; - | ^ expected one of `,`, `.`, `?`, or an operator here + | ^ expected one of `)`, `,`, `.`, `?`, or an operator here error: expected expression, found `)` --> $DIR/issue-10636-2.rs:18:1 diff --git a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test.rs b/src/test/ui/tuple-struct-fields/test.rs index d4ea76d6c26..22d54a38340 100644 --- a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test.rs +++ b/src/test/ui/tuple-struct-fields/test.rs @@ -12,6 +12,6 @@ mod foo { type T = (); struct S1(pub(in foo) (), pub(T), pub(crate) (), pub(((), T))); struct S2(pub((foo)) ()); - //~^ ERROR expected `,`, found `(` + //~^ ERROR expected one of `)` or `,`, found `(` //~| ERROR cannot find type `foo` in this scope } diff --git a/src/test/ui/tuple-struct-fields/test.stderr b/src/test/ui/tuple-struct-fields/test.stderr new file mode 100644 index 00000000000..59228ea8c14 --- /dev/null +++ b/src/test/ui/tuple-struct-fields/test.stderr @@ -0,0 +1,20 @@ +error: expected one of `)` or `,`, found `(` + --> $DIR/test.rs:14:26 + | +LL | struct S2(pub((foo)) ()); + | ^ expected one of `)` or `,` here + +error[E0412]: cannot find type `foo` in this scope + --> $DIR/test.rs:14:20 + | +LL | struct S2(pub((foo)) ()); + | ^^^ not found in this scope + +error[E0601]: `main` function not found in crate `test` + | + = note: consider adding a `main` function to `$DIR/test.rs` + +error: aborting due to 3 previous errors + +Some errors occurred: E0412, E0601. +For more information about an error, try `rustc --explain E0412`. diff --git a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test2.rs b/src/test/ui/tuple-struct-fields/test2.rs index fed9432c6a0..eead027cb13 100644 --- a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test2.rs +++ b/src/test/ui/tuple-struct-fields/test2.rs @@ -13,7 +13,7 @@ macro_rules! define_struct { struct S1(pub $t); struct S2(pub (in foo) ()); struct S3(pub $t ()); - //~^ ERROR expected `,`, found `(` + //~^ ERROR expected one of `)` or `,`, found `(` } } diff --git a/src/test/ui/tuple-struct-fields/test2.stderr b/src/test/ui/tuple-struct-fields/test2.stderr new file mode 100644 index 00000000000..983e74772ac --- /dev/null +++ b/src/test/ui/tuple-struct-fields/test2.stderr @@ -0,0 +1,11 @@ +error: expected one of `)` or `,`, found `(` + --> $DIR/test2.rs:15:26 + | +LL | struct S3(pub $t ()); + | ^ expected one of `)` or `,` here +... +LL | define_struct! { (foo) } + | ------------------------ in this macro invocation + +error: aborting due to previous error + diff --git a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test3.rs b/src/test/ui/tuple-struct-fields/test3.rs index dd2cb0e2184..d666c8abd3c 100644 --- a/src/test/compile-fail/privacy/restricted/tuple-struct-fields/test3.rs +++ b/src/test/ui/tuple-struct-fields/test3.rs @@ -13,7 +13,7 @@ macro_rules! define_struct { struct S1(pub($t)); struct S2(pub (in foo) ()); struct S3(pub($t) ()); - //~^ ERROR expected `,`, found `(` + //~^ ERROR expected one of `)` or `,`, found `(` } } diff --git a/src/test/ui/tuple-struct-fields/test3.stderr b/src/test/ui/tuple-struct-fields/test3.stderr new file mode 100644 index 00000000000..6738595b997 --- /dev/null +++ b/src/test/ui/tuple-struct-fields/test3.stderr @@ -0,0 +1,11 @@ +error: expected one of `)` or `,`, found `(` + --> $DIR/test3.rs:15:27 + | +LL | struct S3(pub($t) ()); + | ^ expected one of `)` or `,` here +... +LL | define_struct! { foo } + | ---------------------- in this macro invocation + +error: aborting due to previous error + |
