Skip to content

Commit

Permalink
Apply clippy hints
Browse files Browse the repository at this point in the history
  • Loading branch information
la10736 committed Jul 4, 2023
1 parent 0a2bed0 commit 8c12f55
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
8 changes: 3 additions & 5 deletions rstest_macros/src/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,17 +630,15 @@ pub(crate) mod arguments {

#[derive(PartialEq, Debug, Clone, Copy)]
#[allow(dead_code)]
#[derive(Default)]
pub(crate) enum FutureArg {
#[default]
None,
Define,
Await,
}

impl Default for FutureArg {
fn default() -> Self {
FutureArg::None
}
}


#[derive(PartialEq, Default, Debug)]
pub(crate) struct ArgumentInfo {
Expand Down
22 changes: 9 additions & 13 deletions rstest_macros/src/parse/rstest/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl FilesGlobReferences {

trait RaiseError: ToTokens {
fn error(&self, msg: &str) -> syn::Error {
syn::Error::new_spanned(&self, msg)
syn::Error::new_spanned(self, msg)
}
}

Expand All @@ -62,15 +62,11 @@ impl FilesGlobReferences {
}

fn is_valid(&self, p: &RelativePath) -> bool {
if self.ignore_dot_files {
if p.components()
.into_iter()
.any(|c| c.as_str().starts_with('.'))
{
return false;
}
if self.ignore_dot_files && p.components()
.any(|c| c.as_str().starts_with('.')) {
return false;
}
!self.exclude.iter().any(|e| e.r.is_match(&p.to_string()))
!self.exclude.iter().any(|e| e.r.is_match(p.as_ref()))
}
}

Expand Down Expand Up @@ -213,13 +209,13 @@ impl VisitMut for ValueFilesExtractor {
let files = self.extract_files(node);
let excludes = self.extract_exclude(node);
let include_dot_files = self.extract_include_dot_files(node);
if include_dot_files.len() > 0 {
if !include_dot_files.is_empty() {
include_dot_files.iter().skip(1).for_each(|attr| {
self.errors
.push(attr.error("Cannot use #[include_dot_files] more than once"))
})
}
if files.len() > 0 {
if !files.is_empty() {
self.files.push((
name,
FilesGlobReferences::new(files, excludes, include_dot_files.is_empty()),
Expand Down Expand Up @@ -255,7 +251,7 @@ impl BaseDir for DefaultBaseDir {}

trait GlobResolver {
fn glob(&self, pattern: &str) -> Result<Vec<PathBuf>, String> {
let pattern = pattern.as_ref();
let pattern = pattern;
let globs =
glob(pattern).map_err(|e| format!("glob failed for whole path `{pattern}` due {e}"))?;
globs
Expand Down Expand Up @@ -322,7 +318,7 @@ impl<'a> ValueListFromFiles<'a> {
))
})?;
if !refs.is_valid(
&RelativePath::from_path(relative_path)
RelativePath::from_path(relative_path)
.map_err(|e| attr.error(&format!("Invalid glob path: {e}")))?,
) {
continue;
Expand Down
3 changes: 1 addition & 2 deletions rstest_macros/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ fn render_test_call(
) -> TokenStream {
let timeout = timeout.map(|x| quote! {#x}).or_else(|| {
std::env::var("RSTEST_TIMEOUT")
.ok()
.and_then(|to| Some(quote! { std::time::Duration::from_secs( (#to).parse().unwrap()) }))
.ok().map(|to| quote! { std::time::Duration::from_secs( (#to).parse().unwrap()) })
});
match (timeout, is_async) {
(Some(to_expr), true) => quote! {
Expand Down

0 comments on commit 8c12f55

Please sign in to comment.