git.delta.rocks / jrsonnet / refs/commits / 4f26f96ee098

difftreelog

perf remove AST (de)serialization

Yaroslav Bolyukin2024-05-19parent: #0ae36ba.patch.diff
in: master

12 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -543,8 +543,6 @@
  "hashbrown 0.14.5",
  "jrsonnet-gcmodule",
  "rustc-hash",
- "serde",
- "structdump",
 ]
 
 [[package]]
@@ -563,9 +561,7 @@
  "jrsonnet-gcmodule",
  "jrsonnet-interner",
  "peg",
- "serde",
  "static_assertions",
- "structdump",
 ]
 
 [[package]]
@@ -586,7 +582,6 @@
 version = "0.5.0-pre96"
 dependencies = [
  "base64",
- "bincode",
  "jrsonnet-evaluator",
  "jrsonnet-gcmodule",
  "jrsonnet-macros",
@@ -602,7 +597,6 @@
  "sha1",
  "sha2",
  "sha3",
- "structdump",
 ]
 
 [[package]]
@@ -1102,28 +1096,6 @@
 version = "0.11.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
-
-[[package]]
-name = "structdump"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b0570327507bf281d8a6e6b0d4c082b12cb6bcee27efce755aa5efacd44076c1"
-dependencies = [
- "proc-macro2",
- "quote",
- "structdump-derive",
-]
-
-[[package]]
-name = "structdump-derive"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "29cc0b59cfa11f1bceda09a9a7e37e6a6c3138575fd24ade8aa9af6d09aedf28"
-dependencies = [
- "proc-macro2",
- "quote",
- "syn 1.0.109",
-]
 
 [[package]]
 name = "syn"
modifiedCargo.tomldiffbeforeafterboth
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -79,7 +79,6 @@
 num-bigint = "0.4.5"
 derivative = "2.2.0"
 strsim = "0.11.0"
-structdump = "0.2.0"
 proc-macro2 = "1.0"
 quote = "1.0"
 syn = "2.0"
modifiedcrates/jrsonnet-interner/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-interner/Cargo.toml
+++ b/crates/jrsonnet-interner/Cargo.toml
@@ -10,20 +10,8 @@
 [lints]
 workspace = true
 
-[features]
-default = []
-# Implement value serialization using structdump
-structdump = ["dep:structdump"]
-# Implement value serialization using serde
-#
-# Warning: serialized values won't be deduplicated
-serde = ["dep:serde"]
-
 [dependencies]
 jrsonnet-gcmodule.workspace = true
-
-serde = { workspace = true, optional = true }
-structdump = { workspace = true, optional = true }
 
 rustc-hash.workspace = true
 hashbrown = { workspace = true, features = ["inline-more"] }
modifiedcrates/jrsonnet-interner/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-interner/src/lib.rs
+++ b/crates/jrsonnet-interner/src/lib.rs
@@ -219,45 +219,6 @@
 	}
 }
 
-#[cfg(feature = "serde")]
-impl serde::Serialize for IStr {
-	fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
-	where
-		S: serde::Serializer,
-	{
-		self.as_str().serialize(serializer)
-	}
-}
-
-#[cfg(feature = "serde")]
-impl<'de> serde::Deserialize<'de> for IStr {
-	fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
-	where
-		D: serde::Deserializer<'de>,
-	{
-		let str = <&str>::deserialize(deserializer)?;
-		Ok(intern_str(str))
-	}
-}
-
-#[cfg(feature = "structdump")]
-impl structdump::Codegen for IStr {
-	fn gen_code(
-		&self,
-		res: &mut structdump::CodegenResult,
-		_unique: bool,
-	) -> structdump::TokenStream {
-		let s: &str = self;
-		res.add_code(
-			structdump::quote! {
-				structdump_import::IStr::from(#s)
-			},
-			Some(structdump::quote![structdump_import::IStr]),
-			false,
-		)
-	}
-}
-
 thread_local! {
 	static POOL: RefCell<HashMap<Inner, (), BuildHasherDefault<FxHasher>>> = RefCell::new(HashMap::with_capacity_and_hasher(200, BuildHasherDefault::default()));
 }
modifiedcrates/jrsonnet-parser/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-parser/Cargo.toml
+++ b/crates/jrsonnet-parser/Cargo.toml
@@ -11,21 +11,6 @@
 default = []
 exp-destruct = []
 exp-null-coaelse = []
-# Implement serialization of AST using structdump
-#
-# Structdump generates code, which exactly replicated passed AST
-# Contrary to serde, has no code bloat problem, and is recommended
-#
-# The only limitation is serialized form is only useable if built from build script
-structdump = ["dep:structdump", "jrsonnet-interner/structdump"]
-# Implement serialization of AST using serde
-#
-# Warning: as serde doesn't deduplicate strings, `Source` struct will bloat
-# output binary with repeating source code. To resolve this issue, you should either
-# override serialization of this struct using custom `Serializer`/`Deserializer`,
-# not rely on Source, and fill its `source_code` with empty value, or use `structdump`
-# instead
-serde = ["dep:serde"]
 
 [dependencies]
 jrsonnet-interner.workspace = true
@@ -34,6 +19,3 @@
 static_assertions.workspace = true
 
 peg.workspace = true
-
-serde = { workspace = true, features = ["derive", "rc"], optional = true }
-structdump = { workspace = true, features = ["derive"], optional = true }
modifiedcrates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth
--- a/crates/jrsonnet-parser/src/expr.rs
+++ b/crates/jrsonnet-parser/src/expr.rs
@@ -6,15 +6,9 @@
 
 use jrsonnet_gcmodule::Trace;
 use jrsonnet_interner::IStr;
-#[cfg(feature = "serde")]
-use serde::{Deserialize, Serialize};
-#[cfg(feature = "structdump")]
-use structdump::Codegen;
 
 use crate::source::Source;
 
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
-#[cfg_attr(feature = "structdump", derive(Codegen))]
 #[derive(Debug, PartialEq, Trace)]
 pub enum FieldName {
 	/// {fixed: 2}
@@ -23,8 +17,6 @@
 	Dyn(LocExpr),
 }
 
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, Clone, Copy, PartialEq, Eq, Trace)]
 #[repr(u8)]
 pub enum Visibility {
@@ -42,13 +34,9 @@
 	}
 }
 
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Clone, Debug, PartialEq, Trace)]
 pub struct AssertStmt(pub LocExpr, pub Option<LocExpr>);
 
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, PartialEq, Trace)]
 pub struct FieldMember {
 	pub name: FieldName,
@@ -58,8 +46,6 @@
 	pub value: LocExpr,
 }
 
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, PartialEq, Trace)]
 pub enum Member {
 	Field(FieldMember),
@@ -67,8 +53,6 @@
 	AssertStmt(AssertStmt),
 }
 
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, Clone, Copy, PartialEq, Eq, Trace)]
 pub enum UnaryOpType {
 	Plus,
@@ -93,8 +77,6 @@
 	}
 }
 
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, Clone, Copy, PartialEq, Eq, Trace)]
 pub enum BinaryOpType {
 	Mul,
@@ -164,14 +146,10 @@
 }
 
 /// name, default value
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, PartialEq, Trace)]
 pub struct Param(pub Destruct, pub Option<LocExpr>);
 
 /// Defined function parameters
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, Clone, PartialEq, Trace)]
 pub struct ParamsDesc(pub Rc<Vec<Param>>);
 
