Skip to content

Commit c1df62a

Browse files
committedJun 1, 2018
Add closing bracket expectation to sequences, modified appropriate test cases.
1 parent df40e61 commit c1df62a

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed
 

‎src/libsyntax/parse/parser.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ impl<'a> Parser<'a> {
651651
Err(err)
652652
}
653653
} else {
654-
self.expect_one_of(unsafe { slice::from_raw_parts(t, 1) }, &[])
654+
self.expect_one_of(slice::from_ref(t), &[])
655655
}
656656
}
657657

@@ -1107,7 +1107,12 @@ impl<'a> Parser<'a> {
11071107
{
11081108
let mut first: bool = true;
11091109
let mut v = vec![];
1110-
while !kets.contains(&&self.token) {
1110+
while !kets.iter().any(|k| {
1111+
match expect {
1112+
TokenExpectType::Expect => self.check(k),
1113+
TokenExpectType::NoExpect => self.token == **k,
1114+
}
1115+
}) {
11111116
match self.token {
11121117
token::CloseDelim(..) | token::Eof => break,
11131118
_ => {}

‎src/test/ui/resolve/token-error-correct-3.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ note: unclosed delimiter
1010
LL | callback(path.as_ref(); //~ ERROR expected one of
1111
| ^
1212

13-
error: expected one of `,`, `.`, `?`, or an operator, found `;`
13+
error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;`
1414
--> $DIR/token-error-correct-3.rs:24:35
1515
|
1616
LL | callback(path.as_ref(); //~ ERROR expected one of
17-
| ^ expected one of `,`, `.`, `?`, or an operator here
17+
| ^ expected one of `)`, `,`, `.`, `?`, or an operator here
1818

1919
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `)`
2020
--> $DIR/token-error-correct-3.rs:30:9

‎src/test/ui/similar-tokens.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: expected one of `,`, `::`, or `as`, found `.`
22
--> $DIR/similar-tokens.rs:17:10
33
|
4-
LL | use x::{A. B}; //~ ERROR expected one of `,`, `::`, or `as`, found `.`
5-
| ^ expected one of `,`, `::`, or `as` here
4+
LL | use x::{A. B}; //~ ERROR expected one of `,`, `::`, `as`, or `}`, found `.`
5+
| ^ expected one of `,`, `::`, `as`, or `}` here
66

77
error: aborting due to previous error
88

0 commit comments

Comments
 (0)
Please sign in to comment.