difftreelog
style fix warnings with nightly clippy
in: master
9 files changed
crates/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,
crates/jrsonnet-evaluator/src/integrations/serde.rsdiffbeforeafterboth131314 fn into_untyped(value: Self, s: State) -> Result<Val> {14 fn into_untyped(value: Self, s: State) -> Result<Val> {15 Ok(match value {15 Ok(match value {16 Value::Null => Val::Null,16 Self::Null => Val::Null,17 Value::Bool(v) => Val::Bool(v),17 Self::Bool(v) => Val::Bool(v),18 Value::Number(n) => Val::Num(n.as_f64().ok_or_else(|| {18 Self::Number(n) => Val::Num(n.as_f64().ok_or_else(|| {19 RuntimeError(format!("json number can't be represented as jsonnet: {}", n).into())19 RuntimeError(format!("json number can't be represented as jsonnet: {}", n).into())20 })?),20 })?),21 Value::String(s) => Val::Str((&s as &str).into()),21 Self::String(s) => Val::Str((&s as &str).into()),22 Value::Array(a) => {22 Self::Array(a) => {23 let mut out: Vec<Val> = Vec::with_capacity(a.len());23 let mut out: Vec<Val> = Vec::with_capacity(a.len());24 for v in a {24 for v in a {25 out.push(Self::into_untyped(v, s.clone())?);25 out.push(Self::into_untyped(v, s.clone())?);26 }26 }27 Val::Arr(out.into())27 Val::Arr(out.into())28 }28 }29 Value::Object(o) => {29 Self::Object(o) => {30 let mut builder = ObjValueBuilder::with_capacity(o.len());30 let mut builder = ObjValueBuilder::with_capacity(o.len());31 for (k, v) in o {31 for (k, v) in o {32 builder32 buildercrates/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
crates/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,
crates/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,
crates/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,
crates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/val.rs
+++ b/crates/jrsonnet-evaluator/src/val.rs
@@ -476,43 +476,43 @@
impl Val {
pub const fn as_bool(&self) -> Option<bool> {
match self {
- Val::Bool(v) => Some(*v),
+ Self::Bool(v) => Some(*v),
_ => None,
}
}
pub const fn as_null(&self) -> Option<()> {
match self {
- Val::Null => Some(()),
+ Self::Null => Some(()),
_ => None,
}
}
pub fn as_str(&self) -> Option<IStr> {
match self {
- Val::Str(s) => Some(s.clone()),
+ Self::Str(s) => Some(s.clone()),
_ => None,
}
}
pub const fn as_num(&self) -> Option<f64> {
match self {
- Val::Num(n) => Some(*n),
+ Self::Num(n) => Some(*n),
_ => None,
}
}
pub fn as_arr(&self) -> Option<ArrValue> {
match self {
- Val::Arr(a) => Some(a.clone()),
+ Self::Arr(a) => Some(a.clone()),
_ => None,
}
}
pub fn as_obj(&self) -> Option<ObjValue> {
match self {
- Val::Obj(o) => Some(o.clone()),
+ Self::Obj(o) => Some(o.clone()),
_ => None,
}
}
pub fn as_func(&self) -> Option<FuncVal> {
match self {
- Val::Func(f) => Some(f.clone()),
+ Self::Func(f) => Some(f.clone()),
_ => None,
}
}
crates/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>()) }
}
crates/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);