Skip to content

Commit

Permalink
Clean up new clippies
Browse files Browse the repository at this point in the history
Signed-off-by: Heinz Gies <[email protected]>
  • Loading branch information
Licenser committed Mar 20, 2024
1 parent f6161f4 commit 8f4a9c2
Show file tree
Hide file tree
Showing 27 changed files with 38 additions and 64 deletions.
6 changes: 0 additions & 6 deletions src/impls/avx2/stage1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,4 @@ impl Stage1Parse for SimdInput {
unsafe fn fill_s8(n: i8) -> __m256i {
_mm256_set1_epi8(n)
}

#[cfg_attr(not(feature = "no-inline"), inline)]
#[target_feature(enable = "avx2")]
unsafe fn zero() -> __m256i {
_mm256_setzero_si256()
}
}
4 changes: 0 additions & 4 deletions src/impls/native/stage1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,4 @@ impl Stage1Parse for SimdInput {
unsafe fn fill_s8(n: i8) -> V128 {
u8x16_splat(n as u8)
}

unsafe fn zero() -> V128 {
u8x16_splat(0)
}
}
2 changes: 1 addition & 1 deletion src/impls/neon/deser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ pub(crate) fn parse_str<'invoke, 'de>(
buffer: &'invoke mut [u8],
mut idx: usize,
) -> Result<&'de str> {
use ErrorType::{InvalidEscape, InvalidUnicodeCodepoint};
let input = input.input;

use ErrorType::{InvalidEscape, InvalidUnicodeCodepoint};
// Add 1 to skip the initial "
idx += 1;
//let mut read: usize = 0;
Expand Down
5 changes: 0 additions & 5 deletions src/impls/neon/stage1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,4 @@ impl Stage1Parse for SimdInput {
unsafe fn fill_s8(n: i8) -> int8x16_t {
vdupq_n_s8(n)
}

#[cfg_attr(not(feature = "no-inline"), inline)]
unsafe fn zero() -> int8x16_t {
vdupq_n_s8(0)
}
}
5 changes: 0 additions & 5 deletions src/impls/portable/stage1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,4 @@ impl Stage1Parse for SimdInput {
#[allow(clippy::cast_sign_loss)]
u8x64::splat(n as u8)
}

#[cfg_attr(not(feature = "no-inline"), inline)]
unsafe fn zero() -> u8x64 {
u8x64::splat(0)
}
}
5 changes: 0 additions & 5 deletions src/impls/simd128/stage1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,4 @@ impl Stage1Parse for SimdInput {
unsafe fn fill_s8(n: i8) -> v128 {
i8x16_splat(n)
}

#[cfg_attr(not(feature = "no-inline"), inline)]
unsafe fn zero() -> v128 {
i8x16_splat(0)
}
}
6 changes: 0 additions & 6 deletions src/impls/sse42/stage1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,4 @@ impl Stage1Parse for SimdInput {
unsafe fn fill_s8(n: i8) -> __m128i {
_mm_set1_epi8(n)
}

#[target_feature(enable = "sse4.2")]
#[cfg_attr(not(feature = "no-inline"), inline)]
unsafe fn zero() -> __m128i {
_mm_setzero_si128()
}
}
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ pub(crate) trait Stage1Parse {
}

unsafe fn fill_s8(n: i8) -> Self::SimdRepresentation;
unsafe fn zero() -> Self::SimdRepresentation;
}

/// Deserializer struct to deserialize a JSON
Expand Down Expand Up @@ -929,7 +928,7 @@ impl<'de> Deserializer<'de> {
self.idx += 1;
}

/// Same as next() but we pull out the check so we don't need to
/// Same as `next()` but we pull out the check so we don't need to
/// stry every time. Use this only if you know the next element exists!
///
/// # Safety
Expand Down
2 changes: 1 addition & 1 deletion src/numberparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ fn parse_eight_digits_unrolled(chars: &[u8]) -> u32 {
))]
#[allow(clippy::cast_ptr_alignment)]
fn parse_eight_digits_unrolled(chars: &[u8]) -> u32 {
let val = unsafe { (chars.as_ptr() as *const u64).read_unaligned() }; // memcpy(&val, chars, sizeof(u64));
let val = unsafe { chars.as_ptr().cast::<u64>().read_unaligned() }; // memcpy(&val, chars, sizeof(u64));
let val = (val & 0x0F0F_0F0F_0F0F_0F0F).wrapping_mul(2561) >> 8;
let val = (val & 0x00FF_00FF_00FF_00FF).wrapping_mul(6_553_601) >> 16;

Expand Down
4 changes: 1 addition & 3 deletions src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ mod se;
mod value;
pub use self::se::*;
pub use self::value::*;
use crate::{stry, Buffers, Deserializer, Error, ErrorType, Result};
use crate::{stry, Buffers, Deserializer, Error, ErrorType, Node, Result};
use crate::{BorrowedValue, OwnedValue};
use crate::{Node, StaticNode};
use serde::de::DeserializeOwned;
use serde_ext::Deserialize;
use std::convert::{TryFrom, TryInto};
use std::fmt;
use std::io;
use value_trait::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion src/serde/de.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::serde_ext::de::IntoDeserializer;
use crate::{serde_ext, stry, Deserializer, Error, ErrorType, Node, Result, StaticNode};
use crate::{stry, Deserializer, Error, ErrorType, Node, Result, StaticNode};
use serde_ext::de::{self, DeserializeSeed, MapAccess, SeqAccess, Visitor};
use serde_ext::forward_to_deserialize_any;
use std::str;
Expand Down
3 changes: 1 addition & 2 deletions src/serde/se.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
mod pp;
use crate::{serde_ext, Error, ErrorType};
use crate::{Error, ErrorType};
pub use pp::*;
use serde_ext::ser;
use std::io::Write;
use std::result::Result;
use std::str;
use value_trait::generator::BaseGenerator;

Expand Down
3 changes: 1 addition & 2 deletions src/serde/se/pp.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{serde_ext, stry, Error, ErrorType};
use crate::{stry, Error, ErrorType};
use serde_ext::ser;
use std::io::Write;
use std::result::Result;
use std::str;
use value_trait::generator::BaseGenerator;

Expand Down
1 change: 0 additions & 1 deletion src/serde/value/borrowed/de.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// A lot of this logic is a re-implementation or copy of serde_json::Value
use crate::Error;
use crate::ObjectHasher;
use crate::StaticNode;
use crate::{cow::Cow, ErrorType};
use crate::{
prelude::*,
Expand Down
1 change: 1 addition & 0 deletions src/serde/value/borrowed/se.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ mod test {
struct Map {
key: u32,
}
#[allow(clippy::struct_field_names)]
#[derive(Deserialize, Serialize, PartialEq, Debug, Default)]
struct Obj {
v_i128: i128,
Expand Down
1 change: 0 additions & 1 deletion src/serde/value/owned/de.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// A lot of this logic is a re-implementation or copy of serde_json::Value
use crate::ErrorType;
use crate::StaticNode;
use crate::{
prelude::*,
serde::value::shared::MapKeyDeserializer,
Expand Down
1 change: 1 addition & 0 deletions src/serde/value/owned/se.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ mod test {
#[derive(Debug, Serialize, Deserialize)]
struct TestPoint(f64, f64);

#[allow(clippy::struct_field_names)]
#[derive(Deserialize, Serialize, PartialEq, Debug, Default)]
struct Obj {
v_i128: i128,
Expand Down
4 changes: 2 additions & 2 deletions src/tests/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ proptest! {
.. ProptestConfig::default()
})]
#[test]
// #[allow(clippy::should_panic_without_expect)]
#[allow(clippy::should_panic_without_expect)]
#[should_panic]
fn prop_junk(d in arb_junk()) {
let mut d1 = d.clone();
Expand All @@ -947,7 +947,7 @@ proptest! {
})]

#[test]
// #[allow(clippy::should_panic_without_expect)]
#[allow(clippy::should_panic_without_expect)]
#[should_panic]
fn prop_string(d in "\\PC*") {
let mut d1 = d.clone();
Expand Down
2 changes: 1 addition & 1 deletion src/value/borrowed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mod serialize;
use super::ObjectHasher;
use crate::cow::Cow;
use crate::{prelude::*, Buffers};
use crate::{Deserializer, Node, Result, StaticNode};
use crate::{Deserializer, Node, Result};
use halfbrown::HashMap;
use std::fmt;
use std::ops::{Index, IndexMut};
Expand Down
1 change: 0 additions & 1 deletion src/value/borrowed/from.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use super::{Object, Value};
use crate::cow::Cow;
use crate::OwnedValue;
use crate::StaticNode;
use std::iter::FromIterator;

impl<'value> From<OwnedValue> for Value<'value> {
#[cfg_attr(not(feature = "no-inline"), inline)]
Expand Down
4 changes: 1 addition & 3 deletions src/value/borrowed/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@

use super::{Object, Value};
use crate::prelude::*;
use crate::stry;
use crate::StaticNode;
use std::io;
use std::io::Write;
use value_trait::generator::{
BaseGenerator, DumpGenerator, PrettyGenerator, PrettyWriterGenerator, WriterGenerator,
DumpGenerator, PrettyGenerator, PrettyWriterGenerator, WriterGenerator,
};

//use util::print_dec;
Expand Down
2 changes: 1 addition & 1 deletion src/value/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mod serialize;

use super::ObjectHasher;
use crate::{prelude::*, Buffers};
use crate::{Deserializer, Node, Result, StaticNode};
use crate::{Deserializer, Node, Result};
use halfbrown::HashMap;
use std::fmt;
use std::ops::{Index, IndexMut};
Expand Down
1 change: 0 additions & 1 deletion src/value/owned/from.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use super::{Object, Value};
use crate::{BorrowedValue, StaticNode};
use std::iter::FromIterator;

impl From<crate::BorrowedValue<'_>> for Value {
#[cfg_attr(not(feature = "no-inline"), inline)]
Expand Down
3 changes: 1 addition & 2 deletions src/value/owned/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

use super::{Object, Value};
use crate::prelude::*;
use crate::{stry, StaticNode};
use std::io;
use std::io::Write;
use value_trait::generator::{
BaseGenerator, DumpGenerator, PrettyGenerator, PrettyWriterGenerator, WriterGenerator,
DumpGenerator, PrettyGenerator, PrettyWriterGenerator, WriterGenerator,
};

//use util::print_dec;
Expand Down
21 changes: 14 additions & 7 deletions src/value/tape/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ pub struct Array<'tape, 'input>(pub(super) &'tape [Node<'input>]);

pub struct ArrayIter<'tape, 'input>(&'tape [Node<'input>]);

impl<'tape, 'input> Iterator for ArrayIter<'tape, 'input> {
type Item = Value<'tape, 'input>;

fn next(&mut self) -> Option<Self::Item> {
let (head, tail) = self.0.split_at(self.0.first()?.count());
self.0 = tail;
Some(Value(head))
}
}

// value_trait::Array for
impl<'tape, 'input> Array<'tape, 'input>
where
Expand Down Expand Up @@ -48,16 +58,13 @@ where
}
}

impl<'tape, 'input> Iterator for ArrayIter<'tape, 'input> {
impl<'tape, 'input> IntoIterator for &Array<'tape, 'input> {
type IntoIter = ArrayIter<'tape, 'input>;
type Item = Value<'tape, 'input>;

fn next(&mut self) -> Option<Self::Item> {
let (head, tail) = self.0.split_at(self.0.first()?.count());
self.0 = tail;
Some(Value(head))
fn into_iter(self) -> Self::IntoIter {
self.iter()
}
}

#[cfg(test)]
mod test {
use crate::to_tape;
Expand Down
2 changes: 1 addition & 1 deletion src/value/tape/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ where
if object.len() != other.len() {
return false;
}
for (key, value) in object.iter() {
for (key, value) in &object {
if !other.get(key).map_or(false, |v| v == &value) {
return false;
}
Expand Down
8 changes: 8 additions & 0 deletions src/value/tape/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ impl<'tape, 'input> Object<'tape, 'input> {
}
}

impl<'tape, 'input> IntoIterator for &Object<'tape, 'input> {
type IntoIter = ObjectIter<'tape, 'input>;
type Item = (&'input str, Value<'tape, 'input>);
fn into_iter(self) -> Self::IntoIter {
self.iter()
}
}

impl<'tape, 'input> Iterator for ObjectIter<'tape, 'input> {
type Item = (&'input str, Value<'tape, 'input>);

Expand Down

0 comments on commit 8f4a9c2

Please sign in to comment.