git.delta.rocks / jrsonnet / refs/commits / fe52b32db444

difftreelog

build upgrade dependencies

Yaroslav Bolyukin2022-10-26parent: #30d381b.patch.diff
in: master

13 files changed

modifiedcmds/jrsonnet/Cargo.tomldiffbeforeafterboth
--- a/cmds/jrsonnet/Cargo.toml
+++ b/cmds/jrsonnet/Cargo.toml
@@ -28,5 +28,5 @@
 
 mimallocator = { version = "0.1.3", optional = true }
 thiserror = "1.0"
-clap = { version = "3.2", features = ["derive"] }
-clap_complete = { version = "3.2" }
+clap = { version = "4.0", features = ["derive"] }
+clap_complete = { version = "4.0" }
modifiedcmds/jrsonnet/src/main.rsdiffbeforeafterboth
--- a/cmds/jrsonnet/src/main.rs
+++ b/cmds/jrsonnet/src/main.rs
@@ -3,7 +3,7 @@
 	io::{Read, Write},
 };
 
-use clap::{AppSettings, IntoApp, Parser};
+use clap::{CommandFactory, Parser};
 use clap_complete::Shell;
 use jrsonnet_cli::{ConfigureState, GeneralOpts, ManifestOpts, OutputOpts};
 use jrsonnet_evaluator::{error::LocError, State};
@@ -42,10 +42,7 @@
 }
 
 #[derive(Parser)]
