Skip to content

Commit

Permalink
Auto merge of #57379 - petrochenkov:parsrecov, r=estebank
Browse files Browse the repository at this point in the history
tests: Do not use `-Z parse-only`, continue compilation to test recovery

Make tests closer to reality!

The next step will be enabling `-Z continue-parse-after-error` by default and looking at the regressions.

A few instances of `-Z parse-only` are kept when it's appropriate, see e.g `ui/impl-trait/impl-trait-plus-priority.rs`, which tests mostly semantically wrong code and would generate too much useless noise if allowed to continue.
  • Loading branch information
bors committed Jan 7, 2019
2 parents d39dddf + 1f64f60 commit 789a15a
Show file tree
Hide file tree
Showing 530 changed files with 749 additions and 882 deletions.
2 changes: 0 additions & 2 deletions src/etc/generate-keyword-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@


template = """
// compile-flags: -Z parse-only
// This file was auto-generated using 'src/etc/generate-keyword-tests.py %s'
fn main() {
Expand Down
1 change: 0 additions & 1 deletion src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {

fn visit_item(&mut self, i: &'a ast::Item) {
match i.node {
ast::ItemKind::Static(..) |
ast::ItemKind::Const(_,_) => {
if i.ident.name == "_" {
gate_feature_post!(&self, underscore_const_names, i.span,
Expand Down
2 changes: 0 additions & 2 deletions src/test/rustfix/tuple-float-index.fixed
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-flags: -Z parse-only

fn main () {
((1, (2, 3)).1).1;
}
2 changes: 0 additions & 2 deletions src/test/rustfix/tuple-float-index.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-flags: -Z parse-only

fn main () {
(1, (2, 3)).1.1;
}
2 changes: 0 additions & 2 deletions src/test/ui/mod/mod_file_disambig.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-flags: -Z parse-only

mod mod_file_disambig_aux; //~ ERROR file for module `mod_file_disambig_aux` found at both

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/mod/mod_file_disambig.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0584]: file for module `mod_file_disambig_aux` found at both mod_file_disambig_aux.rs and mod_file_disambig_aux/mod.rs
--> $DIR/mod_file_disambig.rs:3:5
--> $DIR/mod_file_disambig.rs:1:5
|
LL | mod mod_file_disambig_aux; //~ ERROR file for module `mod_file_disambig_aux` found at both
| ^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/mut/mut-ref.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-flags: -Z parse-only

fn main() {
let mut ref x = 10; //~ ERROR the order of `mut` and `ref` is incorrect
let ref mut y = 11;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/mut/mut-ref.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: the order of `mut` and `ref` is incorrect
--> $DIR/mut-ref.rs:4:9
--> $DIR/mut-ref.rs:2:9
|
LL | let mut ref x = 10; //~ ERROR the order of `mut` and `ref` is incorrect
| ^^^^^^^ help: try switching the order: `ref mut`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/ascii-only-character-escape.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// compile-flags: -Z parse-only -Z continue-parse-after-error
// compile-flags: -Z continue-parse-after-error

fn main() {
let x = "\x80"; //~ ERROR may only be used
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/assoc-oddities-1.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// compile-flags: -Z parse-only

fn that_odd_parse() {
fn main() {
// following lines below parse and must not fail
x = if c { a } else { b }();
x = if true { 1 } else { 0 } as *mut _;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/assoc-oddities-2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// compile-flags: -Z parse-only

fn that_odd_parse() {
fn main() {
// see assoc-oddities-1 for explanation
x..if c { a } else { b }[n]; //~ ERROR expected one of
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// compile-flags: -Z parse-only -Z continue-parse-after-error
// compile-flags: -Z continue-parse-after-error

// Test you can't use a higher-ranked trait bound inside of a qualified
// path (just won't parse).
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/parser/attr-bad-meta-2.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
// compile-flags: -Z parse-only

#[path =] //~ ERROR unexpected token: `]`
mod m {}
2 changes: 1 addition & 1 deletion src/test/ui/parser/attr-bad-meta-2.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: unexpected token: `]`
--> $DIR/attr-bad-meta-2.rs:3:9
--> $DIR/attr-bad-meta-2.rs:1:9
|
LL | #[path =] //~ ERROR unexpected token: `]`
| ^ unexpected token after this
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/parser/attr-bad-meta-3.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
// compile-flags: -Z parse-only

#[path() token] //~ ERROR expected `]`, found `token`
mod m {}
2 changes: 1 addition & 1 deletion src/test/ui/parser/attr-bad-meta-3.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected `]`, found `token`
--> $DIR/attr-bad-meta-3.rs:3:10
--> $DIR/attr-bad-meta-3.rs:1:10
|
LL | #[path() token] //~ ERROR expected `]`, found `token`
| ^^^^^ expected `]`
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/parser/attr-bad-meta.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-flags: -Z parse-only

#![feature(unrestricted_attribute_tokens)]

#[path*] //~ ERROR expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/attr-bad-meta.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*`
--> $DIR/attr-bad-meta.rs:5:7
--> $DIR/attr-bad-meta.rs:3:7
|
LL | #[path*] //~ ERROR expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*`
| ^ expected one of `(`, `::`, `=`, `[`, `]`, or `{` here
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/attr-before-eof.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// compile-flags: -Z parse-only
fn main() {}

#[derive(Debug)] //~ERROR expected item after attributes
2 changes: 0 additions & 2 deletions src/test/ui/parser/attr-dangling-in-fn.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-flags: -Z parse-only

// error-pattern:expected statement

fn f() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/attr-dangling-in-fn.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected statement after outer attribute
--> $DIR/attr-dangling-in-fn.rs:7:1
--> $DIR/attr-dangling-in-fn.rs:5:1
|
LL | }
| ^
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/parser/attr-dangling-in-mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-flags: -Z parse-only

// error-pattern:expected item

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/attr-dangling-in-mod.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected item after attributes
--> $DIR/attr-dangling-in-mod.rs:8:14
--> $DIR/attr-dangling-in-mod.rs:6:14
|
LL | #[foo = "bar"]
| ^
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/parser/attr.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-flags: -Z parse-only

#![feature(lang_items)]

fn main() {}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/attr.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: an inner attribute is not permitted in this context
--> $DIR/attr.rs:7:3
--> $DIR/attr.rs:5:3
|
LL | #![lang(foo)] //~ ERROR an inner attribute is not permitted in this context
| ^
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/parser/attrs-after-extern-mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-flags: -Z parse-only

// Constants (static variables) can be used to match in patterns, but mutable
// statics cannot. This ensures that there's some form of error if this is
// attempted.
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/attrs-after-extern-mod.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected item after attributes
--> $DIR/attrs-after-extern-mod.rs:12:19
--> $DIR/attrs-after-extern-mod.rs:10:19
|
LL | #[cfg(stage37)] //~ ERROR expected item after attributes
| ^
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/bad-char-literals.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// compile-flags: -Z parse-only -Z continue-parse-after-error
// compile-flags: -Z continue-parse-after-error

// ignore-tidy-cr
// ignore-tidy-tab
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/bad-lit-suffixes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// compile-flags: -Z parse-only -Z continue-parse-after-error
// compile-flags: -Z continue-parse-after-error


extern
Expand Down
9 changes: 1 addition & 8 deletions src/test/ui/parser/bad-match.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
// compile-flags: -Z parse-only

// error-pattern: expected

fn main() {
let isize x = 5;
let isize x = 5; //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `x`
match x;
}

fn main() {
}
4 changes: 2 additions & 2 deletions src/test/ui/parser/bad-match.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error: expected one of `:`, `;`, `=`, or `@`, found `x`
--> $DIR/bad-match.rs:6:13
--> $DIR/bad-match.rs:2:13
|
LL | let isize x = 5;
LL | let isize x = 5; //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `x`
| ^ expected one of `:`, `;`, `=`, or `@` here

error: aborting due to previous error
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/parser/bad-name.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-flags: -Z parse-only

// error-pattern: expected

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/bad-name.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected one of `:`, `;`, `=`, or `@`, found `.`
--> $DIR/bad-name.rs:6:8
--> $DIR/bad-name.rs:4:8
|
LL | let x.y::<isize>.z foo;
| ^ expected one of `:`, `;`, `=`, or `@` here
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/parser/bad-pointer-type.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// compile-flags: -Z parse-only

fn foo(_: *()) {
//~^ expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate)
}

fn main() {}
2 changes: 1 addition & 1 deletion src/test/ui/parser/bad-pointer-type.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate)
--> $DIR/bad-pointer-type.rs:3:11
--> $DIR/bad-pointer-type.rs:1:11
|
LL | fn foo(_: *()) {
| ^
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/parser/bad-value-ident-false.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
// compile-flags: -Z parse-only

fn false() { } //~ ERROR expected identifier, found keyword `false`
fn main() { }
2 changes: 1 addition & 1 deletion src/test/ui/parser/bad-value-ident-false.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected identifier, found keyword `false`
--> $DIR/bad-value-ident-false.rs:3:4
--> $DIR/bad-value-ident-false.rs:1:4
|
LL | fn false() { } //~ ERROR expected identifier, found keyword `false`
| ^^^^^ expected identifier, found keyword
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/parser/bad-value-ident-true.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
// compile-flags: -Z parse-only

fn true() { } //~ ERROR expected identifier, found keyword `true`
fn main() { }
2 changes: 1 addition & 1 deletion src/test/ui/parser/bad-value-ident-true.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected identifier, found keyword `true`
--> $DIR/bad-value-ident-true.rs:3:4
--> $DIR/bad-value-ident-true.rs:1:4
|
LL | fn true() { } //~ ERROR expected identifier, found keyword `true`
| ^^^^ expected identifier, found keyword
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/parser/better-expected.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-flags: -Z parse-only

fn main() {
let x: [isize 3]; //~ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `3`
}
2 changes: 1 addition & 1 deletion src/test/ui/parser/better-expected.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `3`
--> $DIR/better-expected.rs:4:19
--> $DIR/better-expected.rs:2:19
|
LL | let x: [isize 3]; //~ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `3`
| - ^ expected one of 7 possible tokens here
Expand Down
3 changes: 1 addition & 2 deletions src/test/ui/parser/bind-struct-early-modifiers.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// compile-flags: -Z parse-only

fn main() {
struct Foo { x: isize }
match (Foo { x: 10 }) {
Foo { ref x: ref x } => {}, //~ ERROR expected `,`
//~| ERROR pattern does not mention field `x`
_ => {}
}
}
11 changes: 9 additions & 2 deletions src/test/ui/parser/bind-struct-early-modifiers.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
error: expected `,`
--> $DIR/bind-struct-early-modifiers.rs:6:19
--> $DIR/bind-struct-early-modifiers.rs:4:19
|
LL | Foo { ref x: ref x } => {}, //~ ERROR expected `,`
| ^

error: aborting due to previous error
error[E0027]: pattern does not mention field `x`
--> $DIR/bind-struct-early-modifiers.rs:4:9
|
LL | Foo { ref x: ref x } => {}, //~ ERROR expected `,`
| ^^^^^^^^^^^^^^^^^^^^ missing field `x`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0027`.
2 changes: 0 additions & 2 deletions src/test/ui/parser/bound-single-question-mark.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
// compile-flags: -Z parse-only

fn f<T: ?>() {} //~ ERROR expected identifier, found `>`
2 changes: 1 addition & 1 deletion src/test/ui/parser/bound-single-question-mark.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected identifier, found `>`
--> $DIR/bound-single-question-mark.rs:3:10
--> $DIR/bound-single-question-mark.rs:1:10
|
LL | fn f<T: ?>() {} //~ ERROR expected identifier, found `>`
| ^ expected identifier
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/parser/bounds-lifetime-1.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-flags: -Z parse-only

type A = for<'a 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `'b`

fn main() {}
2 changes: 1 addition & 1 deletion src/test/ui/parser/bounds-lifetime-1.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected one of `,`, `:`, or `>`, found `'b`
--> $DIR/bounds-lifetime-1.rs:3:17
--> $DIR/bounds-lifetime-1.rs:1:17
|
LL | type A = for<'a 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `'b`
| ^^ expected one of `,`, `:`, or `>` here
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/parser/bounds-lifetime-2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-flags: -Z parse-only

type A = for<'a + 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `+`

fn main() {}
2 changes: 1 addition & 1 deletion src/test/ui/parser/bounds-lifetime-2.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected one of `,`, `:`, or `>`, found `+`
--> $DIR/bounds-lifetime-2.rs:3:17
--> $DIR/bounds-lifetime-2.rs:1:17
|
LL | type A = for<'a + 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `+`
| ^ expected one of `,`, `:`, or `>` here
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/parser/bounds-lifetime-where-1.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-flags: -Z parse-only

type A where 'a; //~ ERROR expected `:`, found `;`

fn main() {}
2 changes: 1 addition & 1 deletion src/test/ui/parser/bounds-lifetime-where-1.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected `:`, found `;`
--> $DIR/bounds-lifetime-where-1.rs:3:16
--> $DIR/bounds-lifetime-where-1.rs:1:16
|
LL | type A where 'a; //~ ERROR expected `:`, found `;`
| ^ expected `:`
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/parser/bounds-lifetime-where.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-flags: -Z parse-only

type A where 'a: 'b + 'c = u8; // OK
type A where 'a: 'b, = u8; // OK
type A where 'a: = u8; // OK
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/bounds-lifetime-where.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected one of `=`, lifetime, or type, found `,`
--> $DIR/bounds-lifetime-where.rs:10:14
--> $DIR/bounds-lifetime-where.rs:8:14
|
LL | type A where , = u8; //~ ERROR expected one of `=`, lifetime, or type, found `,`
| ^ expected one of `=`, lifetime, or type here
Expand Down
2 changes: 0 additions & 2 deletions src/test/ui/parser/bounds-lifetime.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-flags: -Z parse-only

type A = for<'a:> fn(); // OK
type A = for<'a:,> fn(); // OK
type A = for<'a> fn(); // OK
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/parser/bounds-lifetime.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected one of `>`, identifier, or lifetime, found `,`
--> $DIR/bounds-lifetime.rs:11:14
--> $DIR/bounds-lifetime.rs:9:14
|
LL | type A = for<,> fn(); //~ ERROR expected one of `>`, identifier, or lifetime, found `,`
| ^ expected one of `>`, identifier, or lifetime here
Expand Down
5 changes: 3 additions & 2 deletions src/test/ui/parser/bounds-obj-parens.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// compile-pass
// compile-flags: -Z parse-only

type A = Box<(Fn(D::Error) -> E) + 'static + Send + Sync>; // OK (but see #39318)
type A = Box<(Fn(u8) -> u8) + 'static + Send + Sync>; // OK (but see #39318)

fn main() {}
2 changes: 0 additions & 2 deletions src/test/ui/parser/bounds-type-where.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// compile-flags: -Z parse-only

type A where for<'a> for<'b> Trait1 + ?Trait2: 'a + Trait = u8; // OK
type A where T: Trait, = u8; // OK
type A where T: = u8; // OK
Expand Down
Loading

0 comments on commit 789a15a

Please sign in to comment.