Avoid "whitelist"

Other terms are more inclusive and precise.
This commit is contained in:
Tamir Duberstein 2020-07-07 11:12:44 -04:00 committed by Tamir Duberstein
parent e59b08e62e
commit 62cf767a4a
No known key found for this signature in database
GPG key ID: 32E33EC15E1FEF3C
55 changed files with 296 additions and 278 deletions

View file

@ -52,7 +52,7 @@ impl CodegenBackend for TheBackend {
fn provide(&self, providers: &mut Providers) {
rustc_symbol_mangling::provide(providers);
providers.target_features_whitelist = |tcx, _cnum| {
providers.supported_target_features = |tcx, _cnum| {
Default::default() // Just a dummy
};
providers.is_reachable_non_generic = |_tcx, _defid| true;

View file

@ -5,7 +5,7 @@ from os.path import isfile, join
from subprocess import PIPE, Popen
# This is a whitelist of files which are stable crates or simply are not crates,
# This is n list of files which are stable crates or simply are not crates,
# we don't check for the instability of these crates as they're all stable!
STABLE_CRATES = ['std', 'alloc', 'core', 'proc_macro',
'rsbegin.o', 'rsend.o', 'dllcrt2.o', 'crt2.o', 'clang_rt']

View file

@ -21,19 +21,19 @@ use rustc_span::source_map;
#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
reg.lint_store.register_lints(&[&MISSING_WHITELISTED_ATTR]);
reg.lint_store.register_late_pass(|| box MissingWhitelistedAttrPass);
reg.lint_store.register_lints(&[&MISSING_ALLOWED_ATTR]);
reg.lint_store.register_late_pass(|| box MissingAllowedAttrPass);
}
declare_lint! {
MISSING_WHITELISTED_ATTR,
MISSING_ALLOWED_ATTR,
Deny,
"Checks for missing `whitelisted_attr` attribute"
"Checks for missing `allowed_attr` attribute"
}
declare_lint_pass!(MissingWhitelistedAttrPass => [MISSING_WHITELISTED_ATTR]);
declare_lint_pass!(MissingAllowedAttrPass => [MISSING_ALLOWED_ATTR]);
impl<'tcx> LateLintPass<'tcx> for MissingWhitelistedAttrPass {
impl<'tcx> LateLintPass<'tcx> for MissingAllowedAttrPass {
fn check_fn(
&mut self,
cx: &LateContext<'tcx>,
@ -48,10 +48,10 @@ impl<'tcx> LateLintPass<'tcx> for MissingWhitelistedAttrPass {
_ => cx.tcx.hir().expect_item(cx.tcx.hir().get_parent_item(id)),
};
let whitelisted = |attr| pprust::attribute_to_string(attr).contains("whitelisted_attr");
if !item.attrs.iter().any(whitelisted) {
cx.lint(MISSING_WHITELISTED_ATTR, |lint| {
lint.build("Missing 'whitelisted_attr' attribute").set_span(span).emit()
let allowed = |attr| pprust::attribute_to_string(attr).contains("allowed_attr");
if !item.attrs.iter().any(allowed) {
cx.lint(MISSING_ALLOWED_ATTR, |lint| {
lint.build("Missing 'allowed_attr' attribute").set_span(span).emit()
});
}
}

View file

@ -6,5 +6,5 @@
#![plugin(issue_40001_plugin)] //~ WARNING compiler plugins are deprecated
#![register_tool(plugin)]
#[plugin::whitelisted_attr]
#[plugin::allowed_attr]
fn main() {}

View file

@ -7,7 +7,7 @@ use std::arch::x86_64::{_mm256_setzero_ps, _mm_setzero_ps};
fn main() {
unsafe {
// Types must be in the whitelist for the register class
// Types must be listed in the register class.
asm!("{}", in(reg) 0i128);
//~^ ERROR type `i128` cannot be used with this register class

View file

@ -1,7 +1,7 @@
// edition:2018
// Tests that `meta` is whitelisted, even if the crate doesn't exist
// yet (i.e., it causes a different error than `not-whitelisted.rs`).
// Tests that `meta` is allowed, even if the crate doesn't exist
// yet (i.e., it causes a different error than `not-allowed.rs`).
use meta; //~ ERROR can't find crate for `meta`
fn main() {}

View file

@ -1,5 +1,5 @@
error[E0432]: unresolved import `alloc`
--> $DIR/not-whitelisted.rs:5:5
--> $DIR/not-allowed.rs:5:5
|
LL | use alloc;
| ^^^^^ no `alloc` external crate

View file

@ -20,7 +20,7 @@ fn main() {
assert!(cfg!(target_feature = "sse2"),
"SSE2 was not detected as available on an x86 platform");
}
// check a negative case too -- whitelisted on x86, but not enabled by default
// check a negative case too -- allowed on x86, but not enabled by default
assert!(cfg!(not(target_feature = "avx2")),
"AVX2 shouldn't be detected as available by default on any platform");
}