diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-01-30 13:02:06 +0100 | 
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2020-02-13 10:39:24 +0100 | 
| commit | a833be21626890de406e12f2561d2ffbda4aadb4 (patch) | |
| tree | bd75ba7b37902e0ba9d09e775bdd413f9c868201 /src/libsyntax/token.rs | |
| parent | 36a17e4067d2e67223cd9a172476ee5503d6b44b (diff) | |
| download | rust-a833be21626890de406e12f2561d2ffbda4aadb4.tar.gz rust-a833be21626890de406e12f2561d2ffbda4aadb4.zip | |
parser: fuse free `fn` parsing together.
Diffstat (limited to 'src/libsyntax/token.rs')
| -rw-r--r-- | src/libsyntax/token.rs | 8 | 
1 files changed, 5 insertions, 3 deletions
| diff --git a/src/libsyntax/token.rs b/src/libsyntax/token.rs index 3045f147698..862934300e0 100644 --- a/src/libsyntax/token.rs +++ b/src/libsyntax/token.rs @@ -402,12 +402,14 @@ impl Token { /// Returns `true` if the token is any literal, a minus (which can prefix a literal, /// for example a '-42', or one of the boolean idents). + /// + /// Keep this in sync with `Lit::from_token`. pub fn can_begin_literal_or_bool(&self) -> bool { match self.kind { Literal(..) | BinOp(Minus) => true, Ident(name, false) if name.is_bool_lit() => true, - Interpolated(ref nt) => match **nt { - NtLiteral(..) => true, + Interpolated(ref nt) => match &**nt { + NtExpr(e) | NtLiteral(e) => matches!(e.kind, ast::ExprKind::Lit(_)), _ => false, }, _ => false, @@ -530,7 +532,7 @@ impl Token { } /// Returns `true` if the token is a non-raw identifier for which `pred` holds. - fn is_non_raw_ident_where(&self, pred: impl FnOnce(ast::Ident) -> bool) -> bool { + pub fn is_non_raw_ident_where(&self, pred: impl FnOnce(ast::Ident) -> bool) -> bool { match self.ident() { Some((id, false)) => pred(id), _ => false, | 
