]> git.lizzy.rs Git - rust.git/commitdiff
Fold rustfix tests back into the UI test suite
authorAlex Crichton <alex@alexcrichton.com>
Thu, 3 May 2018 18:26:58 +0000 (11:26 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 4 May 2018 22:01:28 +0000 (15:01 -0700)
29 files changed:
src/bootstrap/builder.rs
src/bootstrap/test.rs
src/test/ui/suggestions/closure-immutable-outer-variable.fixed [new file with mode: 0644]
src/test/ui/suggestions/closure-immutable-outer-variable.nll.fixed [new file with mode: 0644]
src/test/ui/suggestions/closure-immutable-outer-variable.nll.stderr
src/test/ui/suggestions/closure-immutable-outer-variable.rs
src/test/ui/suggestions/closure-immutable-outer-variable.stderr
src/test/ui/suggestions/issue-45562.fixed [new file with mode: 0644]
src/test/ui/suggestions/issue-45562.rs
src/test/ui/suggestions/issue-45562.stderr
src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed [new file with mode: 0644]
src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs
src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr
src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.fixed [new file with mode: 0644]
src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.rs
src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.stderr
src/test/ui/suggestions/missing-comma-in-match.fixed [new file with mode: 0644]
src/test/ui/suggestions/missing-comma-in-match.rs
src/test/ui/suggestions/missing-comma-in-match.stderr
src/test/ui/suggestions/str-as-char.fixed [new file with mode: 0644]
src/test/ui/suggestions/str-as-char.rs
src/test/ui/suggestions/str-as-char.stderr
src/test/ui/suggestions/tuple-float-index.fixed [new file with mode: 0644]
src/test/ui/suggestions/tuple-float-index.rs
src/test/ui/suggestions/tuple-float-index.stderr
src/test/ui/update-references.sh
src/tools/compiletest/src/common.rs
src/tools/compiletest/src/header.rs
src/tools/compiletest/src/runtest.rs

index 5920e356bca40dabe83c8a3dfa4faee9a6c72ddb..08bb8ab481513bbf803f3a657442cef390c0907f 100644 (file)
@@ -326,7 +326,7 @@ macro_rules! describe {
                 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,
index fa32dd3163560ec6e6f683f92c27c903d2075b6d..e8c40dfdb0ad2bcfdc877b9a269f26f6aca760e6 100644 (file)
@@ -716,12 +716,6 @@ fn run(self, builder: &Builder) {
     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",
diff --git a/src/test/ui/suggestions/closure-immutable-outer-variable.fixed b/src/test/ui/suggestions/closure-immutable-outer-variable.fixed
new file mode 100644 (file)
index 0000000..b3a0d59
--- /dev/null
@@ -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
+}
diff --git a/src/test/ui/suggestions/closure-immutable-outer-variable.nll.fixed b/src/test/ui/suggestions/closure-immutable-outer-variable.nll.fixed
new file mode 100644 (file)
index 0000000..e162678
--- /dev/null
@@ -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
+}
index e4e93ecac8e620656ca2c160c2b89a2d3eed7077..bc655114c2b471a764e8ce670620cacf369ffed3 100644 (file)
@@ -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
index 1d14afd6a01acb6a893d4e23b1d72147f63407c0..e162678460c6c0a2e84bf2f83d65e86256b1d5fd 100644 (file)
@@ -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()>) {
index 3353e2c7291728c3805c52cf130a0e1c22d26161..0ee11d8cf15dead51f9e482ea4627b6a2e816bdf 100644 (file)
@@ -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`
diff --git a/src/test/ui/suggestions/issue-45562.fixed b/src/test/ui/suggestions/issue-45562.fixed
new file mode 100644 (file)
index 0000000..7c01f0d
--- /dev/null
@@ -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() {}
index f493df56f949d9e06d3fa37f0e4105ded9d1d714..c27d52fcdd392ab78c81e6bdfe6edaffbdfc3f0c 100644 (file)
@@ -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]
 
index d6960dca0546f15a23be65e8cb86de9b55711215..d9e624cadc70543811e30db2eb001a8df1ab86ec 100644 (file)
@@ -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;
    |              ---------^^^^^^^^^^^^^^^^
diff --git a/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed b/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed
new file mode 100644 (file)
index 0000000..e328703
--- /dev/null
@@ -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]
index 4d75127b645bd3e5d3e5717da6e81cb49baa4f4e..f47ea474d510b2fe3e8c3d3ab9bc828117428e1b 100644 (file)
@@ -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]
index 8e2b2d845e9b01d6e2a3d97ae418a6c55ff466fe..ecdfec2b3bfd6aaef1aed023e5f5ebdfd0662d2e 100644 (file)
@@ -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
diff --git a/src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.fixed b/src/test/ui/suggestions/issue-46756-consider-borrowing-cast-or-binexpr.fixed
new file mode 100644 (file)
index 0000000..77171ca
--- /dev/null
@@ -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]
+}
index 5617c46afa94c7a347ea462cb1ea5374a9cf0286..e5ea9b5ed099dfa949479d3f7a94be6cf67ece2e 100644 (file)
@@ -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 {
index e89e9dce94dc41171457f564c06091b80f9d60c7..9c492751ca1a026be52083622c2970f14a135d4b 100644 (file)
@@ -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);
    |                                          ^^^^^^^^^^^^^^^
@@ -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);
    |                                          ^^^^^^^^^^^^^^
diff --git a/src/test/ui/suggestions/missing-comma-in-match.fixed b/src/test/ui/suggestions/missing-comma-in-match.fixed
new file mode 100644 (file)
index 0000000..4832f35
--- /dev/null
@@ -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
+    };
+}
index 6f86cdea3cf5e867806e81fedab1cc537e70d867..e39b20e77ea800a7e9d89626bac9c2c3c7ff340a 100644 (file)
@@ -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
index b71a50b66318e6abbd9e9e521472aac4fd30f66a..779359341073ea7f54141f9521a7e81a917179e0 100644 (file)
@@ -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
diff --git a/src/test/ui/suggestions/str-as-char.fixed b/src/test/ui/suggestions/str-as-char.fixed
new file mode 100644 (file)
index 0000000..c0dad38
--- /dev/null
@@ -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
+}
index 09aca61147df0f791b760f86dbf9a4e432f956c4..b5a5df0af7f94009ce071fa770eed6c2256bb093 100644 (file)
@@ -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
index d881becf00c9ef881d46325f104cf0aaa2adec04..60eb182adf14546959ef6832ab03b92d300e6cf6 100644 (file)
@@ -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!('●●');
    |              ^^^^
diff --git a/src/test/ui/suggestions/tuple-float-index.fixed b/src/test/ui/suggestions/tuple-float-index.fixed
new file mode 100644 (file)
index 0000000..55bc2f7
--- /dev/null
@@ -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`
+}
index 0a188305a9228cb6bce149ba8b767302494e2133..d569ca4cb861e01a20fce5fd83aa6ed69ead7dd2 100644 (file)
@@ -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 () {
index 4a1e34890f4847be3962bdf4fb1ff4715f490a13..15af0834f03729a12b2f1fd27f42ea6d09e3abf4 100644 (file)
@@ -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`
    |     ------------^^^
index 4fc11daaa3afa0de5758d8c046f433467e571299..47a85352b0044c0d39c78dd9c0bb35f6c95f2e65 100755 (executable)
@@ -26,7 +26,6 @@ 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
@@ -34,7 +33,8 @@ 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
index 733fc1f16d24bef905fb103e3054fd17047e33ae..2df5281659934c88717fafa379f458415165a1e7 100644 (file)
@@ -32,7 +32,6 @@ pub enum Mode {
     RunMake,
     Ui,
     MirOpt,
-    Rustfix,
 }
 
 impl Mode {
@@ -68,7 +67,6 @@ fn from_str(s: &str) -> Result<Mode, ()> {
             "run-make" => Ok(RunMake),
             "ui" => Ok(Ui),
             "mir-opt" => Ok(MirOpt),
-            "rustfix" => Ok(Rustfix),
             _ => Err(()),
         }
     }
@@ -92,7 +90,6 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             RunMake => "run-make",
             Ui => "ui",
             MirOpt => "mir-opt",
-            Rustfix => "rustfix",
         };
         fmt::Display::fmt(s, f)
     }
index 73dd079cf0ccb8f40e1cc4a494519cb9dfaaab37..7ac3f5b5b25e8e5115f7943c0b0f3594a7906a0d 100644 (file)
@@ -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 {
@@ -267,6 +268,7 @@ pub fn new() -> Self {
             normalize_stdout: vec![],
             normalize_stderr: vec![],
             failure_status: 101,
+            run_rustfix: false,
         }
     }
 
@@ -403,6 +405,10 @@ fn load_from(&mut self,
             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"] {
@@ -642,6 +648,10 @@ pub fn find_rust_src_root(&self) -> Option<PathBuf> {
 
         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 {
index ea1863b2fd16cdb830ff470fcc4b9d81deb9c3b2..fae75c352da1f7d21bd3a3060696d67bd18200fc 100644 (file)
@@ -11,7 +11,7 @@
 use common::{Config, TestPaths};
 use common::{CompileFail, ParseFail, Pretty, RunFail, RunPass, RunPassValgrind};
 use common::{Codegen, CodegenUnits, DebugInfoGdb, DebugInfoLldb, Rustdoc};
-use common::{Incremental, MirOpt, RunMake, Ui, Rustfix};
+use common::{Incremental, MirOpt, RunMake, Ui};
 use common::{expected_output_path, UI_STDERR, UI_STDOUT, UI_FIXED};
 use common::CompareMode;
 use diff;
@@ -242,7 +242,6 @@ fn run_revision(&self) {
             CodegenUnits => self.run_codegen_units_test(),
             Incremental => self.run_incremental_test(),
             RunMake => self.run_rmake_test(),
-            Rustfix => self.run_rustfix_test(),
             Ui => self.run_ui_test(),
             MirOpt => self.run_mir_opt_test(),
         }
@@ -1689,7 +1688,6 @@ fn make_compile_args(&self, input_file: &Path, output_file: TargetLocation) -> C
 
                 rustc.arg(dir_opt);
             }
-            Rustfix |
             RunPass |
             RunFail |
             RunPassValgrind |
@@ -2555,6 +2553,7 @@ fn run_ui_test(&self) {
 
         let expected_stderr = self.load_expected_output(UI_STDERR);
         let expected_stdout = self.load_expected_output(UI_STDOUT);
+        let expected_fixed = self.load_expected_output(UI_FIXED);
 
         let normalized_stdout =
             self.normalize_output(&proc_res.stdout, &self.props.normalize_stdout);
@@ -2571,6 +2570,21 @@ fn run_ui_test(&self) {
         errors += self.compare_output("stdout", &normalized_stdout, &expected_stdout);
         errors += self.compare_output("stderr", &normalized_stderr, &expected_stderr);
 
+        if self.config.compare_mode.is_some() {
+            // don't test rustfix with nll right now
+        } else if self.props.run_rustfix {
+            // Apply suggestions from rustc to the code itself
+            let unfixed_code = self.load_expected_output_from_path(&self.testpaths.file)
+                .unwrap();
+            let suggestions = get_suggestions_from_json(&proc_res.stderr, &HashSet::new()).unwrap();
+            let fixed_code = apply_suggestions(&unfixed_code, &suggestions);
+
+            errors += self.compare_output("fixed", &fixed_code, &expected_fixed);
+        } else if !expected_fixed.is_empty() {
+            panic!("the `// run-rustfix` directive wasn't found but a `*.fixed` \
+                    file was found");
+        }
+
         if errors > 0 {
             println!("To update references, run this command from build directory:");
             let relative_path_to_file = self.testpaths
@@ -2606,6 +2620,23 @@ fn run_ui_test(&self) {
                 self.check_error_patterns(&proc_res.stderr, &proc_res);
             }
         }
