difftreelog
style fix warnings with nightly clippy
in: master
9 files changed
crates/jrsonnet-cli/src/trace.rsdiffbeforeafterboth9910use crate::ConfigureState;10use crate::ConfigureState;111112#[derive(PartialEq)]12#[derive(PartialEq, Eq)]13pub enum TraceFormatName {13pub enum TraceFormatName {14 Compact,14 Compact,15 Explaining,15 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.rsdiffbeforeafterboth17 clippy::cast_possible_wrap,17 clippy::cast_possible_wrap,18 clippy::cast_possible_truncation,18 clippy::cast_possible_truncation,19 clippy::cast_sign_loss,19 clippy::cast_sign_loss,20 // False positives21 // https://github.com/rust-lang/rust-clippy/issues/690222 clippy::use_self,23 // https://github.com/rust-lang/rust-clippy/issues/853924 clippy::iter_with_drain,20)]25)]212622// For jrsonnet-macros27// For jrsonnet-macroscrates/jrsonnet-evaluator/src/stdlib/format.rsdiffbeforeafterboth120 Ok((out, &str[i..]))120 Ok((out, &str[i..]))121}121}122122123#[derive(Debug, PartialEq)]123#[derive(Debug, PartialEq, Eq)]124pub enum Width {124pub enum Width {125 Star,125 Star,126 Fixed(usize),126 Fixed(usize),174 Ok(((), &str[idx..]))174 Ok(((), &str[idx..]))175}175}176176177#[derive(Debug, PartialEq)]177#[derive(Debug, PartialEq, Eq)]178pub enum ConvTypeV {178pub enum ConvTypeV {179 Decimal,179 Decimal,180 Octal,180 Octal,crates/jrsonnet-evaluator/src/stdlib/manifest.rsdiffbeforeafterboth3 throw, State, Val,3 throw, State, Val,4};4};556#[derive(PartialEq, Clone, Copy)]6#[derive(PartialEq, Eq, Clone, Copy)]7pub enum ManifestType {7pub enum ManifestType {8 // Applied in manifestification8 // Applied in manifestification9 Manifest,9 Manifest,crates/jrsonnet-evaluator/src/trace/location.rsdiffbeforeafterboth1#[allow(clippy::module_name_repetitions)]1#[allow(clippy::module_name_repetitions)]2#[derive(Clone, PartialEq, Debug)]2#[derive(Clone, PartialEq, Eq, Debug)]3pub struct CodeLocation {3pub struct CodeLocation {4 pub offset: usize,4 pub offset: usize,55crates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth476impl 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 }crates/jrsonnet-interner/src/inner.rsdiffbeforeafterboth157 pub fn ptr_eq(a: &Self, b: &Self) -> bool {157 pub fn ptr_eq(a: &Self, b: &Self) -> bool {158 a.0 == b.0158 a.0 == b.0159 }159 }160 pub fn as_ptr(this: &Self) -> *const u8 {160 pub const fn as_ptr(this: &Self) -> *const u8 {161 // SAFETY: data is initialized161 // SAFETY: data is initialized162 unsafe { this.0.as_ptr().add(mem::size_of::<InnerHeader>()) }162 unsafe { this.0.as_ptr().add(mem::size_of::<InnerHeader>()) }163 }163 }crates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth21}21}222223#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]23#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]24#[derive(Debug, Clone, Copy, PartialEq, Trace)]24#[derive(Debug, Clone, Copy, PartialEq, Eq, Trace)]25pub enum Visibility {25pub enum Visibility {26 /// :26 /// :27 Normal,27 Normal,60}60}616162#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]62#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]63#[derive(Debug, Clone, Copy, PartialEq, Trace)]63#[derive(Debug, Clone, Copy, PartialEq, Eq, Trace)]64pub enum UnaryOpType {64pub enum UnaryOpType {65 Plus,65 Plus,66 Minus,66 Minus,85}85}868687#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]87#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]88#[derive(Debug, Clone, Copy, PartialEq, Trace)]88#[derive(Debug, Clone, Copy, PartialEq, Eq, Trace)]89pub enum BinaryOpType {89pub enum BinaryOpType {90 Mul,90 Mul,91 Div,91 Div,179}179}180180181#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]181#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]182#[derive(Debug, Clone, PartialEq, Trace)]182#[derive(Debug, Clone, PartialEq, Eq, Trace)]183pub enum DestructRest {183pub enum DestructRest {184 /// ...rest184 /// ...rest185 Keep(IStr),185 Keep(IStr),188}188}189189190#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]190#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]191#[derive(Debug, Clone, PartialEq, Trace)]191#[derive(Debug, Clone, PartialEq, Eq, Trace)]192pub enum Destruct {192pub enum Destruct {193 Full(IStr),193 Full(IStr),194 #[cfg(feature = "exp-destruct")]194 #[cfg(feature = "exp-destruct")]263}263}264264265#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]265#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]266#[derive(Debug, PartialEq, Clone, Copy, Trace)]266#[derive(Debug, PartialEq, Eq, Clone, Copy, Trace)]267pub enum LiteralType {267pub enum LiteralType {268 This,268 This,269 Super,269 Super,357357358/// file, begin offset, end offset358/// file, begin offset, end offset359#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]359#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]360#[derive(Clone, PartialEq, Trace)]360#[derive(Clone, PartialEq, Eq, Trace)]361#[skip_trace]361#[skip_trace]362#[repr(C)]362#[repr(C)]363pub struct ExprLocation(pub Source, pub u32, pub u32);363pub struct ExprLocation(pub Source, pub u32, pub u32);