Skip to content

Commit d1822b3

Browse files
committed
use check_path more
1 parent c0b073b commit d1822b3

File tree

6 files changed

+6
-9
lines changed

6 files changed

+6
-9
lines changed

src/librustc_parse/parser/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ impl<'a> Parser<'a> {
919919
} else if self.eat_lt() {
920920
let (qself, path) = self.parse_qpath(PathStyle::Expr)?;
921921
Ok(self.mk_expr(lo.to(path.span), ExprKind::Path(Some(qself), path), attrs))
922-
} else if self.token.is_path_start() {
922+
} else if self.check_path() {
923923
self.parse_path_start_expr(attrs)
924924
} else if self.check_keyword(kw::Move) || self.check_keyword(kw::Static) {
925925
self.parse_closure_expr(attrs)

src/librustc_parse/parser/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ impl<'a> Parser<'a> {
218218
} else if vis.node.is_pub() && self.isnt_macro_invocation() {
219219
self.recover_missing_kw_before_item()?;
220220
return Ok(None);
221-
} else if macros_allowed && self.token.is_path_start() {
221+
} else if macros_allowed && self.check_path() {
222222
// MACRO INVOCATION ITEM
223223
(Ident::invalid(), ItemKind::Mac(self.parse_item_macro(vis)?))
224224
} else {

src/librustc_parse/parser/pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ impl<'a> Parser<'a> {
704704
}
705705

706706
fn parse_pat_range_end(&mut self) -> PResult<'a, P<Expr>> {
707-
if self.token.is_path_start() {
707+
if self.check_path() {
708708
let lo = self.token.span;
709709
let (qself, path) = if self.eat_lt() {
710710
// Parse a qualified path

src/librustc_parse/parser/stmt.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ impl<'a> Parser<'a> {
4848
self.bump(); // `var`
4949
let msg = "write `let` instead of `var` to introduce a new variable";
5050
self.recover_stmt_local(lo, attrs.into(), msg, "let")?
51-
} else if self.token.is_path_start()
52-
&& !self.token.is_qpath_start()
53-
&& !self.is_path_start_item()
54-
{
51+
} else if self.check_path() && !self.token.is_qpath_start() && !self.is_path_start_item() {
5552
// We have avoided contextual keywords like `union`, items with `crate` visibility,
5653
// or `auto trait` items. We aim to parse an arbitrary path `a::b` but not something
5754
// that starts like a path (1 token), but it fact not a path.

src/librustc_parse/parser/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl<'a> Parser<'a> {
158158
// Qualified path
159159
let (qself, path) = self.parse_qpath(PathStyle::Type)?;
160160
TyKind::Path(Some(qself), path)
161-
} else if self.token.is_path_start() {
161+
} else if self.check_path() {
162162
self.parse_path_start_ty(lo, allow_plus)?
163163
} else if self.eat(&token::DotDotDot) {
164164
if allow_c_variadic == AllowCVariadic::Yes {

src/test/ui/parser/issue-63116.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `;`
1212
LL | impl W <s(f;Y(;]
1313
| ^ expected one of 7 possible tokens
1414

15-
error: expected one of `!`, `&&`, `&`, `(`, `)`, `*`, `+`, `,`, `->`, `...`, `::`, `<`, `>`, `?`, `[`, `_`, `dyn`, `extern`, `fn`, `for`, `impl`, `unsafe`, or lifetime, found `;`
15+
error: expected one of `!`, `&&`, `&`, `(`, `)`, `*`, `+`, `,`, `->`, `...`, `::`, `<`, `>`, `?`, `[`, `_`, `dyn`, `extern`, `fn`, `for`, `impl`, `unsafe`, lifetime, or path, found `;`
1616
--> $DIR/issue-63116.rs:3:15
1717
|
1818
LL | impl W <s(f;Y(;]

0 commit comments

Comments
 (0)