mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 10:44:36 +08:00
Fix SyntaxError visualize order: message first location later
This commit is contained in:
1 parent
e4be376336
commit
7bce7baf4a
2 files changed
+4
-8
No files matched your search
@@ -125,7 +125,7 @@ impl fmt::Display for CompileError {
|
||||
if self.location.column() > 0 {
|
||||
if let Some(line) = statement.lines().nth(self.location.row() - 1) {
|
||||
// visualize the error, when location and statement are provided
|
||||
return write!(f, "\n{}\n{}", line, self.location.visualize(&error_desc));
|
||||
return write!(f, "{}", self.location.visualize(line, &error_desc));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,9 @@ impl fmt::Display for Location {
|
||||
}
|
||||
|
||||
impl Location {
|
||||
pub fn visualize(&self, desc: &str) -> String {
|
||||
format!(
|
||||
"{}↑\n{}{}",
|
||||
" ".repeat(self.column - 1),
|
||||
" ".repeat(self.column - 1),
|
||||
desc
|
||||
)
|
||||
pub fn visualize(&self, line: &str, desc: &str) -> String {
|
||||
// desc.to_owned()
|
||||
format!("{}\n{}\n{}↑", desc, line, " ".repeat(self.column - 1))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user