Skip to content

Commit

Permalink
Print some log information about what's being fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed May 4, 2018
1 parent 5f81993 commit 82fb067
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cargo-fix/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,15 @@ fn rustfix_crate(rustc: &Path, filename: &str) -> Result<(), Error> {
// we would do with multiple locations.
let (file_name, range) = match suggestion.snippets.get(0) {
Some(s) => (s.file_name.clone(), s.line_range),
None => continue,
None => {
trace!("rejecting as it has no snippets {:?}", suggestion);
continue
}
};
if !suggestion.snippets.iter().all(|s| {
s.file_name == file_name && s.line_range == range
}) {
trace!("rejecting as it spans mutliple files {:?}", suggestion);
continue
}

Expand All @@ -171,6 +175,8 @@ fn rustfix_crate(rustc: &Path, filename: &str) -> Result<(), Error> {
warn!("failed to read `{}`: {}", file, e);
continue
}
debug!("applying {} fixes to {}", suggestions.len(), file);

let new_code = rustfix::apply_suggestions(&code, &suggestions);
File::create(&file)
.and_then(|mut f| f.write_all(new_code.as_bytes()))
Expand Down

0 comments on commit 82fb067

Please sign in to comment.