use self.create_snapshot_for_diagnostic
instead of self.clone()
This commit is contained in:
parent
d6f3a4ecb4
commit
201a86046c
@ -1,9 +1,10 @@
|
|||||||
|
use super::diagnostics::SnapshotParser;
|
||||||
use super::pat::{CommaRecoveryMode, RecoverColon, RecoverComma, PARAM_EXPECTED};
|
use super::pat::{CommaRecoveryMode, RecoverColon, RecoverComma, PARAM_EXPECTED};
|
||||||
use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign};
|
use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign};
|
||||||
use super::{
|
use super::{
|
||||||
AttrWrapper, BlockMode, ClosureSpans, ForceCollect, Parser, PathStyle, Restrictions, TokenType,
|
AttrWrapper, BlockMode, ClosureSpans, ForceCollect, Parser, PathStyle, Restrictions,
|
||||||
|
SemiColonMode, SeqSep, TokenExpectType, TokenType, TrailingToken,
|
||||||
};
|
};
|
||||||
use super::{SemiColonMode, SeqSep, TokenExpectType, TrailingToken};
|
|
||||||
use crate::maybe_recover_from_interpolated_ty_qpath;
|
use crate::maybe_recover_from_interpolated_ty_qpath;
|
||||||
|
|
||||||
use ast::token::DelimToken;
|
use ast::token::DelimToken;
|
||||||
@ -1105,7 +1106,7 @@ impl<'a> Parser<'a> {
|
|||||||
let snapshot = if self.token.kind == token::OpenDelim(token::Paren)
|
let snapshot = if self.token.kind == token::OpenDelim(token::Paren)
|
||||||
&& self.look_ahead_type_ascription_as_field()
|
&& self.look_ahead_type_ascription_as_field()
|
||||||
{
|
{
|
||||||
Some((self.clone(), fun.kind.clone()))
|
Some((self.create_snapshot_for_diagnostic(), fun.kind.clone()))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
@ -1130,7 +1131,7 @@ impl<'a> Parser<'a> {
|
|||||||
lo: Span,
|
lo: Span,
|
||||||
open_paren: Span,
|
open_paren: Span,
|
||||||
seq: &mut PResult<'a, P<Expr>>,
|
seq: &mut PResult<'a, P<Expr>>,
|
||||||
snapshot: Option<(Self, ExprKind)>,
|
snapshot: Option<(SnapshotParser<'a>, ExprKind)>,
|
||||||
) -> Option<P<Expr>> {
|
) -> Option<P<Expr>> {
|
||||||
match (seq.as_mut(), snapshot) {
|
match (seq.as_mut(), snapshot) {
|
||||||
(Err(err), Some((mut snapshot, ExprKind::Path(None, path)))) => {
|
(Err(err), Some((mut snapshot, ExprKind::Path(None, path)))) => {
|
||||||
@ -1140,7 +1141,7 @@ impl<'a> Parser<'a> {
|
|||||||
Ok((fields, ..)) if snapshot.eat(&token::CloseDelim(token::Paren)) => {
|
Ok((fields, ..)) if snapshot.eat(&token::CloseDelim(token::Paren)) => {
|
||||||
// We are certain we have `Enum::Foo(a: 3, b: 4)`, suggest
|
// We are certain we have `Enum::Foo(a: 3, b: 4)`, suggest
|
||||||
// `Enum::Foo { a: 3, b: 4 }` or `Enum::Foo(3, 4)`.
|
// `Enum::Foo { a: 3, b: 4 }` or `Enum::Foo(3, 4)`.
|
||||||
*self = 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(self.prev_token.span);
|
||||||
if !fields.is_empty() {
|
if !fields.is_empty() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user