diff --git a/core/Cargo.toml b/core/Cargo.toml index 0316035..4df8932 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -13,5 +13,6 @@ bstr = { workspace = true } itertools = { workspace = true } num-bigint = { workspace = true } num-complex = { workspace = true } +serde = { version = "1.0.133", optional = true, default-features = false } lz4_flex = "0.9.2" diff --git a/core/src/location.rs b/core/src/location.rs index 2a2d029..a6e7d39 100644 --- a/core/src/location.rs +++ b/core/src/location.rs @@ -1,5 +1,9 @@ +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; + /// Sourcecode location. #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct Location { pub(super) row: u32, pub(super) column: u32, diff --git a/parser/Cargo.toml b/parser/Cargo.toml index 026616d..4ff560a 100644 --- a/parser/Cargo.toml +++ b/parser/Cargo.toml @@ -10,6 +10,7 @@ edition = "2021" [features] default = ["lalrpop"] # removing this causes potential build failure +serde = ["dep:serde", "rustpython-compiler-core/serde"] [build-dependencies] anyhow = { workspace = true } @@ -33,6 +34,7 @@ unic-ucd-ident = "0.9.0" lalrpop-util = "0.19.8" phf = "0.11.1" rustc-hash = "1.1.0" +serde = { version = "1.0.133", optional = true, default-features = false } [dev-dependencies] insta = { workspace = true }