-#[clap(
-	global_setting = AppSettings::DeriveDisplayOrder,
-	args_conflicts_with_subcommands = true,
-)]
+#[clap(args_conflicts_with_subcommands = true, disable_version_flag = true)]
 struct Opts {
 	#[clap(subcommand)]
 	sub: Option<SubOpts>,
modifiedcrates/jrsonnet-cli/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-cli/Cargo.toml
+++ b/crates/jrsonnet-cli/Cargo.toml
@@ -21,4 +21,4 @@
 jrsonnet-gcmodule = { version = "0.3.4" }
 jrsonnet-stdlib = { path = "../../crates/jrsonnet-stdlib", version = "0.4.2" }
 
-clap = { version = "3.2", features = ["derive"] }
+clap = { version = "4.0", features = ["derive"] }
modifiedcrates/jrsonnet-cli/src/lib.rsdiffbeforeafterboth
before · crates/jrsonnet-cli/src/lib.rs
1mod manifest;2mod stdlib;3mod tla;4mod trace;56use std::{env, marker::PhantomData, path::PathBuf};78use clap::Parser;9use jrsonnet_evaluator::{10	error::Result, stack::StackDepthLimitOverrideGuard, FileImportResolver, State,11};12use jrsonnet_gcmodule::with_thread_object_space;13pub use manifest::*;14pub use stdlib::*;15pub use tla::*;16pub use trace::*;1718pub trait ConfigureState {19	type Guards;2021	fn configure(&self, s: &State) -> Result<Self::Guards>;22}2324#[derive(Parser)]25#[clap(next_help_heading = "INPUT")]26pub struct InputOpts {27	/// Treat input as code, evaluate them instead of reading file28	#[clap(long, short = 'e')]29	pub exec: bool,3031	/// Path to the file to be compiled if `--evaluate` is unset, otherwise code itself32	pub input: String,33}3435#[derive(Parser)]36#[clap(next_help_heading = "OPTIONS")]37pub struct MiscOpts {38	/// Maximal allowed number of stack frames,39	/// stack overflow error will be raised if this number gets exceeded.40	#[clap(long, short = 's', default_value = "200")]41	max_stack: usize,4243	/// Library search dirs. (right-most wins)44	/// Any not found `imported` file will be searched in these.45	/// This can also be specified via `JSONNET_PATH` variable,46	/// which should contain a colon-separated (semicolon-separated on Windows) list of directories.47	#[clap(long, short = 'J', multiple_occurrences = true)]48	jpath: Vec<PathBuf>,49}50impl ConfigureState for MiscOpts {51	type Guards = StackDepthLimitOverrideGuard;52	fn configure(&self, s: &State) -> Result<Self::Guards> {53		let mut library_paths = self.jpath.clone();54		library_paths.reverse();55		if let Some(path) = env::var_os("JSONNET_PATH") {56			library_paths.extend(env::split_paths(path.as_os_str()));57		}5859		s.set_import_resolver(Box::new(FileImportResolver::new(library_paths)));6061		let _depth_limit = jrsonnet_evaluator::stack::limit_stack_depth(self.max_stack);62		Ok(_depth_limit)63	}64}6566/// General configuration of jsonnet67#[derive(Parser)]68#[clap(name = "jrsonnet", version, author)]69pub struct GeneralOpts {70	#[clap(flatten)]71	misc: MiscOpts,7273	#[clap(flatten)]74	tla: TLAOpts,75	#[clap(flatten)]76	std: StdOpts,7778	#[clap(flatten)]79	trace: TraceOpts,8081	#[clap(flatten)]82	gc: GcOpts,83}8485impl ConfigureState for GeneralOpts {86	type Guards = (87		<MiscOpts as ConfigureState>::Guards,88		<GcOpts as ConfigureState>::Guards,89	);90	fn configure(&self, s: &State) -> Result<Self::Guards> {91		// Configure trace first, because tla-code/ext-code can throw92		self.trace.configure(s)?;93		let misc_guards = self.misc.configure(s)?;94		self.tla.configure(s)?;95		self.std.configure(s)?;96		let gc_guards = self.gc.configure(s)?;97		Ok((misc_guards, gc_guards))98	}99}100101#[derive(Parser)]102#[clap(next_help_heading = "GARBAGE COLLECTION")]103pub struct GcOpts {104	/// Do not skip gc on exit105	#[clap(long)]106	gc_collect_on_exit: bool,107	/// Print gc stats before exit108	#[clap(long)]109	gc_print_stats: bool,110	/// Force garbage collection before printing stats111	/// Useful for checking for memory leaks112	/// Does nothing useless --gc-print-stats is specified113	#[clap(long)]114	gc_collect_before_printing_stats: bool,115}116impl ConfigureState for GcOpts {117	type Guards = (Option<GcStatsPrinter>, Option<LeakSpace>);118119	fn configure(&self, _s: &State) -> Result<Self::Guards> {120		// Constructed structs have side-effects in Drop impl121		#[allow(clippy::unnecessary_lazy_evaluations)]122		Ok((123			self.gc_print_stats.then(|| GcStatsPrinter {124				collect_before_printing_stats: self.gc_collect_before_printing_stats,125			}),126			(!self.gc_collect_on_exit).then(|| LeakSpace(PhantomData)),127		))128	}129}130131pub struct LeakSpace(PhantomData<()>);132133impl Drop for LeakSpace {134	fn drop(&mut self) {135		with_thread_object_space(|s| s.leak())136	}137}138139pub struct GcStatsPrinter {140	collect_before_printing_stats: bool,141}142impl Drop for GcStatsPrinter {143	fn drop(&mut self) {144		eprintln!("=== GC STATS ===");145		if self.collect_before_printing_stats {146			let collected = jrsonnet_gcmodule::collect_thread_cycles();147			eprintln!("Collected: {}", collected);148		}149		eprintln!("Tracked: {}", jrsonnet_gcmodule::count_thread_tracked())150	}151}
modifiedcrates/jrsonnet-cli/src/manifest.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/manifest.rs
+++ b/crates/jrsonnet-cli/src/manifest.rs
@@ -1,10 +1,11 @@
 use std::{path::PathBuf, str::FromStr};
 
-use clap::Parser;
+use clap::{Parser, ValueEnum};
 use jrsonnet_evaluator::{error::Result, ManifestFormat, State};
 
 use crate::ConfigureState;
 
+#[derive(Clone, ValueEnum)]
 pub enum ManifestFormatName {
 	/// Expect string as output, and write them directly
 	String,
@@ -28,7 +29,7 @@
 #[clap(next_help_heading = "MANIFESTIFICATION OUTPUT")]
 pub struct ManifestOpts {
 	/// Output format, wraps resulting value to corresponding std.manifest call.
-	#[clap(long, short = 'f', default_value = "json", possible_values = &["json", "yaml"])]
+	#[clap(long, short = 'f', default_value = "json")]
 	format: ManifestFormatName,
 	/// Expect plain string as output.
 	/// Mutually exclusive with `--format`
modifiedcrates/jrsonnet-cli/src/stdlib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/stdlib.rs
+++ b/crates/jrsonnet-cli/src/stdlib.rs
@@ -69,40 +69,19 @@
 	/// to use top level arguments whenever it's possible.
 	/// If [=data] is not set then it will be read from `name` env variable.
 	/// Can be accessed from code via `std.extVar("name")`.
-	#[clap(
-		long,
-		short = 'V',
-		name = "name[=var data]",
-		number_of_values = 1,
-		multiple_occurrences = true
-	)]
+	#[clap(long, short = 'V', name = "name[=var data]", number_of_values = 1)]
 	ext_str: Vec<ExtStr>,
 	/// Read string external variable from file.
 	/// See also `--ext-str`
-	#[clap(
-		long,
-		name = "name=var path",
-		number_of_values = 1,
-		multiple_occurrences = true
-	)]
+	#[clap(long, name = "name=var path", number_of_values = 1)]
 	ext_str_file: Vec<ExtFile>,
 	/// Add external variable from code.
 	/// See also `--ext-str`
