From 92cda8c7da86b6770a483bc45ce32c8b94b019ec Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 5 Jul 2018 20:06:33 +0200 Subject: [PATCH] Whitelist lints --- src/librustc_lint/builtin.rs | 2 +- src/librustc_lint/lib.rs | 2 +- src/librustdoc/core.rs | 23 +++++++++++++++++------ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index c5f3b45950e..d6e5c70b8f7 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -280,7 +280,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnsafeCode { } declare_lint! { - MISSING_DOCS, + pub MISSING_DOCS, Allow, "detects missing documentation for public members" } diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index adc700506ff..459f496c9fe 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -56,7 +56,7 @@ use lint::LintId; use lint::FutureIncompatibleInfo; mod bad_style; -mod builtin; +pub mod builtin; mod types; mod unused; diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 5cfdd07ab92..c7a8e6804f6 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -189,6 +189,7 @@ pub fn run_core(search_paths: SearchPaths, let intra_link_resolution_failure_name = lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURE.name; let warnings_lint_name = lint::builtin::WARNINGS.name; + let missing_docs = rustc_lint::builtin::MISSING_DOCS.name; let lints = lint::builtin::HardwiredLints.get_lints() .into_iter() .chain(rustc_lint::SoftLints.get_lints().into_iter()) @@ -236,12 +237,22 @@ pub fn run_core(search_paths: SearchPaths, sessopts, cpath, diagnostic_handler, codemap, ); - let shutdown_lints = [lint::builtin::UNUSED_IMPORTS, - lint::builtin::UNUSED_EXTERN_CRATES]; - - for l in &shutdown_lints { - sess.driver_lint_caps.insert(lint::LintId::of(l), lint::Allow); - } + lint::builtin::HardwiredLints.get_lints() + .into_iter() + .chain(rustc_lint::SoftLints.get_lints().into_iter()) + .filter_map(|lint| { + if lint.name == warnings_lint_name || + lint.name == intra_link_resolution_failure_name || + lint.name == missing_docs { + None + } else { + Some(lint) + } + }) + .for_each(|l| { + sess.driver_lint_caps.insert(lint::LintId::of(l), + lint::Allow); + }); let codegen_backend = rustc_driver::get_codegen_backend(&sess); let cstore = Rc::new(CStore::new(codegen_backend.metadata_loader()));