X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Ftools%2Fclippy%2Fclippy_lints%2Fsrc%2Fnon_expressive_names.rs;h=7128fee9bcf5157c238e089486bdf75db299a080;hb=a8bb2458e1798891112e53b08fe72477fdb75070;hp=5f14fe97afefad36255744823e9fe5799ea680d5;hpb=278e26eaf6a2b8312aadb7b05d432182dae55ce4;p=rust.git diff --git a/src/tools/clippy/clippy_lints/src/non_expressive_names.rs b/src/tools/clippy/clippy_lints/src/non_expressive_names.rs index 5f14fe97afe..7128fee9bcf 100644 --- a/src/tools/clippy/clippy_lints/src/non_expressive_names.rs +++ b/src/tools/clippy/clippy_lints/src/non_expressive_names.rs @@ -78,7 +78,7 @@ struct ExistingName { interned: SymbolStr, span: Span, len: usize, - whitelist: &'static [&'static str], + exemptions: &'static [&'static str], } struct SimilarNamesLocalVisitor<'a, 'tcx> { @@ -117,7 +117,7 @@ fn check_single_char_names(&self) { // this list contains lists of names that are allowed to be similar // the assumption is that no name is ever contained in multiple lists. #[rustfmt::skip] -const WHITELIST: &[&[&str]] = &[ +const ALLOWED_TO_BE_SIMILAR: &[&[&str]] = &[ &["parsed", "parser"], &["lhs", "rhs"], &["tx", "rx"], @@ -156,17 +156,17 @@ fn visit_mac(&mut self, _mac: &MacCall) { } #[must_use] -fn get_whitelist(interned_name: &str) -> Option<&'static [&'static str]> { - for &allow in WHITELIST { - if whitelisted(interned_name, allow) { - return Some(allow); +fn get_exemptions(interned_name: &str) -> Option<&'static [&'static str]> { + for &list in ALLOWED_TO_BE_SIMILAR { + if allowed_to_be_similar(interned_name, list) { + return Some(list); } } None } #[must_use] -fn whitelisted(interned_name: &str, list: &[&str]) -> bool { +fn allowed_to_be_similar(interned_name: &str, list: &[&str]) -> bool { list.iter() .any(|&name| interned_name.starts_with(name) || interned_name.ends_with(name)) } @@ -212,7 +212,7 @@ fn check_ident(&mut self, ident: Ident) { return; } for existing_name in &self.0.names { - if whitelisted(&interned_name, existing_name.whitelist) { + if allowed_to_be_similar(&interned_name, existing_name.exemptions) { continue; } let mut split_at = None; @@ -301,7 +301,7 @@ fn check_ident(&mut self, ident: Ident) { return; } self.0.names.push(ExistingName { - whitelist: get_whitelist(&interned_name).unwrap_or(&[]), + exemptions: get_exemptions(&interned_name).unwrap_or(&[]), interned: interned_name, span: ident.span, len: count,