Handfix dogfood issues with the rustfmt changes
diff --git a/clippy_lints/src/lifetimes.rs b/clippy_lints/src/lifetimes.rs
index dd721db..21b8bf6 100644
--- a/clippy_lints/src/lifetimes.rs
+++ b/clippy_lints/src/lifetimes.rs
@@ -192,10 +192,10 @@
// no output lifetimes, check distinctness of input lifetimes
// only unnamed and static, ok
- if input_lts.iter().all(|lt| {
+ let unnamed_and_static = input_lts.iter().all(|lt| {
*lt == RefLt::Unnamed || *lt == RefLt::Static
- })
- {
+ });
+ if unnamed_and_static {
return false;
}
// we have no output reference, so we only need all distinct lifetimes
diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs
index 17b3ad4..8f62494 100644
--- a/clippy_lints/src/missing_doc.rs
+++ b/clippy_lints/src/missing_doc.rs
@@ -21,6 +21,7 @@
//
//
//
+//
// rs#L246
//
diff --git a/clippy_lints/src/non_expressive_names.rs b/clippy_lints/src/non_expressive_names.rs
index fa915e8..a28dc42 100644
--- a/clippy_lints/src/non_expressive_names.rs
+++ b/clippy_lints/src/non_expressive_names.rs
@@ -104,26 +104,7 @@
}
fn whitelisted(interned_name: &str, list: &[&str]) -> bool {
- if list.iter().any(|&name| interned_name == name) {
- return true;
- }
- for name in list {
- // name_*
- if interned_name.chars().zip(name.chars()).all(|(l, r)| l == r) {
- return true;
- }
- // *_name
- if interned_name.chars().rev().zip(name.chars().rev()).all(
- |(l,
- r)| {
- l == r
- },
- )
- {
- return true;
- }
- }
- false
+ list.iter().any(|&name| interned_name.starts_with(name) || interned_name.ends_with(name))
}
impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
@@ -180,19 +161,19 @@
let first_e = existing_chars.next().expect(
"we know we have at least one char",
);
- let eq_or_numeric = |a: char, b: char| a == b || a.is_numeric() && b.is_numeric();
+ let eq_or_numeric = |(a, b): (char, char)| a == b || a.is_numeric() && b.is_numeric();
- if eq_or_numeric(first_i, first_e) {
+ if eq_or_numeric((first_i, first_e)) {
let last_i = interned_chars.next_back().expect(
"we know we have at least two chars",
);
let last_e = existing_chars.next_back().expect(
"we know we have at least two chars",
);
- if eq_or_numeric(last_i, last_e) {
+ if eq_or_numeric((last_i, last_e)) {
if interned_chars
.zip(existing_chars)
- .filter(|&(i, e)| !eq_or_numeric(i, e))
+ .filter(|&ie| !eq_or_numeric(ie))
.count() != 1
{
continue;
@@ -204,10 +185,8 @@
let second_last_e = existing_chars.next_back().expect(
"we know we have at least three chars",
);
- if !eq_or_numeric(second_last_i, second_last_e) || second_last_i == '_' ||
- !interned_chars.zip(existing_chars).all(|(i, e)| {
- eq_or_numeric(i, e)
- })
+ if !eq_or_numeric((second_last_i, second_last_e)) || second_last_i == '_' ||
+ !interned_chars.zip(existing_chars).all(eq_or_numeric)
{
// allowed similarity foo_x, foo_y
// or too many chars differ (foo_x, boo_y) or (foox, booy)
@@ -222,10 +201,8 @@
let second_e = existing_chars.next().expect(
"we know we have at least two chars",
);
- if !eq_or_numeric(second_i, second_e) || second_i == '_' ||
- !interned_chars.zip(existing_chars).all(|(i, e)| {
- eq_or_numeric(i, e)
- })
+ if !eq_or_numeric((second_i, second_e)) || second_i == '_' ||
+ !interned_chars.zip(existing_chars).all(eq_or_numeric)
{
// allowed similarity x_foo, y_foo
// or too many chars differ (x_foo, y_boo) or (xfoo, yboo)
diff --git a/src/lib.rs b/src/lib.rs
index a1e18ec..df692b7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -12,14 +12,13 @@
#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
if let Ok(lint_store) = reg.sess.lint_store.try_borrow() {
- if lint_store
- .get_lint_groups()
- .iter()
- .any(|&(s, _, _)| s == "clippy") {
- reg.sess
- .struct_warn("running cargo clippy on a crate that also imports the clippy plugin")
- .emit();
- return;
+ for (lint, _, _) in lint_store.get_lint_groups() {
+ if lint == "clippy" {
+ reg.sess
+ .struct_warn("running cargo clippy on a crate that also imports the clippy plugin")
+ .emit();
+ return;
+ }
}
}