]> git.lizzy.rs Git - rust.git/commit
auto merge of #8418 : pnkfelix/rust/fsk-issue3192-improve-parse-error-for-empty-struc...
authorbors <bors@rust-lang.org>
Mon, 12 Aug 2013 07:32:11 +0000 (00:32 -0700)
committerbors <bors@rust-lang.org>
Mon, 12 Aug 2013 07:32:11 +0000 (00:32 -0700)
commitde48274c50952dc629914e33d8b65ba222c1e093
tree99a839b77545858f03063ea02aea76a0c2445547
parent1785841a5b8d33f13a7d90495213ce67c41b680e
parenteee044734c55bcdc540e334d6edc8cb7d7a040d7
auto merge of #8418 : pnkfelix/rust/fsk-issue3192-improve-parse-error-for-empty-struct-init, r=pcwalton,me

Fix #3192.  r? anyone

There are 4 different new tests, to check some different scenarios for
what the parse context is at the time of recovery, becasue our
compile-fail infrastructure does not appear to handle verifying
error-recovery situations.

Differentiate between unit-like struct definition item and unit-like
struct construction in the error message.

----

More generally, outlines a more generic strategy for parse error
recovery: By committing to an expression/statement at set points in
the parser, we can then do some look-ahead to catch common mistakes
and skip over them.

One detail about this strategy is that you want to avoid emitting the
"helpful" message unless the input is reasonably close to the case of
interest.  (E.g. do not warn about a potential unit struct for an
input of the form `let hmm = do foo { } { };`)

To accomplish this, I added (partial) last_token tracking; used for
`commit_stmt` support.

The check_for_erroneous_unit_struct_expecting fn returns bool to
signal whether it "made progress"; currently unused; this is meant for
use to compose several such recovery checks together in a loop.
src/libsyntax/parse/parser.rs