mirror of
https://github.com/RustPython/Parser.git
synced 2025-08-31 15:48:24 +00:00
Replace row/column based Location with byte-offsets.
This commit is contained in:
parent
7b8844bd3e
commit
58c35ab458
131 changed files with 12120 additions and 23198 deletions
|
@ -9,10 +9,11 @@ license = "MIT"
|
|||
|
||||
[dependencies]
|
||||
bitflags = { workspace = true }
|
||||
bstr = { workspace = true }
|
||||
itertools = { workspace = true }
|
||||
num-bigint = { workspace = true }
|
||||
num-complex = { workspace = true }
|
||||
serde = { version = "1.0.133", optional = true, default-features = false, features = ["derive"] }
|
||||
ruff_text_size = { path = "../ruff_text_size" }
|
||||
|
||||
lz4_flex = "0.9.2"
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use crate::Location;
|
||||
use ruff_text_size::TextSize;
|
||||
use std::error::Error as StdError;
|
||||
use std::fmt::Display;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct BaseError<T> {
|
||||
pub error: T,
|
||||
pub location: Location,
|
||||
pub location: TextSize,
|
||||
pub source_path: String,
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,12 @@ where
|
|||
T: std::fmt::Display,
|
||||
{
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
self.location.fmt_with(f, &self.error)
|
||||
write!(
|
||||
f,
|
||||
"{} at byte offset {}",
|
||||
&self.error,
|
||||
u32::from(self.location)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue