Skip to content

Commit

Permalink
[nextest-filtering] Address clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jan 10, 2024
1 parent 849f547 commit 822eaa3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
36 changes: 18 additions & 18 deletions nextest-filtering/src/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ where
fn ws<'a, T, P: Parser<Span<'a>, T, Error>>(mut inner: P) -> impl Parser<Span<'a>, T, Error> {
move |input: &mut Span<'a>| {
let start = input.checkpoint();
let _: () = repeat(
repeat(
0..,
alt((
// Match individual space characters.
Expand Down Expand Up @@ -357,7 +357,7 @@ fn parse_matcher_text<'i>(input: &mut Span<'i>) -> PResult<Option<String>> {
.parse_next(input)
}

fn parse_contains_matcher<'i>(input: &mut Span<'i>) -> PResult<Option<NameMatcher>> {
fn parse_contains_matcher(input: &mut Span<'_>) -> PResult<Option<NameMatcher>> {
trace(
"parse_contains_matcher",
preceded('~', parse_matcher_text).map(|res: Option<String>| {
Expand All @@ -370,7 +370,7 @@ fn parse_contains_matcher<'i>(input: &mut Span<'i>) -> PResult<Option<NameMatche
.parse_next(input)
}

fn parse_equal_matcher<'i>(input: &mut Span<'i>) -> PResult<Option<NameMatcher>> {
fn parse_equal_matcher(input: &mut Span<'_>) -> PResult<Option<NameMatcher>> {
trace(
"parse_equal_matcher",
ws(
Expand All @@ -385,7 +385,7 @@ fn parse_equal_matcher<'i>(input: &mut Span<'i>) -> PResult<Option<NameMatcher>>
.parse_next(input)
}

fn parse_regex_inner<'i>(input: &mut Span<'i>) -> PResult<String> {
fn parse_regex_inner(input: &mut Span<'_>) -> PResult<String> {
trace("parse_regex_inner", |input: &mut _| {
enum Frag<'a> {
Literal(&'a str),
Expand Down Expand Up @@ -477,15 +477,15 @@ fn parse_regex<'i>(input: &mut Span<'i>) -> PResult<Option<NameMatcher>> {
.parse_next(input)
}

fn parse_regex_matcher<'i>(input: &mut Span<'i>) -> PResult<Option<NameMatcher>> {
fn parse_regex_matcher(input: &mut Span<'_>) -> PResult<Option<NameMatcher>> {
trace(
"parse_regex_matcher",
ws(delimited('/', parse_regex, silent_expect(ws('/')))),
)
.parse_next(input)
}

fn parse_glob_matcher<'i>(input: &mut Span<'i>) -> PResult<Option<NameMatcher>> {
fn parse_glob_matcher(input: &mut Span<'_>) -> PResult<Option<NameMatcher>> {
trace(
"parse_glob_matcher",
ws(preceded('#', glob::parse_glob(false))),
Expand Down Expand Up @@ -585,20 +585,20 @@ fn unary_set_def<'a>(
let start = i.location();
let res = set_matcher(default_matcher).parse_next(i)?;
let end = i.location();
let _ = recover_unexpected_comma.parse_next(i)?;
recover_unexpected_comma.parse_next(i)?;
let _ = expect_char(')', ParseSingleError::ExpectedCloseParenthesis).parse_next(i)?;
Ok(res.map(|matcher| make_set(matcher, (start, end - start).into())))
}
}

fn platform_def<'i>(i: &mut Span<'i>) -> PResult<Option<SetDef>> {
fn platform_def(i: &mut Span<'_>) -> PResult<Option<SetDef>> {
let _ = "platform".parse_next(i)?;
let _ = expect_char('(', ParseSingleError::ExpectedOpenParenthesis).parse_next(i)?;
let start = i.location();
// Try parsing the argument as a string for better error messages.
let res = ws(parse_matcher_text).parse_next(i)?;
let end = i.location();
let _ = recover_unexpected_comma.parse_next(i)?;
recover_unexpected_comma.parse_next(i)?;
let _ = expect_char(')', ParseSingleError::ExpectedCloseParenthesis).parse_next(i)?;

// The returned string will include leading and trailing whitespace.
Expand All @@ -620,7 +620,7 @@ fn platform_def<'i>(i: &mut Span<'i>) -> PResult<Option<SetDef>> {
Ok(platform.map(|platform| SetDef::Platform(platform, (start, end - start).into())))
}

fn parse_set_def<'i>(input: &mut Span<'i>) -> PResult<Option<SetDef>> {
fn parse_set_def(input: &mut Span<'_>) -> PResult<Option<SetDef>> {
trace(
"parse_set_def",
ws(alt((
Expand All @@ -646,7 +646,7 @@ fn expect_expr<'a, P: Parser<Span<'a>, ExprResult, Error>>(
expect(inner, ParseSingleError::ExpectedExpr).map(|res| res.unwrap_or(ExprResult::Error))
}

fn parse_parentheses_expr<'i>(input: &mut Span<'i>) -> PResult<ExprResult> {
fn parse_parentheses_expr(input: &mut Span<'_>) -> PResult<ExprResult> {
trace(
"parse_parentheses_expr",
delimited(
Expand All @@ -659,7 +659,7 @@ fn parse_parentheses_expr<'i>(input: &mut Span<'i>) -> PResult<ExprResult> {
.parse_next(input)
}

fn parse_basic_expr<'i>(input: &mut Span<'i>) -> PResult<ExprResult> {
fn parse_basic_expr(input: &mut Span<'_>) -> PResult<ExprResult> {
trace(
"parse_basic_expr",
ws(alt((
Expand Down Expand Up @@ -693,7 +693,7 @@ impl fmt::Display for NotOperator {
}
}

fn parse_expr_not<'i>(input: &mut Span<'i>) -> PResult<ExprResult> {
fn parse_expr_not(input: &mut Span<'_>) -> PResult<ExprResult> {
trace(
"parse_expr_not",
(
Expand Down Expand Up @@ -731,7 +731,7 @@ impl fmt::Display for OrOperator {
}
}

fn parse_expr<'i>(input: &mut Span<'i>) -> PResult<ExprResult> {
fn parse_expr(input: &mut Span<'_>) -> PResult<ExprResult> {
trace("parse_expr", |input: &mut _| {
// "or" binds less tightly than "and", so parse and within or.
let expr = expect_expr(parse_and_or_difference_expr).parse_next(input)?;
Expand Down Expand Up @@ -830,7 +830,7 @@ enum AndOrDifferenceOperator {
Difference(DifferenceOperator),
}

fn parse_and_or_difference_expr<'i>(input: &mut Span<'i>) -> PResult<ExprResult> {
fn parse_and_or_difference_expr(input: &mut Span<'_>) -> PResult<ExprResult> {
trace("parse_and_or_difference_expr", |input: &mut _| {
let expr = expect_expr(parse_basic_expr).parse_next(input)?;

Expand Down Expand Up @@ -956,7 +956,7 @@ mod tests {
(reported errors: {errors:?})"
)
});
if errors.len() > 0 {
if !errors.is_empty() {
panic!("for input {input}, parse_glob_matcher reported errors: {errors:?}");
}

Expand Down Expand Up @@ -1412,8 +1412,8 @@ mod tests {
assert_eq_both_ways(&expr, r"test(~a\,)");

// string parsing is compatible with possible future syntax
fn parse_future_syntax<'i>(
input: &mut Span<'i>,
fn parse_future_syntax(
input: &mut Span<'_>,
) -> PResult<(Option<NameMatcher>, Option<NameMatcher>)> {
let _ = "something".parse_next(input)?;
let _ = '('.parse_next(input)?;
Expand Down
12 changes: 6 additions & 6 deletions nextest-filtering/src/parsing/unicode_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use winnow::{
Parser,
};

fn parse_unicode<'i>(input: &mut Span<'i>) -> PResult<char> {
fn parse_unicode(input: &mut Span<'_>) -> PResult<char> {
trace("parse_unicode", |input: &mut _| {
let parse_hex = take_while(1..=6, |c: char| c.is_ascii_hexdigit());
let parse_delimited_hex = preceded('u', delimited('{', parse_hex, '}'));
Expand All @@ -23,7 +23,7 @@ fn parse_unicode<'i>(input: &mut Span<'i>) -> PResult<char> {
.parse_next(input)
}

fn parse_escaped_char<'i>(input: &mut Span<'i>) -> PResult<Option<char>> {
fn parse_escaped_char(input: &mut Span<'_>) -> PResult<Option<char>> {
trace("parse_escaped_char", |input: &mut _| {
let valid = alt((
parse_unicode,
Expand Down Expand Up @@ -73,10 +73,10 @@ impl fmt::Display for DisplayParsedString<'_> {
fn parse_literal<'i>(input: &mut Span<'i>) -> PResult<&'i str> {
trace("parse_literal", |input: &mut _| {
let not_quote_slash = take_till(1.., (',', ')', '\\'));
let res = not_quote_slash

not_quote_slash
.verify(|s: &str| !s.is_empty())
.parse_next(input);
res
.parse_next(input)
})
.parse_next(input)
}
Expand All @@ -101,7 +101,7 @@ fn parse_fragment<'i>(input: &mut Span<'i>) -> PResult<Option<StringFragment<'i>
/// Construct a string by consuming the input until the next unescaped ) or ,.
///
/// Returns None if the string isn't valid.
pub(super) fn parse_string<'i>(input: &mut Span<'i>) -> PResult<Option<String>> {
pub(super) fn parse_string(input: &mut Span<'_>) -> PResult<Option<String>> {
trace(
"parse_string",
fold_repeat(
Expand Down

0 comments on commit 822eaa3

Please sign in to comment.