From b000cf07261af68c7aa47e10140c692bc03c85da Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 4 Jun 2018 23:44:35 +0200 Subject: [PATCH 1/8] Add lint for intra link resolution failure --- src/librustc/lint/builtin.rs | 7 +++++ src/librustdoc/clean/mod.rs | 20 +++++++++---- src/librustdoc/core.rs | 28 ++++++++++++++++--- .../deny-intra-link-resolution-failure.rs | 14 ++++++++++ .../deny-intra-link-resolution-failure.stderr | 16 +++++++++++ 5 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs create mode 100644 src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 02559e413fc6f..e2acd77a3b6cb 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -298,6 +298,12 @@ declare_lint! { "detects duplicate macro exports" } +declare_lint! { + pub INTRA_LINK_RESOLUTION_FAILURE, + Warn, + "warn about documentation intra links resolution failure" +} + /// Does nothing as a lint pass, but registers some `Lint`s /// which are used by other parts of the compiler. #[derive(Copy, Clone)] @@ -351,6 +357,7 @@ impl LintPass for HardwiredLints { UNSTABLE_NAME_COLLISIONS, DUPLICATE_ASSOCIATED_TYPE_BINDINGS, DUPLICATE_MACRO_EXPORTS, + INTRA_LINK_RESOLUTION_FAILURE, ) } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 3f883eab172db..8328a8385c314 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -21,7 +21,7 @@ pub use self::Visibility::{Public, Inherited}; use syntax; use rustc_target::spec::abi::Abi; -use syntax::ast::{self, AttrStyle, Ident}; +use syntax::ast::{self, AttrStyle, NodeId, Ident}; use syntax::attr; use syntax::codemap::{dummy_spanned, Spanned}; use syntax::feature_gate::UnstableFeatures; @@ -46,9 +46,10 @@ use rustc::middle::stability; use rustc::util::nodemap::{FxHashMap, FxHashSet}; use rustc_typeck::hir_ty_to_ty; use rustc::infer::region_constraints::{RegionConstraintData, Constraint}; +use rustc::lint as lint; + use std::collections::hash_map::Entry; use std::fmt; - use std::default::Default; use std::{mem, slice, vec}; use std::iter::{FromIterator, once}; @@ -1283,10 +1284,16 @@ fn resolution_failure( link_range.end + code_dox_len, ); - diag = cx.sess().struct_span_warn(sp, &msg); + diag = cx.tcx.struct_span_lint_node(lint::builtin::INTRA_LINK_RESOLUTION_FAILURE, + NodeId::new(0), + sp, + &msg); diag.span_label(sp, "cannot be resolved, ignoring"); } else { - diag = cx.sess().struct_span_warn(sp, &msg); + diag = cx.tcx.struct_span_lint_node(lint::builtin::INTRA_LINK_RESOLUTION_FAILURE, + NodeId::new(0), + sp, + &msg); let last_new_line_offset = dox[..link_range.start].rfind('\n').map_or(0, |n| n + 1); let line = dox[last_new_line_offset..].lines().next().unwrap_or(""); @@ -1303,7 +1310,10 @@ fn resolution_failure( } diag } else { - cx.sess().struct_span_warn(sp, &msg) + cx.tcx.struct_span_lint_node(lint::builtin::INTRA_LINK_RESOLUTION_FAILURE, + NodeId::new(0), + sp, + &msg) }; diag.emit(); } diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index bad5ff2596fd3..9a733ab424906 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -17,7 +17,7 @@ use rustc::middle::cstore::CrateStore; use rustc::middle::privacy::AccessLevels; use rustc::ty::{self, TyCtxt, AllArenas}; use rustc::hir::map as hir_map; -use rustc::lint; +use rustc::lint::{self, LintPass}; use rustc::session::config::ErrorOutputType; use rustc::util::nodemap::{FxHashMap, FxHashSet}; use rustc_resolve as resolve; @@ -187,7 +187,23 @@ pub fn run_core(search_paths: SearchPaths, _ => None }; - let warning_lint = lint::builtin::WARNINGS.name_lower(); + let intra_link_resolution_failure_name = lint::builtin::INTRA_LINK_RESOLUTION_FAILURE.name; + let warnings_lint_name = lint::builtin::WARNINGS.name; + let lints = lint::builtin::HardwiredLints.get_lints() + .iter() + .filter_map(|lint| { + if lint.name == warnings_lint_name { + None + } else { + let level = if lint.name == intra_link_resolution_failure_name { + lint::Warn + } else { + lint::Allow + }; + Some((lint.name_lower(), level)) + } + }) + .collect::>(); let host_triple = TargetTriple::from_triple(config::host_triple()); // plays with error output here! @@ -195,8 +211,12 @@ pub fn run_core(search_paths: SearchPaths, maybe_sysroot, search_paths, crate_types: vec![config::CrateTypeRlib], - lint_opts: if !allow_warnings { vec![(warning_lint, lint::Allow)] } else { vec![] }, - lint_cap: Some(lint::Allow), + lint_opts: if !allow_warnings { + lints + } else { + vec![] + }, + lint_cap: Some(lint::Warn), cg, externs, target_triple: triple.unwrap_or(host_triple), diff --git a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs new file mode 100644 index 0000000000000..f816621c16f27 --- /dev/null +++ b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs @@ -0,0 +1,14 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![deny(intra_link_resolution_failure)] + +/// [v2] //~ ERROR +pub fn foo() {} diff --git a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr new file mode 100644 index 0000000000000..39fb33ce9337e --- /dev/null +++ b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr @@ -0,0 +1,16 @@ +warning: [v2] cannot be resolved, ignoring it... + --> src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs:13:1 + | +LL | /// [v2] //~ ERROR + | ^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs:11:9 + | +LL | #![deny(intra_link_resolution_failure)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: the link appears in this line: + + [v2] //~ ERROR + ^^ + From 8c43c93e6d8526ef6a3beb656003dd723aa0e952 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 9 Jun 2018 17:20:58 +0200 Subject: [PATCH 2/8] 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 0a6473655980c..79796d788719a 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1665,3 +1665,36 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TrivialConstraints { } } } + +/// 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 47f17285f5f38..9ac22f8dceb05 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -60,6 +60,9 @@ use builtin::*; 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 9a733ab424906..f46d3d834ae0d 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 39fb33ce9337e..3aa45405fd400 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 52adba5679fe0..4949c450343ce 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 From 2e343f384fa6517330c290f353d3bd8d21476dc3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 9 Jun 2018 17:30:22 +0200 Subject: [PATCH 3/8] Add help for intra-link lint --- src/librustdoc/clean/mod.rs | 8 +++++--- .../deny-intra-link-resolution-failure.stderr | 1 + .../rustdoc-ui/intra-links-warning.stderr | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 8328a8385c314..6842f1fae496f 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1311,10 +1311,12 @@ fn resolution_failure( diag } else { cx.tcx.struct_span_lint_node(lint::builtin::INTRA_LINK_RESOLUTION_FAILURE, - NodeId::new(0), - sp, - &msg) + NodeId::new(0), + sp, + &msg) }; + diag.help("to escape `[` and `]` characters, either put them into \"`[]`\" or \ + use HTML values `[` and `]`"); diag.emit(); } 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 3aa45405fd400..40a7427d733b2 100644 --- a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr +++ b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr @@ -9,4 +9,5 @@ note: lint level defined here | 11 | #![deny(intra_link_resolution_failure)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` diff --git a/src/test/rustdoc-ui/intra-links-warning.stderr b/src/test/rustdoc-ui/intra-links-warning.stderr index 4949c450343ce..d19ea93fa6344 100644 --- a/src/test/rustdoc-ui/intra-links-warning.stderr +++ b/src/test/rustdoc-ui/intra-links-warning.stderr @@ -5,48 +5,63 @@ warning: `[Foo::baz]` cannot be resolved, ignoring it... | ^^^^^^^^ cannot be resolved, ignoring | = note: #[warn(intra_link_resolution_failure)] on by default + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[Bar::foo]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:13:35 | 13 | //! Test with [Foo::baz], [Bar::foo], ... | ^^^^^^^^ cannot be resolved, ignoring + | + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[Uniooon::X]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:14:13 | 14 | //! , [Uniooon::X] and [Qux::Z]. | ^^^^^^^^^^ cannot be resolved, ignoring + | + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[Qux::Z]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:14:30 | 14 | //! , [Uniooon::X] and [Qux::Z]. | ^^^^^^ cannot be resolved, ignoring + | + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[Uniooon::X]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:16:14 | 16 | //! , [Uniooon::X] and [Qux::Z]. | ^^^^^^^^^^ cannot be resolved, ignoring + | + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[Qux::Z]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:16:31 | 16 | //! , [Uniooon::X] and [Qux::Z]. | ^^^^^^ cannot be resolved, ignoring + | + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[Qux:Y]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:18:13 | 18 | /// [Qux:Y] | ^^^^^ cannot be resolved, ignoring + | + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[BarA]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:24:10 | 24 | /// bar [BarA] bar | ^^^^ cannot be resolved, ignoring + | + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[BarB]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:28:1 @@ -62,6 +77,7 @@ warning: `[BarB]` cannot be resolved, ignoring it... bar [BarB] bar ^^^^ + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[BarC]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:35:1 @@ -79,6 +95,7 @@ warning: `[BarC]` cannot be resolved, ignoring it... bar [BarC] bar ^^^^ + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[BarD]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:48:1 @@ -90,6 +107,7 @@ warning: `[BarD]` cannot be resolved, ignoring it... bar [BarD] bar ^^^^ + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` warning: `[BarF]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:53:9 @@ -104,4 +122,5 @@ warning: `[BarF]` cannot be resolved, ignoring it... bar [BarF] bar ^^^^ + = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` From 6d5e6b49285766151d9fe148341a3497b7800843 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 9 Jun 2018 21:06:40 +0200 Subject: [PATCH 4/8] Fix rustdoc test failure --- src/test/rustdoc/cap-lints.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/rustdoc/cap-lints.rs b/src/test/rustdoc/cap-lints.rs index e7f308a6f0b69..39e753daadbd1 100644 --- a/src/test/rustdoc/cap-lints.rs +++ b/src/test/rustdoc/cap-lints.rs @@ -13,8 +13,8 @@ // therefore should not concern itself with the lints. #[deny(warnings)] -// @has cap_lints/struct.foo.html //pre '#[must_use]' +// @has cap_lints/struct.Foo.html //pre '#[must_use]' #[must_use] -pub struct foo { +pub struct Foo { field: i32, } From e6c7868fb289c3f34a24a9498e5d010ca0f48fa6 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 9 Jun 2018 21:07:09 +0200 Subject: [PATCH 5/8] Update help message to escape square brackets --- src/librustdoc/clean/mod.rs | 4 ++-- .../deny-intra-link-resolution-failure.stderr | 2 +- .../rustdoc-ui/intra-links-warning.stderr | 24 +++++++++---------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 6842f1fae496f..9905c69b38da1 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1315,8 +1315,8 @@ fn resolution_failure( sp, &msg) }; - diag.help("to escape `[` and `]` characters, either put them into \"`[]`\" or \ - use HTML values `[` and `]`"); + diag.help("to escape `[` and `]` characters, just add '\\' before them like \ + `\\[` or `\\]`"); diag.emit(); } 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 40a7427d733b2..78526b3087a21 100644 --- a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr +++ b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr @@ -9,5 +9,5 @@ note: lint level defined here | 11 | #![deny(intra_link_resolution_failure)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` + = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` diff --git a/src/test/rustdoc-ui/intra-links-warning.stderr b/src/test/rustdoc-ui/intra-links-warning.stderr index d19ea93fa6344..6e47114af7050 100644 --- a/src/test/rustdoc-ui/intra-links-warning.stderr +++ b/src/test/rustdoc-ui/intra-links-warning.stderr @@ -5,7 +5,7 @@ warning: `[Foo::baz]` cannot be resolved, ignoring it... | ^^^^^^^^ cannot be resolved, ignoring | = note: #[warn(intra_link_resolution_failure)] on by default - = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` + = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` warning: `[Bar::foo]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:13:35 @@ -13,7 +13,7 @@ warning: `[Bar::foo]` cannot be resolved, ignoring it... 13 | //! Test with [Foo::baz], [Bar::foo], ... | ^^^^^^^^ cannot be resolved, ignoring | - = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` + = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` warning: `[Uniooon::X]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:14:13 @@ -21,7 +21,7 @@ warning: `[Uniooon::X]` cannot be resolved, ignoring it... 14 | //! , [Uniooon::X] and [Qux::Z]. | ^^^^^^^^^^ cannot be resolved, ignoring | - = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` + = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` warning: `[Qux::Z]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:14:30 @@ -29,7 +29,7 @@ warning: `[Qux::Z]` cannot be resolved, ignoring it... 14 | //! , [Uniooon::X] and [Qux::Z]. | ^^^^^^ cannot be resolved, ignoring | - = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` + = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` warning: `[Uniooon::X]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:16:14 @@ -37,7 +37,7 @@ warning: `[Uniooon::X]` cannot be resolved, ignoring it... 16 | //! , [Uniooon::X] and [Qux::Z]. | ^^^^^^^^^^ cannot be resolved, ignoring | - = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` + = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` warning: `[Qux::Z]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:16:31 @@ -45,7 +45,7 @@ warning: `[Qux::Z]` cannot be resolved, ignoring it... 16 | //! , [Uniooon::X] and [Qux::Z]. | ^^^^^^ cannot be resolved, ignoring | - = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` + = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` warning: `[Qux:Y]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:18:13 @@ -53,7 +53,7 @@ warning: `[Qux:Y]` cannot be resolved, ignoring it... 18 | /// [Qux:Y] | ^^^^^ cannot be resolved, ignoring | - = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` + = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` warning: `[BarA]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:24:10 @@ -61,7 +61,7 @@ warning: `[BarA]` cannot be resolved, ignoring it... 24 | /// bar [BarA] bar | ^^^^ cannot be resolved, ignoring | - = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` + = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` warning: `[BarB]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:28:1 @@ -77,7 +77,7 @@ warning: `[BarB]` cannot be resolved, ignoring it... bar [BarB] bar ^^^^ - = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` + = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` warning: `[BarC]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:35:1 @@ -95,7 +95,7 @@ warning: `[BarC]` cannot be resolved, ignoring it... bar [BarC] bar ^^^^ - = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` + = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` warning: `[BarD]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:48:1 @@ -107,7 +107,7 @@ warning: `[BarD]` cannot be resolved, ignoring it... bar [BarD] bar ^^^^ - = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` + = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` warning: `[BarF]` cannot be resolved, ignoring it... --> $DIR/intra-links-warning.rs:53:9 @@ -122,5 +122,5 @@ warning: `[BarF]` cannot be resolved, ignoring it... bar [BarF] bar ^^^^ - = help: to escape `[` and `]` characters, either put them into "`[]`" or use HTML values `[` and `]` + = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` From d2a4e429591432d2f64ddccd7bcd9f09b3f6755d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 13 Jun 2018 21:17:15 +0200 Subject: [PATCH 6/8] Rename intra-doc lint --- src/librustc/lint/builtin.rs | 4 ++-- src/librustdoc/clean/mod.rs | 6 +++--- src/librustdoc/core.rs | 2 +- src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs | 2 +- .../rustdoc-ui/deny-intra-link-resolution-failure.stderr | 4 ++-- src/test/rustdoc-ui/intra-links-warning.stderr | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index e2acd77a3b6cb..7d4a18c2a570b 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -299,7 +299,7 @@ declare_lint! { } declare_lint! { - pub INTRA_LINK_RESOLUTION_FAILURE, + pub INTRA_DOC_LINK_RESOLUTION_FAILURE, Warn, "warn about documentation intra links resolution failure" } @@ -357,7 +357,7 @@ impl LintPass for HardwiredLints { UNSTABLE_NAME_COLLISIONS, DUPLICATE_ASSOCIATED_TYPE_BINDINGS, DUPLICATE_MACRO_EXPORTS, - INTRA_LINK_RESOLUTION_FAILURE, + INTRA_DOC_LINK_RESOLUTION_FAILURE, ) } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 9905c69b38da1..4bdb1822450cc 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1284,13 +1284,13 @@ fn resolution_failure( link_range.end + code_dox_len, ); - diag = cx.tcx.struct_span_lint_node(lint::builtin::INTRA_LINK_RESOLUTION_FAILURE, + diag = cx.tcx.struct_span_lint_node(lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURE, NodeId::new(0), sp, &msg); diag.span_label(sp, "cannot be resolved, ignoring"); } else { - diag = cx.tcx.struct_span_lint_node(lint::builtin::INTRA_LINK_RESOLUTION_FAILURE, + diag = cx.tcx.struct_span_lint_node(lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURE, NodeId::new(0), sp, &msg); @@ -1310,7 +1310,7 @@ fn resolution_failure( } diag } else { - cx.tcx.struct_span_lint_node(lint::builtin::INTRA_LINK_RESOLUTION_FAILURE, + cx.tcx.struct_span_lint_node(lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURE, NodeId::new(0), sp, &msg) diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index f46d3d834ae0d..89923653125a3 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -187,7 +187,7 @@ pub fn run_core(search_paths: SearchPaths, _ => None }; - let intra_link_resolution_failure_name = lint::builtin::INTRA_LINK_RESOLUTION_FAILURE.name; + let intra_link_resolution_failure_name = lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURE.name; let warnings_lint_name = lint::builtin::WARNINGS.name; let lints = lint::builtin::HardwiredLints.get_lints() .iter() diff --git a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs index f816621c16f27..85d19c8354788 100644 --- a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs +++ b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![deny(intra_link_resolution_failure)] +#![deny(intra_doc_link_resolution_failure)] /// [v2] //~ ERROR pub fn foo() {} 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 78526b3087a21..66ee48ed4c9c0 100644 --- a/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr +++ b/src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr @@ -7,7 +7,7 @@ error: `[v2]` cannot be resolved, ignoring it... note: lint level defined here --> $DIR/deny-intra-link-resolution-failure.rs:11:9 | -11 | #![deny(intra_link_resolution_failure)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +11 | #![deny(intra_doc_link_resolution_failure)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` diff --git a/src/test/rustdoc-ui/intra-links-warning.stderr b/src/test/rustdoc-ui/intra-links-warning.stderr index 6e47114af7050..2a51e94b1f5d7 100644 --- a/src/test/rustdoc-ui/intra-links-warning.stderr +++ b/src/test/rustdoc-ui/intra-links-warning.stderr @@ -4,7 +4,7 @@ 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 + = note: #[warn(intra_doc_link_resolution_failure)] on by default = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]` warning: `[Bar::foo]` cannot be resolved, ignoring it... From 231c61a76bba716ad0a7d571f64825d57be2a75e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 13 Jun 2018 22:28:21 +0200 Subject: [PATCH 7/8] Add missing allow_missing_docs --- src/libstd/sys/windows/ext/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libstd/sys/windows/ext/mod.rs b/src/libstd/sys/windows/ext/mod.rs index 4b458d293bce2..1f10609f32c48 100644 --- a/src/libstd/sys/windows/ext/mod.rs +++ b/src/libstd/sys/windows/ext/mod.rs @@ -18,6 +18,7 @@ #![stable(feature = "rust1", since = "1.0.0")] #![doc(cfg(windows))] +#![allow(missing_docs)] pub mod ffi; pub mod fs; From 6a03884ce99df2002ddaa1155de65384f7767cd5 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 15 Jun 2018 10:00:57 +0200 Subject: [PATCH 8/8] Fix issue on unix --- src/libstd/sys/unix/ext/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libstd/sys/unix/ext/mod.rs b/src/libstd/sys/unix/ext/mod.rs index c221f7c8cfe24..88e4237f8e2b7 100644 --- a/src/libstd/sys/unix/ext/mod.rs +++ b/src/libstd/sys/unix/ext/mod.rs @@ -35,6 +35,7 @@ #![stable(feature = "rust1", since = "1.0.0")] #![doc(cfg(unix))] +#![allow(missing_docs)] pub mod io; pub mod ffi;