Skip to content

Commit c02aedf

Browse files
killercupalexcrichton
authored andcommitted
Use rustfix' suggestion fixing API
Uses branch from <rust-lang/rustfix#63> until we publish a new release.
1 parent fd6aa14 commit c02aedf

File tree

4 files changed

+6
-74
lines changed

4 files changed

+6
-74
lines changed

src/tools/compiletest/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ regex = "0.2"
1313
serde = "1.0"
1414
serde_json = "1.0"
1515
serde_derive = "1.0"
16-
rustfix = { git = "https://github.com/rust-lang-nursery/rustfix" }
16+
rustfix = { git = "https://github.com/rust-lang-nursery/rustfix", branch = "apply_suggestion" }
1717

1818
[target.'cfg(unix)'.dependencies]
1919
libc = "0.2"

src/tools/compiletest/src/autofix.rs

-70
This file was deleted.

src/tools/compiletest/src/main.rs

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ pub mod common;
5353
pub mod errors;
5454
mod raise_fd_limit;
5555
mod read2;
56-
mod autofix;
5756

5857
fn main() {
5958
env_logger::init();

src/tools/compiletest/src/runtest.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ use std::path::{Path, PathBuf};
3535
use std::process::{Child, Command, ExitStatus, Output, Stdio};
3636
use std::str;
3737

38-
use autofix::run_rustfix;
3938
use extract_gdb_version;
4039

4140
/// The name of the environment variable that holds dynamic library locations.
@@ -2607,10 +2606,14 @@ impl<'test> TestCx<'test> {
26072606

26082607
let fixture_path = expected_output_path(&self.testpaths, None, &None, UI_FIXED);
26092608
if fixture_path.exists() {
2609+
use std::collections::HashSet;
2610+
use rustfix::{apply_suggestions, get_suggestions_from_json};
2611+
26102612
let unfixed_code = self.load_expected_output_from_path(&self.testpaths.file)
26112613
.unwrap();
26122614
let expected_fixed = self.load_expected_output_from_path(&fixture_path).unwrap();
2613-
let fixed_code = run_rustfix(&unfixed_code, &proc_res.stderr);
2615+
let suggestions = get_suggestions_from_json(&proc_res.stderr, &HashSet::new()).unwrap();
2616+
let fixed_code = apply_suggestions(&unfixed_code, &suggestions);
26142617
let errors = self.compare_output("rs.fixed", &fixed_code, &expected_fixed);
26152618
if errors > 0 {
26162619
panic!("rustfix produced different fixed file!");

0 commit comments

Comments
 (0)