Clippy fixes

This commit is contained in:
nora 2022-12-19 14:00:32 +01:00
parent e1fd83b4d9
commit 92826697a3
No known key found for this signature in database
6 changed files with 22 additions and 22 deletions

View file

@ -28,7 +28,7 @@ impl FileChange<'_, '_> {
pub fn write(&mut self, new: &str) -> Result<()> {
self.has_written_change = true;
fs::write(&self.path, new).with_context(|| format!("writing file {}", self.path.display()))
fs::write(self.path, new).with_context(|| format!("writing file {}", self.path.display()))
}
pub fn rollback(mut self) -> Result<()> {
@ -48,7 +48,7 @@ impl FileChange<'_, '_> {
impl Drop for FileChange<'_, '_> {
fn drop(&mut self) {
if self.has_written_change {
fs::write(&self.path, self.before_content()).ok();
fs::write(self.path, self.before_content()).ok();
if !std::thread::panicking() {
panic!("File contains unsaved changes!");
}

View file

@ -76,7 +76,7 @@ impl Minimizer {
passes: impl IntoIterator<Item = Box<dyn Processor + 'a>>,
) -> Result<()> {
let inital_build = self.build.build()?;
println!("Initial build: {}", inital_build);
println!("Initial build: {inital_build}");
inital_build.require_reproduction("Initial")?;
for mut pass in passes {
@ -106,7 +106,7 @@ impl Minimizer {
}
if !changes.had_changes() {
if !refresh_and_try_again && invalidated_files.len() > 0 {
if !refresh_and_try_again && !invalidated_files.is_empty() {
// A few files have been invalidated, let's refresh and try these again.
pass.refresh_state().context("refreshing state for pass")?;
invalidated_files.clear();

View file

@ -23,7 +23,7 @@ fn file_for_suggestion(suggestion: &Suggestion) -> &str {
impl Minimizer {
pub fn delete_dead_code(&mut self) -> Result<()> {
let inital_build = self.build.build()?;
println!("Before reaper: {}", inital_build);
println!("Before reaper: {inital_build}");
inital_build.require_reproduction("Initial")?;
@ -51,7 +51,7 @@ impl Minimizer {
Ok(())
}
fn apply_unused_imports<'a>(
fn apply_unused_imports(
&mut self,
suggestions: &HashMap<&str, Vec<&Suggestion>>,
) -> Result<()> {
@ -63,9 +63,9 @@ impl Minimizer {
continue;
};
let mut changes = &mut Changes::default();
let changes = &mut Changes::default();
let mut change = file.try_change(&mut changes)?;
let mut change = file.try_change(changes)?;
let desired_suggestions = suggestions
.iter()