-	#[clap(
-		long,
-		name = "name[=var source]",
-		number_of_values = 1,
-		multiple_occurrences = true
-	)]
+	#[clap(long, name = "name[=var source]", number_of_values = 1)]
 	ext_code: Vec<ExtStr>,
 	/// Read string external variable from file.
 	/// See also `--ext-str`
-	#[clap(
-		long,
-		name = "name=var code path",
-		number_of_values = 1,
-		multiple_occurrences = true
-	)]
+	#[clap(long, name = "name=var code path", number_of_values = 1)]
 	ext_code_file: Vec<ExtFile>,
 }
 impl ConfigureState for StdOpts {
modifiedcrates/jrsonnet-cli/src/tla.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/tla.rs
+++ b/crates/jrsonnet-cli/src/tla.rs
@@ -10,40 +10,19 @@
 	/// Top level arguments will be passed to function before manifestification stage.
 	/// This is preferred to ExtVars method.
 	/// If [=data] is not set then it will be read from `name` env variable.
-	#[clap(
-		long,
-		short = 'A',
-		name = "name[=tla data]",
-		number_of_values = 1,
-		multiple_occurrences = true
-	)]
+	#[clap(long, short = 'A', name = "name[=tla data]", number_of_values = 1)]
 	tla_str: Vec<ExtStr>,
 	/// Read top level argument string from file.
 	/// See also `--tla-str`
-	#[clap(
-		long,
-		name = "name=tla path",
-		number_of_values = 1,
-		multiple_occurrences = true
-	)]
+	#[clap(long, name = "name=tla path", number_of_values = 1)]
 	tla_str_file: Vec<ExtFile>,
 	/// Add top level argument from code.
 	/// See also `--tla-str`
-	#[clap(
-		long,
-		name = "name[=tla source]",
-		number_of_values = 1,
-		multiple_occurrences = true
-	)]
+	#[clap(long, name = "name[=tla source]", number_of_values = 1)]
 	tla_code: Vec<ExtStr>,
 	/// Read top level argument code from file.
 	/// See also `--tla-str`
