check if snippet is )
This commit is contained in:
parent
13471d3b20
commit
871ee18086
@ -1210,8 +1210,13 @@ impl<'a> Parser<'a> {
|
|||||||
// `Enum::Foo { a: 3, b: 4 }` or `Enum::Foo(3, 4)`.
|
// `Enum::Foo { a: 3, b: 4 }` or `Enum::Foo(3, 4)`.
|
||||||
self.restore_snapshot(snapshot);
|
self.restore_snapshot(snapshot);
|
||||||
let close_paren = self.prev_token.span;
|
let close_paren = self.prev_token.span;
|
||||||
let span = lo.to(self.prev_token.span);
|
let span = lo.to(close_paren);
|
||||||
if !fields.is_empty() {
|
if !fields.is_empty() &&
|
||||||
|
// `token.kind` should not be compared here.
|
||||||
|
// This is because the `snapshot.token.kind` is treated as the same as
|
||||||
|
// that of the open delim in `TokenTreesReader::parse_token_tree`, even if they are different.
|
||||||
|
self.span_to_snippet(close_paren).map_or(false, |snippet| snippet == ")")
|
||||||
|
{
|
||||||
let mut replacement_err = errors::ParenthesesWithStructFields {
|
let mut replacement_err = errors::ParenthesesWithStructFields {
|
||||||
span,
|
span,
|
||||||
r#type: path,
|
r#type: path,
|
||||||
|
3
tests/ui/parser/issue-107705.rs
Normal file
3
tests/ui/parser/issue-107705.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
// compile-flags: -C debug-assertions
|
||||||
|
|
||||||
|
fn f() {a(b:&, //~ ERROR this file contains an unclosed delimiter
|
10
tests/ui/parser/issue-107705.stderr
Normal file
10
tests/ui/parser/issue-107705.stderr
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
error: this file contains an unclosed delimiter
|
||||||
|
--> $DIR/issue-107705.rs:3:67
|
||||||
|
|
|
||||||
|
LL | fn f() {a(b:&,
|
||||||
|
| - - unclosed delimiter ^
|
||||||
|
| |
|
||||||
|
| unclosed delimiter
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user