@@ -182,8 +160,6 @@
 	}
 }
 
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, PartialEq, Trace)]
 pub struct ArgsDesc {
 	pub unnamed: Vec<LocExpr>,
@@ -195,8 +171,6 @@
 	}
 }
 
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, Clone, PartialEq, Eq, Trace)]
 pub enum DestructRest {
 	/// ...rest
@@ -205,8 +179,6 @@
 	Drop,
 }
 
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, Clone, PartialEq, Trace)]
 pub enum Destruct {
 	Full(IStr),
@@ -268,8 +240,6 @@
 	}
 }
 
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, Clone, PartialEq, Trace)]
 pub enum BindSpec {
 	Field {
@@ -291,26 +261,18 @@
 	}
 }
 
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, PartialEq, Trace)]
 pub struct IfSpecData(pub LocExpr);
 
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, PartialEq, Trace)]
 pub struct ForSpecData(pub Destruct, pub LocExpr);
 
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, PartialEq, Trace)]
 pub enum CompSpec {
 	IfSpec(IfSpecData),
 	ForSpec(ForSpecData),
 }
 
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, PartialEq, Trace)]
 pub struct ObjComp {
 	pub pre_locals: Vec<BindSpec>,
@@ -319,16 +281,12 @@
 	pub compspecs: Vec<CompSpec>,
 }
 
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, PartialEq, Trace)]
 pub enum ObjBody {
 	MemberList(Vec<Member>),
 	ObjComp(ObjComp),
 }
 
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, PartialEq, Eq, Clone, Copy, Trace)]
 pub enum LiteralType {
 	This,
@@ -339,8 +297,6 @@
 	False,
 }
 
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, PartialEq, Trace)]
 pub struct SliceDesc {
 	pub start: Option<LocExpr>,
@@ -349,8 +305,6 @@
 }
 
 /// Syntax base
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, PartialEq, Trace)]
 pub enum Expr {
 	Literal(LiteralType),
@@ -420,8 +374,6 @@
 	Slice(LocExpr, SliceDesc),
 }
 
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, PartialEq, Trace)]
 pub struct IndexPart {
 	pub value: LocExpr,
@@ -430,8 +382,6 @@
 }
 
 /// file, begin offset, end offset
-#[cfg_attr(feature = "structdump", derive(Codegen))]
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Clone, PartialEq, Eq, Trace)]
 #[trace(skip)]
 #[repr(C)]
@@ -452,8 +402,6 @@
 }
 
 /// Holds AST expression and its location in source file
-#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
-#[cfg_attr(feature = "structdump", derive(Codegen))]
 #[derive(Clone, PartialEq, Trace)]
 pub struct LocExpr(pub Rc<Expr>, pub ExprLocation);
 
