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: Optimize code based on cargo clippy suggestions #1013

Merged
merged 1 commit into from
Mar 18, 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
15 changes: 6 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2060,14 +2060,11 @@ impl Build {
} else {
cmd.push_cc_arg(format!("--target={}", target).into());
}
} else {
if target.contains("i586") {
cmd.push_cc_arg("-arch:IA32".into());
} else if target.contains("arm64ec") {
cmd.push_cc_arg("-arm64EC".into());
}
} else if target.contains("i586") {
cmd.push_cc_arg("-arch:IA32".into());
} else if target.contains("arm64ec") {
cmd.push_cc_arg("-arm64EC".into());
}

// There is a check in corecrt.h that will generate a
// compilation error if
// _ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE is
Expand Down Expand Up @@ -3414,12 +3411,11 @@ impl Build {
})
})
.map(|prefix| *prefix)
.or_else(||
// If no toolchain was found, provide the first toolchain that was passed in.
// This toolchain has been shown not to exist, however it will appear in the
// error that is shown to the user which should make it easier to search for
// where it should be obtained.
prefixes.first().map(|prefix| *prefix))
.or_else(|| prefixes.first().map(|prefix| *prefix))
}

fn get_target(&self) -> Result<Arc<str>, Error> {
Expand Down Expand Up @@ -3753,6 +3749,7 @@ enum AppleOs {
WatchOs,
TvOs,
}

impl std::fmt::Debug for AppleOs {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Expand Down
6 changes: 2 additions & 4 deletions src/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,8 @@ impl Tool {
if chars.next() != Some('/') {
return false;
}
} else if self.is_like_gnu() || self.is_like_clang() {
if chars.next() != Some('-') {
return false;
}
} else if (self.is_like_gnu() || self.is_like_clang()) && chars.next() != Some('-') {
return false;
}

// Check for existing optimization flags (-O, /O)
Expand Down