Skip to content

Commit 789a15a

Browse files
committed
Auto merge of #57379 - petrochenkov:parsrecov, r=estebank
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.
2 parents d39dddf + 1f64f60 commit 789a15a

File tree

530 files changed

+749
-882
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

530 files changed

+749
-882
lines changed

src/etc/generate-keyword-tests.py

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717

1818
template = """
19-
// compile-flags: -Z parse-only
20-
2119
// This file was auto-generated using 'src/etc/generate-keyword-tests.py %s'
2220
2321
fn main() {

src/libsyntax/feature_gate.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1543,7 +1543,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
15431543

15441544
fn visit_item(&mut self, i: &'a ast::Item) {
15451545
match i.node {
1546-
ast::ItemKind::Static(..) |
15471546
ast::ItemKind::Const(_,_) => {
15481547
if i.ident.name == "_" {
15491548
gate_feature_post!(&self, underscore_const_names, i.span,
-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -Z parse-only
2-
31
fn main () {
42
((1, (2, 3)).1).1;
53
}

src/test/rustfix/tuple-float-index.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -Z parse-only
2-
31
fn main () {
42
(1, (2, 3)).1.1;
53
}

src/test/ui/mod/mod_file_disambig.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -Z parse-only
2-
31
mod mod_file_disambig_aux; //~ ERROR file for module `mod_file_disambig_aux` found at both
42

53
fn main() {

src/test/ui/mod/mod_file_disambig.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0584]: file for module `mod_file_disambig_aux` found at both mod_file_disambig_aux.rs and mod_file_disambig_aux/mod.rs
2-
--> $DIR/mod_file_disambig.rs:3:5
2+
--> $DIR/mod_file_disambig.rs:1:5
33
|
44
LL | mod mod_file_disambig_aux; //~ ERROR file for module `mod_file_disambig_aux` found at both
55
| ^^^^^^^^^^^^^^^^^^^^^

src/test/ui/mut/mut-ref.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -Z parse-only
2-
31
fn main() {
42
let mut ref x = 10; //~ ERROR the order of `mut` and `ref` is incorrect
53
let ref mut y = 11;

src/test/ui/mut/mut-ref.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: the order of `mut` and `ref` is incorrect
2-
--> $DIR/mut-ref.rs:4:9
2+
--> $DIR/mut-ref.rs:2:9
33
|
44
LL | let mut ref x = 10; //~ ERROR the order of `mut` and `ref` is incorrect
55
| ^^^^^^^ help: try switching the order: `ref mut`

src/test/ui/parser/ascii-only-character-escape.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: -Z parse-only -Z continue-parse-after-error
1+
// compile-flags: -Z continue-parse-after-error
22

33
fn main() {
44
let x = "\x80"; //~ ERROR may only be used

src/test/ui/parser/assoc-oddities-1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// compile-flags: -Z parse-only
22

3-
fn that_odd_parse() {
3+
fn main() {
44
// following lines below parse and must not fail
55
x = if c { a } else { b }();
66
x = if true { 1 } else { 0 } as *mut _;
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// compile-flags: -Z parse-only
22

3-
fn that_odd_parse() {
3+
fn main() {
44
// see assoc-oddities-1 for explanation
55
x..if c { a } else { b }[n]; //~ ERROR expected one of
66
}

src/test/ui/parser/associated-types-project-from-hrtb-explicit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: -Z parse-only -Z continue-parse-after-error
1+
// compile-flags: -Z continue-parse-after-error
22

33
// Test you can't use a higher-ranked trait bound inside of a qualified
44
// path (just won't parse).

src/test/ui/parser/attr-bad-meta-2.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
// compile-flags: -Z parse-only
2-
31
#[path =] //~ ERROR unexpected token: `]`
42
mod m {}

src/test/ui/parser/attr-bad-meta-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: unexpected token: `]`
2-
--> $DIR/attr-bad-meta-2.rs:3:9
2+
--> $DIR/attr-bad-meta-2.rs:1:9
33
|
44
LL | #[path =] //~ ERROR unexpected token: `]`
55
| ^ unexpected token after this

src/test/ui/parser/attr-bad-meta-3.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
// compile-flags: -Z parse-only
2-
31
#[path() token] //~ ERROR expected `]`, found `token`
42
mod m {}

src/test/ui/parser/attr-bad-meta-3.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected `]`, found `token`
2-
--> $DIR/attr-bad-meta-3.rs:3:10
2+
--> $DIR/attr-bad-meta-3.rs:1:10
33
|
44
LL | #[path() token] //~ ERROR expected `]`, found `token`
55
| ^^^^^ expected `]`

src/test/ui/parser/attr-bad-meta.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -Z parse-only
2-
31
#![feature(unrestricted_attribute_tokens)]
42

53
#[path*] //~ ERROR expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*`

src/test/ui/parser/attr-bad-meta.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*`
2-
--> $DIR/attr-bad-meta.rs:5:7
2+
--> $DIR/attr-bad-meta.rs:3:7
33
|
44
LL | #[path*] //~ ERROR expected one of `(`, `::`, `=`, `[`, `]`, or `{`, found `*`
55
| ^ expected one of `(`, `::`, `=`, `[`, `]`, or `{` here

src/test/ui/parser/attr-before-eof.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
// compile-flags: -Z parse-only
1+
fn main() {}
22

33
#[derive(Debug)] //~ERROR expected item after attributes

src/test/ui/parser/attr-dangling-in-fn.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -Z parse-only
2-
31
// error-pattern:expected statement
42

53
fn f() {

src/test/ui/parser/attr-dangling-in-fn.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected statement after outer attribute
2-
--> $DIR/attr-dangling-in-fn.rs:7:1
2+
--> $DIR/attr-dangling-in-fn.rs:5:1
33
|
44
LL | }
55
| ^

src/test/ui/parser/attr-dangling-in-mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -Z parse-only
2-
31
// error-pattern:expected item
42

53
fn main() {

src/test/ui/parser/attr-dangling-in-mod.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected item after attributes
2-
--> $DIR/attr-dangling-in-mod.rs:8:14
2+
--> $DIR/attr-dangling-in-mod.rs:6:14
33
|
44
LL | #[foo = "bar"]
55
| ^

src/test/ui/parser/attr.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -Z parse-only
2-
31
#![feature(lang_items)]
42

53
fn main() {}

src/test/ui/parser/attr.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: an inner attribute is not permitted in this context
2-
--> $DIR/attr.rs:7:3
2+
--> $DIR/attr.rs:5:3
33
|
44
LL | #![lang(foo)] //~ ERROR an inner attribute is not permitted in this context
55
| ^

src/test/ui/parser/attrs-after-extern-mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -Z parse-only
2-
31
// Constants (static variables) can be used to match in patterns, but mutable
42
// statics cannot. This ensures that there's some form of error if this is
53
// attempted.

src/test/ui/parser/attrs-after-extern-mod.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected item after attributes
2-
--> $DIR/attrs-after-extern-mod.rs:12:19
2+
--> $DIR/attrs-after-extern-mod.rs:10:19
33
|
44
LL | #[cfg(stage37)] //~ ERROR expected item after attributes
55
| ^

src/test/ui/parser/bad-char-literals.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: -Z parse-only -Z continue-parse-after-error
1+
// compile-flags: -Z continue-parse-after-error
22

33
// ignore-tidy-cr
44
// ignore-tidy-tab

src/test/ui/parser/bad-lit-suffixes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags: -Z parse-only -Z continue-parse-after-error
1+
// compile-flags: -Z continue-parse-after-error
22

33

44
extern

src/test/ui/parser/bad-match.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
// compile-flags: -Z parse-only
2-
3-
// error-pattern: expected
4-
51
fn main() {
6-
let isize x = 5;
2+
let isize x = 5; //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `x`
73
match x;
84
}
9-
10-
fn main() {
11-
}

src/test/ui/parser/bad-match.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error: expected one of `:`, `;`, `=`, or `@`, found `x`
2-
--> $DIR/bad-match.rs:6:13
2+
--> $DIR/bad-match.rs:2:13
33
|
4-
LL | let isize x = 5;
4+
LL | let isize x = 5; //~ ERROR expected one of `:`, `;`, `=`, or `@`, found `x`
55
| ^ expected one of `:`, `;`, `=`, or `@` here
66

77
error: aborting due to previous error

src/test/ui/parser/bad-name.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -Z parse-only
2-
31
// error-pattern: expected
42

53
fn main() {

src/test/ui/parser/bad-name.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected one of `:`, `;`, `=`, or `@`, found `.`
2-
--> $DIR/bad-name.rs:6:8
2+
--> $DIR/bad-name.rs:4:8
33
|
44
LL | let x.y::<isize>.z foo;
55
| ^ expected one of `:`, `;`, `=`, or `@` here
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// compile-flags: -Z parse-only
2-
31
fn foo(_: *()) {
42
//~^ expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate)
53
}
4+
5+
fn main() {}

src/test/ui/parser/bad-pointer-type.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected mut or const in raw pointer type (use `*mut T` or `*const T` as appropriate)
2-
--> $DIR/bad-pointer-type.rs:3:11
2+
--> $DIR/bad-pointer-type.rs:1:11
33
|
44
LL | fn foo(_: *()) {
55
| ^
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
// compile-flags: -Z parse-only
2-
31
fn false() { } //~ ERROR expected identifier, found keyword `false`
42
fn main() { }

src/test/ui/parser/bad-value-ident-false.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected identifier, found keyword `false`
2-
--> $DIR/bad-value-ident-false.rs:3:4
2+
--> $DIR/bad-value-ident-false.rs:1:4
33
|
44
LL | fn false() { } //~ ERROR expected identifier, found keyword `false`
55
| ^^^^^ expected identifier, found keyword
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
// compile-flags: -Z parse-only
2-
31
fn true() { } //~ ERROR expected identifier, found keyword `true`
42
fn main() { }

src/test/ui/parser/bad-value-ident-true.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected identifier, found keyword `true`
2-
--> $DIR/bad-value-ident-true.rs:3:4
2+
--> $DIR/bad-value-ident-true.rs:1:4
33
|
44
LL | fn true() { } //~ ERROR expected identifier, found keyword `true`
55
| ^^^^ expected identifier, found keyword

src/test/ui/parser/better-expected.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -Z parse-only
2-
31
fn main() {
42
let x: [isize 3]; //~ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `3`
53
}

src/test/ui/parser/better-expected.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `3`
2-
--> $DIR/better-expected.rs:4:19
2+
--> $DIR/better-expected.rs:2:19
33
|
44
LL | let x: [isize 3]; //~ ERROR expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `]`, found `3`
55
| - ^ expected one of 7 possible tokens here
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
// compile-flags: -Z parse-only
2-
31
fn main() {
42
struct Foo { x: isize }
53
match (Foo { x: 10 }) {
64
Foo { ref x: ref x } => {}, //~ ERROR expected `,`
5+
//~| ERROR pattern does not mention field `x`
76
_ => {}
87
}
98
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
error: expected `,`
2-
--> $DIR/bind-struct-early-modifiers.rs:6:19
2+
--> $DIR/bind-struct-early-modifiers.rs:4:19
33
|
44
LL | Foo { ref x: ref x } => {}, //~ ERROR expected `,`
55
| ^
66

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

15+
For more information about this error, try `rustc --explain E0027`.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
// compile-flags: -Z parse-only
2-
31
fn f<T: ?>() {} //~ ERROR expected identifier, found `>`

src/test/ui/parser/bound-single-question-mark.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected identifier, found `>`
2-
--> $DIR/bound-single-question-mark.rs:3:10
2+
--> $DIR/bound-single-question-mark.rs:1:10
33
|
44
LL | fn f<T: ?>() {} //~ ERROR expected identifier, found `>`
55
| ^ expected identifier
-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -Z parse-only
2-
31
type A = for<'a 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `'b`
42

53
fn main() {}

src/test/ui/parser/bounds-lifetime-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected one of `,`, `:`, or `>`, found `'b`
2-
--> $DIR/bounds-lifetime-1.rs:3:17
2+
--> $DIR/bounds-lifetime-1.rs:1:17
33
|
44
LL | type A = for<'a 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `'b`
55
| ^^ expected one of `,`, `:`, or `>` here
-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -Z parse-only
2-
31
type A = for<'a + 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `+`
42

53
fn main() {}

src/test/ui/parser/bounds-lifetime-2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected one of `,`, `:`, or `>`, found `+`
2-
--> $DIR/bounds-lifetime-2.rs:3:17
2+
--> $DIR/bounds-lifetime-2.rs:1:17
33
|
44
LL | type A = for<'a + 'b> fn(); //~ ERROR expected one of `,`, `:`, or `>`, found `+`
55
| ^ expected one of `,`, `:`, or `>` here
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -Z parse-only
2-
31
type A where 'a; //~ ERROR expected `:`, found `;`
42

53
fn main() {}

src/test/ui/parser/bounds-lifetime-where-1.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected `:`, found `;`
2-
--> $DIR/bounds-lifetime-where-1.rs:3:16
2+
--> $DIR/bounds-lifetime-where-1.rs:1:16
33
|
44
LL | type A where 'a; //~ ERROR expected `:`, found `;`
55
| ^ expected `:`

src/test/ui/parser/bounds-lifetime-where.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -Z parse-only
2-
31
type A where 'a: 'b + 'c = u8; // OK
42
type A where 'a: 'b, = u8; // OK
53
type A where 'a: = u8; // OK

src/test/ui/parser/bounds-lifetime-where.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected one of `=`, lifetime, or type, found `,`
2-
--> $DIR/bounds-lifetime-where.rs:10:14
2+
--> $DIR/bounds-lifetime-where.rs:8:14
33
|
44
LL | type A where , = u8; //~ ERROR expected one of `=`, lifetime, or type, found `,`
55
| ^ expected one of `=`, lifetime, or type here

src/test/ui/parser/bounds-lifetime.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -Z parse-only
2-
31
type A = for<'a:> fn(); // OK
42
type A = for<'a:,> fn(); // OK
53
type A = for<'a> fn(); // OK

src/test/ui/parser/bounds-lifetime.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected one of `>`, identifier, or lifetime, found `,`
2-
--> $DIR/bounds-lifetime.rs:11:14
2+
--> $DIR/bounds-lifetime.rs:9:14
33
|
44
LL | type A = for<,> fn(); //~ ERROR expected one of `>`, identifier, or lifetime, found `,`
55
| ^ expected one of `>`, identifier, or lifetime here
+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// compile-pass
2-
// compile-flags: -Z parse-only
32

4-
type A = Box<(Fn(D::Error) -> E) + 'static + Send + Sync>; // OK (but see #39318)
3+
type A = Box<(Fn(u8) -> u8) + 'static + Send + Sync>; // OK (but see #39318)
4+
5+
fn main() {}

src/test/ui/parser/bounds-type-where.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -Z parse-only
2-
31
type A where for<'a> for<'b> Trait1 + ?Trait2: 'a + Trait = u8; // OK
42
type A where T: Trait, = u8; // OK
53
type A where T: = u8; // OK

0 commit comments

Comments
 (0)