From d5eca75690f690e075b7bdeafecd9a8450d98e97 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Tue, 27 Jun 2023 00:36:40 -0700 Subject: [PATCH] Clippy --- src/loader.rs | 20 +++++++------------- src/summary.rs | 9 +++++---- tests/test.rs | 2 -- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/loader.rs b/src/loader.rs index 038b509122..a172ee5a22 100644 --- a/src/loader.rs +++ b/src/loader.rs @@ -14,7 +14,7 @@ impl Loader { } } - pub(crate) fn load_and_compile<'src>(&'src self, path: &Path) -> RunResult { + pub(crate) fn load_and_compile(&self, path: &Path) -> RunResult { let root_src = self.load_and_alloc(path)?; let root_ast = Compiler::parse(root_src)?; let root_imports = Analyzer::get_imports(&root_ast); @@ -46,29 +46,23 @@ impl Loader { let mut imported_asts = vec![]; let mut seen: HashSet = HashSet::new(); - seen.insert(Self::canonicalize_path(&root_path, &root_path)?); + seen.insert(Self::canonicalize_path(root_path, root_path)?); let mut queue: VecDeque<(PathBuf, Vec)> = VecDeque::new(); queue.push_back((root_path.to_owned(), root_imports)); - loop { - let (cur_path, imports) = match queue.pop_front() { - Some(item) => item, - None => break, - }; - - for mut import in imports.into_iter() { + while let Some((cur_path, imports)) = queue.pop_front() { + for mut import in imports { let given_path = import.path(); - let canonical_path = Self::canonicalize_path(&given_path, &cur_path)?; + let canonical_path = Self::canonicalize_path(given_path, &cur_path)?; if seen.contains(&canonical_path) { return Err(Error::CircularInclude { - current: cur_path.to_owned(), + current: cur_path, include: canonical_path, }); - } else { - seen.insert(canonical_path.clone()); } + seen.insert(canonical_path.clone()); let src = self.load_and_alloc(&canonical_path)?; let ast = Compiler::parse(src)?; diff --git a/src/summary.rs b/src/summary.rs index bc7d6a200a..ebbe78ad90 100644 --- a/src/summary.rs +++ b/src/summary.rs @@ -31,9 +31,10 @@ pub fn summary(path: &Path) -> Result, io::Error> { match loader.load_and_compile(path) { Ok(compilation) => Ok(Ok(Summary::new(compilation.justfile()))), - Err(error) => Ok(Err(match error { - Error::Compile { compile_error } => compile_error.to_string(), - _ => format!("{:?}", error), + Err(error) => Ok(Err(if let Error::Compile { compile_error } = error { + compile_error.to_string() + } else { + format!("{error:?}") })), } } @@ -61,7 +62,7 @@ impl Summary { .iter() .map(|(name, recipe)| { ( - name.to_string(), + (*name).to_string(), Recipe::new(recipe, aliases.remove(name).unwrap_or_default()), ) }) diff --git a/tests/test.rs b/tests/test.rs index 58944f6255..e8dc786bb7 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -239,8 +239,6 @@ impl Test { } if let Some(ref stderr_regex) = self.stderr_regex { - println!("AAAA:\n{}", output_stderr); - println!("{:?}", stderr_regex); if !stderr_regex.is_match(output_stderr) { panic!("Stderr regex mismatch:\n{output_stderr:?}\n!~=\n/{stderr_regex:?}/"); }