@@ -132,6 +132,9 @@ pub enum ErrorKind {
132
132
/// An io error during reading or writing.
133
133
#[ fail( display = "io error: {}" , _0) ]
134
134
IoError ( io:: Error ) ,
135
+ /// Parse error occured when parsing the Input.
136
+ #[ fail( display = "parse error" ) ]
137
+ ParseError ,
135
138
/// The user mandated a version and the current version of Rustfmt does not
136
139
/// satisfy that requirement.
137
140
#[ fail( display = "Version mismatch" ) ]
@@ -172,9 +175,10 @@ impl FormattingError {
172
175
}
173
176
fn msg_prefix ( & self ) -> & str {
174
177
match self . kind {
175
- ErrorKind :: LineOverflow ( ..) | ErrorKind :: TrailingWhitespace | ErrorKind :: IoError ( _) => {
176
- "internal error:"
177
- }
178
+ ErrorKind :: LineOverflow ( ..)
179
+ | ErrorKind :: TrailingWhitespace
180
+ | ErrorKind :: IoError ( _)
181
+ | ErrorKind :: ParseError => "internal error:" ,
178
182
ErrorKind :: LicenseCheck | ErrorKind :: BadAttr | ErrorKind :: VersionMismatch => "error:" ,
179
183
ErrorKind :: BadIssue ( _) | ErrorKind :: DeprecatedAttr => "warning:" ,
180
184
}
@@ -844,7 +848,7 @@ fn format_input_inner<T: Write>(
844
848
ParseError :: Recovered => { }
845
849
}
846
850
summary. add_parsing_error ( ) ;
847
- return Ok ( ( summary , FileMap :: new ( ) , FormatReport :: new ( ) ) ) ;
851
+ return Err ( ( ErrorKind :: ParseError , summary ) ) ;
848
852
}
849
853
} ;
850
854
0 commit comments