git.delta.rocks / jrsonnet / refs/commits / 06fa714fdb66

difftreelog

style apply clippy suggestions

Yaroslav Bolyukin2022-07-23parent: #50ca1d2.patch.diff
in: master

5 files changed

modifiedbindings/jsonnet/src/import.rsdiffbeforeafterboth
--- a/bindings/jsonnet/src/import.rs
+++ b/bindings/jsonnet/src/import.rs
@@ -143,7 +143,7 @@
 pub unsafe extern "C" fn jsonnet_jpath_add(vm: &State, v: *const c_char) {
 	let cstr = CStr::from_ptr(v);
 	let path = PathBuf::from(cstr.to_str().unwrap());
-	let any_resolver = &vm.settings().import_resolver;
+	let any_resolver = vm.import_resolver();
 	let resolver = any_resolver
 		.as_any()
 		.downcast_ref::<NativeImportResolver>()
modifiedcrates/jrsonnet-evaluator/src/gc.rsdiffbeforeafterboth
before · crates/jrsonnet-evaluator/src/gc.rs
1/// Macros to help deal with Gc2use std::{3	borrow::{Borrow, BorrowMut},4	collections::HashSet,5	hash::BuildHasherDefault,6	ops::{Deref, DerefMut},7};89use hashbrown::HashMap;10use jrsonnet_gcmodule::{Trace, Tracer};11use rustc_hash::{FxHashSet, FxHasher};1213/// Replacement for box, which assumes that the underlying type is [`Trace`]14/// Used in places, where `Cc<dyn Trait>` should be used instead, but it can't, because `CoerceUnsiced` is not stable15#[derive(Debug, Clone)]16pub struct TraceBox<T: ?Sized>(pub Box<T>);17#[macro_export]18macro_rules! tb {19	($v:expr) => {20		$crate::gc::TraceBox(Box::new($v))21	};22}2324impl<T: ?Sized + Trace> Trace for TraceBox<T> {25	fn trace(&self, tracer: &mut Tracer) {26		self.0.trace(tracer);27	}2829	fn is_type_tracked() -> bool {30		true31	}32}3334// TODO: Replace with CoerceUnsized35impl<T: ?Sized> From<Box<T>> for TraceBox<T> {36	fn from(inner: Box<T>) -> Self {37		Self(inner)38	}39}4041impl<T: ?Sized> Deref for TraceBox<T> {42	type Target = T;4344	fn deref(&self) -> &Self::Target {45		&self.046	}47}48impl<T: Trace + ?Sized> DerefMut for TraceBox<T> {49	fn deref_mut(&mut self) -> &mut Self::Target {50		&mut self.051	}52}5354impl<T: ?Sized> Borrow<T> for TraceBox<T> {55	fn borrow(&self) -> &T {56		&*self.057	}58}5960impl<T: ?Sized> BorrowMut<T> for TraceBox<T> {61	fn borrow_mut(&mut self) -> &mut T {62		&mut *self.063	}64}6566impl<T: ?Sized> AsRef<T> for TraceBox<T> {67	fn as_ref(&self) -> &T {68		&*self.069	}70}7172impl<T: ?Sized> AsMut<T> for TraceBox<T> {73	fn as_mut(&mut self) -> &mut T {74		&mut *self.075	}76}7778#[derive(Clone)]79pub struct GcHashSet<V>(pub FxHashSet<V>);80impl<V> GcHashSet<V> {81	pub fn new() -> Self {82		Self(HashSet::default())83	}84	pub fn with_capacity(capacity: usize) -> Self {85		Self(FxHashSet::with_capacity_and_hasher(86			capacity,87			BuildHasherDefault::default(),88		))89	}90}91impl<V> Trace for GcHashSet<V>92where93	V: Trace,94{95	fn trace(&self, tracer: &mut jrsonnet_gcmodule::Tracer) {96		for v in &self.0 {97			v.trace(tracer);98		}99	}100}101impl<V> Deref for GcHashSet<V> {102	type Target = FxHashSet<V>;103104	fn deref(&self) -> &Self::Target {105		&self.0106	}107}108impl<V> DerefMut for GcHashSet<V> {109	fn deref_mut(&mut self) -> &mut Self::Target {110		&mut self.0111	}112}113impl<V> Default for GcHashSet<V> {114	fn default() -> Self {115		Self::new()116	}117}118119pub struct GcHashMap<K, V>(pub HashMap<K, V, BuildHasherDefault<FxHasher>>);120impl<K, V> GcHashMap<K, V> {121	pub fn new() -> Self {122		Self(HashMap::default())123	}124	pub fn with_capacity(capacity: usize) -> Self {125		Self(HashMap::with_capacity_and_hasher(126			capacity,127			BuildHasherDefault::default(),128		))129	}130}131impl<K, V> Trace for GcHashMap<K, V>132where133	K: Trace,134	V: Trace,135{136	fn trace(&self, tracer: &mut jrsonnet_gcmodule::Tracer) {137		for (k, v) in &self.0 {138			k.trace(tracer);139			v.trace(tracer);140		}141	}142}143impl<K, V> Deref for GcHashMap<K, V> {144	type Target = HashMap<K, V, BuildHasherDefault<FxHasher>>;145146	fn deref(&self) -> &Self::Target {147		&self.0148	}149}150impl<K, V> DerefMut for GcHashMap<K, V> {151	fn deref_mut(&mut self) -> &mut Self::Target {152		&mut self.0153	}154}155impl<K, V> Default for GcHashMap<K, V> {156	fn default() -> Self {157		Self::new()158	}159}
after · crates/jrsonnet-evaluator/src/gc.rs
1/// Macros to help deal with Gc2use std::{3	borrow::{Borrow, BorrowMut},4	collections::HashSet,5	hash::BuildHasherDefault,6	ops::{Deref, DerefMut},7};89use hashbrown::HashMap;10use jrsonnet_gcmodule::{Trace, Tracer};11use rustc_hash::{FxHashSet, FxHasher};1213/// Replacement for box, which assumes that the underlying type is [`Trace`]14/// Used in places, where `Cc<dyn Trait>` should be used instead, but it can't, because `CoerceUnsiced` is not stable15#[derive(Debug, Clone)]16pub struct TraceBox<T: ?Sized>(pub Box<T>);17#[macro_export]18macro_rules! tb {19	($v:expr) => {20		$crate::gc::TraceBox(Box::new($v))21	};22}2324impl<T: ?Sized + Trace> Trace for TraceBox<T> {25	fn trace(&self, tracer: &mut Tracer) {26		self.0.trace(tracer);27	}2829	fn is_type_tracked() -> bool {30		true31	}32}3334// TODO: Replace with CoerceUnsized35impl<T: ?Sized> From<Box<T>> for TraceBox<T> {36	fn from(inner: Box<T>) -> Self {37		Self(inner)38	}39}4041impl<T: ?Sized> Deref for TraceBox<T> {42	type Target = T;4344	fn deref(&self) -> &Self::Target {45		&self.046	}47}48impl<T: Trace + ?Sized> DerefMut for TraceBox<T> {49	fn deref_mut(&mut self) -> &mut Self::Target {50		&mut self.051	}52}5354impl<T: ?Sized> Borrow<T> for TraceBox<T> {55	fn borrow(&self) -> &T {56		&self.057	}58}5960impl<T: ?Sized> BorrowMut<T> for TraceBox<T> {61	fn borrow_mut(&mut self) -> &mut T {62		&mut self.063	}64}6566impl<T: ?Sized> AsRef<T> for TraceBox<T> {67	fn as_ref(&self) -> &T {68		&self.069	}70}7172impl<T: ?Sized> AsMut<T> for TraceBox<T> {73	fn as_mut(&mut self) -> &mut T {74		&mut self.075	}76}7778#[derive(Clone)]79pub struct GcHashSet<V>(pub FxHashSet<V>);80impl<V> GcHashSet<V> {81	pub fn new() -> Self {82		Self(HashSet::default())83	}84	pub fn with_capacity(capacity: usize) -> Self {85		Self(FxHashSet::with_capacity_and_hasher(86			capacity,87			BuildHasherDefault::default(),88		))89	}90}91impl<V> Trace for GcHashSet<V>92where93	V: Trace,94{95	fn trace(&self, tracer: &mut jrsonnet_gcmodule::Tracer) {96		for v in &self.0 {97			v.trace(tracer);98		}99	}100}101impl<V> Deref for GcHashSet<V> {102	type Target = FxHashSet<V>;103104	fn deref(&self) -> &Self::Target {105		&self.0106	}107}108impl<V> DerefMut for GcHashSet<V> {109	fn deref_mut(&mut self) -> &mut Self::Target {110		&mut self.0111	}112}113impl<V> Default for GcHashSet<V> {114	fn default() -> Self {115		Self::new()116	}117}118119pub struct GcHashMap<K, V>(pub HashMap<K, V, BuildHasherDefault<FxHasher>>);120impl<K, V> GcHashMap<K, V> {121	pub fn new() -> Self {122		Self(HashMap::default())123	}124	pub fn with_capacity(capacity: usize) -> Self {125		Self(HashMap::with_capacity_and_hasher(126			capacity,127			BuildHasherDefault::default(),128		))129	}130}131impl<K, V> Trace for GcHashMap<K, V>132where133	K: Trace,134	V: Trace,135{136	fn trace(&self, tracer: &mut jrsonnet_gcmodule::Tracer) {137		for (k, v) in &self.0 {138			k.trace(tracer);139			v.trace(tracer);140		}141	}142}143impl<K, V> Deref for GcHashMap<K, V> {144	type Target = HashMap<K, V, BuildHasherDefault<FxHasher>>;145146	fn deref(&self) -> &Self::Target {147		&self.0148	}149}150impl<K, V> DerefMut for GcHashMap<K, V> {151	fn deref_mut(&mut self) -> &mut Self::Target {152		&mut self.0153	}154}155impl<K, V> Default for GcHashMap<K, V> {156	fn default() -> Self {157		Self::new()158	}159}
modifiedcrates/jrsonnet-evaluator/src/import.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/import.rs
+++ b/crates/jrsonnet-evaluator/src/import.rs
@@ -41,7 +41,7 @@
 	}
 
 	unsafe fn as_any(&self) -> &dyn Any {
-		panic!("`as_any($self)` is not supported by dummy resolver")
+		panic!("`as_any(&self)` is not supported by dummy resolver")
 	}
 }
 #[allow(clippy::use_self)]
