git.delta.rocks / jrsonnet / refs/commits / 2d0d919b58c4

difftreelog

style fix warnings with nightly clippy

Yaroslav Bolyukin2022-05-26parent: #e1e1d4b.patch.diff
in: master

9 files changed

modifiedcrates/jrsonnet-cli/src/trace.rsdiffbeforeafterboth
--- a/crates/jrsonnet-cli/src/trace.rs
+++ b/crates/jrsonnet-cli/src/trace.rs
@@ -9,7 +9,7 @@
 
 use crate::ConfigureState;
 
-#[derive(PartialEq)]
+#[derive(PartialEq, Eq)]
 pub enum TraceFormatName {
 	Compact,
 	Explaining,
modifiedcrates/jrsonnet-evaluator/src/integrations/serde.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/integrations/serde.rs
+++ b/crates/jrsonnet-evaluator/src/integrations/serde.rs
@@ -13,20 +13,20 @@
 
 	fn into_untyped(value: Self, s: State) -> Result<Val> {
 		Ok(match value {
-			Value::Null => Val::Null,
-			Value::Bool(v) => Val::Bool(v),
-			Value::Number(n) => Val::Num(n.as_f64().ok_or_else(|| {
+			Self::Null => Val::Null,
+			Self::Bool(v) => Val::Bool(v),
+			Self::Number(n) => Val::Num(n.as_f64().ok_or_else(|| {
 				RuntimeError(format!("json number can't be represented as jsonnet: {}", n).into())
 			})?),
-			Value::String(s) => Val::Str((&s as &str).into()),
-			Value::Array(a) => {
+			Self::String(s) => Val::Str((&s as &str).into()),
+			Self::Array(a) => {
 				let mut out: Vec<Val> = Vec::with_capacity(a.len());
 				for v in a {
 					out.push(Self::into_untyped(v, s.clone())?);
 				}
 				Val::Arr(out.into())
 			}
-			Value::Object(o) => {
+			Self::Object(o) => {
 				let mut builder = ObjValueBuilder::with_capacity(o.len());
 				for (k, v) in o {
 					builder
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/lib.rs
+++ b/crates/jrsonnet-evaluator/src/lib.rs
@@ -17,6 +17,11 @@
 	clippy::cast_possible_wrap,
 	clippy::cast_possible_truncation,
 	clippy::cast_sign_loss,
+	// False positives
+	// https://github.com/rust-lang/rust-clippy/issues/6902
+	clippy::use_self,
+	// https://github.com/rust-lang/rust-clippy/issues/8539
+	clippy::iter_with_drain,
 )]
 
 // For jrsonnet-macros
modifiedcrates/jrsonnet-evaluator/src/stdlib/format.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/stdlib/format.rs
+++ b/crates/jrsonnet-evaluator/src/stdlib/format.rs
@@ -120,7 +120,7 @@
 	Ok((out, &str[i..]))
 }
 
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Eq)]
 pub enum Width {
 	Star,
 	Fixed(usize),
@@ -174,7 +174,7 @@
 	Ok(((), &str[idx..]))
 }
 
-#[derive(Debug, PartialEq)]
+#[derive(Debug, PartialEq, Eq)]
 pub enum ConvTypeV {
 	Decimal,
 	Octal,
modifiedcrates/jrsonnet-evaluator/src/stdlib/manifest.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/stdlib/manifest.rs
+++ b/crates/jrsonnet-evaluator/src/stdlib/manifest.rs
@@ -3,7 +3,7 @@
 	throw, State, Val,
 };
 
-#[derive(PartialEq, Clone, Copy)]
+#[derive(PartialEq, Eq, Clone, Copy)]
 pub enum ManifestType {
 	// Applied in manifestification
 	Manifest,
modifiedcrates/jrsonnet-evaluator/src/trace/location.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/trace/location.rs
+++ b/crates/jrsonnet-evaluator/src/trace/location.rs
@@ -1,5 +1,5 @@
 #[allow(clippy::module_name_repetitions)]
-#[derive(Clone, PartialEq, Debug)]
+#[derive(Clone, PartialEq, Eq, Debug)]
 pub struct CodeLocation {
 	pub offset: usize,
 
modifiedcrates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth
476impl Val {476impl Val {
477 pub const fn as_bool(&self) -> Option<bool> {477 pub const fn as_bool(&self) -> Option<bool> {
478 match self {478 match self {
479 Val::Bool(v) => Some(*v),479 Self::Bool(v) => Some(*v),
480 _ => None,480 _ => None,
481 }481 }
482 }482 }
483 pub const fn as_null(&self) -> Option<()> {483 pub const fn as_null(&self) -> Option<()> {
484 match self {484 match self {
485 Val::Null => Some(()),485 Self::Null => Some(()),
486 _ => None,486 _ => None,
487 }487 }
488 }488 }
489 pub fn as_str(&self) -> Option<IStr> {489 pub fn as_str(&self) -> Option<IStr> {
490 match self {490 match self {
491 Val::Str(s) => Some(s.clone()),491 Self::Str(s) => Some(s.clone()),
492 _ => None,492 _ => None,
493 }493 }
494 }494 }
495 pub const fn as_num(&self) -> Option<f64> {495 pub const fn as_num(&self) -> Option<f64> {
496 match self {496 match self {
497 Val::Num(n) => Some(*n),497 Self::Num(n) => Some(*n),
498 _ => None,498 _ => None,
499 }499 }
500 }500 }
501 pub fn as_arr(&self) -> Option<ArrValue> {501 pub fn as_arr(&self) -> Option<ArrValue> {
502 match self {502 match self {
503 Val::Arr(a) => Some(a.clone()),503 Self::Arr(a) => Some(a.clone()),
504 _ => None,504 _ => None,
505 }505 }
506 }506 }
507 pub fn as_obj(&self) -> Option<ObjValue> {507 pub fn as_obj(&self) -> Option<ObjValue> {
508 match self {508 match self {
509 Val::Obj(o) => Some(o.clone()),509 Self::Obj(o) => Some(o.clone()),
510 _ => None,510 _ => None,
511 }511 }
512 }512 }
513 pub fn as_func(&self) -> Option<FuncVal> {513 pub fn as_func(&self) -> Option<FuncVal> {
514 match self {514 match self {
515 Val::Func(f) => Some(f.clone()),515 Self::Func(f) => Some(f.clone()),
516 _ => None,516 _ => None,
517 }517 }
518 }518 }
modifiedcrates/jrsonnet-interner/src/inner.rsdiffbeforeafterboth
--- a/crates/jrsonnet-interner/src/inner.rs
+++ b/crates/jrsonnet-interner/src/inner.rs
@@ -157,7 +157,7 @@
 	pub fn ptr_eq(a: &Self, b: &Self) -> bool {
 		a.0 == b.0
 	}
-	pub fn as_ptr(this: &Self) -> *const u8 {
+	pub const fn as_ptr(this: &Self) -> *const u8 {
 		// SAFETY: data is initialized
 		unsafe { this.0.as_ptr().add(mem::size_of::<InnerHeader>()) }
 	}
modifiedcrates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth
--- a/crates/jrsonnet-parser/src/expr.rs
+++ b/crates/jrsonnet-parser/src/expr.rs
@@ -21,7 +21,7 @@
 }
 
 #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
-#[derive(Debug, Clone, Copy, PartialEq, Trace)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Trace)]
 pub enum Visibility {
 	/// :
 	Normal,
@@ -60,7 +60,7 @@
 }
 
 #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
-#[derive(Debug, Clone, Copy, PartialEq, Trace)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Trace)]
 pub enum UnaryOpType {
 	Plus,
 	Minus,
@@ -85,7 +85,7 @@
 }
 
 #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
-#[derive(Debug, Clone, Copy, PartialEq, Trace)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Trace)]
 pub enum BinaryOpType {
 	Mul,
 	Div,
@@ -179,7 +179,7 @@
 }
 
 #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
-#[derive(Debug, Clone, PartialEq, Trace)]
+#[derive(Debug, Clone, PartialEq, Eq, Trace)]
 pub enum DestructRest {
 	/// ...rest
 	Keep(IStr),
@@ -188,7 +188,7 @@
 }
 
 #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
-#[derive(Debug, Clone, PartialEq, Trace)]
+#[derive(Debug, Clone, PartialEq, Eq, Trace)]
 pub enum Destruct {
 	Full(IStr),
 	#[cfg(feature = "exp-destruct")]
@@ -263,7 +263,7 @@
 }
 
 #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
-#[derive(Debug, PartialEq, Clone, Copy, Trace)]
+#[derive(Debug, PartialEq, Eq, Clone, Copy, Trace)]
 pub enum LiteralType {
 	This,
 	Super,
@@ -357,7 +357,7 @@
 
 /// file, begin offset, end offset
 #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
-#[derive(Clone, PartialEq, Trace)]
+#[derive(Clone, PartialEq, Eq, Trace)]
 #[skip_trace]
 #[repr(C)]
 pub struct ExprLocation(pub Source, pub u32, pub u32);