Handfix dogfood issues with the rustfmt changes
This commit is contained in:
parent
b25b6b3355
commit
0e4c49b145
4 changed files with 20 additions and 43 deletions
|
@ -192,10 +192,10 @@ fn could_use_elision<'a, 'tcx: 'a>(
|
||||||
// no output lifetimes, check distinctness of input lifetimes
|
// no output lifetimes, check distinctness of input lifetimes
|
||||||
|
|
||||||
// only unnamed and static, ok
|
// 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
|
*lt == RefLt::Unnamed || *lt == RefLt::Static
|
||||||
})
|
});
|
||||||
{
|
if unnamed_and_static {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// we have no output reference, so we only need all distinct lifetimes
|
// we have no output reference, so we only need all distinct lifetimes
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
//
|
||||||
// rs#L246
|
// rs#L246
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
|
@ -104,26 +104,7 @@ fn get_whitelist(interned_name: &str) -> Option<&'static [&'static str]> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn whitelisted(interned_name: &str, list: &[&str]) -> bool {
|
fn whitelisted(interned_name: &str, list: &[&str]) -> bool {
|
||||||
if list.iter().any(|&name| interned_name == name) {
|
list.iter().any(|&name| interned_name.starts_with(name) || interned_name.ends_with(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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
|
impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
|
||||||
|
@ -180,19 +161,19 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
|
||||||
let first_e = existing_chars.next().expect(
|
let first_e = existing_chars.next().expect(
|
||||||
"we know we have at least one char",
|
"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(
|
let last_i = interned_chars.next_back().expect(
|
||||||
"we know we have at least two chars",
|
"we know we have at least two chars",
|
||||||
);
|
);
|
||||||
let last_e = existing_chars.next_back().expect(
|
let last_e = existing_chars.next_back().expect(
|
||||||
"we know we have at least two chars",
|
"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
|
if interned_chars
|
||||||
.zip(existing_chars)
|
.zip(existing_chars)
|
||||||
.filter(|&(i, e)| !eq_or_numeric(i, e))
|
.filter(|&ie| !eq_or_numeric(ie))
|
||||||
.count() != 1
|
.count() != 1
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -204,10 +185,8 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
|
||||||
let second_last_e = existing_chars.next_back().expect(
|
let second_last_e = existing_chars.next_back().expect(
|
||||||
"we know we have at least three chars",
|
"we know we have at least three chars",
|
||||||
);
|
);
|
||||||
if !eq_or_numeric(second_last_i, second_last_e) || second_last_i == '_' ||
|
if !eq_or_numeric((second_last_i, second_last_e)) || second_last_i == '_' ||
|
||||||
!interned_chars.zip(existing_chars).all(|(i, e)| {
|
!interned_chars.zip(existing_chars).all(eq_or_numeric)
|
||||||
eq_or_numeric(i, e)
|
|
||||||
})
|
|
||||||
{
|
{
|
||||||
// allowed similarity foo_x, foo_y
|
// allowed similarity foo_x, foo_y
|
||||||
// or too many chars differ (foo_x, boo_y) or (foox, booy)
|
// or too many chars differ (foo_x, boo_y) or (foox, booy)
|
||||||
|
@ -222,10 +201,8 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
|
||||||
let second_e = existing_chars.next().expect(
|
let second_e = existing_chars.next().expect(
|
||||||
"we know we have at least two chars",
|
"we know we have at least two chars",
|
||||||
);
|
);
|
||||||
if !eq_or_numeric(second_i, second_e) || second_i == '_' ||
|
if !eq_or_numeric((second_i, second_e)) || second_i == '_' ||
|
||||||
!interned_chars.zip(existing_chars).all(|(i, e)| {
|
!interned_chars.zip(existing_chars).all(eq_or_numeric)
|
||||||
eq_or_numeric(i, e)
|
|
||||||
})
|
|
||||||
{
|
{
|
||||||
// allowed similarity x_foo, y_foo
|
// allowed similarity x_foo, y_foo
|
||||||
// or too many chars differ (x_foo, y_boo) or (xfoo, yboo)
|
// or too many chars differ (x_foo, y_boo) or (xfoo, yboo)
|
||||||
|
|
15
src/lib.rs
15
src/lib.rs
|
@ -12,14 +12,13 @@ extern crate clippy_lints;
|
||||||
#[plugin_registrar]
|
#[plugin_registrar]
|
||||||
pub fn plugin_registrar(reg: &mut Registry) {
|
pub fn plugin_registrar(reg: &mut Registry) {
|
||||||
if let Ok(lint_store) = reg.sess.lint_store.try_borrow() {
|
if let Ok(lint_store) = reg.sess.lint_store.try_borrow() {
|
||||||
if lint_store
|
for (lint, _, _) in lint_store.get_lint_groups() {
|
||||||
.get_lint_groups()
|
if lint == "clippy" {
|
||||||
.iter()
|
reg.sess
|
||||||
.any(|&(s, _, _)| s == "clippy") {
|
.struct_warn("running cargo clippy on a crate that also imports the clippy plugin")
|
||||||
reg.sess
|
.emit();
|
||||||
.struct_warn("running cargo clippy on a crate that also imports the clippy plugin")
|
return;
|
||||||
.emit();
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue