]> git.lizzy.rs Git - rust.git/commit
Identify when a stmt could have been parsed as an expr
authorEsteban Küber <esteban@kuber.com.ar>
Tue, 23 Apr 2019 02:37:23 +0000 (19:37 -0700)
committerEsteban Küber <esteban@kuber.com.ar>
Mon, 29 Apr 2019 21:07:02 +0000 (14:07 -0700)
commitf007e6f442adafae3e5f2f7f635dc12463bbe0bb
tree7b48de502fcceeefbb8b6767455aa1d7248e4c3e
parenta55c2eb325029960991508e64650a139b040d24f
Identify when a stmt could have been parsed as an expr

There are some expressions that can be parsed as a statement without
a trailing semicolon depending on the context, which can lead to
confusing errors due to the same looking code being accepted in some
places and not others. Identify these cases and suggest enclosing in
parenthesis making the parse non-ambiguous without changing the
accepted grammar.
src/librustc_typeck/check/mod.rs
src/libsyntax/parse/lexer/mod.rs
src/libsyntax/parse/mod.rs
src/libsyntax/parse/parser.rs
src/libsyntax/util/parser.rs
src/test/ui/parser/expr-as-stmt.fixed [new file with mode: 0644]
src/test/ui/parser/expr-as-stmt.rs [new file with mode: 0644]
src/test/ui/parser/expr-as-stmt.stderr [new file with mode: 0644]
src/test/ui/parser/match-arrows-block-then-binop.rs
src/test/ui/parser/match-arrows-block-then-binop.stderr