-	#[clap(
-		long,
-		name = "name=tla code path",
-		number_of_values = 1,
-		multiple_occurrences = true
-	)]
+	#[clap(long, name = "name=tla code path", number_of_values = 1)]
 	tla_code_file: Vec<ExtFile>,
 }
 impl ConfigureState for TLAOpts {
modifiedcrates/jrsonnet-cli/src/trace.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/trace.rs
+++ b/crates/jrsonnet-cli/src/trace.rs
@@ -1,6 +1,4 @@
-use std::str::FromStr;
-
-use clap::Parser;
+use clap::{Parser, ValueEnum};
 use jrsonnet_evaluator::{
 	error::Result,
 	trace::{CompactFormat, ExplainingFormat, PathResolver},
@@ -9,31 +7,19 @@
 
 use crate::ConfigureState;
 
-#[derive(PartialEq, Eq)]
+#[derive(PartialEq, Eq, ValueEnum, Clone)]
 pub enum TraceFormatName {
+	/// Only show `filename:line:column`
 	Compact,
+	/// Display source code with attached trace annotations
 	Explaining,
-}
-
-impl FromStr for TraceFormatName {
-	type Err = &'static str;
-	fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
-		Ok(match s {
-			"compact" => TraceFormatName::Compact,
-			"explaining" => TraceFormatName::Explaining,
-			_ => return Err("no such format"),
-		})
-	}
 }
 
 #[derive(Parser)]
 #[clap(next_help_heading = "STACK TRACE VISUAL")]
 pub struct TraceOpts {
 	/// Format of stack traces' display in console.
-	/// `compact` format only shows `filename:line:column`s
-	/// while `explaining` displays source code with attached trace annotations
-	/// thus being more verbose.
-	#[clap(long, possible_values = &["compact", "explaining"])]
+	#[clap(long)]
 	trace_format: Option<TraceFormatName>,
 	/// Amount of stack trace elements to be displayed.
 	/// If set to `0` then full stack trace will be displayed.
modifiedcrates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/Cargo.toml
+++ b/crates/jrsonnet-evaluator/Cargo.toml
@@ -31,7 +31,7 @@
 jrsonnet-gcmodule = { version = "0.3.4" }
 
 pathdiff = "0.2.1"
-hashbrown = "0.12.1"
+hashbrown = "0.12.3"
 static_assertions = "1.1"
 
 rustc-hash = "1.1"
modifiedcrates/jrsonnet-interner/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-interner/Cargo.toml
+++ b/crates/jrsonnet-interner/Cargo.toml
@@ -22,4 +22,4 @@
 structdump = { version = "0.2.0", optional = true }
 
 rustc-hash = "1.1"
-hashbrown = { version = "0.12.1", features = ["inline-more"] }
+hashbrown = { version = "0.12.3", features = ["inline-more"] }
modifiedcrates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth
--- a/crates/jrsonnet-parser/src/expr.rs
+++ b/crates/jrsonnet-parser/src/expr.rs
@@ -190,6 +190,7 @@
 	}
 }
 
+#[cfg_attr(feature = "structdump", derive(Codegen))]
 #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[derive(Debug, Clone, PartialEq, Eq, Trace)]
 pub enum DestructRest {
modifiedcrates/jrsonnet-stdlib/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/Cargo.toml
+++ b/crates/jrsonnet-stdlib/Cargo.toml
@@ -30,7 +30,7 @@
 # std.md5
 md5 = "0.7.0"
 # std.base64
-base64 = "0.13.0"
+base64 = "0.13.1"
 # std.parseJson
 serde_json = "1.0"
 # std.parseYaml, custom library fork is used for C++/golang compatibility
modifiedcrates/jrsonnet-types/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-types/Cargo.toml
+++ b/crates/jrsonnet-types/Cargo.toml
@@ -9,4 +9,4 @@
 [dependencies]
 jrsonnet-gcmodule = { version = "0.3.4" }
 
-peg = "0.8.0"
+peg = "0.8.1"