File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed
rustfmt-bin/src/git-rustfmt
rustfmt-lib/src/formatting Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff 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
7685struct NullOptions ;
Original file line number Diff line number Diff 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
178173impl NonFormattedRange {
You can’t perform that action at this time.
0 commit comments