fixup! Update src/cargo/ops/cargo_clean.rs

This commit is contained in:
Piotr Osiewicz 2024-05-02 12:30:38 +02:00
parent a49a2b9584
commit 574d086cb3

View file

@ -254,11 +254,11 @@ fn clean_specs(
let paths = [
// Remove dep-info file generated by rustc. It is not tracked in
// file_types. It does not have a prefix.
(path_dash.clone(), ".d"),
(path_dash, ".d"),
// Remove split-debuginfo files generated by rustc.
(path_dot.clone(), ".o"),
(path_dot.clone(), ".dwo"),
(path_dot.clone(), ".dwp"),
(path_dot, ".o"),
(path_dot, ".dwo"),
(path_dot, ".dwp"),
];
clean_ctx.rm_rf_prefix_list(&dir_glob_str, &paths)?;
}
@ -347,14 +347,15 @@ impl<'gctx> CleanContext<'gctx> {
fn rm_rf_prefix_list(
&mut self,
pattern: &str,
path_matchers: &[(Rc<str>, &str)],
path_matchers: &[(&str, &str)],
) -> CargoResult<()> {
for path in glob::glob(pattern)? {
let path = path?;
let filename = path.file_name().and_then(|name| name.to_str()).unwrap();
if path_matchers.iter().any(|(prefix, suffix)| {
filename.starts_with(&**prefix) && filename.ends_with(suffix)
}) {
if path_matchers
.iter()
.any(|(prefix, suffix)| filename.starts_with(prefix) && filename.ends_with(suffix))
{
self.rm_rf(&path)?;
}
}