Rollup merge of #88553 - theo-lw:issue-88276, r=estebank
Improve diagnostics for unary plus operators (#88276) This pull request improves the diagnostics emitted on parsing a unary plus operator. See #88276. Before: ``` error: expected expression, found `+` --> src/main.rs:2:13 | 2 | let x = +1; | ^ expected expression ``` After: ``` error: leading `+` is not supported --> main.rs:2:13 | 2 | let x = +1; | ^ | | | unexpected `+` | help: try removing the `+` ```
This commit is contained in:
commit
77ac329a08
9 changed files with 105 additions and 6 deletions
|
@ -586,6 +586,13 @@ impl Token {
|
|||
self.is_non_raw_ident_where(|id| id.name.is_bool_lit())
|
||||
}
|
||||
|
||||
pub fn is_numeric_lit(&self) -> bool {
|
||||
matches!(
|
||||
self.kind,
|
||||
Literal(Lit { kind: LitKind::Integer, .. }) | Literal(Lit { kind: LitKind::Float, .. })
|
||||
)
|
||||
}
|
||||
|
||||
/// Returns `true` if the token is a non-raw identifier for which `pred` holds.
|
||||
pub fn is_non_raw_ident_where(&self, pred: impl FnOnce(Ident) -> bool) -> bool {
|
||||
match self.ident() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue