Skip to content

Commit

Permalink
Fix clippy warning
Browse files Browse the repository at this point in the history
  • Loading branch information
la10736 committed Apr 9, 2024
1 parent f7b4b57 commit e0624fe
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 26 deletions.
1 change: 1 addition & 0 deletions rstest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::test_attr_in_doctest)]
//! This crate will help you to write simpler tests by leveraging a software testing concept called
//! [test fixtures](https://en.wikipedia.org/wiki/Test_fixture#Software). A fixture is something
//! that you can use in your tests to encapsulate a test's dependencies.
Expand Down
1 change: 1 addition & 0 deletions rstest_macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::test_attr_in_doctest)]
#![cfg_attr(use_proc_macro_diagnostic, feature(proc_macro_diagnostic))]
extern crate proc_macro;

Expand Down
4 changes: 2 additions & 2 deletions rstest_macros/src/parse/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ impl VisitMut for FixturesFunctionExtractor {
arg.attrs = remain;

let (pos, errors) = parse_attribute_args_just_once(extracted.iter(), "with");
self.1.extend(errors.into_iter());
self.1.extend(errors);
let (resolve, errors) = parse_attribute_args_just_once(extracted.iter(), "from");
self.1.extend(errors.into_iter());
self.1.extend(errors);
if pos.is_some() || resolve.is_some() {
self.0
.push(Fixture::new(name, resolve, pos.unwrap_or_default()))
Expand Down
33 changes: 16 additions & 17 deletions rstest_macros/src/parse/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,21 @@ impl FutureFunctionExtractor {
Err(self.errors.into())
}
}

fn compute_arguments_kind(arg: &syn::Attribute) -> Result<FutureArg, syn::Error> {
if matches!(arg.meta, syn::Meta::Path(_)) {
Ok(FutureArg::Define)
} else {
match arg.parse_args::<Option<Ident>>()? {
Some(awt) if awt == format_ident!("awt") => Ok(FutureArg::Await),
None => Ok(FutureArg::Define),
Some(invalid) => Err(syn::Error::new_spanned(
arg.parse_args::<Option<Ident>>()?.into_token_stream(),
format!("Invalid '{invalid}' #[future(...)] arg."),
)),
}
}
}
}

impl VisitMut for FutureFunctionExtractor {
Expand All @@ -118,23 +133,7 @@ impl VisitMut for FutureFunctionExtractor {
match extract_argument_attrs(
node,
|a| attr_is(a, "future"),
|arg, name| {
let kind = if matches!(arg.meta, syn::Meta::Path(_)) {
FutureArg::Define
} else {
match arg.parse_args::<Option<Ident>>()? {
Some(awt) if awt == format_ident!("awt") => FutureArg::Await,
None => FutureArg::Define,
Some(invalid) => {
return Err(syn::Error::new_spanned(
arg.parse_args::<Option<Ident>>()?.into_token_stream(),
format!("Invalid '{invalid}' #[future(...)] arg."),
));
}
}
};
Ok((arg, name.clone(), kind))
},
|arg, name| Self::compute_arguments_kind(&arg).map(|kind| (arg, name.clone(), kind)),
)
.collect::<Result<Vec<_>, _>>()
{
Expand Down
1 change: 0 additions & 1 deletion rstest_macros/src/parse/rstest/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ impl BaseDir for DefaultBaseDir {}

trait GlobResolver {
fn glob(&self, pattern: &str) -> Result<Vec<PathBuf>, String> {
let pattern = pattern;
let globs =
glob(pattern).map_err(|e| format!("glob failed for whole path `{pattern}` due {e}"))?;
globs
Expand Down
10 changes: 4 additions & 6 deletions rstest_macros/src/refident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,10 @@ pub trait RemoveMutability {

impl RemoveMutability for FnArg {
fn remove_mutability(&mut self) {
match self {
FnArg::Typed(PatType { pat, .. }) => match pat.as_mut() {
Pat::Ident(ident) => ident.mutability = None,
_ => {}
},
_ => {}
if let FnArg::Typed(PatType { pat, .. }) = self {
if let Pat::Ident(ident) = pat.as_mut() {
ident.mutability = None
}
};
}
}

0 comments on commit e0624fe

Please sign in to comment.