Skip to content

Commit

Permalink
chore: clippy (#858)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Jan 28, 2025
1 parent ae75f6e commit 6757fb3
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ manual-string-new = "warn"
uninlined-format-args = "warn"
use-self = "warn"
redundant-clone = "warn"
missing-const-for-fn = "warn"
missing-const-for-fn = "allow" # TODO: https://github.com/rust-lang/rust-clippy/issues/14020

[workspace.lints.rust]
missing-copy-implementations = "warn"
Expand Down
22 changes: 11 additions & 11 deletions crates/dyn-abi/src/coerce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use winnow::{
},
stream::Stream,
token::take_while,
PResult, Parser,
ModalResult, Parser,
};

impl DynSolType {
Expand Down Expand Up @@ -90,7 +90,7 @@ struct ValueParser<'a> {
}

impl<'i> Parser<Input<'i>, DynSolValue, ContextError> for ValueParser<'_> {
fn parse_next(&mut self, input: &mut Input<'i>) -> PResult<DynSolValue, ContextError> {
fn parse_next(&mut self, input: &mut Input<'i>) -> ModalResult<DynSolValue, ContextError> {
#[cfg(feature = "debug")]
let name = self.ty.sol_type_name();
#[cfg(not(feature = "debug"))]
Expand Down Expand Up @@ -282,7 +282,7 @@ impl fmt::Display for Error {
}

#[inline]
fn bool(input: &mut Input<'_>) -> PResult<bool> {
fn bool(input: &mut Input<'_>) -> ModalResult<bool> {
trace(
"bool",
dispatch! {alpha1.context(StrContext::Label("boolean"));
Expand Down Expand Up @@ -313,7 +313,7 @@ fn int<'i>(size: usize) -> impl Parser<Input<'i>, I256, ContextError> {
}

#[inline]
fn int_sign(input: &mut Input<'_>) -> PResult<Sign> {
fn int_sign(input: &mut Input<'_>) -> ModalResult<Sign> {
trace("int_sign", |input: &mut Input<'_>| match input.as_bytes().first() {
Some(b'+') => {
let _ = input.next_slice(1);
Expand Down Expand Up @@ -413,7 +413,7 @@ fn uint<'i>(len: usize) -> impl Parser<Input<'i>, U256, ContextError> {
}

#[inline]
fn prefixed_int<'i>(input: &mut Input<'i>) -> PResult<&'i str> {
fn prefixed_int<'i>(input: &mut Input<'i>) -> ModalResult<&'i str> {
trace(
"prefixed_int",
spanned(|input: &mut Input<'i>| {
Expand Down Expand Up @@ -441,7 +441,7 @@ fn prefixed_int<'i>(input: &mut Input<'i>) -> PResult<&'i str> {
}

#[inline]
fn int_units(input: &mut Input<'_>) -> PResult<usize> {
fn int_units(input: &mut Input<'_>) -> ModalResult<usize> {
trace(
"int_units",
dispatch! {alpha0;
Expand All @@ -455,7 +455,7 @@ fn int_units(input: &mut Input<'_>) -> PResult<usize> {
}

#[inline]
fn scientific_notation(input: &mut Input<'_>) -> PResult<isize> {
fn scientific_notation(input: &mut Input<'_>) -> ModalResult<isize> {
// Check if we have 'e' or 'E' followed by an optional sign and digits
if !matches!(input.chars().next(), Some('e' | 'E')) {
return Err(ErrMode::from_error_kind(input, ErrorKind::Fail));
Expand Down Expand Up @@ -490,22 +490,22 @@ fn fixed_bytes<'i>(len: usize) -> impl Parser<Input<'i>, Word, ContextError> {
}

#[inline]
fn address(input: &mut Input<'_>) -> PResult<Address> {
fn address(input: &mut Input<'_>) -> ModalResult<Address> {
trace("address", hex_str.try_map(hex::FromHex::from_hex)).parse_next(input)
}

#[inline]
fn function(input: &mut Input<'_>) -> PResult<Function> {
fn function(input: &mut Input<'_>) -> ModalResult<Function> {
trace("function", hex_str.try_map(hex::FromHex::from_hex)).parse_next(input)
}

#[inline]
fn bytes(input: &mut Input<'_>) -> PResult<Vec<u8>> {
fn bytes(input: &mut Input<'_>) -> ModalResult<Vec<u8>> {
trace("bytes", hex_str.try_map(hex::decode)).parse_next(input)
}

#[inline]
fn hex_str<'i>(input: &mut Input<'i>) -> PResult<&'i str> {
fn hex_str<'i>(input: &mut Input<'i>) -> ModalResult<&'i str> {
trace("hex_str", |input: &mut Input<'i>| {
// Allow empty `bytes` only with a prefix.
let has_prefix = opt("0x").parse_next(input)?.is_some();
Expand Down
6 changes: 3 additions & 3 deletions crates/sol-type-parser/src/ident.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use winnow::{
error::{ErrMode, ErrorKind, ParserError},
stream::{AsBStr, Stream},
PResult,
ModalResult,
};

/// The regular expression for a Solidity identifier.
Expand Down Expand Up @@ -54,12 +54,12 @@ pub const fn is_valid_identifier(s: &str) -> bool {

/// Parses a Solidity identifier.
#[inline]
pub fn identifier<'a>(input: &mut &'a str) -> PResult<&'a str> {
pub fn identifier<'a>(input: &mut &'a str) -> ModalResult<&'a str> {
identifier_parser(input)
}

#[inline]
pub(crate) fn identifier_parser<'a, I>(input: &mut I) -> PResult<&'a str>
pub(crate) fn identifier_parser<'a, I>(input: &mut I) -> ModalResult<&'a str>
where
I: Stream<Slice = &'a str> + AsBStr,
{
Expand Down
6 changes: 3 additions & 3 deletions crates/sol-type-parser/src/parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
};
use alloc::vec::Vec;
use core::fmt;
use winnow::{combinator::trace, PResult, Parser};
use winnow::{combinator::trace, ModalResult, Parser};

// TODO: Parse visibility and state mutability

Expand Down Expand Up @@ -41,7 +41,7 @@ impl<'a> ParameterSpecifier<'a> {
}

/// [`winnow`] parser for this type.
pub(crate) fn parser(input: &mut Input<'a>) -> PResult<Self> {
pub(crate) fn parser(input: &mut Input<'a>) -> ModalResult<Self> {
trace(
"ParameterSpecifier",
spanned(|input: &mut Input<'a>| {
Expand Down Expand Up @@ -104,7 +104,7 @@ impl<'a> Parameters<'a> {
}

/// [`winnow`] parser for this type.
pub(crate) fn parser(input: &mut Input<'a>) -> PResult<Self> {
pub(crate) fn parser(input: &mut Input<'a>) -> ModalResult<Self> {
trace("Parameters", spanned(tuple_parser(ParameterSpecifier::parser)))
.parse_next(input)
.map(|(span, params)| Self { span, params })
Expand Down
4 changes: 2 additions & 2 deletions crates/sol-type-parser/src/root.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{ident::identifier_parser, is_valid_identifier, new_input, Error, Input, Result};
use core::fmt;
use winnow::{combinator::trace, stream::Stream, PResult, Parser};
use winnow::{combinator::trace, stream::Stream, ModalResult, Parser};

/// A root type, with no array suffixes. Corresponds to a single, non-sequence
/// type. This is the most basic type specifier.
Expand Down Expand Up @@ -73,7 +73,7 @@ impl<'a> RootType<'a> {
}

/// [`winnow`] parser for this type.
pub(crate) fn parser(input: &mut Input<'a>) -> PResult<Self> {
pub(crate) fn parser(input: &mut Input<'a>) -> ModalResult<Self> {
trace("RootType", |input: &mut Input<'a>| {
identifier_parser(input).map(|ident| {
// Workaround for enums in library function params or returns.
Expand Down
4 changes: 2 additions & 2 deletions crates/sol-type-parser/src/stem.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{Error, Input, Result, RootType, TupleSpecifier};
use winnow::{combinator::trace, PResult, Parser};
use winnow::{combinator::trace, ModalResult, Parser};

/// A stem of a Solidity array type. It is either a root type, or a tuple type.
///
Expand Down Expand Up @@ -54,7 +54,7 @@ impl<'a> TypeStem<'a> {
}

/// [`winnow`] parser for this type.
pub(crate) fn parser(input: &mut Input<'a>) -> PResult<Self> {
pub(crate) fn parser(input: &mut Input<'a>) -> ModalResult<Self> {
let name = "TypeStem";
if input.starts_with('(') || input.starts_with("tuple(") {
trace(name, TupleSpecifier::parser).parse_next(input).map(Self::Tuple)
Expand Down
6 changes: 3 additions & 3 deletions crates/sol-type-parser/src/tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
use alloc::vec::Vec;
use winnow::{
combinator::{opt, preceded, trace},
PResult, Parser,
ModalResult, Parser,
};

/// A tuple specifier, with no array suffixes. Corresponds to a sequence of
Expand Down Expand Up @@ -60,14 +60,14 @@ impl<'a> TupleSpecifier<'a> {
}

/// [`winnow`] parser for this type.
pub(crate) fn parser(input: &mut Input<'a>) -> PResult<Self> {
pub(crate) fn parser(input: &mut Input<'a>) -> ModalResult<Self> {
trace("TupleSpecifier", spanned(Self::parse_types))
.parse_next(input)
.map(|(span, types)| Self { span, types })
}

#[inline]
fn parse_types(input: &mut Input<'a>) -> PResult<Vec<TypeSpecifier<'a>>> {
fn parse_types(input: &mut Input<'a>) -> ModalResult<Vec<TypeSpecifier<'a>>> {
preceded(opt("tuple"), tuple_parser(TypeSpecifier::parser)).parse_next(input)
}

Expand Down
6 changes: 3 additions & 3 deletions crates/sol-type-parser/src/type_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use winnow::{
ascii::digit0,
combinator::{cut_err, delimited, repeat, trace},
error::{ErrMode, ErrorKind, FromExternalError},
PResult, Parser,
ModalResult, Parser,
};

/// Represents a type-name. Consists of an identifier and optional array sizes.
Expand Down Expand Up @@ -93,7 +93,7 @@ impl<'a> TypeSpecifier<'a> {
}

/// [`winnow`] parser for this type.
pub(crate) fn parser(input: &mut Input<'a>) -> PResult<Self> {
pub(crate) fn parser(input: &mut Input<'a>) -> ModalResult<Self> {
trace(
"TypeSpecifier",
spanned(|input: &mut Input<'a>| {
Expand Down Expand Up @@ -139,7 +139,7 @@ impl<'a> TypeSpecifier<'a> {
}
}

fn array_size_parser(input: &mut Input<'_>) -> PResult<Option<NonZeroUsize>> {
fn array_size_parser(input: &mut Input<'_>) -> ModalResult<Option<NonZeroUsize>> {
let digits = digit0(input)?;
if digits.is_empty() {
return Ok(None);
Expand Down
4 changes: 2 additions & 2 deletions crates/sol-type-parser/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use winnow::{
combinator::{alt, cut_err, opt, preceded, separated, terminated, trace},
error::{ContextError, StrContext, StrContextValue},
stream::{Accumulate, AsChar, Stream},
PResult, Parser,
ModalResult, Parser,
};

pub use crate::ident::identifier;
Expand Down Expand Up @@ -96,7 +96,7 @@ where
})
}

pub fn opt_ws_ident<'a>(input: &mut Input<'a>) -> PResult<Option<&'a str>> {
pub fn opt_ws_ident<'a>(input: &mut Input<'a>) -> ModalResult<Option<&'a str>> {
preceded(space0, opt(identifier_parser)).parse_next(input)
}

Expand Down

0 comments on commit 6757fb3

Please sign in to comment.