diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7b91c49170068..022de0fe4097c 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -651,7 +651,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), &[]) } } @@ -1107,7 +1107,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 d601249c036b1..13b4c0896e75c 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 284acd20ba5e7..24186d94acce9 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 eb7eab9e42dd7..350a2262391b5 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 fe157b99e65da..90acc56cbc999 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 56a30423171da..6c0053f2f8597 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 similarity index 92% rename from src/test/compile-fail/privacy/restricted/tuple-struct-fields/test.rs rename to src/test/ui/tuple-struct-fields/test.rs index d4ea76d6c2655..22d54a3834073 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 0000000000000..59228ea8c14d2 --- /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 similarity index 92% rename from src/test/compile-fail/privacy/restricted/tuple-struct-fields/test2.rs rename to src/test/ui/tuple-struct-fields/test2.rs index fed9432c6a0e9..eead027cb1351 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 0000000000000..983e74772ac69 --- /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 similarity index 92% rename from src/test/compile-fail/privacy/restricted/tuple-struct-fields/test3.rs rename to src/test/ui/tuple-struct-fields/test3.rs index dd2cb0e218422..d666c8abd3c95 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 0000000000000..6738595b99798 --- /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 +