Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: fix clippy::nonminimal_bool and clippy::ref_option issues #230

Merged
merged 3 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/wdk-build/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ clap = { workspace = true, features = ["derive"] }
clap-cargo.workspace = true
lazy_static.workspace = true
paste.workspace = true
rustversion.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
thiserror.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/wdk-build/src/cargo_make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ impl ParseCargoArgs for CompilationOptions {
);
}

configure_wdf_build_output_dir(target, &cargo_make_cargo_profile);
configure_wdf_build_output_dir(target.as_ref(), &cargo_make_cargo_profile);

if let Some(timings_option) = &timings {
timings_option.as_ref().map_or_else(
Expand Down Expand Up @@ -1007,7 +1007,7 @@ pub fn package_driver_flow_condition_script() -> anyhow::Result<()> {
})
}

fn configure_wdf_build_output_dir(target_arg: &Option<String>, cargo_make_cargo_profile: &str) {
fn configure_wdf_build_output_dir(target_arg: Option<&String>, cargo_make_cargo_profile: &str) {
let cargo_make_crate_custom_triple_target_directory =
env::var(CARGO_MAKE_CRATE_CUSTOM_TRIPLE_TARGET_DIRECTORY_ENV_VAR).unwrap_or_else(|_| {
panic!(
Expand Down
9 changes: 9 additions & 0 deletions crates/wdk-build/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,21 @@ pub fn detect_cpu_architecture_in_build_script() -> CpuArchitecture {

/// Validates that a given string matches the WDK version format (10.xxx.yyy.zzz
/// where xxx, yyy, and zzz are numeric and not necessarily 3 digits long).
#[rustversion::attr(
nightly,
allow(
clippy::nonminimal_bool,
reason = "is_some_or is not stable until 1.82.0 is released on 10/17/24"
)
)]
pub fn validate_wdk_version_format<S: AsRef<str>>(version_string: S) -> bool {
let version = version_string.as_ref();
let version_parts: Vec<&str> = version.split('.').collect();

// First, check if we have "10" as our first value
if !version_parts.first().is_some_and(|first| *first == "10") {
// FIXME: Once is_some_or is stabilized, replace the above with:
// if version_parts.first().is_none_or(|first| *first != "10") {
return false;
}

Expand Down
Loading