From 8c43c93e6d8526ef6a3beb656003dd723aa0e952 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 9 Jun 2018 17:20:58 +0200 Subject: [PATCH] Fix options issues --- src/librustc_lint/builtin.rs | 33 +++++++++++++++++++ src/librustc_lint/lib.rs | 3 ++ src/librustdoc/core.rs | 13 +++----- .../deny-intra-link-resolution-failure.stderr | 16 ++++----- .../rustdoc-ui/intra-links-warning.stderr | 2 ++ 5 files changed, 49 insertions(+), 18 deletions(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 0a647365598..79796d78871 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1665,3 +1665,36 @@ fn check_item( } } } + +/// Does nothing as a lint pass, but registers some `Lint`s +/// which are used by other parts of the compiler. +#[derive(Copy, Clone)] +pub struct SoftLints; + +impl LintPass for SoftLints { + fn get_lints(&self) -> LintArray { + lint_array!( + WHILE_TRUE, + BOX_POINTERS, + NON_SHORTHAND_FIELD_PATTERNS, + UNSAFE_CODE, + MISSING_DOCS, + MISSING_COPY_IMPLEMENTATIONS, + MISSING_DEBUG_IMPLEMENTATIONS, + ANONYMOUS_PARAMETERS, + UNUSED_DOC_COMMENTS, + UNCONDITIONAL_RECURSION, + PLUGIN_AS_LIBRARY, + PRIVATE_NO_MANGLE_FNS, + PRIVATE_NO_MANGLE_STATICS, + NO_MANGLE_CONST_ITEMS, + NO_MANGLE_GENERIC_ITEMS, + MUTABLE_TRANSMUTES, + UNSTABLE_FEATURES, + UNIONS_WITH_DROP_FIELDS, + UNREACHABLE_PUB, + TYPE_ALIAS_BOUNDS, + TRIVIAL_BOUNDS, + ) + } +} diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 47f17285f5f..9ac22f8dceb 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -60,6 +60,9 @@ use types::*; use unused::*; +/// Useful for other parts of the compiler. +pub use builtin::SoftLints; + /// Tell the `LintStore` about all the built-in lints (the ones /// defined in this crate and the ones defined in /// `rustc::lint::builtin`). diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 9a733ab4249..f46d3d834ae 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -191,16 +191,13 @@ pub fn run_core(search_paths: SearchPaths, let warnings_lint_name = lint::builtin::WARNINGS.name; let lints = lint::builtin::HardwiredLints.get_lints() .iter() + .chain(rustc_lint::SoftLints.get_lints()) .filter_map(|lint| { - if lint.name == warnings_lint_name { + if lint.name == warnings_lint_name || + lint.name == intra_link_resolution_failure_name { None } else { - let level = if lint.name == intra_link_resolution_failure_name { - lint::Warn - } else { - lint::Allow - }; - Some((lint.name_lower(), level)) + Some((lint.name_lower(), lint::Allow)) } }) .collect::>(); @@ -216,7 +213,7 @@ pub fn run_core(search_paths: SearchPaths, } else { vec![] }, - lint_cap: Some(lint::Warn), + lint_cap: Some(lint::Forbid), cg, externs, target_triple: triple.unwrap_or(host_triple), diff --git a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr index 39fb33ce933..3aa45405fd4 100644 --- a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr +++ b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr @@ -1,16 +1,12 @@ -warning: [v2] cannot be resolved, ignoring it... - --> src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs:13:1 +error: `[v2]` cannot be resolved, ignoring it... + --> $DIR/deny-intra-link-resolution-failure.rs:13:6 | -LL | /// [v2] //~ ERROR - | ^^^^^^^^^^^^^^^^^^ +13 | /// [v2] //~ ERROR + | ^^ cannot be resolved, ignoring | note: lint level defined here - --> src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs:11:9 + --> $DIR/deny-intra-link-resolution-failure.rs:11:9 | -LL | #![deny(intra_link_resolution_failure)] +11 | #![deny(intra_link_resolution_failure)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: the link appears in this line: - - [v2] //~ ERROR - ^^ diff --git a/src/test/rustdoc-ui/intra-links-warning.stderr b/src/test/rustdoc-ui/intra-links-warning.stderr index 52adba5679f..4949c450343 100644 --- a/src/test/rustdoc-ui/intra-links-warning.stderr +++ b/src/test/rustdoc-ui/intra-links-warning.stderr @@ -3,6 +3,8 @@ warning: `[Foo::baz]` cannot be resolved, ignoring it... | 13 | //! Test with [Foo::baz], [Bar::foo], ... | ^^^^^^^^ cannot be resolved, ignoring + | + = note: #[warn(intra_link_resolution_failure)] on by default warning: `[Bar::foo]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:13:35