Add some simple error recovery to the parser and fix tests

Some tests just add the extra errors, others I fix by doing some simple error recovery. I've tried to avoid doing too much in the hope of doing something more principled later.

In general error messages are getting worse at this stage, but I think in the long run they will get better.
This commit is contained in:
Nick Cameron 2016-02-01 08:39:50 +13:00
parent 0ef9c5f585
commit ffd2a0b9d7
6 changed files with 69 additions and 49 deletions

View file

@ -12,3 +12,4 @@
fn bar<'a, T>(x: mymodule::X<'a, T, 'b, 'c>) {}
//~^ ERROR lifetime parameters must be declared prior to type parameters
//~^^ ERROR unexpected token

View file

@ -12,8 +12,8 @@
fn foo() { //~ HELP did you mean to close this delimiter?
match Some(x) {
Some(y) { panic!(); }
None { panic!(); }
Some(y) => { panic!(); }
None => { panic!(); }
}
fn bar() {

View file

@ -10,4 +10,5 @@
fn main() {
let Test(&desc[..]) = x; //~ error: expected one of `,` or `@`, found `[`
//~^ ERROR expected one of `:`, `;`, or `=`, found `..`
}

View file

@ -9,5 +9,6 @@
// except according to those terms.
fn main() {
for thing(x[]) {} //~ error: expected one of `,` or `@`, found `[`
for thing(x[]) in foo {} //~ error: expected one of `,` or `@`, found `[`
//~^ ERROR: expected `in`, found `]`
}

View file

@ -1,18 +0,0 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// compile-flags: -Z parse-only
extern {
fn printf(...); //~ ERROR: variadic function must be declared with at least one named argument
fn printf(..., foo: isize); //~ ERROR: `...` must be last in argument list for variadic function
}
fn main() {}