+
+        if self.props.run_rustfix && self.config.compare_mode.is_none() {
+            // And finally, compile the fixed code and make sure it both
+            // succeeds and has no diagnostics.
+            let mut rustc = self.make_compile_args(
+                &self.testpaths.file.with_extension(UI_FIXED),
+                TargetLocation::ThisFile(self.make_exe_name()),
+            );
+            rustc.arg("-L").arg(&self.aux_output_dir_name());
+            let res = self.compose_and_run_compiler(rustc, None);
+            if !res.status.success() {
+                self.fatal_proc_rec("failed to compile fixed code", &res);
+            }
+            if !res.stderr.is_empty() {
+                self.fatal_proc_rec("fixed code is still producing diagnostics", &res);
+            }
+        }
     }
 
     fn run_mir_opt_test(&self) {
@@ -2930,62 +2961,6 @@ fn compare_output(&self, kind: &str, actual: &str, expected: &str) -> usize {
         println!("Actual {} saved to {}", kind, output_file.display());
         1
     }
-
-    fn run_rustfix_test(&self) {
-        // First up, compile the test with --error-format=json
-        let mut rustc = self.make_compile_args(
-            &self.testpaths.file,
-            TargetLocation::ThisFile(self.make_exe_name()),
-        );
-        rustc.arg("--error-format").arg("json")
-            .arg("-L").arg(&self.aux_output_dir_name());
-        let proc_res = self.compose_and_run_compiler(rustc, None);
-
-        // Now apply suggestions from rustc to the code itself
-        let unfixed_code = self.load_expected_output_from_path(&self.testpaths.file)
-            .unwrap();
-        let suggestions = get_suggestions_from_json(&proc_res.stderr, &HashSet::new()).unwrap();
-        let fixed_code = apply_suggestions(&unfixed_code, &suggestions);
-
-        // Load up what the expected result of fixing should be
-        let fixture_path = expected_output_path(&self.testpaths, None, &None, UI_FIXED);
-        let expected_fixed = self.load_expected_output_from_path(&fixture_path)
-            .unwrap_or(String::new());
-
-        // Make sure our fixed code is the same as what we're expecting
-        let errors = self.compare_output(UI_FIXED, &fixed_code, &expected_fixed);
-        if errors > 0 {
-            println!("To update references, run this command from build directory:");
-            let relative_path_to_file = self.testpaths
-                .relative_dir
-                .join(self.testpaths.file.file_name().unwrap());
-            println!(
-                "{}/update-references.sh '{}' '{}'",
-                self.config.src_base.display(),
-                self.config.build_base.display(),
-                relative_path_to_file.display()
-            );
-            self.fatal_proc_rec(
-                &format!("{} errors occurred comparing output.", errors),
-                &proc_res,
-            );
-        }
-
-        // And finally, compile the fixed code and make sure it both succeeds
-        // and has no diagnostics.
-        let mut rustc = self.make_compile_args(
-            &self.testpaths.file.with_extension(UI_FIXED),
-            TargetLocation::ThisFile(self.make_exe_name()),
-        );
-        rustc.arg("-L").arg(&self.aux_output_dir_name());
-        let res = self.compose_and_run_compiler(rustc, None);
-        if !res.status.success() {
-            self.fatal_proc_rec("failed to compile fixed code", &res);
-        }
-        if !res.stderr.is_empty() {
-            self.fatal_proc_rec("fixed code is still producing diagnostics", &res);
-        }
-    }
 }
 
 struct ProcArgs {