mirror of
https://gitee.com/openharmony/third_party_rust_syn
synced 2024-11-27 09:50:41 +00:00
Add dump-syntax fallback error message
This commit is contained in:
parent
c2ddaaf1c0
commit
2e7bd2581c
@ -91,12 +91,12 @@ fn render_location(
|
||||
let mut end = err.span().end();
|
||||
|
||||
if start.line == end.line && start.column == end.column {
|
||||
return Ok(());
|
||||
return render_fallback(formatter, err);
|
||||
}
|
||||
|
||||
let code_line = match code.lines().nth(start.line - 1) {
|
||||
Some(line) => line,
|
||||
None => return Ok(()),
|
||||
None => return render_fallback(formatter, err),
|
||||
};
|
||||
|
||||
if end.line > start.line {
|
||||
@ -128,3 +128,7 @@ fn render_location(
|
||||
message = err,
|
||||
)
|
||||
}
|
||||
|
||||
fn render_fallback(formatter: &mut fmt::Formatter, err: &syn::Error) -> fmt::Result {
|
||||
write!(formatter, "Unable to parse file: {}", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user