]> git.lizzy.rs Git - rust.git/commit
Improve error message when failing to parse a block
authorJames Miller <james@aatch.net>
Tue, 23 Aug 2016 06:23:31 +0000 (18:23 +1200)
committerJames Miller <james@aatch.net>
Tue, 23 Aug 2016 06:23:31 +0000 (18:23 +1200)
commit72d629caa50fa482dd4165cb43b9fb02ac24c8d8
tree1c140a34db4fa49bd2d6a59150a8cb5faa18e884
parent3c5a0fa45b5e2786b6e64e27f48cd129e7aefdbd
Improve error message when failing to parse a block

We want to catch this error:

```
if (foo)
    bar;
```

as it's valid syntax in other languages, and say how to fix it.
Unfortunately it didn't care if the suggestion made sense and just
highlighted the unexpected token.

Now it attempts to parse a statement, and if it succeeds, it shows the
help message.

Fixes #35907
src/libsyntax/parse/parser.rs
src/test/compile-fail/missing-block-hint.rs [new file with mode: 0644]