Avoid "whitelist"
Other terms are more inclusive and precise.
This commit is contained in:
parent
e59b08e62e
commit
62cf767a4a
55 changed files with 296 additions and 278 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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']
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,5 +6,5 @@
|
|||
#![plugin(issue_40001_plugin)] //~ WARNING compiler plugins are deprecated
|
||||
#![register_tool(plugin)]
|
||||
|
||||
#[plugin::whitelisted_attr]
|
||||
#[plugin::allowed_attr]
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue