Skip to content

Commit

Permalink
style: fix warnings with nightly clippy
Browse files Browse the repository at this point in the history
Signed-off-by: Yaroslav Bolyukin <[email protected]>
  • Loading branch information
CertainLach committed May 26, 2022
1 parent e1e1d4b commit 2d0d919
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 26 deletions.
2 changes: 1 addition & 1 deletion crates/jrsonnet-cli/src/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use jrsonnet_evaluator::{

use crate::ConfigureState;

#[derive(PartialEq)]
#[derive(PartialEq, Eq)]
pub enum TraceFormatName {
Compact,
Explaining,
Expand Down
12 changes: 6 additions & 6 deletions crates/jrsonnet-evaluator/src/integrations/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ impl Typed for Value {

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
Expand Down
5 changes: 5 additions & 0 deletions crates/jrsonnet-evaluator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions crates/jrsonnet-evaluator/src/stdlib/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub fn try_parse_cflags(str: &str) -> ParseResult<CFlags> {
Ok((out, &str[i..]))
}

#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum Width {
Star,
Fixed(usize),
Expand Down Expand Up @@ -174,7 +174,7 @@ pub fn try_parse_length_modifier(str: &str) -> ParseResult<()> {
Ok(((), &str[idx..]))
}

#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum ConvTypeV {
Decimal,
Octal,
Expand Down
2 changes: 1 addition & 1 deletion crates/jrsonnet-evaluator/src/stdlib/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
throw, State, Val,
};

#[derive(PartialEq, Clone, Copy)]
#[derive(PartialEq, Eq, Clone, Copy)]
pub enum ManifestType {
// Applied in manifestification
Manifest,
Expand Down
2 changes: 1 addition & 1 deletion crates/jrsonnet-evaluator/src/trace/location.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[allow(clippy::module_name_repetitions)]
#[derive(Clone, PartialEq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct CodeLocation {
pub offset: usize,

Expand Down
14 changes: 7 additions & 7 deletions crates/jrsonnet-evaluator/src/val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,43 +476,43 @@ static_assertions::assert_eq_size!(Val, [u8; 32]);
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,
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/jrsonnet-interner/src/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl Inner {
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>()) }
}
Expand Down
14 changes: 7 additions & 7 deletions crates/jrsonnet-parser/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub enum FieldName {
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Copy, PartialEq, Trace)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Trace)]
pub enum Visibility {
/// :
Normal,
Expand Down Expand Up @@ -60,7 +60,7 @@ pub enum Member {
}

#[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,
Expand All @@ -85,7 +85,7 @@ impl Display for UnaryOpType {
}

#[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,
Expand Down Expand Up @@ -179,7 +179,7 @@ impl ArgsDesc {
}

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, PartialEq, Trace)]
#[derive(Debug, Clone, PartialEq, Eq, Trace)]
pub enum DestructRest {
/// ...rest
Keep(IStr),
Expand All @@ -188,7 +188,7 @@ pub enum DestructRest {
}

#[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")]
Expand Down Expand Up @@ -263,7 +263,7 @@ pub enum ObjBody {
}

#[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,
Expand Down Expand Up @@ -357,7 +357,7 @@ pub enum Expr {

/// 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);
Expand Down

0 comments on commit 2d0d919

Please sign in to comment.