Skip to content

Commit 6f2d023

Browse files
committed
Fold rustfix tests back into the UI test suite
1 parent a563027 commit 6f2d023

29 files changed

+223
-80
lines changed

src/bootstrap/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ impl<'a> Builder<'a> {
326326
test::TheBook, test::UnstableBook, test::RustcBook,
327327
test::Rustfmt, test::Miri, test::Clippy, test::RustdocJS, test::RustdocTheme,
328328
// Run run-make last, since these won't pass without make on Windows
329-
test::RunMake, test::RustdocUi, test::Rustfix),
329+
test::RunMake, test::RustdocUi),
330330
Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
331331
Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook,
332332
doc::Standalone, doc::Std, doc::Test, doc::WhitelistedRustc, doc::Rustc,

src/bootstrap/test.rs

-6
Original file line numberDiff line numberDiff line change
@@ -716,12 +716,6 @@ default_test!(RunFail {
716716
suite: "run-fail"
717717
});
718718

719-
default_test!(Rustfix {
720-
path: "src/test/rustfix",
721-
mode: "rustfix",
722-
suite: "rustfix"
723-
});
724-
725719
default_test!(RunPassValgrind {
726720
path: "src/test/run-pass-valgrind",
727721
mode: "run-pass-valgrind",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// run-rustfix
12+
13+
// Point at the captured immutable outer variable
14+
15+
fn foo(mut f: Box<FnMut()>) {
16+
f();
17+
}
18+
19+
fn main() {
20+
let mut y = true;
21+
foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// run-rustfix
12+
13+
// Point at the captured immutable outer variable
14+
15+
fn foo(mut f: Box<FnMut()>) {
16+
f();
17+
}
18+
19+
fn main() {
20+
let y = true;
21+
foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable
22+
}

src/test/ui/suggestions/closure-immutable-outer-variable.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0594]: cannot assign to immutable item `y`
2-
--> $DIR/closure-immutable-outer-variable.rs:19:26
2+
--> $DIR/closure-immutable-outer-variable.rs:21:26
33
|
44
LL | foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable
55
| ^^^^^^^^^ cannot mutate

src/test/ui/suggestions/closure-immutable-outer-variable.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// run-rustfix
12+
1113
// Point at the captured immutable outer variable
1214

1315
fn foo(mut f: Box<FnMut()>) {

src/test/ui/suggestions/closure-immutable-outer-variable.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0594]: cannot assign to captured outer variable in an `FnMut` closure
2-
--> $DIR/closure-immutable-outer-variable.rs:19:26
2+
--> $DIR/closure-immutable-outer-variable.rs:21:26
33
|
44
LL | let y = true;
55
| - help: consider making `y` mutable: `mut y`
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// run-rustfix
12+
13+
#[no_mangle] pub static RAH: usize = 5;
14+
//~^ ERROR const items should never be #[no_mangle]
15+
16+
fn main() {}

src/test/ui/suggestions/issue-45562.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// run-rustfix
12+
1113
#[no_mangle] pub const RAH: usize = 5;
1214
//~^ ERROR const items should never be #[no_mangle]
1315

src/test/ui/suggestions/issue-45562.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: const items should never be #[no_mangle]
2-
--> $DIR/issue-45562.rs:11:14
2+
--> $DIR/issue-45562.rs:13:14
33
|
44
LL | #[no_mangle] pub const RAH: usize = 5;
55
| ---------^^^^^^^^^^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// run-rustfix
12+
13+
extern crate std as other_std;
14+
fn main() {}
15+
//~^^ ERROR the name `std` is defined multiple times [E0259]

src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// run-rustfix
12+
1113
extern crate std;
1214
fn main() {}
1315
//~^^ ERROR the name `std` is defined multiple times [E0259]

src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0259]: the name `std` is defined multiple times
2-
--> $DIR/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs:11:1
2+
--> $DIR/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs:13:1
33
|
44
LL | extern crate std;
55
| ^^^^^^^^^^^^^^^^^ `std` reimported here
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// run-rustfix
12+
13+
#![allow(unused)]
14+
15+
fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize {
16+
and_yet + 1
17+
}
18+
19+
fn main() {
20+
let behold: isize = 2;
21+
let with_tears: usize = 3;
22+
light_flows_our_war_of_mocking_words(&(behold as usize));
23+
//~^ ERROR mismatched types [E0308]
24+
light_flows_our_war_of_mocking_words(&(with_tears + 4));
25+
//~^ ERROR mismatched types [E0308]
26+
}

src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// run-rustfix
12+
1113
#![allow(unused)]
1214

1315
fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize {

src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:20:42
2+
--> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:22:42
33
|
44
LL | light_flows_our_war_of_mocking_words(behold as usize);
55
| ^^^^^^^^^^^^^^^
@@ -11,7 +11,7 @@ LL | light_flows_our_war_of_mocking_words(behold as usize);
1111
found type `usize`
1212

1313
error[E0308]: mismatched types
14-
--> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:22:42
14+
--> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:24:42
1515
|
1616
LL | light_flows_our_war_of_mocking_words(with_tears + 4);
1717
| ^^^^^^^^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// run-rustfix
12+
13+
fn main() {
14+
match &Some(3) {
15+
&None => 1,
16+
&Some(2) => { 3 }
17+
//~^ ERROR expected one of `,`, `.`, `?`, `}`, or an operator, found `=>`
18+
//~| NOTE expected one of `,`, `.`, `?`, `}`, or an operator here
19+
_ => 2
20+
};
21+
}

src/test/ui/suggestions/missing-comma-in-match.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// run-rustfix
12+
1113
fn main() {
1214
match &Some(3) {
1315
&None => 1

src/test/ui/suggestions/missing-comma-in-match.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: expected one of `,`, `.`, `?`, `}`, or an operator, found `=>`
2-
--> $DIR/missing-comma-in-match.rs:14:18
2+
--> $DIR/missing-comma-in-match.rs:16:18
33
|
44
LL | &None => 1
55
| - help: missing a comma here to end this `match` arm
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// run-rustfix
12+
13+
fn main() {
14+
println!("●●");
15+
//~^ ERROR character literal may only contain one codepoint
16+
}

src/test/ui/suggestions/str-as-char.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// run-rustfix
12+
1113
fn main() {
1214
println!('●●');
1315
//~^ ERROR character literal may only contain one codepoint

src/test/ui/suggestions/str-as-char.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: character literal may only contain one codepoint
2-
--> $DIR/str-as-char.rs:12:14
2+
--> $DIR/str-as-char.rs:14:14
33
|
44
LL | println!('●●');
55
| ^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// run-rustfix
12+
// compile-flags: -Z parse-only
13+
14+
fn main () {
15+
((1, (2, 3)).1).1; //~ ERROR unexpected token: `1.1`
16+
}

src/test/ui/suggestions/tuple-float-index.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// run-rustfix
1112
// compile-flags: -Z parse-only
1213

1314
fn main () {

src/test/ui/suggestions/tuple-float-index.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: unexpected token: `1.1`
2-
--> $DIR/tuple-float-index.rs:14:17
2+
--> $DIR/tuple-float-index.rs:15:17
33
|
44
LL | (1, (2, 3)).1.1; //~ ERROR unexpected token: `1.1`
55
| ------------^^^

src/test/ui/update-references.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ if [[ "$1" == "--help" || "$1" == "-h" || "$1" == "" || "$2" == "" ]]; then
2626
echo " $0 ../../../build/x86_64-apple-darwin/test/ui *.rs */*.rs"
2727
fi
2828

29-
MYDIR=$(dirname $0)
3029

3130
BUILD_DIR="$1"
3231
shift
3332

3433
shopt -s nullglob
3534

3635
while [[ "$1" != "" ]]; do
37-
for EXT in "stderr" "stdout"; do
36+
MYDIR=$(dirname $1)
37+
for EXT in "stderr" "stdout" "fixed"; do
3838
for OUT_NAME in $BUILD_DIR/${1%.rs}.*$EXT; do
3939
OUT_BASE=`basename "$OUT_NAME"`
4040
if ! (diff $OUT_NAME $MYDIR/$OUT_BASE >& /dev/null); then

src/tools/compiletest/src/common.rs

-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ pub enum Mode {
3232
RunMake,
3333
Ui,
3434
MirOpt,
35-
Rustfix,
3635
}
3736

3837
impl Mode {
@@ -68,7 +67,6 @@ impl FromStr for Mode {
6867
"run-make" => Ok(RunMake),
6968
"ui" => Ok(Ui),
7069
"mir-opt" => Ok(MirOpt),
71-
"rustfix" => Ok(Rustfix),
7270
_ => Err(()),
7371
}
7472
}
@@ -92,7 +90,6 @@ impl fmt::Display for Mode {
9290
RunMake => "run-make",
9391
Ui => "ui",
9492
MirOpt => "mir-opt",
95-
Rustfix => "rustfix",
9693
};
9794
fmt::Display::fmt(s, f)
9895
}

src/tools/compiletest/src/header.rs

+10
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ pub struct TestProps {
236236
pub normalize_stdout: Vec<(String, String)>,
237237
pub normalize_stderr: Vec<(String, String)>,
238238
pub failure_status: i32,
239+
pub run_rustfix: bool,
239240
}
240241

241242
impl TestProps {
@@ -267,6 +268,7 @@ impl TestProps {
267268
normalize_stdout: vec![],
268269
normalize_stderr: vec![],
269270
failure_status: 101,
271+
run_rustfix: false,
270272
}
271273
}
272274

@@ -403,6 +405,10 @@ impl TestProps {
403405
if let Some(code) = config.parse_failure_status(ln) {
404406
self.failure_status = code;
405407
}
408+
409+
if !self.run_rustfix {
410+
self.run_rustfix = config.parse_run_rustfix(ln);
411+
}
406412
});
407413

408414
for key in &["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] {
@@ -642,6 +648,10 @@ impl Config {
642648

643649
None
644650
}
651+
652+
fn parse_run_rustfix(&self, line: &str) -> bool {
653+
self.parse_name_directive(line, "run-rustfix")
654+
}
645655
}
646656

647657
pub fn lldb_version_to_int(version_string: &str) -> isize {

0 commit comments

Comments
 (0)