mirror of
https://github.com/Noratrieb/cargo-minimize.git
synced 2026-01-14 16:35:01 +01:00
clippy
This commit is contained in:
parent
d5f4d6e8ce
commit
d97dbd6a94
2 changed files with 11 additions and 11 deletions
18
src/build.rs
18
src/build.rs
|
|
@ -224,6 +224,13 @@ impl Build {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_diags(&self) -> Result<(Vec<Diagnostic>, Vec<rustfix::Suggestion>)> {
|
pub fn get_diags(&self) -> Result<(Vec<Diagnostic>, Vec<rustfix::Suggestion>)> {
|
||||||
|
fn grab_rustc_diags(output: &str) -> Result<Vec<Diagnostic>> {
|
||||||
|
serde_json::Deserializer::from_str(output)
|
||||||
|
.into_iter::<Diagnostic>()
|
||||||
|
.collect::<Result<_, _>>()
|
||||||
|
.map_err(Into::into)
|
||||||
|
}
|
||||||
|
|
||||||
let inner = &self.inner;
|
let inner = &self.inner;
|
||||||
|
|
||||||
fn grab_cargo_diags(output: &str) -> Result<Vec<Diagnostic>> {
|
fn grab_cargo_diags(output: &str) -> Result<Vec<Diagnostic>> {
|
||||||
|
|
@ -234,17 +241,10 @@ impl Build {
|
||||||
Ok(messages
|
Ok(messages
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|msg| msg.reason == "compiler-message")
|
.filter(|msg| msg.reason == "compiler-message")
|
||||||
.flat_map(|msg| msg.message)
|
.filter_map(|msg| msg.message)
|
||||||
.collect())
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn grab_rustc_diags(output: &str) -> Result<Vec<Diagnostic>> {
|
|
||||||
serde_json::Deserializer::from_str(&output)
|
|
||||||
.into_iter::<Diagnostic>()
|
|
||||||
.collect::<Result<_, _>>()
|
|
||||||
.map_err(Into::into)
|
|
||||||
}
|
|
||||||
|
|
||||||
let diags = match &inner.lint_mode {
|
let diags = match &inner.lint_mode {
|
||||||
BuildMode::Cargo { subcommand } => {
|
BuildMode::Cargo { subcommand } => {
|
||||||
let mut cmd = self.cmd("cargo");
|
let mut cmd = self.cmd("cargo");
|
||||||
|
|
@ -392,7 +392,7 @@ fn read_script_output<'a>(stdout: &'a str, stderr: &'a str) -> (&'a str, LintMod
|
||||||
is_marked_output(stdout)
|
is_marked_output(stdout)
|
||||||
.map(|mode| (stdout, mode))
|
.map(|mode| (stdout, mode))
|
||||||
.or(is_marked_output(stderr).map(|mode| (stderr, mode)))
|
.or(is_marked_output(stderr).map(|mode| (stderr, mode)))
|
||||||
.unwrap_or_else(|| (stdout, LintMode::Cargo))
|
.unwrap_or((stdout, LintMode::Cargo))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ impl Minimizer {
|
||||||
let desired_suggestions = suggestions
|
let desired_suggestions = suggestions
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|sugg| sugg.message.contains("unused import"))
|
.filter(|sugg| sugg.message.contains("unused import"))
|
||||||
.cloned()
|
.copied()
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
|
@ -300,7 +300,7 @@ impl VisitMut for FindUnusedFunction<'_> {
|
||||||
should_retain
|
should_retain
|
||||||
}
|
}
|
||||||
_ => true,
|
_ => true,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
syn::visit_mut::visit_item_mod_mut(self, module);
|
syn::visit_mut::visit_item_mod_mut(self, module);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue