Skip to content

Commit

Permalink
chore: type CompilerFamilyLookupCache to preempt `clippy::type_comp…
Browse files Browse the repository at this point in the history
…lexity`
  • Loading branch information
ErichDonGubler committed Jan 31, 2025
1 parent dfb5491 commit 50a3f70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ use command_helpers::*;

mod tool;
pub use tool::Tool;
use tool::ToolFamily;
use tool::{CompilerFamilyLookupCache, ToolFamily};

mod tempfile;

Expand All @@ -277,7 +277,7 @@ struct BuildCache {
env_cache: RwLock<HashMap<Box<str>, Env>>,
apple_sdk_root_cache: RwLock<HashMap<Box<str>, Arc<OsStr>>>,
apple_versions_cache: RwLock<HashMap<Box<str>, Arc<str>>>,
cached_compiler_family: RwLock<HashMap<Box<Path>, ToolFamily>>,
cached_compiler_family: RwLock<CompilerFamilyLookupCache>,
known_flag_support_status_cache: RwLock<HashMap<CompilerFlag, bool>>,
target_info_parser: target::TargetInfoParser,
}
Expand Down
10 changes: 6 additions & 4 deletions src/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use crate::{
Error, ErrorKind, OutputKind,
};

pub(crate) type CompilerFamilyLookupCache = HashMap<Box<Path>, ToolFamily>;

/// Configuration used to represent an invocation of a C compiler.
///
/// This can be used to figure out what compiler is in use, what the arguments
Expand All @@ -40,7 +42,7 @@ pub struct Tool {
impl Tool {
pub(crate) fn new(
path: PathBuf,
cached_compiler_family: &RwLock<HashMap<Box<Path>, ToolFamily>>,
cached_compiler_family: &RwLock<CompilerFamilyLookupCache>,
cargo_output: &CargoOutput,
out_dir: Option<&Path>,
) -> Self {
Expand All @@ -57,7 +59,7 @@ impl Tool {
pub(crate) fn with_args(
path: PathBuf,
args: Vec<String>,
cached_compiler_family: &RwLock<HashMap<Box<Path>, ToolFamily>>,
cached_compiler_family: &RwLock<CompilerFamilyLookupCache>,
cargo_output: &CargoOutput,
out_dir: Option<&Path>,
) -> Self {
Expand Down Expand Up @@ -90,7 +92,7 @@ impl Tool {
path: PathBuf,
args: Vec<String>,
cuda: bool,
cached_compiler_family: &RwLock<HashMap<Box<Path>, ToolFamily>>,
cached_compiler_family: &RwLock<CompilerFamilyLookupCache>,
cargo_output: &CargoOutput,
out_dir: Option<&Path>,
) -> Self {
Expand Down Expand Up @@ -238,7 +240,7 @@ impl Tool {
Some(fname) if fname.contains("clang") => {
let is_clang_cl = args
.iter()
.find_map(|a| a.strip_prefix("--driver-mode=") == Some("cl"))
.any(|a| a.strip_prefix("--driver-mode=") == Some("cl"));
if is_clang_cl {
ToolFamily::Msvc { clang_cl: true }
} else {
Expand Down

0 comments on commit 50a3f70

Please sign in to comment.