diff --git a/src/non_expressive_names.rs b/src/non_expressive_names.rs index 32118b11c4e..36fcc292bfc 100644 --- a/src/non_expressive_names.rs +++ b/src/non_expressive_names.rs @@ -60,6 +60,8 @@ struct SimilarNamesLocalVisitor<'a, 'b: 'a> { const WHITELIST: &'static [&'static [&'static str]] = &[ &["parsed", "parser"], &["lhs", "rhs"], + &["tx", "rx"], + &["set", "get"], ]; struct SimilarNamesNameVisitor<'a, 'b: 'a, 'c: 'b>(&'a mut SimilarNamesLocalVisitor<'b, 'c>); @@ -88,13 +90,11 @@ fn whitelisted(interned_name: &str, list: &[&str]) -> bool { } for name in list { // name_* - let allow_start = name.chars().chain(Some('_')); - if interned_name.chars().zip(allow_start).all(|(l, r)| l == r) { + if interned_name.chars().zip(name.chars()).all(|(l, r)| l == r) { return true; } // *_name - let allow_end = Some('_').into_iter().chain(name.chars()); - if interned_name.chars().rev().zip(allow_end.rev()).all(|(l, r)| l == r) { + if interned_name.chars().rev().zip(name.chars().rev()).all(|(l, r)| l == r) { return true; } } diff --git a/tests/compile-fail/non_expressive_names.rs b/tests/compile-fail/non_expressive_names.rs index aab88f742a6..b756253e6ad 100644 --- a/tests/compile-fail/non_expressive_names.rs +++ b/tests/compile-fail/non_expressive_names.rs @@ -11,7 +11,6 @@ //~| NOTE: lint level defined here //~| NOTE: lint level defined here //~| NOTE: lint level defined here -//~| NOTE: lint level defined here #![allow(unused)] fn main() { @@ -45,9 +44,8 @@ fn main() { let bla_rhs: i32; let bla_lhs: i32; - let blubrhs: i32; //~ NOTE: existing binding defined here - let blublhs: i32; //~ ERROR: name is too similar - //~| HELP: for further information visit + let blubrhs: i32; + let blublhs: i32; let blubx: i32; //~ NOTE: existing binding defined here let bluby: i32; //~ ERROR: name is too similar @@ -83,6 +81,13 @@ fn main() { let parsee: i32; //~ ERROR: name is too similar //~| HELP: for further information visit //~| HELP: separate the discriminating character by an underscore like: `parse_e` + + let setter: i32; + let getter: i32; + let tx1: i32; + let rx1: i32; + let tx_cake: i32; + let rx_cake: i32; } #[derive(Clone, Debug)]