Remove Path::is_ident.

It checks that a path has a single segment that matches the given
symbol, and that there are zero generic arguments. It has a single use.

We also have `impl PartialEq<Symbol> for Path` which does exactly the
same thing *except* it doesn't check for zero generic arguments, which
seems like an oversight. It has numerous uses.

This commit removes `Path::is_ident`, adds a test for zero generic
arguments to `PartialEq<Symbol> for Path`, and changes the single use of
`is_ident` to instead use `==`.
This commit is contained in:
Nicholas Nethercote
2025-06-03 15:21:33 +10:00
parent 99e7c15e81
commit 04391045d0
2 changed files with 10 additions and 14 deletions

View File

@@ -834,7 +834,7 @@ impl<'a> Parser<'a> {
// guides recovery in case we write `&raw expr`.
if borrow_kind == ast::BorrowKind::Ref
&& mutbl == ast::Mutability::Not
&& matches!(&expr.kind, ExprKind::Path(None, p) if p.is_ident(kw::Raw))
&& matches!(&expr.kind, ExprKind::Path(None, p) if *p == kw::Raw)
{
self.expected_token_types.insert(TokenType::KwMut);
self.expected_token_types.insert(TokenType::KwConst);