Skip to content

Commit 1e8de34

Browse files
committed
fix: cargo clippy lint
1 parent 21f2b00 commit 1e8de34

File tree

6 files changed

+15
-19
lines changed

6 files changed

+15
-19
lines changed

src/command_helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl CargoOutput {
4646
warnings: true,
4747
output: OutputKind::Forward,
4848
debug: match std::env::var_os("CC_ENABLE_DEBUG_OUTPUT") {
49-
Some(v) => v != "0" && v != "false" && v != "",
49+
Some(v) => v != "0" && v != "false" && !v.is_empty(),
5050
None => false,
5151
},
5252
checked_dbg_var: Arc::new(AtomicBool::new(false)),

src/flags.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ impl<'this> RustcCodegenFlags<'this> {
185185
};
186186

187187
let clang_or_gnu =
188-
matches!(family, ToolFamily::Clang { .. }) || matches!(family, ToolFamily::Gnu { .. });
188+
matches!(family, ToolFamily::Clang { .. }) || matches!(family, ToolFamily::Gnu);
189189

190190
// Flags shared between clang and gnu
191191
if clang_or_gnu {
@@ -315,7 +315,7 @@ impl<'this> RustcCodegenFlags<'this> {
315315
}
316316
}
317317
}
318-
ToolFamily::Gnu { .. } => {}
318+
ToolFamily::Gnu => {}
319319
ToolFamily::Msvc { .. } => {
320320
// https://learn.microsoft.com/en-us/cpp/build/reference/guard-enable-control-flow-guard
321321
if let Some(value) = self.control_flow_guard {

src/lib.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,13 +1392,9 @@ impl Build {
13921392

13931393
fn get_canonical_library_names(name: &str) -> (&str, String, String) {
13941394
let lib_striped = name.strip_prefix("lib").unwrap_or(name);
1395-
let lib_name = if lib_striped.ends_with(".a") {
1396-
&lib_striped[..lib_striped.len() - 2]
1397-
} else if lib_striped.ends_with(".so") {
1398-
&lib_striped[..lib_striped.len() - 3]
1399-
} else {
1400-
lib_striped
1401-
};
1395+
let static_striped = lib_striped.strip_suffix(".a").unwrap_or(lib_striped);
1396+
let lib_name = lib_striped.strip_suffix(".so").unwrap_or(static_striped);
1397+
14021398
(
14031399
lib_name,
14041400
format!("lib{lib_name}.a"),

src/target/parser.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -477,13 +477,13 @@ mod tests {
477477
let (full_arch, _rest) = target.split_once('-').expect("target to have arch");
478478

479479
let mut target = TargetInfo {
480-
full_arch: full_arch.into(),
481-
arch: "invalid-none-set".into(),
482-
vendor: "invalid-none-set".into(),
483-
os: "invalid-none-set".into(),
484-
env: "invalid-none-set".into(),
480+
full_arch,
481+
arch: "invalid-none-set",
482+
vendor: "invalid-none-set",
483+
os: "invalid-none-set",
484+
env: "invalid-none-set",
485485
// Not set in older Rust versions
486-
abi: "".into(),
486+
abi: "",
487487
};
488488

489489
for cfg in cfgs.lines() {

tests/cc_env.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn clang_cl() {
117117
for exe_suffix in ["", ".exe"] {
118118
let test = Test::clang();
119119
let bin = format!("clang{exe_suffix}");
120-
env::set_var("CC", &format!("{bin} --driver-mode=cl"));
120+
env::set_var("CC", format!("{bin} --driver-mode=cl"));
121121
let test_compiler = |build: cc::Build| {
122122
let compiler = build.get_compiler();
123123
assert_eq!(compiler.path(), Path::new(&*bin));

tests/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,8 @@ fn gnu_apple_sysroot() {
532532
test.shim("fake-gcc")
533533
.gcc()
534534
.compiler("fake-gcc")
535-
.target(&target)
536-
.host(&target)
535+
.target(target)
536+
.host(target)
537537
.file("foo.c")
538538
.compile("foo");
539539

0 commit comments

Comments
 (0)