modifiedcrates/jrsonnet-parser/src/source.rsdiffbeforeafterboth
before · crates/jrsonnet-parser/src/source.rs
1use std::{2	any::Any,3	fmt::{self, Debug, Display},4	hash::{Hash, Hasher},5	path::{Path, PathBuf},6	rc::Rc,7};89use jrsonnet_gcmodule::{Trace, Tracer};10use jrsonnet_interner::{IBytes, IStr};11#[cfg(feature = "serde")]12use serde::{Deserialize, Serialize};13#[cfg(feature = "structdump")]14use structdump::Codegen;1516use crate::location::{location_to_offset, offset_to_location, CodeLocation};1718macro_rules! any_ext_methods {19	($T:ident) => {20		fn as_any(&self) -> &dyn Any;21		fn dyn_hash(&self, hasher: &mut dyn Hasher);22		fn dyn_eq(&self, other: &dyn $T) -> bool;23		fn dyn_debug(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result;24	};25}26macro_rules! any_ext_impl {27	($T:ident) => {28		fn as_any(&self) -> &dyn Any {29			self30		}31		fn dyn_hash(&self, mut hasher: &mut dyn Hasher) {32			self.hash(&mut hasher)33		}34		fn dyn_eq(&self, other: &dyn $T) -> bool {35			let Some(other) = other.as_any().downcast_ref::<Self>() else {36				return false;37			};38			let this = <Self as $T>::as_any(self)39				.downcast_ref::<Self>()40				.expect("restricted by impl");41			this == other42		}43		fn dyn_debug(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {44			<Self as std::fmt::Debug>::fmt(self, fmt)45		}46	};47}48macro_rules! any_ext {49	($T:ident) => {50		impl Hash for dyn $T {51			fn hash<H: Hasher>(&self, state: &mut H) {52				self.dyn_hash(state)53			}54		}55		impl PartialEq for dyn $T {56			fn eq(&self, other: &Self) -> bool {57				self.dyn_eq(other)58			}59		}60		impl Eq for dyn $T {}61	};62}63pub trait SourcePathT: Trace + Debug + Display {64	/// This method should be checked by resolver before panicking with bad SourcePath input65	/// if `true` - then resolver may threat this path as default, and default is usally a CWD66	fn is_default(&self) -> bool;67	fn path(&self) -> Option<&Path>;68	any_ext_methods!(SourcePathT);69}70any_ext!(SourcePathT);7172/// Represents location of a file73///74/// Standard CLI only operates using75/// - [`SourceFile`] - for any file76/// - [`SourceDirectory`] - for resolution from CWD77/// - [`SourceVirtual`] - for stdlib/ext-str78/// - [`SourceFifo`] - for /dev/fd/X (This path may appear with `jrsonnet <(command_that_produces_jsonnet)`)79///80/// From all of those, only [`SourceVirtual`] may be constructed manually, any other path kind should be only obtained81/// from assigned `ImportResolver`82/// However, you should always check `is_default` method return, as it will return true for any paths, where default83/// search location is applicable84///85/// Resolver may also return custom implementations of this trait, for example it may return http url in case of remotely loaded files86#[derive(Eq, Debug, Clone)]87pub struct SourcePath(Rc<dyn SourcePathT>);88impl SourcePath {89	pub fn new(inner: impl SourcePathT) -> Self {90		Self(Rc::new(inner))91	}92	pub fn downcast_ref<T: SourcePathT>(&self) -> Option<&T> {93		self.0.as_any().downcast_ref()94	}95	pub fn is_default(&self) -> bool {96		self.0.is_default()97	}98	pub fn path(&self) -> Option<&Path> {99		self.0.path()100	}101}102impl Hash for SourcePath {103	fn hash<H: Hasher>(&self, state: &mut H) {104		self.0.hash(state);105	}106}107impl PartialEq for SourcePath {108	#[allow(clippy::op_ref)]109	fn eq(&self, other: &Self) -> bool {110		&*self.0 == &*other.0111	}112}113impl Trace for SourcePath {114	fn trace(&self, tracer: &mut Tracer) {115		(*self.0).trace(tracer)116	}117118	fn is_type_tracked() -> bool119	where120		Self: Sized,121	{122		true123	}124}125impl Display for SourcePath {126	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {127		write!(f, "{}", self.0)128	}129}130impl Default for SourcePath {131	fn default() -> Self {132		Self(Rc::new(SourceDefault))133	}134}135136#[cfg(feature = "structdump")]137impl Codegen for SourcePath {138	fn gen_code(139		&self,140		res: &mut structdump::CodegenResult,141		unique: bool,142	) -> structdump::TokenStream {143		let source_virtual = self144			.0145			.as_any()146			.downcast_ref::<SourceVirtual>()147			.expect("can only codegen for virtual source paths!")148			.0149			.clone();150		let val = res.add_value(source_virtual, false);151		res.add_code(152			structdump::quote! {153				structdump_import::SourcePath::new(structdump_import::SourceVirtual(#val))154			},155			Some(structdump::quote!(SourcePath)),156			unique,157		)158	}159}160161#[derive(Trace, Hash, PartialEq, Eq, Debug)]162struct SourceDefault;163impl Display for SourceDefault {164	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {165		write!(f, "<default>")166	}167}168impl SourcePathT for SourceDefault {169	fn is_default(&self) -> bool {170		true171	}172	fn path(&self) -> Option<&Path> {173		None174	}175	any_ext_impl!(SourcePathT);176}177178/// Represents path to the file on the disk179/// Directories shouldn't be put here, as resolution for files differs from resolution for directories:180///181/// When `file` is being resolved from `SourceFile(a/b/c)`, it should be resolved to `SourceFile(a/b/file)`,182/// however if it is being resolved from `SourceDirectory(a/b/c)`, then it should be resolved to `SourceDirectory(a/b/c/file)`183#[derive(Trace, Hash, PartialEq, Eq, Debug)]184pub struct SourceFile(PathBuf);185impl SourceFile {186	pub fn new(path: PathBuf) -> Self {187		Self(path)188	}189	pub fn path(&self) -> &Path {190		&self.0191	}192}193impl Display for SourceFile {194	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {195		write!(f, "{}", self.0.display())196	}197}198impl SourcePathT for SourceFile {199	fn is_default(&self) -> bool {200		false201	}202	fn path(&self) -> Option<&Path> {203		Some(&self.0)204	}205	any_ext_impl!(SourcePathT);206}207208/// Represents path to the directory on the disk209///210/// See also [`SourceFile`]211#[derive(Trace, Hash, PartialEq, Eq, Debug)]212pub struct SourceDirectory(PathBuf);213impl SourceDirectory {214	pub fn new(path: PathBuf) -> Self {215		Self(path)216	}217	pub fn path(&self) -> &Path {218		&self.0219	}220}221impl Display for SourceDirectory {222	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {223		write!(f, "{}", self.0.display())224	}225}226impl SourcePathT for SourceDirectory {227	fn is_default(&self) -> bool {228		false229	}230	fn path(&self) -> Option<&Path> {231		Some(&self.0)232	}233	any_ext_impl!(SourcePathT);234}235236/// Represents virtual file, whose are located in memory, and shouldn't be cached237///238/// It is used for --ext-code=.../--tla-code=.../standard library source code by default,239/// and user can construct arbitrary values by hand, without asking import resolver240#[cfg_attr(feature = "structdump", derive(Codegen))]241#[derive(Trace, Hash, PartialEq, Eq, Debug, Clone)]242pub struct SourceVirtual(pub IStr);243impl Display for SourceVirtual {244	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {245		write!(f, "{}", self.0)246	}247}248impl SourcePathT for SourceVirtual {249	fn is_default(&self) -> bool {250		true251	}252	fn path(&self) -> Option<&Path> {253		None254	}255	any_ext_impl!(SourcePathT);256}257258/// Represents resolved FIFO file, those files may only be read once, and this type is only used for259/// unix, where user might want to do `jrsonnet <(command_that_produces_jsonnet_source)`260/// In most cases, user most probably want to use `jrsonnet -` instead of `jrsonnet /dev/stdin`261/// for better cross-platform support.262// PartialEq is limited to ptr equality263#[allow(clippy::derived_hash_with_manual_eq)]264#[derive(Trace, Debug, Hash)]265pub struct SourceFifo(pub String, pub IBytes);266impl PartialEq for SourceFifo {267	fn eq(&self, other: &Self) -> bool {268		std::ptr::eq(self, other)269	}270}271impl fmt::Display for SourceFifo {272	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {273		write!(f, "fifo({:?})", self.0)274	}275}276impl SourcePathT for SourceFifo {277	fn is_default(&self) -> bool {278		// In case of FD input, user won't expect relative paths to be resolved from /dev/fd/279		true280	}281282	fn path(&self) -> Option<&Path> {283		None284	}285286	any_ext_impl!(SourcePathT);287}288289/// Either real file, or virtual290/// Hash of FileName always have same value as raw Path, to make it possible to use with raw_entry_mut291#[cfg_attr(feature = "structdump", derive(Codegen))]292#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]293#[derive(Clone, PartialEq, Eq, Debug)]294pub struct Source(pub Rc<(SourcePath, IStr)>);295296impl Trace for Source {297	fn trace(&self, _tracer: &mut Tracer) {}298299	fn is_type_tracked() -> bool {300		false301	}302}303304impl Source {305	pub fn new(path: SourcePath, code: IStr) -> Self {306		Self(Rc::new((path, code)))307	}308309	pub fn new_virtual(name: IStr, code: IStr) -> Self {310		Self::new(SourcePath::new(SourceVirtual(name)), code)311	}312313	pub fn code(&self) -> &str {314		&self.0 .1315	}316317	pub fn source_path(&self) -> &SourcePath {318		&self.0 .0319	}320321	pub fn map_source_locations<const S: usize>(&self, locs: &[u32; S]) -> [CodeLocation; S] {322		offset_to_location(&self.0 .1, locs)323	}324	pub fn map_from_source_location(&self, line: usize, column: usize) -> Option<usize> {325		location_to_offset(&self.0 .1, line, column)326	}327}
modifiedcrates/jrsonnet-stdlib/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/Cargo.toml
+++ b/crates/jrsonnet-stdlib/Cargo.toml
@@ -11,14 +11,6 @@
 workspace = true
 
 [features]
