Skip to content

Commit 8c32a9d

Browse files
committed
Parse Error return an Error instead of a successful empty response
1 parent 34067a1 commit 8c32a9d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/lib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ pub enum ErrorKind {
132132
/// An io error during reading or writing.
133133
#[fail(display = "io error: {}", _0)]
134134
IoError(io::Error),
135+
/// Parse error occured when parsing the Input.
136+
#[fail(display = "parse error")]
137+
ParseError,
135138
/// The user mandated a version and the current version of Rustfmt does not
136139
/// satisfy that requirement.
137140
#[fail(display = "Version mismatch")]
@@ -172,9 +175,10 @@ impl FormattingError {
172175
}
173176
fn msg_prefix(&self) -> &str {
174177
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:",
178182
ErrorKind::LicenseCheck | ErrorKind::BadAttr | ErrorKind::VersionMismatch => "error:",
179183
ErrorKind::BadIssue(_) | ErrorKind::DeprecatedAttr => "warning:",
180184
}
@@ -844,7 +848,7 @@ fn format_input_inner<T: Write>(
844848
ParseError::Recovered => {}
845849
}
846850
summary.add_parsing_error();
847-
return Ok((summary, FileMap::new(), FormatReport::new()));
851+
return Err((ErrorKind::ParseError, summary));
848852
}
849853
};
850854

0 commit comments

Comments
 (0)