syntax::parse: don't depend on syntax::ext
This commit is contained in:
parent
7ec38a9ae3
commit
d160a4e422
@ -1946,4 +1946,8 @@ impl<'a> Parser<'a> {
|
||||
crate fn mk_expr(&self, span: Span, kind: ExprKind, attrs: ThinVec<Attribute>) -> P<Expr> {
|
||||
P(Expr { kind, span, attrs, id: DUMMY_NODE_ID })
|
||||
}
|
||||
|
||||
pub(super) fn mk_expr_err(&self, span: Span) -> P<Expr> {
|
||||
self.mk_expr(span, ExprKind::Err, ThinVec::new())
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ use crate::ast::{PathSegment, IsAuto, Constness, IsAsync, Unsafety, Defaultness}
|
||||
use crate::ast::{Visibility, VisibilityKind, Mutability, FnHeader, ForeignItem, ForeignItemKind};
|
||||
use crate::ast::{Ty, TyKind, Generics, GenericBounds, TraitRef, EnumDef, VariantData, StructField};
|
||||
use crate::ast::{Mac, MacDelimiter, Block, BindingMode, FnDecl, MethodSig, SelfKind, Param};
|
||||
use crate::ext::base::DummyResult;
|
||||
use crate::parse::token;
|
||||
use crate::parse::parser::maybe_append;
|
||||
use crate::tokenstream::{TokenTree, TokenStream};
|
||||
@ -606,7 +605,7 @@ impl<'a> Parser<'a> {
|
||||
let ty_second = if self.token == token::DotDot {
|
||||
// We need to report this error after `cfg` expansion for compatibility reasons
|
||||
self.bump(); // `..`, do not add it to expected tokens
|
||||
Some(DummyResult::raw_ty(self.prev_span, true))
|
||||
Some(self.mk_ty(self.prev_span, TyKind::Err))
|
||||
} else if has_for || self.token.can_begin_type() {
|
||||
Some(self.parse_ty()?)
|
||||
} else {
|
||||
|
@ -8,7 +8,6 @@ use crate::ptr::P;
|
||||
use crate::{maybe_whole, ThinVec};
|
||||
use crate::ast::{self, DUMMY_NODE_ID, Stmt, StmtKind, Local, Block, BlockCheckMode, Expr, ExprKind};
|
||||
use crate::ast::{Attribute, AttrStyle, VisibilityKind, MacStmtStyle, Mac, MacDelimiter};
|
||||
use crate::ext::base::DummyResult;
|
||||
use crate::parse::{classify, DirectoryOwnership};
|
||||
use crate::parse::token;
|
||||
use crate::source_map::{respan, Span};
|
||||
@ -400,7 +399,7 @@ impl<'a> Parser<'a> {
|
||||
self.recover_stmt_(SemiColonMode::Ignore, BlockMode::Ignore);
|
||||
Some(Stmt {
|
||||
id: DUMMY_NODE_ID,
|
||||
kind: StmtKind::Expr(DummyResult::raw_expr(self.token.span, true)),
|
||||
kind: StmtKind::Expr(self.mk_expr_err(self.token.span)),
|
||||
span: self.token.span,
|
||||
})
|
||||
}
|
||||
@ -443,7 +442,7 @@ impl<'a> Parser<'a> {
|
||||
self.recover_stmt();
|
||||
// Don't complain about type errors in body tail after parse error (#57383).
|
||||
let sp = expr.span.to(self.prev_span);
|
||||
stmt.kind = StmtKind::Expr(DummyResult::raw_expr(sp, true));
|
||||
stmt.kind = StmtKind::Expr(self.mk_expr_err(sp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ impl<'a> Parser<'a> {
|
||||
};
|
||||
|
||||
let span = lo.to(self.prev_span);
|
||||
let ty = P(Ty { kind, span, id: ast::DUMMY_NODE_ID });
|
||||
let ty = self.mk_ty(span, kind);
|
||||
|
||||
// Try to recover from use of `+` with incorrect priority.
|
||||
self.maybe_report_ambiguous_plus(allow_plus, impl_dyn_multi, &ty);
|
||||
@ -448,4 +448,8 @@ impl<'a> Parser<'a> {
|
||||
self.span_bug(self.token.span, "not a lifetime")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn mk_ty(&self, span: Span, kind: TyKind) -> P<Ty> {
|
||||
P(Ty { kind, span, id: ast::DUMMY_NODE_ID })
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user