-default = ["codegenerated-stdlib"]
-# Speed-up initialization by generating code for parsed stdlib,
-# instead of invoking parser for it.
-# This is mutually exclusive with `serialized-stdlib`.
-codegenerated-stdlib = ["jrsonnet-parser/structdump"]
-# Use the embedded serialized stdlib.
-# This is mutually exclusive with `codegenerated-stdlib`.
-serialized-stdlib = []
 # Enables legacy `std.thisFile` support, at the cost of worse caching
 legacy-this-file = []
 # Add order preservation flag to some functions
@@ -36,9 +28,7 @@
 jrsonnet-parser.workspace = true
 jrsonnet-gcmodule.workspace = true
 
-# Used for stdlib AST serialization
-bincode = { workspace = true, optional = true }
-# Used both for stdlib AST serialization and std.parseJson/std.parseYaml
+# Used for std.parseJson/std.parseYaml
 serde.workspace = true
 
 # std.md5
@@ -65,4 +55,3 @@
 
 [build-dependencies]
 jrsonnet-parser.workspace = true
-structdump = { workspace = true, features = ["derive"] }
deletedcrates/jrsonnet-stdlib/build.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/build.rs
+++ /dev/null
@@ -1,36 +0,0 @@
-fn main() {
-	#[cfg(feature = "codegenerated-stdlib")]
-	{
-		use std::{env, fs::File, io::Write, path::Path};
-
-		use jrsonnet_parser::{parse, ParserSettings, Source};
-		use structdump::CodegenResult;
-
-		let parsed = parse(
-			include_str!("./src/std.jsonnet"),
-			&ParserSettings {
-				source: Source::new_virtual(
-					"<std>".into(),
-					include_str!("./src/std.jsonnet").into(),
-				),
-			},
-		)
-		.expect("parse");
-
-		let mut out = CodegenResult::default();
-
-		let v = out.codegen(&parsed, true);
-
-		{
-			let out_dir = env::var("OUT_DIR").unwrap();
-			let dest_path = Path::new(&out_dir).join("stdlib.rs");
-			let mut f = File::create(dest_path).unwrap();
-			f.write_all(
-				("#[allow(clippy::redundant_clone, clippy::similar_names)]".to_owned()
-					+ &v.to_string())
-					.as_bytes(),
-			)
-			.unwrap();
-		}
-	}
-}
deletedcrates/jrsonnet-stdlib/src/expr.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/expr.rs
+++ /dev/null
@@ -1,109 +0,0 @@
-use jrsonnet_parser::LocExpr;
-
-pub fn stdlib_expr() -> LocExpr {
-	#[cfg(all(feature = "serialized-stdlib", feature = "codegenerated-stdlib"))]
-	compile_error!(
-		"features `serialized-stdlib` and `codegenerated-stdlib` are mutually exclusive"
-	);
-	#[cfg(all(feature = "serialized-stdlib", not(feature = "codegenerated-stdlib")))]
-	{
-		use bincode::{BincodeRead, DefaultOptions, Options};
-		use serde::{Deserialize, Deserializer};
-
-		struct LocDeserializer<R, O: Options> {
-			source: Source,
-			wrapped: bincode::Deserializer<R, O>,
-		}
-		macro_rules! delegate {
-			($(fn $name:ident($($arg:ident: $ty:ty),*))+) => {$(
-				fn $name<V>(mut self $(, $arg: $ty)*, visitor: V) -> Result<V::Value, Self::Error>
-				where V: serde::de::Visitor<'de>,
-				{
-					self.wrapped.$name($($arg,)* visitor)
-				}
-			)+};
-		}
-		impl<'de, R, O> Deserializer<'de> for LocDeserializer<R, O>
-		where
-			R: BincodeRead<'de>,
-			O: Options,
-		{
-			type Error = <&'de mut bincode::Deserializer<R, O> as Deserializer<'de>>::Error;
-
-			delegate! {
-				fn deserialize_any()
-				fn deserialize_bool()
-				fn deserialize_u16()
-				fn deserialize_u32()
-				fn deserialize_u64()
-				fn deserialize_i16()
-				fn deserialize_i32()
-				fn deserialize_i64()
-				fn deserialize_f32()
-				fn deserialize_f64()
-				fn deserialize_u128()
-				fn deserialize_i128()
-				fn deserialize_u8()
-				fn deserialize_i8()
-				fn deserialize_unit()
-				fn deserialize_char()
-				fn deserialize_str()
-				fn deserialize_string()
-				fn deserialize_bytes()
-				fn deserialize_byte_buf()
-				fn deserialize_enum(name: &'static str, variants: &'static [&'static str])
-				fn deserialize_tuple(len: usize)
-				fn deserialize_option()
-				fn deserialize_seq()
-				fn deserialize_map()
-				fn deserialize_struct(name: &'static str, fields: &'static [&'static str])
-				fn deserialize_identifier()
-				fn deserialize_newtype_struct(name: &'static str)
-				fn deserialize_unit_struct(name: &'static str)
-				fn deserialize_tuple_struct(name: &'static str, len: usize)
-				fn deserialize_ignored_any()
-			}
-
-			fn is_human_readable(&self) -> bool {
-				false
-			}
-		}
-
-		// In build.rs, Source object is populated with empty values, deserializer wrapper loads correct values on deserialize
-		let mut deserializer = bincode::Deserializer::from_slice(
-			include_bytes!(concat!(env!("OUT_DIR"), "/stdlib.bincode")),
-			DefaultOptions::new()
-				.with_fixint_encoding()
-				.allow_trailing_bytes(),
-		);
-
-		// Should not panic, stdlib.bincode is generated in build.rs
-		LocExpr::deserialize(&mut deserializer).unwrap()
-	}
-
-	#[cfg(all(feature = "codegenerated-stdlib", not(feature = "serialized-stdlib")))]
-	{
-		mod structdump_import {
-			pub(super) use std::{option::Option, rc::Rc, vec};
-
-			pub(super) use jrsonnet_parser::*;
-		}
-
-		include!(concat!(env!("OUT_DIR"), "/stdlib.rs"))
-	}
-
-	#[cfg(not(any(feature = "serialized-stdlib", feature = "codegenerated-stdlib")))]
-	{
-		use jrsonnet_parser::Source;
-
-		const STDLIB_STR: &str = include_str!("./std.jsonnet");
-
-		jrsonnet_parser::parse(
-			STDLIB_STR,
-			&jrsonnet_parser::ParserSettings {
-				source: Source::new_virtual("<std>".into(), STDLIB_STR.into()),
-			},
-		)
-		.unwrap()
-	}
-}
modifiedcrates/jrsonnet-stdlib/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/lib.rs
+++ b/crates/jrsonnet-stdlib/src/lib.rs
@@ -36,7 +36,6 @@
 mod arrays;
 mod compat;
 mod encoding;
-mod expr;
 mod hash;
 mod manifest;
 mod math;
@@ -54,14 +53,6 @@
 #[allow(clippy::too_many_lines)]
 pub fn stdlib_uncached(settings: Rc<RefCell<Settings>>) -> ObjValue {
 	let mut builder = ObjValueBuilder::new();
-
-	let expr = expr::stdlib_expr();
-	let eval = jrsonnet_evaluator::evaluate(ContextBuilder::dangerous_empty_state().build(), &expr)
-		.expect("stdlib.jsonnet should have no errors")
-		.as_obj()
-		.expect("stdlib.jsonnet should evaluate to object");
-
-	builder.with_super(eval);
 
 	// FIXME: Use PHF
 	for (name, builtin) in [
deletedcrates/jrsonnet-stdlib/src/std.jsonnetdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/std.jsonnet
+++ /dev/null
@@ -1,5 +0,0 @@
-{
-  local std = self,
-
-  thisFile:: error 'std.thisFile is deprecated, to enable its support in jrsonnet - recompile it with "legacy-this-file" support.\nThis will slow down stdlib caching a bit, though',
-}