mirror of
https://github.com/Noratrieb/cargo-minimize.git
synced 2026-01-15 00:45:02 +01:00
more tests
This commit is contained in:
parent
75108c8553
commit
4f4afa627d
7 changed files with 69 additions and 24 deletions
|
|
@ -1,10 +1,11 @@
|
|||
use anyhow::{Context, Result};
|
||||
use std::{
|
||||
fmt::Debug,
|
||||
fs,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
|
||||
#[derive(PartialEq, Eq, Clone, Hash)]
|
||||
pub(crate) struct SourceFile {
|
||||
pub(crate) path: PathBuf,
|
||||
}
|
||||
|
|
@ -77,3 +78,9 @@ impl Changes {
|
|||
self.any_change
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for SourceFile {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
<Path as Debug>::fmt(&self.path, f)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ impl Minimizer {
|
|||
}
|
||||
}
|
||||
|
||||
#[instrument(skip(self, pass, invalidated_files, changes), fields(pass = %pass.name()), level = "debug")]
|
||||
fn process_file<'file>(
|
||||
&self,
|
||||
pass: &mut dyn Processor,
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ impl Minimizer {
|
|||
.get_diags()
|
||||
.context("getting suggestions from rustc")?;
|
||||
|
||||
debug!(?diags, "Got diagnostics");
|
||||
|
||||
let mut suggestions_for_file = HashMap::<_, Vec<_>>::new();
|
||||
for suggestion in &suggestions {
|
||||
suggestions_for_file
|
||||
|
|
@ -197,7 +199,8 @@ impl<'a> FindUnusedFunction<'a> {
|
|||
"encountered multiline span in dead_code"
|
||||
);
|
||||
|
||||
if Path::new(&span.file_name) != file.path {
|
||||
// When the project directory is remapped, the path may be absolute or generally have some prefix.
|
||||
if !file.path.ends_with(&span.file_name) {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue