about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser
diff options
context:
space:
mode:
authorLeón Orell Valerian Liehr <me@fmease.dev>2025-03-23 22:00:39 +0100
committerLeón Orell Valerian Liehr <me@fmease.dev>2025-03-24 20:04:23 +0100
commit848b0da34fa20d0ff5d12d1d4f506affc765534b (patch)
treefed3f6166c6cb5d868d3efe8cb7bdb29f3306872 /compiler/rustc_parse/src/parser
parent90f5eab952728ac6edcf529a171f7de5c25e5d49 (diff)
downloadrust-848b0da34fa20d0ff5d12d1d4f506affc765534b.tar.gz
rust-848b0da34fa20d0ff5d12d1d4f506affc765534b.zip
Remove fields that are dead since the removal of type ascription syntax
Since `{ ident: ident }` is a parse error, these fields are dead.
Diffstat (limited to 'compiler/rustc_parse/src/parser')
-rw-r--r--compiler/rustc_parse/src/parser/diagnostics.rs25
-rw-r--r--compiler/rustc_parse/src/parser/stmt.rs9
2 files changed, 11 insertions, 23 deletions
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs
index c1cca1186af..daa27b14669 100644
--- a/compiler/rustc_parse/src/parser/diagnostics.rs
+++ b/compiler/rustc_parse/src/parser/diagnostics.rs
@@ -971,18 +971,8 @@ impl<'a> Parser<'a> {
                     // fn foo() -> Foo {
                     //     field: value,
                     // }
-                    // Suggest:
-                    // fn foo() -> Foo { Path {
-                    //     field: value,
-                    // } }
                     let guar = err.delay_as_bug();
                     self.restore_snapshot(snapshot);
-                    let mut tail = self.mk_block(
-                        thin_vec![self.mk_stmt_err(expr.span, guar)],
-                        s,
-                        lo.to(self.prev_token.span),
-                    );
-                    tail.could_be_bare_literal = true;
                     if maybe_struct_name.is_ident() && can_be_struct_literal {
                         // Account for `if Example { a: one(), }.is_pos() {}`.
                         // expand `before` so that we take care of module path such as:
@@ -1004,6 +994,10 @@ impl<'a> Parser<'a> {
                             return None;
                         }
                     } else {
+                        // Suggest:
+                        // fn foo() -> Foo { Path {
+                        //     field: value,
+                        // } }
                         self.dcx().emit_err(StructLiteralBodyWithoutPath {
                             span: expr.span,
                             sugg: StructLiteralBodyWithoutPathSugg {
@@ -1011,7 +1005,11 @@ impl<'a> Parser<'a> {
                                 after: expr.span.shrink_to_hi(),
                             },
                         });
-                        Ok(tail)
+                        Ok(self.mk_block(
+                            thin_vec![self.mk_stmt_err(expr.span, guar)],
+                            s,
+                            lo.to(self.prev_token.span),
+                        ))
                     }
                 }
                 (Err(err), Ok(tail)) => {
@@ -1025,10 +1023,7 @@ impl<'a> Parser<'a> {
                     self.consume_block(exp!(OpenBrace), exp!(CloseBrace), ConsumeClosingDelim::Yes);
                     Err(err)
                 }
-                (Ok(_), Ok(mut tail)) => {
-                    tail.could_be_bare_literal = true;
-                    Ok(tail)
-                }
+                (Ok(_), Ok(tail)) => Ok(tail),
             });
         }
         None
diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs
index 0fe247078d5..368366c60d6 100644
--- a/compiler/rustc_parse/src/parser/stmt.rs
+++ b/compiler/rustc_parse/src/parser/stmt.rs
@@ -1043,14 +1043,7 @@ impl<'a> Parser<'a> {
         rules: BlockCheckMode,
         span: Span,
     ) -> P<Block> {
-        P(Block {
-            stmts,
-            id: DUMMY_NODE_ID,
-            rules,
-            span,
-            tokens: None,
-            could_be_bare_literal: false,
-        })
+        P(Block { stmts, id: DUMMY_NODE_ID, rules, span, tokens: None })
     }
 
     pub(super) fn mk_stmt(&self, span: Span, kind: StmtKind) -> Stmt {