modifiedcrates/jrsonnet-evaluator/src/stdlib/format.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/stdlib/format.rs
+++ b/crates/jrsonnet-evaluator/src/stdlib/format.rs
@@ -774,10 +774,7 @@
 			format_arr(s.clone(), "%+-4o", &[Val::Num(8.0)]).unwrap(),
 			"+10 "
 		);
-		assert_eq!(
-			format_arr(s.clone(), "%+-04o", &[Val::Num(8.0)]).unwrap(),
-			"+10 "
-		);
+		assert_eq!(format_arr(s, "%+-04o", &[Val::Num(8.0)]).unwrap(), "+10 ");
 	}
 
 	#[test]
modifiedcrates/jrsonnet-evaluator/src/typed/conversions.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/typed/conversions.rs
+++ b/crates/jrsonnet-evaluator/src/typed/conversions.rs
@@ -393,6 +393,7 @@
 	($a:ty, $b:ty, $c:ty, $d:ty, $e:ty, $f:ty) => {Either6<$a, $b, $c, $d, $e, $f>};
 	($a:ty, $b:ty, $c:ty, $d:ty, $e:ty, $f:ty, $g:ty) => {Either7<$a, $b, $c, $d, $e, $f, $g>};
 }
+pub use Either;
 
 pub type MyType = Either![u32, f64, String];