syntax: Make is_path_start precise and improve some error messages about unexpected tokens
This commit is contained in:
parent
6c44bea644
commit
a97f60ee86
25 changed files with 88 additions and 73 deletions
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
|
||||
// error-pattern:unexpected token
|
||||
fn main() {
|
||||
panic!(@);
|
||||
panic!(@); //~ ERROR expected expression, found `@`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,4 +15,4 @@ pub fn trace_option(option: Option<isize>) {
|
|||
option.map(|some| 42; //~ NOTE: unclosed delimiter
|
||||
//~^ ERROR: expected one of
|
||||
} //~ ERROR: incorrect close delimiter
|
||||
//~^ ERROR: unexpected token
|
||||
//~^ ERROR: expected expression, found `)`
|
||||
|
|
|
|||
|
|
@ -13,4 +13,4 @@
|
|||
|
||||
fn main() {
|
||||
let
|
||||
} //~ ERROR unexpected token: `}`
|
||||
} //~ ERROR expected pattern, found `}`
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
// (typeof used because it's surprisingly hard to find an unparsed token after a stmt)
|
||||
macro_rules! m {
|
||||
() => ( i ; typeof ); //~ ERROR `typeof` is a reserved keyword
|
||||
() => ( i ; typeof ); //~ ERROR expected expression, found reserved keyword `typeof`
|
||||
//~| ERROR macro expansion ignores token `typeof`
|
||||
//~| ERROR macro expansion ignores token `;`
|
||||
//~| ERROR macro expansion ignores token `;`
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ macro_rules! ignored_item {
|
|||
}
|
||||
|
||||
macro_rules! ignored_expr {
|
||||
() => ( 1, //~ ERROR unexpected token: `,`
|
||||
() => ( 1, //~ ERROR expected expression, found `,`
|
||||
2 )
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@
|
|||
|
||||
fn main() {
|
||||
let become = 0;
|
||||
//~^ ERROR `become` is a reserved keyword
|
||||
//~^ ERROR expected pattern, found reserved keyword `become`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,10 @@
|
|||
fn main() {
|
||||
foo(bar(; //~ NOTE: unclosed delimiter
|
||||
//~^ NOTE: unclosed delimiter
|
||||
//~^^ ERROR: unexpected token: `;`
|
||||
//~^^ ERROR: expected expression, found `;`
|
||||
//~^^^ ERROR: unresolved name `bar`
|
||||
//~^^^^ ERROR: unresolved name `foo`
|
||||
//~^^^^^ ERROR: expected one of `)`, `,`, `.`, `<`, `?`
|
||||
} //~ ERROR: incorrect close delimiter: `}`
|
||||
//~^ ERROR: incorrect close delimiter: `}`
|
||||
//~^^ ERROR: expected expression, found `)`
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@
|
|||
// except according to those terms.
|
||||
|
||||
pub fn main() {
|
||||
vec!(,); //~ ERROR unexpected token
|
||||
vec!(,); //~ ERROR expected expression, found `,`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,4 +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
|
||||
//~^^ ERROR expected pattern, found `'c`
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
// compile-flags: -Z parse-only -Z continue-parse-after-error
|
||||
|
||||
pub fn test() {
|
||||
foo(|_|) //~ ERROR unexpected token: `)`
|
||||
foo(|_|) //~ ERROR expected expression, found `)`
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
|
|||
|
|
@ -11,5 +11,5 @@
|
|||
// compile-flags: -Z parse-only
|
||||
|
||||
fn main() {
|
||||
let abstract = (); //~ ERROR `abstract` is a reserved keyword
|
||||
let abstract = (); //~ ERROR expected pattern, found reserved keyword `abstract`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,5 +11,5 @@
|
|||
// compile-flags: -Z parse-only
|
||||
|
||||
fn main() {
|
||||
let final = (); //~ ERROR `final` is a reserved keyword
|
||||
let final = (); //~ ERROR expected pattern, found reserved keyword `final`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,5 +11,5 @@
|
|||
// compile-flags: -Z parse-only
|
||||
|
||||
fn main() {
|
||||
let override = (); //~ ERROR `override` is a reserved keyword
|
||||
let override = (); //~ ERROR expected pattern, found reserved keyword `override`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,5 +11,5 @@
|
|||
// compile-flags: -Z parse-only
|
||||
|
||||
fn main() {
|
||||
let typeof = (); //~ ERROR `typeof` is a reserved keyword
|
||||
let typeof = (); //~ ERROR expected pattern, found reserved keyword `typeof`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@
|
|||
|
||||
fn main() {
|
||||
struct::foo(); //~ ERROR expected identifier
|
||||
mut::baz(); //~ ERROR expected identifier
|
||||
mut::baz(); //~ ERROR expected expression, found keyword `mut`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,6 @@ fn main() {
|
|||
|
||||
match 0 {
|
||||
0 => {
|
||||
} + 5 //~ ERROR unexpected token: `+`
|
||||
} + 5 //~ ERROR expected pattern, found `+`
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,9 +12,8 @@
|
|||
|
||||
// Test that we generate obsolete syntax errors around usages of `proc`.
|
||||
|
||||
fn foo(p: proc()) { } //~ ERROR `proc` is a reserved keyword
|
||||
fn foo(p: proc()) { } //~ ERROR expected type, found reserved keyword `proc`
|
||||
|
||||
fn bar() { proc() 1; } //~ ERROR `proc` is a reserved keyword
|
||||
//~^ ERROR expected
|
||||
fn bar() { proc() 1; } //~ ERROR expected expression, found reserved keyword `proc`
|
||||
|
||||
fn main() { }
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@
|
|||
|
||||
// compile-flags: -Z parse-only
|
||||
|
||||
fn f(+x: isize) {} //~ ERROR unexpected token: `+`
|
||||
fn f(+x: isize) {} //~ ERROR expected pattern, found `+`
|
||||
|
|
|
|||
|
|
@ -11,7 +11,5 @@
|
|||
// compile-flags: -Z parse-only
|
||||
|
||||
fn f() {
|
||||
let v = [mut 1, 2, 3, 4];
|
||||
//~^ ERROR expected identifier, found keyword `mut`
|
||||
//~^^ ERROR expected one of `!`, `,`, `.`, `::`, `;`, `?`, `]`, `{`, or an operator, found `1`
|
||||
let v = [mut 1, 2, 3, 4]; //~ ERROR expected expression, found keyword `mut`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,4 @@
|
|||
|
||||
// compile-flags: -Z parse-only
|
||||
|
||||
type v = [mut isize];
|
||||
//~^ ERROR expected identifier, found keyword `mut`
|
||||
//~^^ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `isize`
|
||||
type v = [mut isize]; //~ ERROR expected type, found keyword `mut`
|
||||
|
|
|
|||
|
|
@ -11,7 +11,5 @@
|
|||
// compile-flags: -Z parse-only
|
||||
|
||||
fn f() {
|
||||
let a_box = box mut 42;
|
||||
//~^ ERROR expected identifier, found keyword `mut`
|
||||
//~^^ ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `42`
|
||||
let a_box = box mut 42; //~ ERROR expected expression, found keyword `mut`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,4 @@
|
|||
|
||||
// compile-flags: -Z parse-only
|
||||
|
||||
type mut_box = Box<mut isize>;
|
||||
//~^ ERROR expected identifier, found keyword `mut`
|
||||
//~^^ ERROR expected one of `!`, `(`, `+`, `,`, `::`, `<`, or `>`, found `isize`
|
||||
type mut_box = Box<mut isize>; //~ ERROR expected type, found keyword `mut`
|
||||
|
|
|
|||
|
|
@ -15,8 +15,5 @@
|
|||
fn f<X>() {}
|
||||
|
||||
pub fn main() {
|
||||
f<type>();
|
||||
//~^ ERROR expected identifier, found keyword `type`
|
||||
//~^^ ERROR: chained comparison
|
||||
//~^^^ HELP: use `::<
|
||||
f<type>(); //~ ERROR expected expression, found keyword `type`
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue