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

@ -439,8 +439,6 @@ impl Step for Std {
builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "rustdoc"); builder.cargo(compiler, Mode::Std, SourceType::InTree, target, "rustdoc");
compile::std_cargo(builder, target, compiler.stage, &mut cargo); compile::std_cargo(builder, target, compiler.stage, &mut cargo);
// Keep a whitelist so we do not build internal stdlib crates, these will be
// build by the rustc step later if enabled.
cargo.arg("-p").arg(package); cargo.arg("-p").arg(package);
// Create all crate output directories first to make sure rustdoc uses // Create all crate output directories first to make sure rustdoc uses
// relative links. // relative links.
@ -460,6 +458,10 @@ impl Step for Std {
builder.run(&mut cargo.into()); builder.run(&mut cargo.into());
}; };
// Only build the following crates. While we could just iterate over the
// folder structure, that would also build internal crates that we do
// not want to show in documentation. These crates will later be visited
// by the rustc step, so internal documentation will show them.
let krates = ["alloc", "core", "std", "proc_macro", "test"]; let krates = ["alloc", "core", "std", "proc_macro", "test"];
for krate in &krates { for krate in &krates {
run_cargo_rustdoc_for(krate); run_cargo_rustdoc_for(krate);

View File

@ -195,9 +195,9 @@ def main():
global MAILBOX global MAILBOX
tests = [os.path.splitext(f)[0] for f in glob('*.rs') tests = [os.path.splitext(f)[0] for f in glob('*.rs')
if not f.startswith('_')] if not f.startswith('_')]
whitelist = sys.argv[1:] listed = sys.argv[1:]
if whitelist: if listed:
tests = [test for test in tests if test in whitelist] tests = [test for test in tests if test in listed]
if not tests: if not tests:
print("Error: No tests to run") print("Error: No tests to run")
sys.exit(1) sys.exit(1)
@ -210,8 +210,6 @@ def main():
mailman.daemon = True mailman.daemon = True
mailman.start() mailman.start()
for test in tests: for test in tests:
if whitelist and test not in whitelist:
continue
run(test) run(test)
MAILBOX.put(None) MAILBOX.put(None)
mailman.join() mailman.join()

View File

@ -280,7 +280,7 @@ impl<'a, 'f: 'a> DerefMut for VaList<'a, 'f> {
// within a private module. Once RFC 2145 has been implemented look into // within a private module. Once RFC 2145 has been implemented look into
// improving this. // improving this.
mod sealed_trait { mod sealed_trait {
/// Trait which whitelists the allowed types to be used with [VaList::arg] /// Trait which permits the allowed types to be used with [VaList::arg].
/// ///
/// [VaList::arg]: ../struct.VaList.html#method.arg /// [VaList::arg]: ../struct.VaList.html#method.arg
#[unstable( #[unstable(

View File

@ -263,7 +263,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
// Windows we end up still needing the `uwtable` attribute even if the `-C // Windows we end up still needing the `uwtable` attribute even if the `-C
// panic=abort` flag is passed. // panic=abort` flag is passed.
// //
// You can also find more info on why Windows is whitelisted here in: // You can also find more info on why Windows always requires uwtables here:
// https://bugzilla.mozilla.org/show_bug.cgi?id=1302078 // https://bugzilla.mozilla.org/show_bug.cgi?id=1302078
if cx.sess().must_emit_unwind_tables() { if cx.sess().must_emit_unwind_tables() {
attributes::emit_uwtable(llfn, true); attributes::emit_uwtable(llfn, true);
@ -343,14 +343,14 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
} }
pub fn provide(providers: &mut Providers) { pub fn provide(providers: &mut Providers) {
providers.target_features_whitelist = |tcx, cnum| { providers.supported_target_features = |tcx, cnum| {
assert_eq!(cnum, LOCAL_CRATE); assert_eq!(cnum, LOCAL_CRATE);
if tcx.sess.opts.actually_rustdoc { if tcx.sess.opts.actually_rustdoc {
// rustdoc needs to be able to document functions that use all the features, so // rustdoc needs to be able to document functions that use all the features, so
// whitelist them all // provide them all.
llvm_util::all_known_features().map(|(a, b)| (a.to_string(), b)).collect() llvm_util::all_known_features().map(|(a, b)| (a.to_string(), b)).collect()
} else { } else {
llvm_util::target_feature_whitelist(tcx.sess) llvm_util::supported_target_features(tcx.sess)
.iter() .iter()
.map(|&(a, b)| (a.to_string(), b)) .map(|&(a, b)| (a.to_string(), b))
.collect() .collect()

View File

@ -62,11 +62,11 @@ fn prepare_lto(
} }
}; };
let exported_symbols = cgcx.exported_symbols.as_ref().expect("needs exported symbols for LTO"); let exported_symbols = cgcx.exported_symbols.as_ref().expect("needs exported symbols for LTO");
let mut symbol_white_list = { let mut symbols_below_threshold = {
let _timer = cgcx.prof.generic_activity("LLVM_lto_generate_symbol_white_list"); let _timer = cgcx.prof.generic_activity("LLVM_lto_generate_symbols_below_threshold");
exported_symbols[&LOCAL_CRATE].iter().filter_map(symbol_filter).collect::<Vec<CString>>() exported_symbols[&LOCAL_CRATE].iter().filter_map(symbol_filter).collect::<Vec<CString>>()
}; };
info!("{} symbols to preserve in this crate", symbol_white_list.len()); info!("{} symbols to preserve in this crate", symbols_below_threshold.len());
// If we're performing LTO for the entire crate graph, then for each of our // If we're performing LTO for the entire crate graph, then for each of our
// upstream dependencies, find the corresponding rlib and load the bitcode // upstream dependencies, find the corresponding rlib and load the bitcode
@ -102,8 +102,10 @@ fn prepare_lto(
let exported_symbols = let exported_symbols =
cgcx.exported_symbols.as_ref().expect("needs exported symbols for LTO"); cgcx.exported_symbols.as_ref().expect("needs exported symbols for LTO");
{ {
let _timer = cgcx.prof.generic_activity("LLVM_lto_generate_symbol_white_list"); let _timer =
symbol_white_list.extend(exported_symbols[&cnum].iter().filter_map(symbol_filter)); cgcx.prof.generic_activity("LLVM_lto_generate_symbols_below_threshold");
symbols_below_threshold
.extend(exported_symbols[&cnum].iter().filter_map(symbol_filter));
} }
let archive = ArchiveRO::open(&path).expect("wanted an rlib"); let archive = ArchiveRO::open(&path).expect("wanted an rlib");
@ -124,7 +126,7 @@ fn prepare_lto(
} }
} }
Ok((symbol_white_list, upstream_modules)) Ok((symbols_below_threshold, upstream_modules))
} }
fn get_bitcode_slice_from_object_data(obj: &[u8]) -> Result<&[u8], String> { fn get_bitcode_slice_from_object_data(obj: &[u8]) -> Result<&[u8], String> {
@ -155,9 +157,17 @@ pub(crate) fn run_fat(
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>, cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
) -> Result<LtoModuleCodegen<LlvmCodegenBackend>, FatalError> { ) -> Result<LtoModuleCodegen<LlvmCodegenBackend>, FatalError> {
let diag_handler = cgcx.create_diag_handler(); let diag_handler = cgcx.create_diag_handler();
let (symbol_white_list, upstream_modules) = prepare_lto(cgcx, &diag_handler)?; let (symbols_below_threshold, upstream_modules) = prepare_lto(cgcx, &diag_handler)?;
let symbol_white_list = symbol_white_list.iter().map(|c| c.as_ptr()).collect::<Vec<_>>(); let symbols_below_threshold =
fat_lto(cgcx, &diag_handler, modules, cached_modules, upstream_modules, &symbol_white_list) symbols_below_threshold.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();
fat_lto(
cgcx,
&diag_handler,
modules,
cached_modules,
upstream_modules,
&symbols_below_threshold,
)
} }
/// Performs thin LTO by performing necessary global analysis and returning two /// Performs thin LTO by performing necessary global analysis and returning two
@ -169,15 +179,23 @@ pub(crate) fn run_thin(
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>, cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
) -> Result<(Vec<LtoModuleCodegen<LlvmCodegenBackend>>, Vec<WorkProduct>), FatalError> { ) -> Result<(Vec<LtoModuleCodegen<LlvmCodegenBackend>>, Vec<WorkProduct>), FatalError> {
let diag_handler = cgcx.create_diag_handler(); let diag_handler = cgcx.create_diag_handler();
let (symbol_white_list, upstream_modules) = prepare_lto(cgcx, &diag_handler)?; let (symbols_below_threshold, upstream_modules) = prepare_lto(cgcx, &diag_handler)?;
let symbol_white_list = symbol_white_list.iter().map(|c| c.as_ptr()).collect::<Vec<_>>(); let symbols_below_threshold =
symbols_below_threshold.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();
if cgcx.opts.cg.linker_plugin_lto.enabled() { if cgcx.opts.cg.linker_plugin_lto.enabled() {
unreachable!( unreachable!(
"We should never reach this case if the LTO step \ "We should never reach this case if the LTO step \
is deferred to the linker" is deferred to the linker"
); );
} }
thin_lto(cgcx, &diag_handler, modules, upstream_modules, cached_modules, &symbol_white_list) thin_lto(
cgcx,
&diag_handler,
modules,
upstream_modules,
cached_modules,
&symbols_below_threshold,
)
} }
pub(crate) fn prepare_thin(module: ModuleCodegen<ModuleLlvm>) -> (String, ThinBuffer) { pub(crate) fn prepare_thin(module: ModuleCodegen<ModuleLlvm>) -> (String, ThinBuffer) {
@ -192,7 +210,7 @@ fn fat_lto(
modules: Vec<FatLTOInput<LlvmCodegenBackend>>, modules: Vec<FatLTOInput<LlvmCodegenBackend>>,
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>, cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>, mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
symbol_white_list: &[*const libc::c_char], symbols_below_threshold: &[*const libc::c_char],
) -> Result<LtoModuleCodegen<LlvmCodegenBackend>, FatalError> { ) -> Result<LtoModuleCodegen<LlvmCodegenBackend>, FatalError> {
let _timer = cgcx.prof.generic_activity("LLVM_fat_lto_build_monolithic_module"); let _timer = cgcx.prof.generic_activity("LLVM_fat_lto_build_monolithic_module");
info!("going for a fat lto"); info!("going for a fat lto");
@ -306,14 +324,13 @@ fn fat_lto(
drop(linker); drop(linker);
save_temp_bitcode(&cgcx, &module, "lto.input"); save_temp_bitcode(&cgcx, &module, "lto.input");
// Internalize everything that *isn't* in our whitelist to help strip out // Internalize everything below threshold to help strip out more modules and such.
// more modules and such
unsafe { unsafe {
let ptr = symbol_white_list.as_ptr(); let ptr = symbols_below_threshold.as_ptr();
llvm::LLVMRustRunRestrictionPass( llvm::LLVMRustRunRestrictionPass(
llmod, llmod,
ptr as *const *const libc::c_char, ptr as *const *const libc::c_char,
symbol_white_list.len() as libc::size_t, symbols_below_threshold.len() as libc::size_t,
); );
save_temp_bitcode(&cgcx, &module, "lto.after-restriction"); save_temp_bitcode(&cgcx, &module, "lto.after-restriction");
} }
@ -395,7 +412,7 @@ fn thin_lto(
modules: Vec<(String, ThinBuffer)>, modules: Vec<(String, ThinBuffer)>,
serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>, serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>, cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
symbol_white_list: &[*const libc::c_char], symbols_below_threshold: &[*const libc::c_char],
) -> Result<(Vec<LtoModuleCodegen<LlvmCodegenBackend>>, Vec<WorkProduct>), FatalError> { ) -> Result<(Vec<LtoModuleCodegen<LlvmCodegenBackend>>, Vec<WorkProduct>), FatalError> {
let _timer = cgcx.prof.generic_activity("LLVM_thin_lto_global_analysis"); let _timer = cgcx.prof.generic_activity("LLVM_thin_lto_global_analysis");
unsafe { unsafe {
@ -463,8 +480,8 @@ fn thin_lto(
let data = llvm::LLVMRustCreateThinLTOData( let data = llvm::LLVMRustCreateThinLTOData(
thin_modules.as_ptr(), thin_modules.as_ptr(),
thin_modules.len() as u32, thin_modules.len() as u32,
symbol_white_list.as_ptr(), symbols_below_threshold.as_ptr(),
symbol_white_list.len() as u32, symbols_below_threshold.len() as u32,
) )
.ok_or_else(|| write::llvm_err(&diag_handler, "failed to prepare thin LTO context"))?; .ok_or_else(|| write::llvm_err(&diag_handler, "failed to prepare thin LTO context"))?;

View File

@ -139,7 +139,7 @@ pub fn time_trace_profiler_finish(file_name: &str) {
// to LLVM or the feature detection code will walk past the end of the feature // to LLVM or the feature detection code will walk past the end of the feature
// array, leading to crashes. // array, leading to crashes.
const ARM_WHITELIST: &[(&str, Option<Symbol>)] = &[ const ARM_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
("aclass", Some(sym::arm_target_feature)), ("aclass", Some(sym::arm_target_feature)),
("mclass", Some(sym::arm_target_feature)), ("mclass", Some(sym::arm_target_feature)),
("rclass", Some(sym::arm_target_feature)), ("rclass", Some(sym::arm_target_feature)),
@ -162,7 +162,7 @@ const ARM_WHITELIST: &[(&str, Option<Symbol>)] = &[
("thumb-mode", Some(sym::arm_target_feature)), ("thumb-mode", Some(sym::arm_target_feature)),
]; ];
const AARCH64_WHITELIST: &[(&str, Option<Symbol>)] = &[ const AARCH64_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
("fp", Some(sym::aarch64_target_feature)), ("fp", Some(sym::aarch64_target_feature)),
("neon", Some(sym::aarch64_target_feature)), ("neon", Some(sym::aarch64_target_feature)),
("sve", Some(sym::aarch64_target_feature)), ("sve", Some(sym::aarch64_target_feature)),
@ -180,7 +180,7 @@ const AARCH64_WHITELIST: &[(&str, Option<Symbol>)] = &[
("v8.3a", Some(sym::aarch64_target_feature)), ("v8.3a", Some(sym::aarch64_target_feature)),
]; ];
const X86_WHITELIST: &[(&str, Option<Symbol>)] = &[ const X86_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
("adx", Some(sym::adx_target_feature)), ("adx", Some(sym::adx_target_feature)),
("aes", None), ("aes", None),
("avx", None), ("avx", None),
@ -224,12 +224,12 @@ const X86_WHITELIST: &[(&str, Option<Symbol>)] = &[
("xsaves", None), ("xsaves", None),
]; ];
const HEXAGON_WHITELIST: &[(&str, Option<Symbol>)] = &[ const HEXAGON_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
("hvx", Some(sym::hexagon_target_feature)), ("hvx", Some(sym::hexagon_target_feature)),
("hvx-length128b", Some(sym::hexagon_target_feature)), ("hvx-length128b", Some(sym::hexagon_target_feature)),
]; ];
const POWERPC_WHITELIST: &[(&str, Option<Symbol>)] = &[ const POWERPC_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
("altivec", Some(sym::powerpc_target_feature)), ("altivec", Some(sym::powerpc_target_feature)),
("power8-altivec", Some(sym::powerpc_target_feature)), ("power8-altivec", Some(sym::powerpc_target_feature)),
("power9-altivec", Some(sym::powerpc_target_feature)), ("power9-altivec", Some(sym::powerpc_target_feature)),
@ -238,10 +238,10 @@ const POWERPC_WHITELIST: &[(&str, Option<Symbol>)] = &[
("vsx", Some(sym::powerpc_target_feature)), ("vsx", Some(sym::powerpc_target_feature)),
]; ];
const MIPS_WHITELIST: &[(&str, Option<Symbol>)] = const MIPS_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] =
&[("fp64", Some(sym::mips_target_feature)), ("msa", Some(sym::mips_target_feature))]; &[("fp64", Some(sym::mips_target_feature)), ("msa", Some(sym::mips_target_feature))];
const RISCV_WHITELIST: &[(&str, Option<Symbol>)] = &[ const RISCV_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
("m", Some(sym::riscv_target_feature)), ("m", Some(sym::riscv_target_feature)),
("a", Some(sym::riscv_target_feature)), ("a", Some(sym::riscv_target_feature)),
("c", Some(sym::riscv_target_feature)), ("c", Some(sym::riscv_target_feature)),
@ -250,7 +250,7 @@ const RISCV_WHITELIST: &[(&str, Option<Symbol>)] = &[
("e", Some(sym::riscv_target_feature)), ("e", Some(sym::riscv_target_feature)),
]; ];
const WASM_WHITELIST: &[(&str, Option<Symbol>)] = &[ const WASM_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
("simd128", Some(sym::wasm_target_feature)), ("simd128", Some(sym::wasm_target_feature)),
("atomics", Some(sym::wasm_target_feature)), ("atomics", Some(sym::wasm_target_feature)),
("nontrapping-fptoint", Some(sym::wasm_target_feature)), ("nontrapping-fptoint", Some(sym::wasm_target_feature)),
@ -259,19 +259,18 @@ const WASM_WHITELIST: &[(&str, Option<Symbol>)] = &[
/// When rustdoc is running, provide a list of all known features so that all their respective /// When rustdoc is running, provide a list of all known features so that all their respective
/// primitives may be documented. /// primitives may be documented.
/// ///
/// IMPORTANT: If you're adding another whitelist to the above lists, make sure to add it to this /// IMPORTANT: If you're adding another feature list above, make sure to add it to this iterator!
/// iterator!
pub fn all_known_features() -> impl Iterator<Item = (&'static str, Option<Symbol>)> { pub fn all_known_features() -> impl Iterator<Item = (&'static str, Option<Symbol>)> {
ARM_WHITELIST std::iter::empty()
.iter() .chain(ARM_ALLOWED_FEATURES.iter())
.chain(AARCH64_ALLOWED_FEATURES.iter())
.chain(X86_ALLOWED_FEATURES.iter())
.chain(HEXAGON_ALLOWED_FEATURES.iter())
.chain(POWERPC_ALLOWED_FEATURES.iter())
.chain(MIPS_ALLOWED_FEATURES.iter())
.chain(RISCV_ALLOWED_FEATURES.iter())
.chain(WASM_ALLOWED_FEATURES.iter())
.cloned() .cloned()
.chain(AARCH64_WHITELIST.iter().cloned())
.chain(X86_WHITELIST.iter().cloned())
.chain(HEXAGON_WHITELIST.iter().cloned())
.chain(POWERPC_WHITELIST.iter().cloned())
.chain(MIPS_WHITELIST.iter().cloned())
.chain(RISCV_WHITELIST.iter().cloned())
.chain(WASM_WHITELIST.iter().cloned())
} }
pub fn to_llvm_feature<'a>(sess: &Session, s: &'a str) -> &'a str { pub fn to_llvm_feature<'a>(sess: &Session, s: &'a str) -> &'a str {
@ -289,7 +288,7 @@ pub fn to_llvm_feature<'a>(sess: &Session, s: &'a str) -> &'a str {
pub fn target_features(sess: &Session) -> Vec<Symbol> { pub fn target_features(sess: &Session) -> Vec<Symbol> {
let target_machine = create_informational_target_machine(sess); let target_machine = create_informational_target_machine(sess);
target_feature_whitelist(sess) supported_target_features(sess)
.iter() .iter()
.filter_map(|&(feature, gate)| { .filter_map(|&(feature, gate)| {
if UnstableFeatures::from_environment().is_nightly_build() || gate.is_none() { if UnstableFeatures::from_environment().is_nightly_build() || gate.is_none() {
@ -307,16 +306,16 @@ pub fn target_features(sess: &Session) -> Vec<Symbol> {
.collect() .collect()
} }
pub fn target_feature_whitelist(sess: &Session) -> &'static [(&'static str, Option<Symbol>)] { pub fn supported_target_features(sess: &Session) -> &'static [(&'static str, Option<Symbol>)] {
match &*sess.target.target.arch { match &*sess.target.target.arch {
"arm" => ARM_WHITELIST, "arm" => ARM_ALLOWED_FEATURES,
"aarch64" => AARCH64_WHITELIST, "aarch64" => AARCH64_ALLOWED_FEATURES,
"x86" | "x86_64" => X86_WHITELIST, "x86" | "x86_64" => X86_ALLOWED_FEATURES,
"hexagon" => HEXAGON_WHITELIST, "hexagon" => HEXAGON_ALLOWED_FEATURES,
"mips" | "mips64" => MIPS_WHITELIST, "mips" | "mips64" => MIPS_ALLOWED_FEATURES,
"powerpc" | "powerpc64" => POWERPC_WHITELIST, "powerpc" | "powerpc64" => POWERPC_ALLOWED_FEATURES,
"riscv32" | "riscv64" => RISCV_WHITELIST, "riscv32" | "riscv64" => RISCV_ALLOWED_FEATURES,
"wasm32" => WASM_WHITELIST, "wasm32" => WASM_ALLOWED_FEATURES,
_ => &[], _ => &[],
} }
} }

View File

@ -1176,10 +1176,10 @@ impl<'a> Linker for WasmLd<'a> {
self.cmd.arg("--export").arg(&sym); self.cmd.arg("--export").arg(&sym);
} }
// LLD will hide these otherwise-internal symbols since our `--export` // LLD will hide these otherwise-internal symbols since it only exports
// list above is a whitelist of what to export. Various bits and pieces // symbols explicity passed via the `--export` flags above and hides all
// of tooling use this, so be sure these symbols make their way out of // others. Various bits and pieces of tooling use this, so be sure these
// the linker as well. // symbols make their way out of the linker as well.
self.cmd.arg("--export=__heap_base"); self.cmd.arg("--export=__heap_base");
self.cmd.arg("--export=__data_end"); self.cmd.arg("--export=__data_end");
} }

View File

@ -842,10 +842,9 @@ impl CrateInfo {
} }
} }
// No need to look for lang items that are whitelisted and don't // No need to look for lang items that don't actually need to exist.
// actually need to exist.
let missing = let missing =
missing.iter().cloned().filter(|&l| !lang_items::whitelisted(tcx, l)).collect(); missing.iter().cloned().filter(|&l| lang_items::required(tcx, l)).collect();
info.missing_lang_items.insert(cnum, missing); info.missing_lang_items.insert(cnum, missing);
} }

View File

@ -735,7 +735,7 @@ pub struct SyntaxExtension {
pub kind: SyntaxExtensionKind, pub kind: SyntaxExtensionKind,
/// Span of the macro definition. /// Span of the macro definition.
pub span: Span, pub span: Span,
/// Whitelist of unstable features that are treated as stable inside this macro. /// List of unstable features that are treated as stable inside this macro.
pub allow_internal_unstable: Option<Lrc<[Symbol]>>, pub allow_internal_unstable: Option<Lrc<[Symbol]>>,
/// Suppresses the `unsafe_code` lint for code produced by this macro. /// Suppresses the `unsafe_code` lint for code produced by this macro.
pub allow_internal_unsafe: bool, pub allow_internal_unsafe: bool,

View File

@ -47,7 +47,7 @@ pub enum AttributeType {
/// Builtin attribute that may not be consumed by the compiler /// Builtin attribute that may not be consumed by the compiler
/// before the unused_attribute check. These attributes /// before the unused_attribute check. These attributes
/// will be ignored by the unused_attribute lint /// will be ignored by the unused_attribute lint
Whitelisted, AssumedUsed,
/// Builtin attribute that is only allowed at the crate level /// Builtin attribute that is only allowed at the crate level
CrateLevel, CrateLevel,
@ -202,7 +202,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
ungated!(allow, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#)), ungated!(allow, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#)),
ungated!(forbid, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#)), ungated!(forbid, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#)),
ungated!(deny, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#)), ungated!(deny, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#)),
ungated!(must_use, Whitelisted, template!(Word, NameValueStr: "reason")), ungated!(must_use, AssumedUsed, template!(Word, NameValueStr: "reason")),
// FIXME(#14407) // FIXME(#14407)
ungated!( ungated!(
deprecated, Normal, deprecated, Normal,
@ -220,16 +220,16 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
// ABI, linking, symbols, and FFI // ABI, linking, symbols, and FFI
ungated!( ungated!(
link, Whitelisted, link, AssumedUsed,
template!(List: r#"name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...""#), template!(List: r#"name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...""#),
), ),
ungated!(link_name, Whitelisted, template!(NameValueStr: "name")), ungated!(link_name, AssumedUsed, template!(NameValueStr: "name")),
ungated!(no_link, Normal, template!(Word)), ungated!(no_link, Normal, template!(Word)),
ungated!(repr, Normal, template!(List: "C")), ungated!(repr, Normal, template!(List: "C")),
ungated!(export_name, Whitelisted, template!(NameValueStr: "name")), ungated!(export_name, AssumedUsed, template!(NameValueStr: "name")),
ungated!(link_section, Whitelisted, template!(NameValueStr: "name")), ungated!(link_section, AssumedUsed, template!(NameValueStr: "name")),
ungated!(no_mangle, Whitelisted, template!(Word)), ungated!(no_mangle, AssumedUsed, template!(Word)),
ungated!(used, Whitelisted, template!(Word)), ungated!(used, AssumedUsed, template!(Word)),
// Limits: // Limits:
ungated!(recursion_limit, CrateLevel, template!(NameValueStr: "N")), ungated!(recursion_limit, CrateLevel, template!(NameValueStr: "N")),
@ -249,40 +249,40 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
ungated!(path, Normal, template!(NameValueStr: "file")), ungated!(path, Normal, template!(NameValueStr: "file")),
ungated!(no_std, CrateLevel, template!(Word)), ungated!(no_std, CrateLevel, template!(Word)),
ungated!(no_implicit_prelude, Normal, template!(Word)), ungated!(no_implicit_prelude, Normal, template!(Word)),
ungated!(non_exhaustive, Whitelisted, template!(Word)), ungated!(non_exhaustive, AssumedUsed, template!(Word)),
// Runtime // Runtime
ungated!(windows_subsystem, Whitelisted, template!(NameValueStr: "windows|console")), ungated!(windows_subsystem, AssumedUsed, template!(NameValueStr: "windows|console")),
ungated!(panic_handler, Normal, template!(Word)), // RFC 2070 ungated!(panic_handler, Normal, template!(Word)), // RFC 2070
// Code generation: // Code generation:
ungated!(inline, Whitelisted, template!(Word, List: "always|never")), ungated!(inline, AssumedUsed, template!(Word, List: "always|never")),
ungated!(cold, Whitelisted, template!(Word)), ungated!(cold, AssumedUsed, template!(Word)),
ungated!(no_builtins, Whitelisted, template!(Word)), ungated!(no_builtins, AssumedUsed, template!(Word)),
ungated!(target_feature, Whitelisted, template!(List: r#"enable = "name""#)), ungated!(target_feature, AssumedUsed, template!(List: r#"enable = "name""#)),
ungated!(track_caller, Whitelisted, template!(Word)), ungated!(track_caller, AssumedUsed, template!(Word)),
gated!( gated!(
no_sanitize, Whitelisted, no_sanitize, AssumedUsed,
template!(List: "address, memory, thread"), template!(List: "address, memory, thread"),
experimental!(no_sanitize) experimental!(no_sanitize)
), ),
// FIXME: #14408 whitelist docs since rustdoc looks at them // FIXME: #14408 assume docs are used since rustdoc looks at them.
ungated!(doc, Whitelisted, template!(List: "hidden|inline|...", NameValueStr: "string")), ungated!(doc, AssumedUsed, template!(List: "hidden|inline|...", NameValueStr: "string")),
// ========================================================================== // ==========================================================================
// Unstable attributes: // Unstable attributes:
// ========================================================================== // ==========================================================================
// Linking: // Linking:
gated!(naked, Whitelisted, template!(Word), naked_functions, experimental!(naked)), gated!(naked, AssumedUsed, template!(Word), naked_functions, experimental!(naked)),
gated!( gated!(
link_args, Normal, template!(NameValueStr: "args"), link_args, Normal, template!(NameValueStr: "args"),
"the `link_args` attribute is experimental and not portable across platforms, \ "the `link_args` attribute is experimental and not portable across platforms, \
it is recommended to use `#[link(name = \"foo\")] instead", it is recommended to use `#[link(name = \"foo\")] instead",
), ),
gated!( gated!(
link_ordinal, Whitelisted, template!(List: "ordinal"), raw_dylib, link_ordinal, AssumedUsed, template!(List: "ordinal"), raw_dylib,
experimental!(link_ordinal) experimental!(link_ordinal)
), ),
@ -321,19 +321,19 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
// RFC #1268 // RFC #1268
gated!(marker, Normal, template!(Word), marker_trait_attr, experimental!(marker)), gated!(marker, Normal, template!(Word), marker_trait_attr, experimental!(marker)),
gated!( gated!(
thread_local, Whitelisted, template!(Word), thread_local, AssumedUsed, template!(Word),
"`#[thread_local]` is an experimental feature, and does not currently handle destructors", "`#[thread_local]` is an experimental feature, and does not currently handle destructors",
), ),
gated!(no_core, CrateLevel, template!(Word), experimental!(no_core)), gated!(no_core, CrateLevel, template!(Word), experimental!(no_core)),
// RFC 2412 // RFC 2412
gated!( gated!(
optimize, Whitelisted, template!(List: "size|speed"), optimize_attribute, optimize, AssumedUsed, template!(List: "size|speed"), optimize_attribute,
experimental!(optimize), experimental!(optimize),
), ),
gated!(ffi_returns_twice, Whitelisted, template!(Word), experimental!(ffi_returns_twice)), gated!(ffi_returns_twice, AssumedUsed, template!(Word), experimental!(ffi_returns_twice)),
gated!(ffi_pure, Whitelisted, template!(Word), experimental!(ffi_pure)), gated!(ffi_pure, AssumedUsed, template!(Word), experimental!(ffi_pure)),
gated!(ffi_const, Whitelisted, template!(Word), experimental!(ffi_const)), gated!(ffi_const, AssumedUsed, template!(Word), experimental!(ffi_const)),
gated!( gated!(
register_attr, CrateLevel, template!(List: "attr1, attr2, ..."), register_attr, CrateLevel, template!(List: "attr1, attr2, ..."),
experimental!(register_attr), experimental!(register_attr),
@ -351,22 +351,22 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
// FIXME(#14407) -- only looked at on-demand so we can't // FIXME(#14407) -- only looked at on-demand so we can't
// guarantee they'll have already been checked. // guarantee they'll have already been checked.
ungated!( ungated!(
rustc_deprecated, Whitelisted, rustc_deprecated, AssumedUsed,
template!(List: r#"since = "version", reason = "...""#) template!(List: r#"since = "version", reason = "...""#)
), ),
// FIXME(#14407) // FIXME(#14407)
ungated!(stable, Whitelisted, template!(List: r#"feature = "name", since = "version""#)), ungated!(stable, AssumedUsed, template!(List: r#"feature = "name", since = "version""#)),
// FIXME(#14407) // FIXME(#14407)
ungated!( ungated!(
unstable, Whitelisted, unstable, AssumedUsed,
template!(List: r#"feature = "name", reason = "...", issue = "N""#), template!(List: r#"feature = "name", reason = "...", issue = "N""#),
), ),
// FIXME(#14407) // FIXME(#14407)
ungated!(rustc_const_unstable, Whitelisted, template!(List: r#"feature = "name""#)), ungated!(rustc_const_unstable, AssumedUsed, template!(List: r#"feature = "name""#)),
// FIXME(#14407) // FIXME(#14407)
ungated!(rustc_const_stable, Whitelisted, template!(List: r#"feature = "name""#)), ungated!(rustc_const_stable, AssumedUsed, template!(List: r#"feature = "name""#)),
gated!( gated!(
allow_internal_unstable, Whitelisted, template!(Word, List: "feat1, feat2, ..."), allow_internal_unstable, AssumedUsed, template!(Word, List: "feat1, feat2, ..."),
"allow_internal_unstable side-steps feature gating and stability checks", "allow_internal_unstable side-steps feature gating and stability checks",
), ),
gated!( gated!(
@ -378,7 +378,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
// Internal attributes: Type system related: // Internal attributes: Type system related:
// ========================================================================== // ==========================================================================
gated!(fundamental, Whitelisted, template!(Word), experimental!(fundamental)), gated!(fundamental, AssumedUsed, template!(Word), experimental!(fundamental)),
gated!( gated!(
may_dangle, Normal, template!(Word), dropck_eyepatch, may_dangle, Normal, template!(Word), dropck_eyepatch,
"`may_dangle` has unstable semantics and may be removed in the future", "`may_dangle` has unstable semantics and may be removed in the future",
@ -388,30 +388,30 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
// Internal attributes: Runtime related: // Internal attributes: Runtime related:
// ========================================================================== // ==========================================================================
rustc_attr!(rustc_allocator, Whitelisted, template!(Word), IMPL_DETAIL), rustc_attr!(rustc_allocator, AssumedUsed, template!(Word), IMPL_DETAIL),
rustc_attr!(rustc_allocator_nounwind, Whitelisted, template!(Word), IMPL_DETAIL), rustc_attr!(rustc_allocator_nounwind, AssumedUsed, template!(Word), IMPL_DETAIL),
gated!(alloc_error_handler, Normal, template!(Word), experimental!(alloc_error_handler)), gated!(alloc_error_handler, Normal, template!(Word), experimental!(alloc_error_handler)),
gated!( gated!(
default_lib_allocator, Whitelisted, template!(Word), allocator_internals, default_lib_allocator, AssumedUsed, template!(Word), allocator_internals,
experimental!(default_lib_allocator), experimental!(default_lib_allocator),
), ),
gated!( gated!(
needs_allocator, Normal, template!(Word), allocator_internals, needs_allocator, Normal, template!(Word), allocator_internals,
experimental!(needs_allocator), experimental!(needs_allocator),
), ),
gated!(panic_runtime, Whitelisted, template!(Word), experimental!(panic_runtime)), gated!(panic_runtime, AssumedUsed, template!(Word), experimental!(panic_runtime)),
gated!(needs_panic_runtime, Whitelisted, template!(Word), experimental!(needs_panic_runtime)), gated!(needs_panic_runtime, AssumedUsed, template!(Word), experimental!(needs_panic_runtime)),
gated!( gated!(
unwind, Whitelisted, template!(List: "allowed|aborts"), unwind_attributes, unwind, AssumedUsed, template!(List: "allowed|aborts"), unwind_attributes,
experimental!(unwind), experimental!(unwind),
), ),
gated!( gated!(
compiler_builtins, Whitelisted, template!(Word), compiler_builtins, AssumedUsed, template!(Word),
"the `#[compiler_builtins]` attribute is used to identify the `compiler_builtins` crate \ "the `#[compiler_builtins]` attribute is used to identify the `compiler_builtins` crate \
which contains compiler-rt intrinsics and will never be stable", which contains compiler-rt intrinsics and will never be stable",
), ),
gated!( gated!(
profiler_runtime, Whitelisted, template!(Word), profiler_runtime, AssumedUsed, template!(Word),
"the `#[profiler_runtime]` attribute is used to identify the `profiler_builtins` crate \ "the `#[profiler_runtime]` attribute is used to identify the `profiler_builtins` crate \
which contains the profiler runtime and will never be stable", which contains the profiler runtime and will never be stable",
), ),
@ -421,19 +421,19 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
// ========================================================================== // ==========================================================================
gated!( gated!(
linkage, Whitelisted, template!(NameValueStr: "external|internal|..."), linkage, AssumedUsed, template!(NameValueStr: "external|internal|..."),
"the `linkage` attribute is experimental and not portable across platforms", "the `linkage` attribute is experimental and not portable across platforms",
), ),
rustc_attr!(rustc_std_internal_symbol, Whitelisted, template!(Word), INTERNAL_UNSTABLE), rustc_attr!(rustc_std_internal_symbol, AssumedUsed, template!(Word), INTERNAL_UNSTABLE),
// ========================================================================== // ==========================================================================
// Internal attributes, Macro related: // Internal attributes, Macro related:
// ========================================================================== // ==========================================================================
rustc_attr!(rustc_builtin_macro, Whitelisted, template!(Word), IMPL_DETAIL), rustc_attr!(rustc_builtin_macro, AssumedUsed, template!(Word), IMPL_DETAIL),
rustc_attr!(rustc_proc_macro_decls, Normal, template!(Word), INTERNAL_UNSTABLE), rustc_attr!(rustc_proc_macro_decls, Normal, template!(Word), INTERNAL_UNSTABLE),
rustc_attr!( rustc_attr!(
rustc_macro_transparency, Whitelisted, rustc_macro_transparency, AssumedUsed,
template!(NameValueStr: "transparent|semitransparent|opaque"), template!(NameValueStr: "transparent|semitransparent|opaque"),
"used internally for testing macro hygiene", "used internally for testing macro hygiene",
), ),
@ -443,40 +443,40 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
// ========================================================================== // ==========================================================================
rustc_attr!( rustc_attr!(
rustc_on_unimplemented, Whitelisted, rustc_on_unimplemented, AssumedUsed,
template!( template!(
List: r#"/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...""#, List: r#"/*opt*/ message = "...", /*opt*/ label = "...", /*opt*/ note = "...""#,
NameValueStr: "message" NameValueStr: "message"
), ),
INTERNAL_UNSTABLE INTERNAL_UNSTABLE
), ),
// Whitelists "identity-like" conversion methods to suggest on type mismatch. // Enumerates "identity-like" conversion methods to suggest on type mismatch.
rustc_attr!(rustc_conversion_suggestion, Whitelisted, template!(Word), INTERNAL_UNSTABLE), rustc_attr!(rustc_conversion_suggestion, AssumedUsed, template!(Word), INTERNAL_UNSTABLE),
// ========================================================================== // ==========================================================================
// Internal attributes, Const related: // Internal attributes, Const related:
// ========================================================================== // ==========================================================================
rustc_attr!(rustc_promotable, Whitelisted, template!(Word), IMPL_DETAIL), rustc_attr!(rustc_promotable, AssumedUsed, template!(Word), IMPL_DETAIL),
rustc_attr!(rustc_allow_const_fn_ptr, Whitelisted, template!(Word), IMPL_DETAIL), rustc_attr!(rustc_allow_const_fn_ptr, AssumedUsed, template!(Word), IMPL_DETAIL),
rustc_attr!(rustc_args_required_const, Whitelisted, template!(List: "N"), INTERNAL_UNSTABLE), rustc_attr!(rustc_args_required_const, AssumedUsed, template!(List: "N"), INTERNAL_UNSTABLE),
// ========================================================================== // ==========================================================================
// Internal attributes, Layout related: // Internal attributes, Layout related:
// ========================================================================== // ==========================================================================
rustc_attr!( rustc_attr!(
rustc_layout_scalar_valid_range_start, Whitelisted, template!(List: "value"), rustc_layout_scalar_valid_range_start, AssumedUsed, template!(List: "value"),
"the `#[rustc_layout_scalar_valid_range_start]` attribute is just used to enable \ "the `#[rustc_layout_scalar_valid_range_start]` attribute is just used to enable \
niche optimizations in libcore and will never be stable", niche optimizations in libcore and will never be stable",
), ),
rustc_attr!( rustc_attr!(
rustc_layout_scalar_valid_range_end, Whitelisted, template!(List: "value"), rustc_layout_scalar_valid_range_end, AssumedUsed, template!(List: "value"),
"the `#[rustc_layout_scalar_valid_range_end]` attribute is just used to enable \ "the `#[rustc_layout_scalar_valid_range_end]` attribute is just used to enable \
niche optimizations in libcore and will never be stable", niche optimizations in libcore and will never be stable",
), ),
rustc_attr!( rustc_attr!(
rustc_nonnull_optimization_guaranteed, Whitelisted, template!(Word), rustc_nonnull_optimization_guaranteed, AssumedUsed, template!(Word),
"the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to enable \ "the `#[rustc_nonnull_optimization_guaranteed]` attribute is just used to enable \
niche optimizations in libcore and will never be stable", niche optimizations in libcore and will never be stable",
), ),
@ -501,7 +501,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
), ),
gated!( gated!(
// Used in resolve: // Used in resolve:
prelude_import, Whitelisted, template!(Word), prelude_import, AssumedUsed, template!(Word),
"`#[prelude_import]` is for use by rustc only", "`#[prelude_import]` is for use by rustc only",
), ),
gated!( gated!(
@ -509,7 +509,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
"unboxed_closures are still evolving", "unboxed_closures are still evolving",
), ),
rustc_attr!( rustc_attr!(
rustc_inherit_overflow_checks, Whitelisted, template!(Word), rustc_inherit_overflow_checks, AssumedUsed, template!(Word),
"the `#[rustc_inherit_overflow_checks]` attribute is just used to control \ "the `#[rustc_inherit_overflow_checks]` attribute is just used to control \
overflow checking behavior of several libcore functions that are inlined \ overflow checking behavior of several libcore functions that are inlined \
across crates and will never be stable", across crates and will never be stable",
@ -540,42 +540,42 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
rustc_attr!(TEST, rustc_layout, Normal, template!(List: "field1, field2, ...")), rustc_attr!(TEST, rustc_layout, Normal, template!(List: "field1, field2, ...")),
rustc_attr!(TEST, rustc_regions, Normal, template!(Word)), rustc_attr!(TEST, rustc_regions, Normal, template!(Word)),
rustc_attr!( rustc_attr!(
TEST, rustc_error, Whitelisted, TEST, rustc_error, AssumedUsed,
template!(Word, List: "delay_span_bug_from_inside_query") template!(Word, List: "delay_span_bug_from_inside_query")
), ),
rustc_attr!(TEST, rustc_dump_user_substs, Whitelisted, template!(Word)), rustc_attr!(TEST, rustc_dump_user_substs, AssumedUsed, template!(Word)),
rustc_attr!(TEST, rustc_if_this_changed, Whitelisted, template!(Word, List: "DepNode")), rustc_attr!(TEST, rustc_if_this_changed, AssumedUsed, template!(Word, List: "DepNode")),
rustc_attr!(TEST, rustc_then_this_would_need, Whitelisted, template!(List: "DepNode")), rustc_attr!(TEST, rustc_then_this_would_need, AssumedUsed, template!(List: "DepNode")),
rustc_attr!( rustc_attr!(
TEST, rustc_dirty, Whitelisted, TEST, rustc_dirty, AssumedUsed,
template!(List: r#"cfg = "...", /*opt*/ label = "...", /*opt*/ except = "...""#), template!(List: r#"cfg = "...", /*opt*/ label = "...", /*opt*/ except = "...""#),
), ),
rustc_attr!( rustc_attr!(
TEST, rustc_clean, Whitelisted, TEST, rustc_clean, AssumedUsed,
template!(List: r#"cfg = "...", /*opt*/ label = "...", /*opt*/ except = "...""#), template!(List: r#"cfg = "...", /*opt*/ label = "...", /*opt*/ except = "...""#),
), ),
rustc_attr!( rustc_attr!(
TEST, rustc_partition_reused, Whitelisted, TEST, rustc_partition_reused, AssumedUsed,
template!(List: r#"cfg = "...", module = "...""#), template!(List: r#"cfg = "...", module = "...""#),
), ),
rustc_attr!( rustc_attr!(
TEST, rustc_partition_codegened, Whitelisted, TEST, rustc_partition_codegened, AssumedUsed,
template!(List: r#"cfg = "...", module = "...""#), template!(List: r#"cfg = "...", module = "...""#),
), ),
rustc_attr!( rustc_attr!(
TEST, rustc_expected_cgu_reuse, Whitelisted, TEST, rustc_expected_cgu_reuse, AssumedUsed,
template!(List: r#"cfg = "...", module = "...", kind = "...""#), template!(List: r#"cfg = "...", module = "...", kind = "...""#),
), ),
rustc_attr!(TEST, rustc_synthetic, Whitelisted, template!(Word)), rustc_attr!(TEST, rustc_synthetic, AssumedUsed, template!(Word)),
rustc_attr!(TEST, rustc_symbol_name, Whitelisted, template!(Word)), rustc_attr!(TEST, rustc_symbol_name, AssumedUsed, template!(Word)),
rustc_attr!(TEST, rustc_def_path, Whitelisted, template!(Word)), rustc_attr!(TEST, rustc_def_path, AssumedUsed, template!(Word)),
rustc_attr!(TEST, rustc_mir, Whitelisted, template!(List: "arg1, arg2, ...")), rustc_attr!(TEST, rustc_mir, AssumedUsed, template!(List: "arg1, arg2, ...")),
rustc_attr!(TEST, rustc_dump_program_clauses, Whitelisted, template!(Word)), rustc_attr!(TEST, rustc_dump_program_clauses, AssumedUsed, template!(Word)),
rustc_attr!(TEST, rustc_dump_env_program_clauses, Whitelisted, template!(Word)), rustc_attr!(TEST, rustc_dump_env_program_clauses, AssumedUsed, template!(Word)),
rustc_attr!(TEST, rustc_object_lifetime_default, Whitelisted, template!(Word)), rustc_attr!(TEST, rustc_object_lifetime_default, AssumedUsed, template!(Word)),
rustc_attr!(TEST, rustc_dummy, Normal, template!(Word /* doesn't matter*/)), rustc_attr!(TEST, rustc_dummy, Normal, template!(Word /* doesn't matter*/)),
gated!( gated!(
omit_gdb_pretty_printer_section, Whitelisted, template!(Word), omit_gdb_pretty_printer_section, AssumedUsed, template!(Word),
"the `#[omit_gdb_pretty_printer_section]` attribute is just used for the Rust test suite", "the `#[omit_gdb_pretty_printer_section]` attribute is just used for the Rust test suite",
), ),
]; ];

View File

@ -168,7 +168,7 @@ pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
// Note that we cannot use the existing "unused attribute"-infrastructure // Note that we cannot use the existing "unused attribute"-infrastructure
// here, since that is running before codegen. This is also the reason why // here, since that is running before codegen. This is also the reason why
// all codegen-specific attributes are `Whitelisted` in rustc_ast::feature_gate. // all codegen-specific attributes are `AssumedUsed` in rustc_ast::feature_gate.
all_attrs.report_unchecked_attrs(&dirty_clean_visitor.checked_attrs); all_attrs.report_unchecked_attrs(&dirty_clean_visitor.checked_attrs);
}) })
} }

View File

@ -38,8 +38,8 @@ use std::{panic, thread};
/// Adds `target_feature = "..."` cfgs for a variety of platform /// Adds `target_feature = "..."` cfgs for a variety of platform
/// specific features (SSE, NEON etc.). /// specific features (SSE, NEON etc.).
/// ///
/// This is performed by checking whether a whitelisted set of /// This is performed by checking whether a set of permitted features
/// features is available on the target machine, by querying LLVM. /// is available on the target machine, by querying LLVM.
pub fn add_configuration( pub fn add_configuration(
cfg: &mut CrateConfig, cfg: &mut CrateConfig,
sess: &mut Session, sess: &mut Session,

View File

@ -287,8 +287,8 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAttributes {
let attr_info = attr.ident().and_then(|ident| self.builtin_attributes.get(&ident.name)); let attr_info = attr.ident().and_then(|ident| self.builtin_attributes.get(&ident.name));
if let Some(&&(name, ty, ..)) = attr_info { if let Some(&&(name, ty, ..)) = attr_info {
if let AttributeType::Whitelisted = ty { if let AttributeType::AssumedUsed = ty {
debug!("{:?} is Whitelisted", name); debug!("{:?} is AssumedUsed", name);
return; return;
} }
} }

View File

@ -1386,9 +1386,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
let constness = match self.kind(id) { let constness = match self.kind(id) {
EntryKind::AssocFn(data) => data.decode(self).fn_data.constness, EntryKind::AssocFn(data) => data.decode(self).fn_data.constness,
EntryKind::Fn(data) => data.decode(self).constness, EntryKind::Fn(data) => data.decode(self).constness,
// Some intrinsics can be const fn. While we could recompute this (at least until we
// stop having hardcoded whitelists and move to stability attributes), it seems cleaner
// to treat all const fns equally.
EntryKind::ForeignFn(data) => data.decode(self).constness, EntryKind::ForeignFn(data) => data.decode(self).constness,
EntryKind::Variant(..) | EntryKind::Struct(..) => hir::Constness::Const, EntryKind::Variant(..) | EntryKind::Struct(..) => hir::Constness::Const,
_ => hir::Constness::NotConst, _ => hir::Constness::NotConst,

View File

@ -230,8 +230,9 @@ pub fn struct_lint_level<'s, 'd>(
err.allow_suggestions(false); err.allow_suggestions(false);
// If this is a future incompatible lint it'll become a hard error, so // If this is a future incompatible lint it'll become a hard error, so
// we have to emit *something*. Also allow lints to whitelist themselves // we have to emit *something*. Also, if this lint occurs in the
// on a case-by-case basis for emission in a foreign macro. // expansion of a macro from an external crate, allow individual lints
// to opt-out from being reported.
if future_incompatible.is_none() && !lint.report_in_external_macro { if future_incompatible.is_none() && !lint.report_in_external_macro {
err.cancel(); err.cancel();
// Don't continue further, since we don't want to have // Don't continue further, since we don't want to have

View File

@ -42,19 +42,18 @@ impl<'tcx> TyCtxt<'tcx> {
} }
} }
/// Returns `true` if the specified `lang_item` doesn't actually need to be /// Returns `true` if the specified `lang_item` must be present for this
/// present for this compilation. /// compilation.
/// ///
/// Not all lang items are always required for each compilation, particularly in /// Not all lang items are always required for each compilation, particularly in
/// the case of panic=abort. In these situations some lang items are injected by /// the case of panic=abort. In these situations some lang items are injected by
/// crates and don't actually need to be defined in libstd. /// crates and don't actually need to be defined in libstd.
pub fn whitelisted(tcx: TyCtxt<'_>, lang_item: LangItem) -> bool { pub fn required(tcx: TyCtxt<'_>, lang_item: LangItem) -> bool {
// If we're not compiling with unwinding, we won't actually need these // If we're not compiling with unwinding, we won't actually need these
// symbols. Other panic runtimes ensure that the relevant symbols are // symbols. Other panic runtimes ensure that the relevant symbols are
// available to link things together, but they're never exercised. // available to link things together, but they're never exercised.
if tcx.sess.panic_strategy() != PanicStrategy::Unwind { match tcx.sess.panic_strategy() {
return lang_item == LangItem::EhPersonalityLangItem; PanicStrategy::Abort => lang_item != LangItem::EhPersonalityLangItem,
PanicStrategy::Unwind => true,
} }
false
} }

View File

@ -1413,10 +1413,10 @@ rustc_queries! {
} }
Other { Other {
query target_features_whitelist(_: CrateNum) -> FxHashMap<String, Option<Symbol>> { query supported_target_features(_: CrateNum) -> FxHashMap<String, Option<Symbol>> {
storage(ArenaCacheSelector<'tcx>) storage(ArenaCacheSelector<'tcx>)
eval_always eval_always
desc { "looking up the whitelist of target features" } desc { "looking up supported target features" }
} }
// Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning. // Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning.

View File

@ -88,7 +88,7 @@ pub fn is_parent_const_impl_raw(tcx: TyCtxt<'_>, hir_id: hir::HirId) -> bool {
} }
/// Checks whether the function has a `const` modifier or, in case it is an intrinsic, whether /// Checks whether the function has a `const` modifier or, in case it is an intrinsic, whether
/// said intrinsic is on the whitelist for being const callable. /// said intrinsic has a `rustc_const_{un,}stable` attribute.
fn is_const_fn_raw(tcx: TyCtxt<'_>, def_id: DefId) -> bool { fn is_const_fn_raw(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
let hir_id = tcx.hir().as_local_hir_id(def_id.expect_local()); let hir_id = tcx.hir().as_local_hir_id(def_id.expect_local());

View File

@ -45,7 +45,7 @@ macro_rules! throw_validation_failure {
/// If $e throws an error matching the pattern, throw a validation failure. /// If $e throws an error matching the pattern, throw a validation failure.
/// Other errors are passed back to the caller, unchanged -- and if they reach the root of /// Other errors are passed back to the caller, unchanged -- and if they reach the root of
/// the visitor, we make sure only validation errors and `InvalidProgram` errors are left. /// the visitor, we make sure only validation errors and `InvalidProgram` errors are left.
/// This lets you use the patterns as a kind of validation whitelist, asserting which errors /// This lets you use the patterns as a kind of validation list, asserting which errors
/// can possibly happen: /// can possibly happen:
/// ///
/// ``` /// ```

View File

@ -7,7 +7,7 @@ use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::lang_items; use rustc_hir::lang_items;
use rustc_hir::lang_items::ITEM_REFS; use rustc_hir::lang_items::ITEM_REFS;
use rustc_hir::weak_lang_items::WEAK_ITEMS_REFS; use rustc_hir::weak_lang_items::WEAK_ITEMS_REFS;
use rustc_middle::middle::lang_items::whitelisted; use rustc_middle::middle::lang_items::required;
use rustc_middle::ty::TyCtxt; use rustc_middle::ty::TyCtxt;
use rustc_session::config::CrateType; use rustc_session::config::CrateType;
use rustc_span::symbol::sym; use rustc_span::symbol::sym;
@ -59,7 +59,7 @@ fn verify<'tcx>(tcx: TyCtxt<'tcx>, items: &lang_items::LanguageItems) {
} }
for (name, &item) in WEAK_ITEMS_REFS.iter() { for (name, &item) in WEAK_ITEMS_REFS.iter() {
if missing.contains(&item) && !whitelisted(tcx, item) && items.require(item).is_err() { if missing.contains(&item) && required(tcx, item) && items.require(item).is_err() {
if item == lang_items::PanicImplLangItem { if item == lang_items::PanicImplLangItem {
tcx.sess.err("`#[panic_handler]` function required, but not found"); tcx.sess.err("`#[panic_handler]` function required, but not found");
} else if item == lang_items::OomLangItem { } else if item == lang_items::OomLangItem {

View File

@ -2122,7 +2122,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
self.impl_self self.impl_self
{ {
match path.res { match path.res {
// Whitelist the types that unambiguously always // Permit the types that unambiguously always
// result in the same type constructor being used // result in the same type constructor being used
// (it can't differ between `Self` and `self`). // (it can't differ between `Self` and `self`).
Res::Def(DefKind::Struct | DefKind::Union | DefKind::Enum, _) Res::Def(DefKind::Struct | DefKind::Union | DefKind::Enum, _)

View File

@ -16,8 +16,8 @@ pub(super) fn test_target(target: TargetResult) {
impl Target { impl Target {
fn check_consistency(&self) { fn check_consistency(&self) {
// Check that LLD with the given flavor is treated identically to the linker it emulates. // Check that LLD with the given flavor is treated identically to the linker it emulates.
// If you target really needs to deviate from the rules below, whitelist it // If your target really needs to deviate from the rules below, except it and document the
// and document the reasons. // reasons.
assert_eq!( assert_eq!(
self.linker_flavor == LinkerFlavor::Msvc self.linker_flavor == LinkerFlavor::Msvc
|| self.linker_flavor == LinkerFlavor::Lld(LldFlavor::Link), || self.linker_flavor == LinkerFlavor::Lld(LldFlavor::Link),

View File

@ -40,14 +40,14 @@ pub fn options() -> TargetOptions {
// corrupting static data. // corrupting static data.
arg("--stack-first"); arg("--stack-first");
// FIXME we probably shouldn't pass this but instead pass an explicit // FIXME we probably shouldn't pass this but instead pass an explicit list
// whitelist of symbols we'll allow to be undefined. We don't currently have // of symbols we'll allow to be undefined. We don't currently have a
// a mechanism of knowing, however, which symbols are intended to be // mechanism of knowing, however, which symbols are intended to be imported
// imported from the environment and which are intended to be imported from // from the environment and which are intended to be imported from other
// other objects linked elsewhere. This is a coarse approximation but is // objects linked elsewhere. This is a coarse approximation but is sure to
// sure to hide some bugs and frustrate someone at some point, so we should // hide some bugs and frustrate someone at some point, so we should ideally
// ideally work towards a world where we can explicitly list symbols that // work towards a world where we can explicitly list symbols that are
// are supposed to be imported and have all other symbols generate errors if // supposed to be imported and have all other symbols generate errors if
// they remain undefined. // they remain undefined.
arg("--allow-undefined"); arg("--allow-undefined");

View File

@ -2139,7 +2139,7 @@ pub trait NextTypeParamName {
impl NextTypeParamName for &[hir::GenericParam<'_>] { impl NextTypeParamName for &[hir::GenericParam<'_>] {
fn next_type_param_name(&self, name: Option<&str>) -> String { fn next_type_param_name(&self, name: Option<&str>) -> String {
// This is the whitelist of possible parameter names that we might suggest. // This is the list of possible parameter names that we might suggest.
let name = name.and_then(|n| n.chars().next()).map(|c| c.to_string().to_uppercase()); let name = name.and_then(|n| n.chars().next()).map(|c| c.to_string().to_uppercase());
let name = name.as_deref(); let name = name.as_deref();
let possible_names = [name.unwrap_or("T"), "T", "U", "V", "X", "Y", "Z", "A", "B", "C"]; let possible_names = [name.unwrap_or("T"), "T", "U", "V", "X", "Y", "Z", "A", "B", "C"];

View File

@ -236,7 +236,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.tcx .tcx
.get_attrs(m.def_id) .get_attrs(m.def_id)
.iter() .iter()
// This special internal attribute is used to whitelist // This special internal attribute is used to permit
// "identity-like" conversion methods to be suggested here. // "identity-like" conversion methods to be suggested here.
// //
// FIXME (#46459 and #46460): ideally // FIXME (#46459 and #46460): ideally

View File

@ -913,7 +913,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let ty::Adt(..) = rcvr_t.kind { if let ty::Adt(..) = rcvr_t.kind {
// Try alternative arbitrary self types that could fulfill this call. // Try alternative arbitrary self types that could fulfill this call.
// FIXME: probe for all types that *could* be arbitrary self-types, not // FIXME: probe for all types that *could* be arbitrary self-types, not
// just this whitelist. // just this list.
try_alt_rcvr(&mut err, self.tcx.mk_lang_item(rcvr_t, lang_items::OwnedBoxLangItem)); try_alt_rcvr(&mut err, self.tcx.mk_lang_item(rcvr_t, lang_items::OwnedBoxLangItem));
try_alt_rcvr(&mut err, self.tcx.mk_lang_item(rcvr_t, lang_items::PinTypeLangItem)); try_alt_rcvr(&mut err, self.tcx.mk_lang_item(rcvr_t, lang_items::PinTypeLangItem));
try_alt_rcvr(&mut err, self.tcx.mk_diagnostic_item(rcvr_t, sym::Arc)); try_alt_rcvr(&mut err, self.tcx.mk_diagnostic_item(rcvr_t, sym::Arc));
@ -1806,7 +1806,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// If this is an input value, we require its type to be fully resolved // If this is an input value, we require its type to be fully resolved
// at this point. This allows us to provide helpful coercions which help // at this point. This allows us to provide helpful coercions which help
// pass the type whitelist in a later pass. // pass the type candidate list in a later pass.
// //
// We don't require output types to be resolved at this point, which // We don't require output types to be resolved at this point, which
// allows them to be inferred based on how they are used later in the // allows them to be inferred based on how they are used later in the

View File

@ -2150,7 +2150,7 @@ fn from_target_feature(
tcx: TyCtxt<'_>, tcx: TyCtxt<'_>,
id: DefId, id: DefId,
attr: &ast::Attribute, attr: &ast::Attribute,
whitelist: &FxHashMap<String, Option<Symbol>>, supported_target_features: &FxHashMap<String, Option<Symbol>>,
target_features: &mut Vec<Symbol>, target_features: &mut Vec<Symbol>,
) { ) {
let list = match attr.meta_item_list() { let list = match attr.meta_item_list() {
@ -2184,8 +2184,7 @@ fn from_target_feature(
// We allow comma separation to enable multiple features. // We allow comma separation to enable multiple features.
target_features.extend(value.as_str().split(',').filter_map(|feature| { target_features.extend(value.as_str().split(',').filter_map(|feature| {
// Only allow whitelisted features per platform. let feature_gate = match supported_target_features.get(feature) {
let feature_gate = match whitelist.get(feature) {
Some(g) => g, Some(g) => g,
None => { None => {
let msg = let msg =
@ -2196,7 +2195,7 @@ fn from_target_feature(
format!("`{}` is not valid for this target", feature), format!("`{}` is not valid for this target", feature),
); );
if feature.starts_with('+') { if feature.starts_with('+') {
let valid = whitelist.contains_key(&feature[1..]); let valid = supported_target_features.contains_key(&feature[1..]);
if valid { if valid {
err.help("consider removing the leading `+` in the feature name"); err.help("consider removing the leading `+` in the feature name");
} }
@ -2246,9 +2245,9 @@ fn linkage_by_name(tcx: TyCtxt<'_>, def_id: DefId, name: &str) -> Linkage {
// Use the names from src/llvm/docs/LangRef.rst here. Most types are only // Use the names from src/llvm/docs/LangRef.rst here. Most types are only
// applicable to variable declarations and may not really make sense for // applicable to variable declarations and may not really make sense for
// Rust code in the first place but whitelist them anyway and trust that // Rust code in the first place but allow them anyway and trust that the
// the user knows what s/he's doing. Who knows, unanticipated use cases // user knows what s/he's doing. Who knows, unanticipated use cases may pop
// may pop up in the future. // up in the future.
// //
// ghost, dllimport, dllexport and linkonce_odr_autohide are not supported // ghost, dllimport, dllexport and linkonce_odr_autohide are not supported
// and don't have to be, LLVM treats them as no-ops. // and don't have to be, LLVM treats them as no-ops.
@ -2283,7 +2282,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
codegen_fn_attrs.flags |= CodegenFnAttrFlags::TRACK_CALLER; codegen_fn_attrs.flags |= CodegenFnAttrFlags::TRACK_CALLER;
} }
let whitelist = tcx.target_features_whitelist(LOCAL_CRATE); let supported_target_features = tcx.supported_target_features(LOCAL_CRATE);
let mut inline_span = None; let mut inline_span = None;
let mut link_ordinal_span = None; let mut link_ordinal_span = None;
@ -2386,7 +2385,13 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
check_target_feature_trait_unsafe(tcx, local_id, attr.span); check_target_feature_trait_unsafe(tcx, local_id, attr.span);
} }
} }
from_target_feature(tcx, id, attr, &whitelist, &mut codegen_fn_attrs.target_features); from_target_feature(
tcx,
id,
attr,
&supported_target_features,
&mut codegen_fn_attrs.target_features,
);
} else if attr.check_name(sym::linkage) { } else if attr.check_name(sym::linkage) {
if let Some(val) = attr.value_str() { if let Some(val) = attr.value_str() {
codegen_fn_attrs.linkage = Some(linkage_by_name(tcx, id, &val.as_str())); codegen_fn_attrs.linkage = Some(linkage_by_name(tcx, id, &val.as_str()));

View File

@ -225,7 +225,7 @@ pub fn new_handler(
/// * Vector of tuples of lints' name and their associated "max" level /// * Vector of tuples of lints' name and their associated "max" level
/// * HashMap of lint id with their associated "max" level /// * HashMap of lint id with their associated "max" level
pub fn init_lints<F>( pub fn init_lints<F>(
mut whitelisted_lints: Vec<String>, mut allowed_lints: Vec<String>,
lint_opts: Vec<(String, lint::Level)>, lint_opts: Vec<(String, lint::Level)>,
filter_call: F, filter_call: F,
) -> (Vec<(String, lint::Level)>, FxHashMap<lint::LintId, lint::Level>) ) -> (Vec<(String, lint::Level)>, FxHashMap<lint::LintId, lint::Level>)
@ -234,8 +234,8 @@ where
{ {
let warnings_lint_name = lint::builtin::WARNINGS.name; let warnings_lint_name = lint::builtin::WARNINGS.name;
whitelisted_lints.push(warnings_lint_name.to_owned()); allowed_lints.push(warnings_lint_name.to_owned());
whitelisted_lints.extend(lint_opts.iter().map(|(lint, _)| lint).cloned()); allowed_lints.extend(lint_opts.iter().map(|(lint, _)| lint).cloned());
let lints = || { let lints = || {
lint::builtin::HardwiredLints::get_lints() lint::builtin::HardwiredLints::get_lints()
@ -245,7 +245,7 @@ where
let lint_opts = lints() let lint_opts = lints()
.filter_map(|lint| { .filter_map(|lint| {
// Whitelist feature-gated lints to avoid feature errors when trying to // Permit feature-gated lints to avoid feature errors when trying to
// allow all lints. // allow all lints.
if lint.name == warnings_lint_name || lint.feature_gate.is_some() { if lint.name == warnings_lint_name || lint.feature_gate.is_some() {
None None
@ -258,9 +258,9 @@ where
let lint_caps = lints() let lint_caps = lints()
.filter_map(|lint| { .filter_map(|lint| {
// We don't want to whitelist *all* lints so let's // We don't want to allow *all* lints so let's ignore
// ignore those ones. // those ones.
if whitelisted_lints.iter().any(|l| lint.name == l) { if allowed_lints.iter().any(|l| lint.name == l) {
None None
} else { } else {
Some((lint::LintId::of(lint), lint::Allow)) Some((lint::LintId::of(lint), lint::Allow))
@ -317,9 +317,9 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
let no_crate_level_docs = rustc_lint::builtin::MISSING_CRATE_LEVEL_DOCS.name; let no_crate_level_docs = rustc_lint::builtin::MISSING_CRATE_LEVEL_DOCS.name;
let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name; let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name;
// In addition to those specific lints, we also need to whitelist those given through // In addition to those specific lints, we also need to allow those given through
// command line, otherwise they'll get ignored and we don't want that. // command line, otherwise they'll get ignored and we don't want that.
let whitelisted_lints = vec![ let allowed_lints = vec![
intra_link_resolution_failure_name.to_owned(), intra_link_resolution_failure_name.to_owned(),
missing_docs.to_owned(), missing_docs.to_owned(),
missing_doc_example.to_owned(), missing_doc_example.to_owned(),
@ -328,7 +328,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
invalid_codeblock_attribute_name.to_owned(), invalid_codeblock_attribute_name.to_owned(),
]; ];
let (lint_opts, lint_caps) = init_lints(whitelisted_lints, lint_opts, |lint| { let (lint_opts, lint_caps) = init_lints(allowed_lints, lint_opts, |lint| {
if lint.name == intra_link_resolution_failure_name if lint.name == intra_link_resolution_failure_name
|| lint.name == invalid_codeblock_attribute_name || lint.name == invalid_codeblock_attribute_name
{ {

View File

@ -3151,7 +3151,7 @@ fn item_enum(w: &mut Buffer, cx: &Context, it: &clean::Item, e: &clean::Enum) {
render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All) render_assoc_items(w, cx, it, it.def_id, AssocItemRender::All)
} }
const ATTRIBUTE_WHITELIST: &[Symbol] = &[ const ALLOWED_ATTRIBUTES: &[Symbol] = &[
sym::export_name, sym::export_name,
sym::lang, sym::lang,
sym::link_section, sym::link_section,
@ -3173,7 +3173,7 @@ fn render_attributes(w: &mut Buffer, it: &clean::Item, top: bool) {
let mut attrs = String::new(); let mut attrs = String::new();
for attr in &it.attrs.other_attrs { for attr in &it.attrs.other_attrs {
if !ATTRIBUTE_WHITELIST.contains(&attr.name_or_empty()) { if !ALLOWED_ATTRIBUTES.contains(&attr.name_or_empty()) {
continue; continue;
} }

View File

@ -47,11 +47,11 @@ pub fn run(options: Options) -> Result<(), String> {
let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name; let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name;
// In addition to those specific lints, we also need to whitelist those given through // In addition to those specific lints, we also need to allow those given through
// command line, otherwise they'll get ignored and we don't want that. // command line, otherwise they'll get ignored and we don't want that.
let whitelisted_lints = vec![invalid_codeblock_attribute_name.to_owned()]; let allowed_lints = vec![invalid_codeblock_attribute_name.to_owned()];
let (lint_opts, lint_caps) = init_lints(whitelisted_lints, options.lint_opts.clone(), |lint| { let (lint_opts, lint_caps) = init_lints(allowed_lints, options.lint_opts.clone(), |lint| {
if lint.name == invalid_codeblock_attribute_name { if lint.name == invalid_codeblock_attribute_name {
None None
} else { } else {

View File

@ -241,7 +241,7 @@ impl Instant {
// returned instead of what the OS says if the OS goes backwards. // returned instead of what the OS says if the OS goes backwards.
// //
// To hopefully mitigate the impact of this, a few platforms are // To hopefully mitigate the impact of this, a few platforms are
// whitelisted as "these at least haven't gone backwards yet". // excluded as "these at least haven't gone backwards yet".
if time::Instant::actually_monotonic() { if time::Instant::actually_monotonic() {
return Instant(os_now); return Instant(os_now);
} }

View File

@ -52,7 +52,7 @@ impl CodegenBackend for TheBackend {
fn provide(&self, providers: &mut Providers) { fn provide(&self, providers: &mut Providers) {
rustc_symbol_mangling::provide(providers); rustc_symbol_mangling::provide(providers);
providers.target_features_whitelist = |tcx, _cnum| { providers.supported_target_features = |tcx, _cnum| {
Default::default() // Just a dummy Default::default() // Just a dummy
}; };
providers.is_reachable_non_generic = |_tcx, _defid| true; 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 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! # we don't check for the instability of these crates as they're all stable!
STABLE_CRATES = ['std', 'alloc', 'core', 'proc_macro', STABLE_CRATES = ['std', 'alloc', 'core', 'proc_macro',
'rsbegin.o', 'rsend.o', 'dllcrt2.o', 'crt2.o', 'clang_rt'] 'rsbegin.o', 'rsend.o', 'dllcrt2.o', 'crt2.o', 'clang_rt']

View File

@ -21,19 +21,19 @@ use rustc_span::source_map;
#[plugin_registrar] #[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) { pub fn plugin_registrar(reg: &mut Registry) {
reg.lint_store.register_lints(&[&MISSING_WHITELISTED_ATTR]); reg.lint_store.register_lints(&[&MISSING_ALLOWED_ATTR]);
reg.lint_store.register_late_pass(|| box MissingWhitelistedAttrPass); reg.lint_store.register_late_pass(|| box MissingAllowedAttrPass);
} }
declare_lint! { declare_lint! {
MISSING_WHITELISTED_ATTR, MISSING_ALLOWED_ATTR,
Deny, 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( fn check_fn(
&mut self, &mut self,
cx: &LateContext<'tcx>, 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)), _ => cx.tcx.hir().expect_item(cx.tcx.hir().get_parent_item(id)),
}; };
let whitelisted = |attr| pprust::attribute_to_string(attr).contains("whitelisted_attr"); let allowed = |attr| pprust::attribute_to_string(attr).contains("allowed_attr");
if !item.attrs.iter().any(whitelisted) { if !item.attrs.iter().any(allowed) {
cx.lint(MISSING_WHITELISTED_ATTR, |lint| { cx.lint(MISSING_ALLOWED_ATTR, |lint| {
lint.build("Missing 'whitelisted_attr' attribute").set_span(span).emit() 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 #![plugin(issue_40001_plugin)] //~ WARNING compiler plugins are deprecated
#![register_tool(plugin)] #![register_tool(plugin)]
#[plugin::whitelisted_attr] #[plugin::allowed_attr]
fn main() {} fn main() {}

View File

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

View File

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

View File

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

View File

@ -20,7 +20,7 @@ fn main() {
assert!(cfg!(target_feature = "sse2"), assert!(cfg!(target_feature = "sse2"),
"SSE2 was not detected as available on an x86 platform"); "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")), assert!(cfg!(not(target_feature = "avx2")),
"AVX2 shouldn't be detected as available by default on any platform"); "AVX2 shouldn't be detected as available by default on any platform");
} }

View File

@ -72,7 +72,7 @@ declare_clippy_lint! {
/// **What it does:** Checks for `extern crate` and `use` items annotated with /// **What it does:** Checks for `extern crate` and `use` items annotated with
/// lint attributes. /// lint attributes.
/// ///
/// This lint whitelists `#[allow(unused_imports)]`, `#[allow(deprecated)]` and /// This lint permits `#[allow(unused_imports)]`, `#[allow(deprecated)]` and
/// `#[allow(unreachable_pub)]` on `use` items and `#[allow(unused_imports)]` on /// `#[allow(unreachable_pub)]` on `use` items and `#[allow(unused_imports)]` on
/// `extern crate` items with a `#[macro_use]` attribute. /// `extern crate` items with a `#[macro_use]` attribute.
/// ///
@ -294,7 +294,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
if let Some(ident) = attr.ident() { if let Some(ident) = attr.ident() {
match &*ident.as_str() { match &*ident.as_str() {
"allow" | "warn" | "deny" | "forbid" => { "allow" | "warn" | "deny" | "forbid" => {
// whitelist `unused_imports`, `deprecated` and `unreachable_pub` for `use` items // permit `unused_imports`, `deprecated` and `unreachable_pub` for `use` items
// and `unused_imports` for `extern crate` items with `macro_use` // and `unused_imports` for `extern crate` items with `macro_use`
for lint in lint_list { for lint in lint_list {
match item.kind { match item.kind {

View File

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

View File

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

View File

@ -78,7 +78,7 @@ struct ExistingName {
interned: SymbolStr, interned: SymbolStr,
span: Span, span: Span,
len: usize, len: usize,
whitelist: &'static [&'static str], exemptions: &'static [&'static str],
} }
struct SimilarNamesLocalVisitor<'a, 'tcx> { struct SimilarNamesLocalVisitor<'a, 'tcx> {
@ -117,7 +117,7 @@ impl<'a, 'tcx> SimilarNamesLocalVisitor<'a, 'tcx> {
// this list contains lists of names that are allowed to be similar // this list contains lists of names that are allowed to be similar
// the assumption is that no name is ever contained in multiple lists. // the assumption is that no name is ever contained in multiple lists.
#[rustfmt::skip] #[rustfmt::skip]
const WHITELIST: &[&[&str]] = &[ const ALLOWED_TO_BE_SIMILAR: &[&[&str]] = &[
&["parsed", "parser"], &["parsed", "parser"],
&["lhs", "rhs"], &["lhs", "rhs"],
&["tx", "rx"], &["tx", "rx"],
@ -156,17 +156,17 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for SimilarNamesNameVisitor<'a, 'tcx, 'b> {
} }
#[must_use] #[must_use]
fn get_whitelist(interned_name: &str) -> Option<&'static [&'static str]> { fn get_exemptions(interned_name: &str) -> Option<&'static [&'static str]> {
for &allow in WHITELIST { for &list in ALLOWED_TO_BE_SIMILAR {
if whitelisted(interned_name, allow) { if allowed_to_be_similar(interned_name, list) {
return Some(allow); return Some(list);
} }
} }
None None
} }
#[must_use] #[must_use]
fn whitelisted(interned_name: &str, list: &[&str]) -> bool { fn allowed_to_be_similar(interned_name: &str, list: &[&str]) -> bool {
list.iter() list.iter()
.any(|&name| interned_name.starts_with(name) || interned_name.ends_with(name)) .any(|&name| interned_name.starts_with(name) || interned_name.ends_with(name))
} }
@ -212,7 +212,7 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
return; return;
} }
for existing_name in &self.0.names { 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; continue;
} }
let mut split_at = None; let mut split_at = None;
@ -301,7 +301,7 @@ impl<'a, 'tcx, 'b> SimilarNamesNameVisitor<'a, 'tcx, 'b> {
return; return;
} }
self.0.names.push(ExistingName { self.0.names.push(ExistingName {
whitelist: get_whitelist(&interned_name).unwrap_or(&[]), exemptions: get_exemptions(&interned_name).unwrap_or(&[]),
interned: interned_name, interned: interned_name,
span: ident.span, span: ident.span,
len: count, len: count,

View File

@ -5,7 +5,7 @@ use rustc_lint::{EarlyContext, EarlyLintPass};
use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::source_map::Spanned; use rustc_span::source_map::Spanned;
const ODD_FUNCTIONS_WHITELIST: [&str; 14] = [ const ALLOWED_ODD_FUNCTIONS: [&str; 14] = [
"asin", "asin",
"asinh", "asinh",
"atan", "atan",
@ -109,7 +109,7 @@ impl EarlyLintPass for Precedence {
if let ExprKind::Lit(ref lit) = slf.kind { if let ExprKind::Lit(ref lit) = slf.kind {
match lit.kind { match lit.kind {
LitKind::Int(..) | LitKind::Float(..) => { LitKind::Int(..) | LitKind::Float(..) => {
if ODD_FUNCTIONS_WHITELIST if ALLOWED_ODD_FUNCTIONS
.iter() .iter()
.any(|odd_function| **odd_function == *path_segment_str) .any(|odd_function| **odd_function == *path_segment_str)
{ {

View File

@ -1256,7 +1256,7 @@ fn check_loss_of_sign(cx: &LateContext<'_>, expr: &Expr<'_>, op: &Expr<'_>, cast
// don't lint for the result of methods that always return non-negative values // don't lint for the result of methods that always return non-negative values
if let ExprKind::MethodCall(ref path, _, _, _) = op.kind { if let ExprKind::MethodCall(ref path, _, _, _) = op.kind {
let mut method_name = path.ident.name.as_str(); let mut method_name = path.ident.name.as_str();
let whitelisted_methods = ["abs", "checked_abs", "rem_euclid", "checked_rem_euclid"]; let allowed_methods = ["abs", "checked_abs", "rem_euclid", "checked_rem_euclid"];
if_chain! { if_chain! {
if method_name == "unwrap"; if method_name == "unwrap";
@ -1267,7 +1267,7 @@ fn check_loss_of_sign(cx: &LateContext<'_>, expr: &Expr<'_>, op: &Expr<'_>, cast
} }
} }
if whitelisted_methods.iter().any(|&name| method_name == name) { if allowed_methods.iter().any(|&name| method_name == name) {
return; return;
} }
} }

View File

@ -116,7 +116,7 @@ extern "C" fn ext(x: MaybeUninit<usize>) -> usize {
unsafe { x.assume_init() } unsafe { x.assume_init() }
} }
// whitelist RangeArgument // exempt RangeArgument
fn range<T: ::std::ops::RangeBounds<usize>>(range: T) { fn range<T: ::std::ops::RangeBounds<usize>>(range: T) {
let _ = range.start_bound(); let _ = range.start_bound();
} }

View File

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

View File

@ -11,8 +11,8 @@
//! These values are then translated to file URLs if possible and then the //! These values are then translated to file URLs if possible and then the
//! destination is asserted to exist. //! destination is asserted to exist.
//! //!
//! A few whitelisted exceptions are allowed as there's known bugs in rustdoc, //! A few exceptions are allowed as there's known bugs in rustdoc, but this
//! but this should catch the majority of "broken link" cases. //! should catch the majority of "broken link" cases.
use std::collections::hash_map::Entry; use std::collections::hash_map::Entry;
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
@ -118,7 +118,7 @@ fn check(cache: &mut Cache, root: &Path, file: &Path, errors: &mut bool) -> Opti
} }
// Unfortunately we're not 100% full of valid links today to we need a few // Unfortunately we're not 100% full of valid links today to we need a few
// whitelists to get this past `make check` today. // exceptions to get this past `make check` today.
// FIXME(#32129) // FIXME(#32129)
if file.ends_with("std/io/struct.IoSlice.html") if file.ends_with("std/io/struct.IoSlice.html")
|| file.ends_with("std/string/struct.String.html") || file.ends_with("std/string/struct.String.html")

View File

@ -73,8 +73,8 @@ fn verify(tomlfile: &Path, libfile: &Path, bad: &mut bool) {
// This is intentional -- this dependency just makes the crate available // This is intentional -- this dependency just makes the crate available
// for others later on. // for others later on.
let whitelisted = krate.starts_with("panic"); let allowed = krate.starts_with("panic");
if toml.contains("name = \"std\"") && whitelisted { if toml.contains("name = \"std\"") && allowed {
continue; continue;
} }

View File

@ -49,14 +49,14 @@ const EXCEPTIONS: &[(&str, &str)] = &[
/// these and all their dependencies *must not* be in the exception list. /// these and all their dependencies *must not* be in the exception list.
const RUNTIME_CRATES: &[&str] = &["std", "core", "alloc", "test", "panic_abort", "panic_unwind"]; const RUNTIME_CRATES: &[&str] = &["std", "core", "alloc", "test", "panic_abort", "panic_unwind"];
/// Which crates to check against the whitelist? /// Crates whose dependencies must be explicitly permitted.
const WHITELIST_CRATES: &[&str] = &["rustc_middle", "rustc_codegen_llvm"]; const RESTRICTED_DEPENDENCY_CRATES: &[&str] = &["rustc_middle", "rustc_codegen_llvm"];
/// Whitelist of crates rustc is allowed to depend on. Avoid adding to the list if possible. /// Crates rustc is allowed to depend on. Avoid adding to the list if possible.
/// ///
/// This list is here to provide a speed-bump to adding a new dependency to /// This list is here to provide a speed-bump to adding a new dependency to
/// rustc. Please check with the compiler team before adding an entry. /// rustc. Please check with the compiler team before adding an entry.
const WHITELIST: &[&str] = &[ const PERMITTED_DEPENDENCIES: &[&str] = &[
"adler32", "adler32",
"aho-corasick", "aho-corasick",
"annotate-snippets", "annotate-snippets",
@ -190,7 +190,7 @@ pub fn check(path: &Path, cargo: &Path, bad: &mut bool) {
.features(cargo_metadata::CargoOpt::AllFeatures); .features(cargo_metadata::CargoOpt::AllFeatures);
let metadata = t!(cmd.exec()); let metadata = t!(cmd.exec());
check_exceptions(&metadata, bad); check_exceptions(&metadata, bad);
check_whitelist(&metadata, bad); check_dependencies(&metadata, bad);
check_crate_duplicate(&metadata, bad); check_crate_duplicate(&metadata, bad);
} }
@ -272,36 +272,37 @@ fn check_exceptions(metadata: &Metadata, bad: &mut bool) {
} }
} }
/// Checks the dependency of `WHITELIST_CRATES` at the given path. Changes `bad` to `true` if a /// Checks the dependency of `RESTRICTED_DEPENDENCY_CRATES` at the given path. Changes `bad` to
/// check failed. /// `true` if a check failed.
/// ///
/// Specifically, this checks that the dependencies are on the `WHITELIST`. /// Specifically, this checks that the dependencies are on the `PERMITTED_DEPENDENCIES`.
fn check_whitelist(metadata: &Metadata, bad: &mut bool) { fn check_dependencies(metadata: &Metadata, bad: &mut bool) {
// Check that the WHITELIST does not have unused entries. // Check that the PERMITTED_DEPENDENCIES does not have unused entries.
for name in WHITELIST { for name in PERMITTED_DEPENDENCIES {
if !metadata.packages.iter().any(|p| p.name == *name) { if !metadata.packages.iter().any(|p| p.name == *name) {
println!( println!(
"could not find whitelisted package `{}`\n\ "could not find allowed package `{}`\n\
Remove from WHITELIST list if it is no longer used.", Remove from PERMITTED_DEPENDENCIES list if it is no longer used.",
name name
); );
*bad = true; *bad = true;
} }
} }
// Get the whitelist in a convenient form. // Get the list in a convenient form.
let whitelist: HashSet<_> = WHITELIST.iter().cloned().collect(); let permitted_dependencies: HashSet<_> = PERMITTED_DEPENDENCIES.iter().cloned().collect();
// Check dependencies. // Check dependencies.
let mut visited = BTreeSet::new(); let mut visited = BTreeSet::new();
let mut unapproved = BTreeSet::new(); let mut unapproved = BTreeSet::new();
for &krate in WHITELIST_CRATES.iter() { for &krate in RESTRICTED_DEPENDENCY_CRATES.iter() {
let pkg = pkg_from_name(metadata, krate); let pkg = pkg_from_name(metadata, krate);
let mut bad = check_crate_whitelist(&whitelist, metadata, &mut visited, pkg); let mut bad =
check_crate_dependencies(&permitted_dependencies, metadata, &mut visited, pkg);
unapproved.append(&mut bad); unapproved.append(&mut bad);
} }
if !unapproved.is_empty() { if !unapproved.is_empty() {
println!("Dependencies not on the whitelist:"); println!("Dependencies not explicitly permitted:");
for dep in unapproved { for dep in unapproved {
println!("* {}", dep); println!("* {}", dep);
} }
@ -310,9 +311,9 @@ fn check_whitelist(metadata: &Metadata, bad: &mut bool) {
} }
/// Checks the dependencies of the given crate from the given cargo metadata to see if they are on /// Checks the dependencies of the given crate from the given cargo metadata to see if they are on
/// the whitelist. Returns a list of illegal dependencies. /// the list of permitted dependencies. Returns a list of disallowed dependencies.
fn check_crate_whitelist<'a>( fn check_crate_dependencies<'a>(
whitelist: &'a HashSet<&'static str>, permitted_dependencies: &'a HashSet<&'static str>,
metadata: &'a Metadata, metadata: &'a Metadata,
visited: &mut BTreeSet<&'a PackageId>, visited: &mut BTreeSet<&'a PackageId>,
krate: &'a Package, krate: &'a Package,
@ -327,10 +328,10 @@ fn check_crate_whitelist<'a>(
visited.insert(&krate.id); visited.insert(&krate.id);
// If this path is in-tree, we don't require it to be on the whitelist. // If this path is in-tree, we don't require it to be explicitly permitted.
if krate.source.is_some() { if krate.source.is_some() {
// If this dependency is not on `WHITELIST`, add to bad set. // If this dependency is not on `PERMITTED_DEPENDENCIES`, add to bad set.
if !whitelist.contains(krate.name.as_str()) { if !permitted_dependencies.contains(krate.name.as_str()) {
unapproved.insert(&krate.id); unapproved.insert(&krate.id);
} }
} }
@ -339,7 +340,7 @@ fn check_crate_whitelist<'a>(
let to_check = deps_of(metadata, &krate.id); let to_check = deps_of(metadata, &krate.id);
for dep in to_check { for dep in to_check {
let mut bad = check_crate_whitelist(whitelist, metadata, visited, dep); let mut bad = check_crate_dependencies(permitted_dependencies, metadata, visited, dep);
unapproved.append(&mut bad); unapproved.append(&mut bad);
} }

View File

@ -7,7 +7,7 @@ use std::fs::read_to_string;
use std::path::Path; use std::path::Path;
// A few of those error codes can't be tested but all the others can and *should* be tested! // A few of those error codes can't be tested but all the others can and *should* be tested!
const WHITELIST: &[&str] = &[ const EXEMPTED_FROM_TEST: &[&str] = &[
"E0183", "E0227", "E0279", "E0280", "E0311", "E0313", "E0314", "E0315", "E0377", "E0456", "E0183", "E0227", "E0279", "E0280", "E0311", "E0313", "E0314", "E0315", "E0377", "E0456",
"E0461", "E0462", "E0464", "E0465", "E0472", "E0473", "E0474", "E0475", "E0476", "E0479", "E0461", "E0462", "E0464", "E0465", "E0472", "E0473", "E0474", "E0475", "E0476", "E0479",
"E0480", "E0481", "E0482", "E0483", "E0484", "E0485", "E0486", "E0487", "E0488", "E0489", "E0480", "E0481", "E0482", "E0483", "E0484", "E0485", "E0486", "E0487", "E0488", "E0489",
@ -166,7 +166,7 @@ pub fn check(path: &Path, bad: &mut bool) {
println!("Found {} error codes", error_codes.len()); println!("Found {} error codes", error_codes.len());
for (err_code, nb) in &error_codes { for (err_code, nb) in &error_codes {
if !*nb && !WHITELIST.contains(&err_code.as_str()) { if !*nb && !EXEMPTED_FROM_TEST.contains(&err_code.as_str()) {
errors.push(format!("Error code {} needs to have at least one UI test!", err_code)); errors.push(format!("Error code {} needs to have at least one UI test!", err_code));
} }
} }

View File

@ -3,8 +3,8 @@
use std::fs; use std::fs;
use std::path::Path; use std::path::Path;
/// List of whitelisted sources for packages. /// List of allowed sources for packages.
const WHITELISTED_SOURCES: &[&str] = &["\"registry+https://github.com/rust-lang/crates.io-index\""]; const ALLOWED_SOURCES: &[&str] = &["\"registry+https://github.com/rust-lang/crates.io-index\""];
/// Checks for external package sources. /// Checks for external package sources.
pub fn check(path: &Path, bad: &mut bool) { pub fn check(path: &Path, bad: &mut bool) {
@ -24,8 +24,8 @@ pub fn check(path: &Path, bad: &mut bool) {
// Extract source value. // Extract source value.
let source = line.splitn(2, '=').nth(1).unwrap().trim(); let source = line.splitn(2, '=').nth(1).unwrap().trim();
// Ensure source is whitelisted. // Ensure source is allowed.
if !WHITELISTED_SOURCES.contains(&&*source) { if !ALLOWED_SOURCES.contains(&&*source) {
println!("invalid source: {}", source); println!("invalid source: {}", source);
*bad = true; *bad = true;
} }