From b26272ba3e9067197e0aff16ba2ce8780e0acb96 Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 19 Oct 2021 22:27:23 +0530 Subject: minor refactor --- bin/src/main.rs | 8 ++++---- lib/src/lints/legacy_let_syntax.rs | 7 +++---- lib/src/lints/manual_inherit.rs | 2 +- lib/src/lints/manual_inherit_from.rs | 2 +- vfs/src/lib.rs | 2 +- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/bin/src/main.rs b/bin/src/main.rs index a3f04d7..161dcab 100644 --- a/bin/src/main.rs +++ b/bin/src/main.rs @@ -21,14 +21,14 @@ fn _main() -> Result<(), StatixErr> { let vfs = lint_config.vfs()?; let (reports, errors): (Vec<_>, Vec<_>) = vfs.iter().map(lint::lint).partition(Result::is_ok); - let lint_results: Vec<_> = reports.into_iter().map(Result::unwrap).collect(); - let errors: Vec<_> = errors.into_iter().map(Result::unwrap_err).collect(); + let lint_results = reports.into_iter().map(Result::unwrap); + let errors = errors.into_iter().map(Result::unwrap_err); let mut stderr = io::stderr(); - lint_results.into_iter().for_each(|r| { + lint_results.for_each(|r| { stderr.write(&r, &vfs).unwrap(); }); - errors.into_iter().for_each(|e| { + errors.for_each(|e| { eprintln!("{}", e); }); } diff --git a/lib/src/lints/legacy_let_syntax.rs b/lib/src/lints/legacy_let_syntax.rs index c5588e2..2087e27 100644 --- a/lib/src/lints/legacy_let_syntax.rs +++ b/lib/src/lints/legacy_let_syntax.rs @@ -23,15 +23,14 @@ impl Rule for ManualInherit { if legacy_let .entries() - .find(|kv| matches!(kv.key(), Some(k) if key_is_ident(&k, "body"))) - .is_some(); + .any(|kv| matches!(kv.key(), Some(k) if key_is_ident(&k, "body"))); then { let inherits = legacy_let.inherits(); let entries = legacy_let.entries(); let attrset = make::attrset(inherits, entries, true); - let parenthesized = make::parenthesize(&attrset.node()); - let selected = make::select(parenthesized.node(), &make::ident("body").node()); + let parenthesized = make::parenthesize(attrset.node()); + let selected = make::select(parenthesized.node(), make::ident("body").node()); let at = node.text_range(); let message = "Prefer `rec` over undocumented `let` syntax"; diff --git a/lib/src/lints/manual_inherit.rs b/lib/src/lints/manual_inherit.rs index 3524dd3..69f032b 100644 --- a/lib/src/lints/manual_inherit.rs +++ b/lib/src/lints/manual_inherit.rs @@ -32,7 +32,7 @@ impl Rule for ManualInherit { then { let at = node.text_range(); let replacement = make::inherit_stmt(&[key]).node().clone(); - let message = format!("This assignment is better written with `inherit`"); + let message = "This assignment is better written with `inherit`"; Some(Self::report().suggest(at, message, Suggestion::new(at, replacement))) } else { None diff --git a/lib/src/lints/manual_inherit_from.rs b/lib/src/lints/manual_inherit_from.rs index d7a00b2..2bff5f8 100644 --- a/lib/src/lints/manual_inherit_from.rs +++ b/lib/src/lints/manual_inherit_from.rs @@ -37,7 +37,7 @@ impl Rule for ManualInherit { let set = value.set()?; make::inherit_from_stmt(set, &[key]).node().clone() }; - let message = format!("This assignment is better written with `inherit`"); + let message = "This assignment is better written with `inherit`"; Some(Self::report().suggest(at, message, Suggestion::new(at, replacement))) } else { None diff --git a/vfs/src/lib.rs b/vfs/src/lib.rs index f620ab9..98bd1c3 100644 --- a/vfs/src/lib.rs +++ b/vfs/src/lib.rs @@ -58,7 +58,7 @@ impl ReadOnlyVfs { let file_id = self.alloc_file_id(path); self.data.insert(file_id, contents.to_owned()); } - pub fn iter<'ρ>(&'ρ self) -> impl Iterator> { + pub fn iter(&self) -> impl Iterator { self.data.iter().map(move |(file_id, _)| VfsEntry { file_id: *file_id, file_path: self.file_path(*file_id), -- cgit v1.2.3