Skip to content

Commit d160a4e

Browse files
committed
syntax::parse: don't depend on syntax::ext
1 parent 7ec38a9 commit d160a4e

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

src/libsyntax/parse/parser/expr.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,4 +1946,8 @@ impl<'a> Parser<'a> {
19461946
crate fn mk_expr(&self, span: Span, kind: ExprKind, attrs: ThinVec<Attribute>) -> P<Expr> {
19471947
P(Expr { kind, span, attrs, id: DUMMY_NODE_ID })
19481948
}
1949+
1950+
pub(super) fn mk_expr_err(&self, span: Span) -> P<Expr> {
1951+
self.mk_expr(span, ExprKind::Err, ThinVec::new())
1952+
}
19491953
}

src/libsyntax/parse/parser/item.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use crate::ast::{PathSegment, IsAuto, Constness, IsAsync, Unsafety, Defaultness}
99
use crate::ast::{Visibility, VisibilityKind, Mutability, FnHeader, ForeignItem, ForeignItemKind};
1010
use crate::ast::{Ty, TyKind, Generics, GenericBounds, TraitRef, EnumDef, VariantData, StructField};
1111
use crate::ast::{Mac, MacDelimiter, Block, BindingMode, FnDecl, MethodSig, SelfKind, Param};
12-
use crate::ext::base::DummyResult;
1312
use crate::parse::token;
1413
use crate::parse::parser::maybe_append;
1514
use crate::tokenstream::{TokenTree, TokenStream};
@@ -606,7 +605,7 @@ impl<'a> Parser<'a> {
606605
let ty_second = if self.token == token::DotDot {
607606
// We need to report this error after `cfg` expansion for compatibility reasons
608607
self.bump(); // `..`, do not add it to expected tokens
609-
Some(DummyResult::raw_ty(self.prev_span, true))
608+
Some(self.mk_ty(self.prev_span, TyKind::Err))
610609
} else if has_for || self.token.can_begin_type() {
611610
Some(self.parse_ty()?)
612611
} else {

src/libsyntax/parse/parser/stmt.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::ptr::P;
88
use crate::{maybe_whole, ThinVec};
99
use crate::ast::{self, DUMMY_NODE_ID, Stmt, StmtKind, Local, Block, BlockCheckMode, Expr, ExprKind};
1010
use crate::ast::{Attribute, AttrStyle, VisibilityKind, MacStmtStyle, Mac, MacDelimiter};
11-
use crate::ext::base::DummyResult;
1211
use crate::parse::{classify, DirectoryOwnership};
1312
use crate::parse::token;
1413
use crate::source_map::{respan, Span};
@@ -400,7 +399,7 @@ impl<'a> Parser<'a> {
400399
self.recover_stmt_(SemiColonMode::Ignore, BlockMode::Ignore);
401400
Some(Stmt {
402401
id: DUMMY_NODE_ID,
403-
kind: StmtKind::Expr(DummyResult::raw_expr(self.token.span, true)),
402+
kind: StmtKind::Expr(self.mk_expr_err(self.token.span)),
404403
span: self.token.span,
405404
})
406405
}
@@ -443,7 +442,7 @@ impl<'a> Parser<'a> {
443442
self.recover_stmt();
444443
// Don't complain about type errors in body tail after parse error (#57383).
445444
let sp = expr.span.to(self.prev_span);
446-
stmt.kind = StmtKind::Expr(DummyResult::raw_expr(sp, true));
445+
stmt.kind = StmtKind::Expr(self.mk_expr_err(sp));
447446
}
448447
}
449448
}

src/libsyntax/parse/parser/ty.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ impl<'a> Parser<'a> {
210210
};
211211

212212
let span = lo.to(self.prev_span);
213-
let ty = P(Ty { kind, span, id: ast::DUMMY_NODE_ID });
213+
let ty = self.mk_ty(span, kind);
214214

215215
// Try to recover from use of `+` with incorrect priority.
216216
self.maybe_report_ambiguous_plus(allow_plus, impl_dyn_multi, &ty);
@@ -448,4 +448,8 @@ impl<'a> Parser<'a> {
448448
self.span_bug(self.token.span, "not a lifetime")
449449
}
450450
}
451+
452+
pub(super) fn mk_ty(&self, span: Span, kind: TyKind) -> P<Ty> {
453+
P(Ty { kind, span, id: ast::DUMMY_NODE_ID })
454+
}
451455
}

0 commit comments

Comments
 (0)