Skip to content

Commit

Permalink
refactor: Optimize code based on cargo clippy suggestions (#1013)
Browse files Browse the repository at this point in the history
Signed-off-by: InventiveCoder <liucongcong@outlook.com>
  • Loading branch information
InventiveCoder authored Mar 18, 2024
1 parent f36d6a7 commit 30c6b72
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
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

0 comments on commit 30c6b72

Please sign in to comment.