Remove fields that are dead since the removal of type ascription syntax
Since `{ ident: ident }` is a parse error, these fields are dead.
This commit is contained in:
parent
90f5eab952
commit
848b0da34f
13 changed files with 13 additions and 66 deletions
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue