Skip to content

Commit

Permalink
Fold rustfix tests back into the UI test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed May 4, 2018
1 parent a563027 commit 6f2d023
Show file tree
Hide file tree
Showing 29 changed files with 223 additions and 80 deletions.
2 changes: 1 addition & 1 deletion src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ impl<'a> Builder<'a> {
test::TheBook, test::UnstableBook, test::RustcBook,
test::Rustfmt, test::Miri, test::Clippy, test::RustdocJS, test::RustdocTheme,
// Run run-make last, since these won't pass without make on Windows
test::RunMake, test::RustdocUi, test::Rustfix),
test::RunMake, test::RustdocUi),
Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook,
doc::Standalone, doc::Std, doc::Test, doc::WhitelistedRustc, doc::Rustc,
Expand Down
6 changes: 0 additions & 6 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,12 +716,6 @@ default_test!(RunFail {
suite: "run-fail"
});

default_test!(Rustfix {
path: "src/test/rustfix",
mode: "rustfix",
suite: "rustfix"
});

default_test!(RunPassValgrind {
path: "src/test/run-pass-valgrind",
mode: "run-pass-valgrind",
Expand Down
22 changes: 22 additions & 0 deletions src/test/ui/suggestions/closure-immutable-outer-variable.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2017 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.

// run-rustfix

// Point at the captured immutable outer variable

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

fn main() {
let mut y = true;
foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable
}
22 changes: 22 additions & 0 deletions src/test/ui/suggestions/closure-immutable-outer-variable.nll.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2017 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.

// run-rustfix

// Point at the captured immutable outer variable

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

fn main() {
let y = true;
foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0594]: cannot assign to immutable item `y`
--> $DIR/closure-immutable-outer-variable.rs:19:26
--> $DIR/closure-immutable-outer-variable.rs:21:26
|
LL | foo(Box::new(move || y = false) as Box<_>); //~ ERROR cannot assign to captured outer variable
| ^^^^^^^^^ cannot mutate
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/suggestions/closure-immutable-outer-variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// run-rustfix

// Point at the captured immutable outer variable

fn foo(mut f: Box<FnMut()>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0594]: cannot assign to captured outer variable in an `FnMut` closure
--> $DIR/closure-immutable-outer-variable.rs:19:26
--> $DIR/closure-immutable-outer-variable.rs:21:26
|
LL | let y = true;
| - help: consider making `y` mutable: `mut y`
Expand Down
16 changes: 16 additions & 0 deletions src/test/ui/suggestions/issue-45562.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2018 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.

// run-rustfix

#[no_mangle] pub static RAH: usize = 5;
//~^ ERROR const items should never be #[no_mangle]

fn main() {}
2 changes: 2 additions & 0 deletions src/test/ui/suggestions/issue-45562.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// run-rustfix

#[no_mangle] pub const RAH: usize = 5;
//~^ ERROR const items should never be #[no_mangle]

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/suggestions/issue-45562.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: const items should never be #[no_mangle]
--> $DIR/issue-45562.rs:11:14
--> $DIR/issue-45562.rs:13:14
|
LL | #[no_mangle] pub const RAH: usize = 5;
| ---------^^^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2017 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.

// run-rustfix

extern crate std as other_std;
fn main() {}
//~^^ ERROR the name `std` is defined multiple times [E0259]
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// run-rustfix

extern crate std;
fn main() {}
//~^^ ERROR the name `std` is defined multiple times [E0259]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0259]: the name `std` is defined multiple times
--> $DIR/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs:11:1
--> $DIR/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs:13:1
|
LL | extern crate std;
| ^^^^^^^^^^^^^^^^^ `std` reimported here
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright 2017 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.

// run-rustfix

#![allow(unused)]

fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize {
and_yet + 1
}

fn main() {
let behold: isize = 2;
let with_tears: usize = 3;
light_flows_our_war_of_mocking_words(&(behold as usize));
//~^ ERROR mismatched types [E0308]
light_flows_our_war_of_mocking_words(&(with_tears + 4));
//~^ ERROR mismatched types [E0308]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// run-rustfix

#![allow(unused)]

fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:20:42
--> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:22:42
|
LL | light_flows_our_war_of_mocking_words(behold as usize);
| ^^^^^^^^^^^^^^^
Expand All @@ -11,7 +11,7 @@ LL | light_flows_our_war_of_mocking_words(behold as usize);
found type `usize`

error[E0308]: mismatched types
--> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:22:42
--> $DIR/issue-46756-consider-borrowing-cast-or-binexpr.rs:24:42
|
LL | light_flows_our_war_of_mocking_words(with_tears + 4);
| ^^^^^^^^^^^^^^
Expand Down
21 changes: 21 additions & 0 deletions src/test/ui/suggestions/missing-comma-in-match.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2018 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.

// run-rustfix

fn main() {
match &Some(3) {
&None => 1,
&Some(2) => { 3 }
//~^ ERROR expected one of `,`, `.`, `?`, `}`, or an operator, found `=>`
//~| NOTE expected one of `,`, `.`, `?`, `}`, or an operator here
_ => 2
};
}
2 changes: 2 additions & 0 deletions src/test/ui/suggestions/missing-comma-in-match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// run-rustfix

fn main() {
match &Some(3) {
&None => 1
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/suggestions/missing-comma-in-match.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: expected one of `,`, `.`, `?`, `}`, or an operator, found `=>`
--> $DIR/missing-comma-in-match.rs:14:18
--> $DIR/missing-comma-in-match.rs:16:18
|
LL | &None => 1
| - help: missing a comma here to end this `match` arm
Expand Down
16 changes: 16 additions & 0 deletions src/test/ui/suggestions/str-as-char.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2017 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.

// run-rustfix

fn main() {
println!("●●");
//~^ ERROR character literal may only contain one codepoint
}
2 changes: 2 additions & 0 deletions src/test/ui/suggestions/str-as-char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// run-rustfix

fn main() {
println!('●●');
//~^ ERROR character literal may only contain one codepoint
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/suggestions/str-as-char.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: character literal may only contain one codepoint
--> $DIR/str-as-char.rs:12:14
--> $DIR/str-as-char.rs:14:14
|
LL | println!('●●');
| ^^^^
Expand Down
16 changes: 16 additions & 0 deletions src/test/ui/suggestions/tuple-float-index.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2012 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.

// run-rustfix
// compile-flags: -Z parse-only

fn main () {
((1, (2, 3)).1).1; //~ ERROR unexpected token: `1.1`
}
1 change: 1 addition & 0 deletions src/test/ui/suggestions/tuple-float-index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// run-rustfix
// compile-flags: -Z parse-only

fn main () {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/suggestions/tuple-float-index.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: unexpected token: `1.1`
--> $DIR/tuple-float-index.rs:14:17
--> $DIR/tuple-float-index.rs:15:17
|
LL | (1, (2, 3)).1.1; //~ ERROR unexpected token: `1.1`
| ------------^^^
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/update-references.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ if [[ "$1" == "--help" || "$1" == "-h" || "$1" == "" || "$2" == "" ]]; then
echo " $0 ../../../build/x86_64-apple-darwin/test/ui *.rs */*.rs"
fi

MYDIR=$(dirname $0)

BUILD_DIR="$1"
shift

shopt -s nullglob

while [[ "$1" != "" ]]; do
for EXT in "stderr" "stdout"; do
MYDIR=$(dirname $1)
for EXT in "stderr" "stdout" "fixed"; do
for OUT_NAME in $BUILD_DIR/${1%.rs}.*$EXT; do
OUT_BASE=`basename "$OUT_NAME"`
if ! (diff $OUT_NAME $MYDIR/$OUT_BASE >& /dev/null); then
Expand Down
3 changes: 0 additions & 3 deletions src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ pub enum Mode {
RunMake,
Ui,
MirOpt,
Rustfix,
}

impl Mode {
Expand Down Expand Up @@ -68,7 +67,6 @@ impl FromStr for Mode {
"run-make" => Ok(RunMake),
"ui" => Ok(Ui),
"mir-opt" => Ok(MirOpt),
"rustfix" => Ok(Rustfix),
_ => Err(()),
}
}
Expand All @@ -92,7 +90,6 @@ impl fmt::Display for Mode {
RunMake => "run-make",
Ui => "ui",
MirOpt => "mir-opt",
Rustfix => "rustfix",
};
fmt::Display::fmt(s, f)
}
Expand Down
10 changes: 10 additions & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ pub struct TestProps {
pub normalize_stdout: Vec<(String, String)>,
pub normalize_stderr: Vec<(String, String)>,
pub failure_status: i32,
pub run_rustfix: bool,
}

impl TestProps {
Expand Down Expand Up @@ -267,6 +268,7 @@ impl TestProps {
normalize_stdout: vec![],
normalize_stderr: vec![],
failure_status: 101,
run_rustfix: false,
}
}

Expand Down Expand Up @@ -403,6 +405,10 @@ impl TestProps {
if let Some(code) = config.parse_failure_status(ln) {
self.failure_status = code;
}

if !self.run_rustfix {
self.run_rustfix = config.parse_run_rustfix(ln);
}
});

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

None
}

fn parse_run_rustfix(&self, line: &str) -> bool {
self.parse_name_directive(line, "run-rustfix")
}
}

pub fn lldb_version_to_int(version_string: &str) -> isize {
Expand Down
Loading

0 comments on commit 6f2d023

Please sign in to comment.