File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed
compiler/rustc_parse/src/parser Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -1210,8 +1210,13 @@ impl<'a> Parser<'a> {
12101210 // `Enum::Foo { a: 3, b: 4 }` or `Enum::Foo(3, 4)`.
12111211 self . restore_snapshot ( snapshot) ;
12121212 let close_paren = self . prev_token . span ;
1213- let span = lo. to ( self . prev_token . span ) ;
1214- if !fields. is_empty ( ) {
1213+ let span = lo. to ( close_paren) ;
1214+ if !fields. is_empty ( ) &&
1215+ // `token.kind` should not be compared here.
1216+ // This is because the `snapshot.token.kind` is treated as the same as
1217+ // that of the open delim in `TokenTreesReader::parse_token_tree`, even if they are different.
1218+ self . span_to_snippet ( close_paren) . map_or ( false , |snippet| snippet == ")" )
1219+ {
12151220 let mut replacement_err = errors:: ParenthesesWithStructFields {
12161221 span,
12171222 r#type : path,
Original file line number Diff line number Diff line change 1+ // compile-flags: -C debug-assertions
2+
3+ fn f( ) { a( b: & , //~ ERROR this file contains an unclosed delimiter
Original file line number Diff line number Diff line change 1+ error: this file contains an unclosed delimiter
2+ --> $DIR/issue-107705.rs:3:67
3+ |
4+ LL | fn f() {a(b:&,
5+ | - - unclosed delimiter ^
6+ | |
7+ | unclosed delimiter
8+
9+ error: aborting due to previous error
10+
You can’t perform that action at this time.
0 commit comments