Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
la10736 committed Mar 2, 2025
1 parent f570b06 commit eb1f228
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 36 deletions.
55 changes: 25 additions & 30 deletions rstest_macros/src/parse/rstest/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ pub(crate) mod files_mode_keywords {

impl Parse for FilesMode {
fn parse(input: syn::parse::ParseStream) -> syn::Result<Self> {
if let Some(_) = Option::<files_mode_keywords::path>::parse(input)? {
if Option::<files_mode_keywords::path>::parse(input)?.is_some() {
Ok(Self::Path)
} else if let Some(_) = Option::<files_mode_keywords::str>::parse(input)? {
} else if Option::<files_mode_keywords::str>::parse(input)?.is_some() {
Ok(Self::IncludeStr)
} else if let Some(_) = Option::<files_mode_keywords::bytes>::parse(input)? {
} else if Option::<files_mode_keywords::bytes>::parse(input)?.is_some() {
Ok(Self::IncludeBytes)
} else {
Err(input.error("Expected one of the following keywords: path, str or bytes"))
Expand Down Expand Up @@ -377,15 +377,15 @@ impl ValueFilesExtractor {
node,
|a| attr_is(a, "mode"),
|attr| {
attr.meta.require_name_value() .map_err(|_| {
attr.error(
"Use #[mode = ...] to define the argument of the file input",
)
}).and_then(|attr| {
syn::parse2(
attr.value.to_token_stream()
).map(|file_mode| (attr.clone(), file_mode))
})
attr.meta
.require_name_value()
.map_err(|_| {
attr.error("Use #[mode = ...] to define the argument of the file input")
})
.and_then(|attr| {
syn::parse2(attr.value.to_token_stream())
.map(|file_mode| (attr.clone(), file_mode))
})
},
)
}
Expand Down Expand Up @@ -424,11 +424,10 @@ impl VisitMut for ValueFilesExtractor {
let mode_attr = self.extract_mode(node);
let mode = if let Some(value) = mode_attr.first() {
mode_attr.iter().skip(1).for_each(|attr| {
self.errors
.push(syn::Error::new_spanned(
&attr.0,
r#"Cannot use #[mode = ...] more than once"#
))
self.errors.push(syn::Error::new_spanned(
&attr.0,
r#"Cannot use #[mode = ...] more than once"#,
))
});
value.1
} else {
Expand Down Expand Up @@ -600,10 +599,7 @@ impl ValueListFromFiles<'_> {
include_bytes!(#path_str)
},
};
values.push((
value,
render_file_description(&relative_path),
));
values.push((value, render_file_description(&relative_path)));
}

if values.is_empty() {
Expand Down Expand Up @@ -989,7 +985,7 @@ mod should {
exclude,
ignore_dot_files,
false,
Default::default()
Default::default(),
),
)])
.unwrap();
Expand Down Expand Up @@ -1109,14 +1105,13 @@ mod should {
.map(|(k, v)| (k.to_string(), v.to_string()))
.collect(),
);
let refs =
FilesGlobReferences::new(
vec![],
Default::default(),
true,
ignore_missing_env_vars,
Default::default()
);
let refs = FilesGlobReferences::new(
vec![],
Default::default(),
true,
ignore_missing_env_vars,
Default::default(),
);

let result = refs.replace_env_vars(&files_attr(glob), resolver);
match (&result, expected) {
Expand Down
10 changes: 4 additions & 6 deletions rstest_test/src/prj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,11 @@ impl Project {
let rand_name_part: u64 = rand::rng().random();
temp_path.set_file_name(format!("Cargo_{rand_name_part:021}.toml"));
File::create(&temp_path)
.expect(&format!("cannot create {}", temp_path.display()))
.unwrap_or_else(|_| panic!("cannot create {}", temp_path.display()))
.write_all(doc.to_string().as_bytes())
.expect(&format!("cannot write {}", temp_path.display()));
std::fs::rename(&temp_path, path).expect(&format!(
"cannot rename {} -> Cargo.toml",
temp_path.display()
));
.unwrap_or_else(|_| panic!("cannot write {}", temp_path.display()));
std::fs::rename(&temp_path, path)
.unwrap_or_else(|_| panic!("cannot rename {} -> Cargo.toml", temp_path.display()));
}

fn cargo_channel_arg(&self) -> Option<String> {
Expand Down

0 comments on commit eb1f228

Please sign in to comment.