Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: cargo clippy lint
  • Loading branch information
westhide committed Mar 30, 2025
commit 1e8de34a45c0992a6f6b51e85a6fdf8ca07b9544
2 changes: 1 addition & 1 deletion src/command_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl CargoOutput {
warnings: true,
output: OutputKind::Forward,
debug: match std::env::var_os("CC_ENABLE_DEBUG_OUTPUT") {
Some(v) => v != "0" && v != "false" && v != "",
Some(v) => v != "0" && v != "false" && !v.is_empty(),
None => false,
},
checked_dbg_var: Arc::new(AtomicBool::new(false)),
Expand Down
4 changes: 2 additions & 2 deletions src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl<'this> RustcCodegenFlags<'this> {
};

let clang_or_gnu =
matches!(family, ToolFamily::Clang { .. }) || matches!(family, ToolFamily::Gnu { .. });
matches!(family, ToolFamily::Clang { .. }) || matches!(family, ToolFamily::Gnu);

// Flags shared between clang and gnu
if clang_or_gnu {
Expand Down Expand Up @@ -315,7 +315,7 @@ impl<'this> RustcCodegenFlags<'this> {
}
}
}
ToolFamily::Gnu { .. } => {}
ToolFamily::Gnu => {}
ToolFamily::Msvc { .. } => {
// https://learn.microsoft.com/en-us/cpp/build/reference/guard-enable-control-flow-guard
if let Some(value) = self.control_flow_guard {
Expand Down
10 changes: 3 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1392,13 +1392,9 @@ impl Build {

fn get_canonical_library_names(name: &str) -> (&str, String, String) {
let lib_striped = name.strip_prefix("lib").unwrap_or(name);
let lib_name = if lib_striped.ends_with(".a") {
&lib_striped[..lib_striped.len() - 2]
} else if lib_striped.ends_with(".so") {
&lib_striped[..lib_striped.len() - 3]
} else {
lib_striped
};
let static_striped = lib_striped.strip_suffix(".a").unwrap_or(lib_striped);
let lib_name = lib_striped.strip_suffix(".so").unwrap_or(static_striped);

(
lib_name,
format!("lib{lib_name}.a"),
Expand Down
12 changes: 6 additions & 6 deletions src/target/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,13 +477,13 @@ mod tests {
let (full_arch, _rest) = target.split_once('-').expect("target to have arch");

let mut target = TargetInfo {
full_arch: full_arch.into(),
arch: "invalid-none-set".into(),
vendor: "invalid-none-set".into(),
os: "invalid-none-set".into(),
env: "invalid-none-set".into(),
full_arch,
arch: "invalid-none-set",
vendor: "invalid-none-set",
os: "invalid-none-set",
env: "invalid-none-set",
// Not set in older Rust versions
abi: "".into(),
abi: "",
};

for cfg in cfgs.lines() {
Expand Down
2 changes: 1 addition & 1 deletion tests/cc_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ fn clang_cl() {
for exe_suffix in ["", ".exe"] {
let test = Test::clang();
let bin = format!("clang{exe_suffix}");
env::set_var("CC", &format!("{bin} --driver-mode=cl"));
env::set_var("CC", format!("{bin} --driver-mode=cl"));
let test_compiler = |build: cc::Build| {
let compiler = build.get_compiler();
assert_eq!(compiler.path(), Path::new(&*bin));
Expand Down
4 changes: 2 additions & 2 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,8 @@ fn gnu_apple_sysroot() {
test.shim("fake-gcc")
.gcc()
.compiler("fake-gcc")
.target(&target)
.host(&target)
.target(target)
.host(target)
.file("foo.c")
.compile("foo");

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation on compile should also be updated to reflect the new renaming rules.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we actually want to support shared libraries, we should consider a .linker and .get_linker similar to .archiver and .get_archiver, as well as maybe allowing overriding the linker with an LD env var (?)

Though if we allow using a raw linker (e.g. invoke rust-lld binary instead of cc), we're getting into hairy territory of needing to know how to invoke the linker if it's not a compiler driver.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Which again is why I'm really not in favour of it).

Expand Down