Skip to content

Commit 50a3f70

Browse files
chore: type CompilerFamilyLookupCache to preempt clippy::type_complexity
1 parent dfb5491 commit 50a3f70

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ use command_helpers::*;
254254

255255
mod tool;
256256
pub use tool::Tool;
257-
use tool::ToolFamily;
257+
use tool::{CompilerFamilyLookupCache, ToolFamily};
258258

259259
mod tempfile;
260260

@@ -277,7 +277,7 @@ struct BuildCache {
277277
env_cache: RwLock<HashMap<Box<str>, Env>>,
278278
apple_sdk_root_cache: RwLock<HashMap<Box<str>, Arc<OsStr>>>,
279279
apple_versions_cache: RwLock<HashMap<Box<str>, Arc<str>>>,
280-
cached_compiler_family: RwLock<HashMap<Box<Path>, ToolFamily>>,
280+
cached_compiler_family: RwLock<CompilerFamilyLookupCache>,
281281
known_flag_support_status_cache: RwLock<HashMap<CompilerFlag, bool>>,
282282
target_info_parser: target::TargetInfoParser,
283283
}

src/tool.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ use crate::{
1616
Error, ErrorKind, OutputKind,
1717
};
1818

19+
pub(crate) type CompilerFamilyLookupCache = HashMap<Box<Path>, ToolFamily>;
20+
1921
/// Configuration used to represent an invocation of a C compiler.
2022
///
2123
/// This can be used to figure out what compiler is in use, what the arguments
@@ -40,7 +42,7 @@ pub struct Tool {
4042
impl Tool {
4143
pub(crate) fn new(
4244
path: PathBuf,
43-
cached_compiler_family: &RwLock<HashMap<Box<Path>, ToolFamily>>,
45+
cached_compiler_family: &RwLock<CompilerFamilyLookupCache>,
4446
cargo_output: &CargoOutput,
4547
out_dir: Option<&Path>,
4648
) -> Self {
@@ -57,7 +59,7 @@ impl Tool {
5759
pub(crate) fn with_args(
5860
path: PathBuf,
5961
args: Vec<String>,
60-
cached_compiler_family: &RwLock<HashMap<Box<Path>, ToolFamily>>,
62+
cached_compiler_family: &RwLock<CompilerFamilyLookupCache>,
6163
cargo_output: &CargoOutput,
6264
out_dir: Option<&Path>,
6365
) -> Self {
@@ -90,7 +92,7 @@ impl Tool {
9092
path: PathBuf,
9193
args: Vec<String>,
9294
cuda: bool,
93-
cached_compiler_family: &RwLock<HashMap<Box<Path>, ToolFamily>>,
95+
cached_compiler_family: &RwLock<CompilerFamilyLookupCache>,
9496
cargo_output: &CargoOutput,
9597
out_dir: Option<&Path>,
9698
) -> Self {
@@ -238,7 +240,7 @@ impl Tool {
238240
Some(fname) if fname.contains("clang") => {
239241
let is_clang_cl = args
240242
.iter()
241-
.find_map(|a| a.strip_prefix("--driver-mode=") == Some("cl"))
243+
.any(|a| a.strip_prefix("--driver-mode=") == Some("cl"));
242244
if is_clang_cl {
243245
ToolFamily::Msvc { clang_cl: true }
244246
} else {

0 commit comments

Comments
 (0)