refactor: fix ptr_arg clippy warnings (&PathBuf→&Path, &Vec→&[T])

Reduced warnings from 86 to 74 (12 warnings fixed across 16 function signatures).

Changes:
- &PathBuf → &Path (14 signatures in cook_build, fetch, fs)
- &Vec<T> → &[T] (2 signatures in cook_build, web/html)
- &mut Vec<T> → &mut [T] (1 signature in recipe)
- Removed redundant to_path_buf() call exposed by signature change

All callers unaffected via deref coercion. Verification: cargo check ,
cargo test --lib  38/38, cargo clippy 74 remaining (70 result_large_err,
3 too_many_arguments, 1 if_same_then_else).
This commit is contained in:
2026-07-18 18:01:07 +09:00
parent e0533832af
commit 9762cb20b8
6 changed files with 20 additions and 20 deletions
+3 -3
View File
@@ -1069,7 +1069,7 @@ pub fn build(
Ok(BuildResult::new(stage_dirs, auto_deps))
}
pub fn remove_stage_dir(stage_dir: &PathBuf) -> crate::Result<()> {
pub fn remove_stage_dir(stage_dir: &Path) -> crate::Result<()> {
if stage_dir.is_dir() {
remove_all(stage_dir)?;
}
@@ -1114,7 +1114,7 @@ pub fn get_sub_target_dir(target_dir: &Path, sub_path: &str) -> PathBuf {
fn build_deps_dir(
logger: &PtyOut,
deps_dir: &PathBuf,
deps_dir: &Path,
dep_pkgars: &BTreeSet<(PackageName, PathBuf)>,
source_modified: SystemTime,
deps_modified: SystemTime,
@@ -1205,7 +1205,7 @@ fn build_deps_dir(
fn build_auto_deps(
recipe: &Recipe,
auto_deps_path: &Path,
stage_dirs: &Vec<PathBuf>,
stage_dirs: &[PathBuf],
cached: bool,
cook_config: &CookConfig,
mut dep_pkgars: BTreeSet<(PackageName, PathBuf)>,
+7 -7
View File
@@ -270,7 +270,7 @@ fn redbear_source_dir_is_effectively_empty(source_dir: &Path) -> bool {
fn redbear_ensure_offline_source(
recipe_dir: &Path,
source_dir: &PathBuf,
source_dir: &Path,
logger: &PtyOut,
) -> Result<()> {
if !source_dir.exists() || redbear_source_dir_is_effectively_empty(source_dir) {
@@ -281,7 +281,7 @@ fn redbear_ensure_offline_source(
fn redbear_ensure_offline_git_source(
recipe_dir: &Path,
source_dir: &PathBuf,
source_dir: &Path,
logger: &PtyOut,
) -> Result<()> {
let git_head = source_dir.join(".git/HEAD");
@@ -1089,11 +1089,11 @@ pub(crate) fn fetch_extract_tar(
}
pub(crate) fn fetch_cargo(
source_dir: &PathBuf,
source_dir: &Path,
cargopath: Option<&String>,
logger: &PtyOut,
) -> Result<()> {
let mut source_dir = source_dir.clone();
let mut source_dir = source_dir.to_path_buf();
if let Some(cargopath) = cargopath {
source_dir = source_dir.join(cargopath);
}
@@ -1232,8 +1232,8 @@ fn read_source_toml(source_toml: &Path) -> Result<pkg::Package> {
pub(crate) fn fetch_is_patches_newer(
recipe_dir: &Path,
patches: &Vec<String>,
source_dir: &PathBuf,
patches: &[String],
source_dir: &Path,
) -> Result<bool> {
// don't check source files inside as it can be mixed with user patches
let source_time = modified(source_dir)?;
@@ -1639,7 +1639,7 @@ fn fetch_write_patches_state(
script: &Option<String>,
logger: &PtyOut,
) -> Result<()> {
let head_rev = get_git_head_rev(&source_dir.to_path_buf())
let head_rev = get_git_head_rev(source_dir)
.map(|(r, _)| r)
.unwrap_or_else(|_| "unknown".to_string());
let hash = fetch_compute_patches_hash(recipe_dir, applied)
+7 -7
View File
@@ -308,7 +308,7 @@ pub fn serialize_and_write<T: Serialize>(file_path: &Path, content: &T) -> Resul
Ok(())
}
pub fn offline_check_exists(path: &PathBuf) -> Result<()> {
pub fn offline_check_exists(path: &Path) -> Result<()> {
if !path.exists() {
bail_other_err!(
"{path:?} is not exist and unable to continue in offline mode",
@@ -318,7 +318,7 @@ pub fn offline_check_exists(path: &PathBuf) -> Result<()> {
Ok(())
}
pub fn download_wget(url: &str, dest: &PathBuf, logger: &PtyOut) -> Result<()> {
pub fn download_wget(url: &str, dest: &Path, logger: &PtyOut) -> Result<()> {
if !dest.is_file() {
let dest_tmp = PathBuf::from(format!("{}.tmp", dest.display()));
let translated = translate_mirror(url);
@@ -346,7 +346,7 @@ pub fn read_to_string(path: &Path) -> Result<String> {
}
/// get commit rev and return if it's detached or not
pub fn get_git_head_rev(dir: &PathBuf) -> Result<(String, bool)> {
pub fn get_git_head_rev(dir: &Path) -> Result<(String, bool)> {
let git_head = dir.join(".git/HEAD");
let head_str = read_to_string(&git_head)?;
if let Some(stripped) = head_str.strip_prefix("ref: ") {
@@ -364,14 +364,14 @@ pub fn get_git_head_rev(dir: &PathBuf) -> Result<(String, bool)> {
}
/// get commit from "rev" which either a full commit hash or a tag name
pub fn get_git_tag_rev(dir: &PathBuf, tag: &str) -> Result<String> {
pub fn get_git_tag_rev(dir: &Path, tag: &str) -> Result<String> {
if tag.len() == 40 && tag.chars().all(|f| f.is_ascii_hexdigit()) {
return Ok(tag.to_string());
}
get_git_ref_entry(dir, &format!("refs/tags/{tag}"))
}
pub fn get_git_ref_entry(dir: &PathBuf, entry: &str) -> Result<String> {
pub fn get_git_ref_entry(dir: &Path, entry: &str) -> Result<String> {
// https://git-scm.com/book/en/v2/Git-Internals-Maintenance-and-Data-Recovery
let git_refs = dir.join(".git/packed-refs");
let refs_str = read_to_string(&git_refs)?;
@@ -394,7 +394,7 @@ pub fn get_git_ref_entry(dir: &PathBuf, entry: &str) -> Result<String> {
}
/// get commit rev after fetch
pub fn get_git_fetch_rev(dir: &PathBuf, remote_url: &str, remote_branch: &str) -> Result<String> {
pub fn get_git_fetch_rev(dir: &Path, remote_url: &str, remote_branch: &str) -> Result<String> {
let git_fetch_head = dir.join(".git/FETCH_HEAD");
let fetch_head_content = read_to_string(&git_fetch_head)?;
@@ -420,7 +420,7 @@ pub fn get_git_fetch_rev(dir: &PathBuf, remote_url: &str, remote_branch: &str) -
/// (local_branch_name, remote_branch, remote_name, remote_url)
/// -> ("fix_stuff", "master", "origin", "https://gitlab.redox-os.org/willnode/redox")
pub fn get_git_remote_tracking(dir: &PathBuf) -> Result<(String, String, String, String)> {
pub fn get_git_remote_tracking(dir: &Path) -> Result<(String, String, String, String)> {
let git_head = dir.join(".git/HEAD");
let git_config = dir.join(".git/config");
+1 -1
View File
@@ -582,7 +582,7 @@ fn topological_sort(recipes: Vec<CookRecipe>) -> Result<Vec<CookRecipe>, Package
// TODO: Wrap these vectors in a struct
pub fn recipes_mark_as_deps(names: &[PackageName], packages: &mut Vec<CookRecipe>) {
pub fn recipes_mark_as_deps(names: &[PackageName], packages: &mut [CookRecipe]) {
for package in packages.iter_mut() {
package.is_deps = !names.contains(&package.name);
}
+1 -1
View File
@@ -103,7 +103,7 @@ pub fn generate_web(all_packages: &Vec<String>, config: &CliWebConfig) {
generate_html_pkg(
package,
recipe,
&dependents.into_iter().collect(),
&dependents.into_iter().collect::<Vec<_>>(),
&stage_files,
&html_path,
config,
+1 -1
View File
@@ -9,7 +9,7 @@ use std::{fs, path::Path};
pub fn generate_html_pkg(
package: &Package,
recipe: &CookRecipe,
dependents: &Vec<String>,
dependents: &[String],
stage_files: &Option<String>,
html_path: &Path,
config: &crate::web::CliWebConfig,