about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/expr.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-03-04 11:44:02 +0000
committerbors <bors@rust-lang.org>2023-03-04 11:44:02 +0000
commit276b75a843af8822ffe4e395266d9445679a57a4 (patch)
tree73ab77cc1f2e9f7437fec769331f7b7d396310ae /compiler/rustc_parse/src/parser/expr.rs
parent01b7a6a9eac151f82831c402f91894552f5ca36d (diff)
parent0965c7e0a995d7313387f820f84c3f6d469df4a3 (diff)
downloadrust-276b75a843af8822ffe4e395266d9445679a57a4.tar.gz
rust-276b75a843af8822ffe4e395266d9445679a57a4.zip
Auto merge of #108732 - Dylan-DPC:rollup-dy1l8sx, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #108298 (Fix ICE: check if snippet is `)`)
 - #108405 (Lazily compute crate name for consider_optimizing)
 - #108656 (Rustdoc search: Emit an error for unclosed generic)
 - #108660 (Remove ne implementations from strings)
 - #108669 (Allow checking whether a type allows being uninitialized)
 - #108727 (rustc_expand: make proc-macro derive error translatable)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
-rw-r--r--compiler/rustc_parse/src/parser/expr.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs
index b2951e7a184..95a7ca80d5d 100644
--- a/compiler/rustc_parse/src/parser/expr.rs
+++ b/compiler/rustc_parse/src/parser/expr.rs
@@ -1210,8 +1210,13 @@ impl<'a> Parser<'a> {
                         // `Enum::Foo { a: 3, b: 4 }` or `Enum::Foo(3, 4)`.
                         self.restore_snapshot(snapshot);
                         let close_paren = self.prev_token.span;
-                        let span = lo.to(self.prev_token.span);
-                        if !fields.is_empty() {
+                        let span = lo.to(close_paren);
+                        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 {
                                 span,
                                 r#type: path,