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
99
10use crate::ConfigureState;10use crate::ConfigureState;
1111
12#[derive(PartialEq)]12#[derive(PartialEq, Eq)]
13pub enum TraceFormatName {13pub enum TraceFormatName {
14 Compact,14 Compact,
15 Explaining,15 Explaining,
modifiedcrates/jrsonnet-evaluator/src/integrations/serde.rsdiffbeforeafterboth
1313
14 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 builder
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
17 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 positives
21 // https://github.com/rust-lang/rust-clippy/issues/6902
22 clippy::use_self,
23 // https://github.com/rust-lang/rust-clippy/issues/8539
24 clippy::iter_with_drain,
20)]25)]
2126
22// For jrsonnet-macros27// For jrsonnet-macros
modifiedcrates/jrsonnet-evaluator/src/stdlib/format.rsdiffbeforeafterboth
120 Ok((out, &str[i..]))120 Ok((out, &str[i..]))
121}121}
122122
123#[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}
176176
177#[derive(Debug, PartialEq)]177#[derive(Debug, PartialEq, Eq)]
178pub enum ConvTypeV {178pub enum ConvTypeV {
179 Decimal,179 Decimal,
180 Octal,180 Octal,
modifiedcrates/jrsonnet-evaluator/src/stdlib/manifest.rsdiffbeforeafterboth
3 throw, State, Val,3 throw, State, Val,
4};4};
55
6#[derive(PartialEq, Clone, Copy)]6#[derive(PartialEq, Eq, Clone, Copy)]
7pub enum ManifestType {7pub enum ManifestType {
8 // Applied in manifestification8 // Applied in manifestification
9 Manifest,9 Manifest,
modifiedcrates/jrsonnet-evaluator/src/trace/location.rsdiffbeforeafterboth
1#[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,
55
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
157 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.0
159 }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 initialized
162 unsafe { this.0.as_ptr().add(mem::size_of::<InnerHeader>()) }162 unsafe { this.0.as_ptr().add(mem::size_of::<InnerHeader>()) }
163 }163 }
modifiedcrates/jrsonnet-parser/src/expr.rsdiffbeforeafterboth
21}21}
2222
23#[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}
6161
62#[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}
8686
87#[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}
180180
181#[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 /// ...rest
185 Keep(IStr),185 Keep(IStr),
188}188}
189189
190#[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}
264264
265#[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,
357357
358/// file, begin offset, end offset358/// file, begin offset, end offset
359#[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);