mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-15 17:15:24 +00:00
integrate ast::Location into compilre-core::Location
This commit is contained in:
parent
a22abc5550
commit
9d6ab72d79
12 changed files with 34 additions and 99 deletions
|
@ -30,13 +30,10 @@ impl fmt::Display for CompileError {
|
|||
let loc = self.location;
|
||||
if let Some(ref stmt) = self.statement {
|
||||
// visualize the error when location and statement are provided
|
||||
write!(
|
||||
f,
|
||||
"{}",
|
||||
loc.visualize(stmt, &format_args!("{} at {}", self.error, loc))
|
||||
)
|
||||
loc.fmt_with(f, &self.error)?;
|
||||
write!(f, "\n{stmt}{arrow:>pad$}", pad = loc.column(), arrow = "^")
|
||||
} else {
|
||||
write!(f, "{} at {}", self.error, loc)
|
||||
loc.fmt_with(f, &self.error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue