-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an AST
Description
Code like this:
pub fn push(&mut self, ch: char) {
if ch as u32 < 0x80 {
// ...
Gives a parse error:
error: expected type, found `0x80`
if ch as u32 < 0x80 {
^~~~
Adding parentheses to disambiguate works around the issue:
pub fn push(&mut self, ch: char) {
if (ch as u32) < 0x80 {
// ...
I understand that u32
is being parsed as a type and so <
is assumed to be the start of type parameters. But maybe when that fails, the parser should backtrack and try to parse <
as an operator?
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an AST