Skip to content

Commit 000d15c

Browse files
committed
Fix git-rustfmt
1 parent b250dc5 commit 000d15c

File tree

2 files changed

+13
-9
lines changed
  • rustfmt-core

2 files changed

+13
-9
lines changed

rustfmt-core/rustfmt-bin/src/git-rustfmt/main.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,23 @@ fn fmt_files(files: &[&str]) -> i32 {
6363

6464
let mut out = stdout();
6565
for file in files {
66-
let report = format(Input::File(PathBuf::from(file)), &config, setting).unwrap();
67-
if report.has_warnings() {
66+
let report = match format(Input::File(PathBuf::from(file)), &config, setting) {
67+
Ok(report) => report,
68+
Err(e) => {
69+
eprintln!("{}", e);
70+
return 1;
71+
}
72+
};
73+
if report.has_errors() {
6874
eprintln!("{}", FormatReportFormatterBuilder::new(&report).build());
6975
}
70-
emit_format_report(report, &mut out, EmitterConfig::default()).unwrap();
76+
if let Err(e) = emit_format_report(report, &mut out, EmitterConfig::default()) {
77+
eprintln!("{}", e);
78+
return 1;
79+
}
7180
}
7281

73-
todo!("Fix error handling")
82+
0
7483
}
7584

7685
struct NullOptions;

rustfmt-core/rustfmt-lib/src/formatting/report.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,6 @@ impl FormatReport {
168168
.map(|(_, format_result)| format_result.errors_excluding_macro().count())
169169
.sum()
170170
}
171-
172-
/// Whether any warnings or errors are present in the report.
173-
pub fn has_warnings(&self) -> bool {
174-
self.has_errors()
175-
}
176171
}
177172

178173
impl NonFormattedRange {

0 commit comments

Comments
 (0)