Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/cargo/ops/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,12 @@ fn rustfix_and_fix(fixes: &mut FixedCrate, rustc: &Path, filename: &Path, args:
// If not empty, filter by these lints
//
// TODO: Implement a way to specify this
let only = HashSet::new();
let mut only = HashSet::new();
match &args.prepare_for_edition {
PrepareFor::Edition(edition) => { only.insert(format!("rust_{}_compatibility", edition)); },
PrepareFor::Next => { only.insert(format!("rust_{}_compatibility", args.next_edition())); },
PrepareFor::None => (),
}

let mut cmd = Command::new(rustc);
cmd.arg("--error-format=json");
Expand Down
14 changes: 14 additions & 0 deletions tests/testsuite/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,20 @@ fn fix_overlapping() {
assert!(contents.contains("crate::foo::<crate::A>()"));
}

#[test]
fn prepare_for_leaves_unrelated_warnings_alone() {
if !is_nightly() { return; }

let p = project().file("src/main.rs", "fn main() { let x = 1; }").build();

p.cargo("fix --allow-no-vcs --prepare-for 2018").run();

let contents = p.read_file("src/main.rs");
println!("{}", contents);
assert!(contents.contains("let x = 1;"));
assert!(!contents.contains("let _x = 1;"));
}

#[test]
fn fix_idioms() {
if !is_nightly() {
Expand Down