Skip to content

Commit cf91c54

Browse files
committed
Avoid "whitelist"
Other terms are more inclusive and precise.
1 parent c41fcad commit cf91c54

10 files changed

+20
-20
lines changed

clippy_lints/src/attrs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ declare_clippy_lint! {
7272
/// **What it does:** Checks for `extern crate` and `use` items annotated with
7373
/// lint attributes.
7474
///
75-
/// This lint whitelists `#[allow(unused_imports)]`, `#[allow(deprecated)]` and
75+
/// This lint permits `#[allow(unused_imports)]`, `#[allow(deprecated)]` and
7676
/// `#[allow(unreachable_pub)]` on `use` items and `#[allow(unused_imports)]` on
7777
/// `extern crate` items with a `#[macro_use]` attribute.
7878
///
@@ -294,7 +294,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
294294
if let Some(ident) = attr.ident() {
295295
match &*ident.as_str() {
296296
"allow" | "warn" | "deny" | "forbid" => {
297-
// whitelist `unused_imports`, `deprecated` and `unreachable_pub` for `use` items
297+
// permit `unused_imports`, `deprecated` and `unreachable_pub` for `use` items
298298
// and `unused_imports` for `extern crate` items with `macro_use`
299299
for lint in lint_list {
300300
match item.kind {

clippy_lints/src/eq_op.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ declare_clippy_lint! {
1616
/// **Known problems:** False negatives: We had some false positives regarding
1717
/// calls (notably [racer](https://github.com/phildawes/racer) had one instance
1818
/// of `x.pop() && x.pop()`), so we removed matching any function or method
19-
/// calls. We may introduce a whitelist of known pure functions in the future.
19+
/// calls. We may introduce a list of known pure functions in the future.
2020
///
2121
/// **Example:**
2222
/// ```rust

clippy_lints/src/needless_pass_by_value.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
100100

101101
// Allow `Borrow` or functions to be taken by value
102102
let borrow_trait = need!(get_trait_def_id(cx, &paths::BORROW_TRAIT));
103-
let whitelisted_traits = [
103+
let allowed_traits = [
104104
need!(cx.tcx.lang_items().fn_trait()),
105105
need!(cx.tcx.lang_items().fn_once_trait()),
106106
need!(cx.tcx.lang_items().fn_mut_trait()),
@@ -184,7 +184,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
184184
if !is_self(arg);
185185
if !ty.is_mutable_ptr();
186186
if !is_copy(cx, ty);
187-
if !whitelisted_traits.iter().any(|&t| implements_trait(cx, ty, t, &[]));
187+
if !allowed_traits.iter().any(|&t| implements_trait(cx, ty, t, &[]));
188188
if !implements_borrow_trait;
189189
if !all_borrowable_trait;
190190

clippy_lints/src/non_expressive_names.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ struct ExistingName {
7878
interned: SymbolStr,
7979
span: Span,
8080
len: usize,
81-
whitelist: &'static [&'static str],
81+
exemptions: &'static [&'static str],
8282
}
8383

8484
struct SimilarNamesLocalVisitor<'a, 'tcx> {
@@ -117,7 +117,7 @@ impl<'a, 'tcx> SimilarNamesLocalVisitor<'a, 'tcx> {
117117
// this list contains lists of names that are allowed to be similar
118118
// the assumption is that no name is ever contained in multiple lists.
119119
#[rustfmt::skip]
120-
const WHITELIST: &[&[&str]] = &[
120+
const ALLOWED_TO_BE_SIMILAR: &[&[&str]] = &[
121121
&["parsed", "parser"],
122122
&["lhs", "rhs"],
123123
&["tx", "rx"],
@@ -156,17 +156,17 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for SimilarNamesNameVisitor<'a, 'tcx, 'b> {
156156
}
157157

158158
#[must_use]
159-
fn get_whitelist(interned_name: &str) -> Option<&'static [&'static str]> {
160-
for &allow in WHITELIST {
161-
if whitelisted(interned_name, allow) {
162-
return Some(allow);
159+
fn get_exemptions(interned_name: &str) -> Option<&'static [&'static str]> {
160+
for &list in ALLOWED_TO_BE_SIMILAR {
161+
if allowed_to_be_similar(interned_name, list) {
162+
return Some(list);
163163
}
164164
}
165165
None
166166
}
167167

168168
#[must_use]
169-
fn whitelisted(interned_name: &str, list: &[&str]) -> bool {
169+
fn allowed_to_be_similar(interned_name: &str, list: &[&str]) -> bool {
170170
list.iter()
171171
.any(|&name| interned_name.starts_with(name) || interned_name.ends_with(name))
172172
}
@@ -212,7 +212,7 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
212212
return;
213213
}
214214
for existing_name in &self.0.names {
215-
if whitelisted(&interned_name, existing_name.whitelist) {
215+
if allowed_to_be_similar(&interned_name, existing_name.exemptions) {
216216
continue;
217217
}
218218
let mut split_at = None;
@@ -301,7 +301,7 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
301301
return;
302302
}
303303
self.0.names.push(ExistingName {
304-
whitelist: get_whitelist(&interned_name).unwrap_or(&[]),
304+
exemptions: get_exemptions(&interned_name).unwrap_or(&[]),
305305
interned: interned_name,
306306
span: ident.span,
307307
len: count,

clippy_lints/src/precedence.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_lint::{EarlyContext, EarlyLintPass};
55
use rustc_session::{declare_lint_pass, declare_tool_lint};
66
use rustc_span::source_map::Spanned;
77

8-
const ODD_FUNCTIONS_WHITELIST: [&str; 14] = [
8+
const ALLOWED_ODD_FUNCTIONS: [&str; 14] = [
99
"asin",
1010
"asinh",
1111
"atan",
@@ -109,7 +109,7 @@ impl EarlyLintPass for Precedence {
109109
if let ExprKind::Lit(ref lit) = slf.kind {
110110
match lit.kind {
111111
LitKind::Int(..) | LitKind::Float(..) => {
112-
if ODD_FUNCTIONS_WHITELIST
112+
if ALLOWED_ODD_FUNCTIONS
113113
.iter()
114114
.any(|odd_function| **odd_function == *path_segment_str)
115115
{

clippy_lints/src/types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ fn check_loss_of_sign(cx: &LateContext<'_>, expr: &Expr<'_>, op: &Expr<'_>, cast
12561256
// don't lint for the result of methods that always return non-negative values
12571257
if let ExprKind::MethodCall(ref path, _, _, _) = op.kind {
12581258
let mut method_name = path.ident.name.as_str();
1259-
let whitelisted_methods = ["abs", "checked_abs", "rem_euclid", "checked_rem_euclid"];
1259+
let allowed_methods = ["abs", "checked_abs", "rem_euclid", "checked_rem_euclid"];
12601260

12611261
if_chain! {
12621262
if method_name == "unwrap";
@@ -1267,7 +1267,7 @@ fn check_loss_of_sign(cx: &LateContext<'_>, expr: &Expr<'_>, op: &Expr<'_>, cast
12671267
}
12681268
}
12691269

1270-
if whitelisted_methods.iter().any(|&name| method_name == name) {
1270+
if allowed_methods.iter().any(|&name| method_name == name) {
12711271
return;
12721272
}
12731273
}

tests/ui/needless_pass_by_value.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ extern "C" fn ext(x: MaybeUninit<usize>) -> usize {
116116
unsafe { x.assume_init() }
117117
}
118118

119-
// whitelist RangeArgument
119+
// exempt RangeArgument
120120
fn range<T: ::std::ops::RangeBounds<usize>>(range: T) {
121121
let _ = range.start_bound();
122122
}

tests/ui/neg_cmp_op_on_partial_ord.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ fn main() {
5757
// The macro always negates the result of the given comparison in its
5858
// internal check which automatically triggered the lint. As it's an
5959
// external macro there was no chance to do anything about it which led
60-
// to a whitelisting of all external macros.
60+
// to an exempting of all external macros.
6161
assert!(a_value < another_value);
6262
}

0 commit comments

Comments
 (0)