Replace row/column based Location with byte-offsets.

This commit is contained in:
Micha Reiser 2023-05-06 15:54:14 +09:00 committed by Jeong YunWon
parent 7b8844bd3e
commit 58c35ab458
131 changed files with 12120 additions and 23198 deletions

View file

@ -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"

View file

@ -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)
)
}
}