Rename to intra_doc_resolution_failures

This commit is contained in:
Manish Goregaokar 2020-07-29 16:26:32 -07:00
parent da0b10c4fb
commit 4df76f0f90
51 changed files with 80 additions and 86 deletions

View File

@ -11,7 +11,7 @@ can use them like any other lints by doing this:
Here is the list of the lints provided by `rustdoc`:
## intra_doc_link_resolution_failures
## intra_doc_resolution_failures
This lint **warns by default** and is **nightly-only**. This lint detects when
an intra-doc link fails to get resolved. For example:

View File

@ -62,7 +62,7 @@ use rustc_middle::ty::query::Providers;
use rustc_middle::ty::TyCtxt;
use rustc_session::lint::builtin::{
BARE_TRAIT_OBJECTS, ELIDED_LIFETIMES_IN_PATHS, EXPLICIT_OUTLIVES_REQUIREMENTS,
INTRA_DOC_LINK_RESOLUTION_FAILURES, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_DOC_CODE_EXAMPLES,
INTRA_DOC_RESOLUTION_FAILURES, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_DOC_CODE_EXAMPLES,
PRIVATE_DOC_TESTS,
};
use rustc_span::symbol::{Ident, Symbol};
@ -303,7 +303,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
add_lint_group!(
"rustdoc",
INTRA_DOC_LINK_RESOLUTION_FAILURES,
INTRA_DOC_RESOLUTION_FAILURES,
INVALID_CODEBLOCK_ATTRIBUTES,
MISSING_DOC_CODE_EXAMPLES,
PRIVATE_DOC_TESTS
@ -318,7 +318,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
store.register_renamed("async_idents", "keyword_idents");
store.register_renamed("exceeding_bitshifts", "arithmetic_overflow");
store.register_renamed("redundant_semicolon", "redundant_semicolons");
store.register_renamed("intra_doc_link_resolution_failure", "intra_doc_link_resolution_failures");
store.register_renamed("intra_doc_link_resolution_failure", "intra_doc_resolution_failures");
store.register_removed("unknown_features", "replaced by an error");
store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate");
store.register_removed("negate_unsigned", "cast a signed value instead");

View File

@ -398,7 +398,7 @@ declare_lint! {
}
declare_lint! {
pub INTRA_DOC_LINK_RESOLUTION_FAILURES,
pub INTRA_DOC_RESOLUTION_FAILURES,
Warn,
"failures in resolving intra-doc link targets"
}
@ -601,7 +601,7 @@ declare_lint_pass! {
ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
UNSTABLE_NAME_COLLISIONS,
IRREFUTABLE_LET_PATTERNS,
INTRA_DOC_LINK_RESOLUTION_FAILURES,
INTRA_DOC_RESOLUTION_FAILURES,
INVALID_CODEBLOCK_ATTRIBUTES,
MISSING_CRATE_LEVEL_DOCS,
MISSING_DOC_CODE_EXAMPLES,

View File

@ -315,7 +315,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
let cpath = Some(input.clone());
let input = Input::File(input);
let intra_link_resolution_failure_name = lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURES.name;
let intra_link_resolution_failure_name = lint::builtin::INTRA_DOC_RESOLUTION_FAILURES.name;
let missing_docs = rustc_lint::builtin::MISSING_DOCS.name;
let missing_doc_example = rustc_lint::builtin::MISSING_DOC_CODE_EXAMPLES.name;
let private_doc_tests = rustc_lint::builtin::PRIVATE_DOC_TESTS.name;

View File

@ -867,46 +867,40 @@ fn report_diagnostic(
let attrs = &item.attrs;
let sp = span_of_attrs(attrs).unwrap_or(item.source.span());
cx.tcx.struct_span_lint_hir(
lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURES,
hir_id,
sp,
|lint| {
let mut diag = lint.build(msg);
cx.tcx.struct_span_lint_hir(lint::builtin::INTRA_DOC_RESOLUTION_FAILURES, hir_id, sp, |lint| {
let mut diag = lint.build(msg);
let span = link_range
.as_ref()
.and_then(|range| super::source_span_for_markdown_range(cx, dox, range, attrs));
let span = link_range
.as_ref()
.and_then(|range| super::source_span_for_markdown_range(cx, dox, range, attrs));
if let Some(link_range) = link_range {
if let Some(sp) = span {
diag.set_span(sp);
} else {
// blah blah blah\nblah\nblah [blah] blah blah\nblah blah
// ^ ~~~~
// | link_range
// last_new_line_offset
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("");
if let Some(link_range) = link_range {
if let Some(sp) = span {
diag.set_span(sp);
} else {
// blah blah blah\nblah\nblah [blah] blah blah\nblah blah
// ^ ~~~~
// | link_range
// last_new_line_offset
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("");
// Print the line containing the `link_range` and manually mark it with '^'s.
diag.note(&format!(
"the link appears in this line:\n\n{line}\n\
// Print the line containing the `link_range` and manually mark it with '^'s.
diag.note(&format!(
"the link appears in this line:\n\n{line}\n\
{indicator: <before$}{indicator:^<found$}",
line = line,
indicator = "",
before = link_range.start - last_new_line_offset,
found = link_range.len(),
));
}
line = line,
indicator = "",
before = link_range.start - last_new_line_offset,
found = link_range.len(),
));
}
}
decorate(&mut diag, span);
decorate(&mut diag, span);
diag.emit();
},
);
diag.emit();
});
}
fn resolution_failure(

View File

@ -1,4 +1,4 @@
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
/// [intradoc::failure]
pub fn main() {

View File

@ -1,4 +1,4 @@
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
/// [v2] //~ ERROR
pub fn foo() {}

View File

@ -7,7 +7,7 @@ LL | /// [v2]
note: the lint level is defined here
--> $DIR/deny-intra-link-resolution-failure.rs:1:9
|
LL | #![deny(intra_doc_link_resolution_failures)]
LL | #![deny(intra_doc_resolution_failures)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

View File

@ -1,4 +1,4 @@
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
pub type TypeAlias = usize;

View File

@ -7,7 +7,7 @@ LL | /// [broken cross-reference](TypeAlias::hoge)
note: the lint level is defined here
--> $DIR/intra-doc-alias-ice.rs:1:9
|
LL | #![deny(intra_doc_link_resolution_failures)]
LL | #![deny(intra_doc_resolution_failures)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

View File

@ -1,4 +1,4 @@
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
// An error in calculating spans while reporting intra-doc link resolution errors caused rustdoc to
// attempt to slice in the middle of a multibyte character. See

View File

@ -7,7 +7,7 @@ LL | /// arr[i]
note: the lint level is defined here
--> $DIR/intra-link-span-ice-55723.rs:1:9
|
LL | #![deny(intra_doc_link_resolution_failures)]
LL | #![deny(intra_doc_resolution_failures)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

View File

@ -1,4 +1,4 @@
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]

View File

@ -7,7 +7,7 @@ LL | /// [`ambiguous`] is ambiguous.
note: the lint level is defined here
--> $DIR/intra-links-ambiguity.rs:1:9
|
LL | #![deny(intra_doc_link_resolution_failures)]
LL | #![deny(intra_doc_resolution_failures)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: to link to the struct, prefix with the item type
|

View File

@ -1,4 +1,4 @@
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
// A few tests on anchors.

View File

@ -7,7 +7,7 @@ LL | /// Or maybe [Foo::f#hola].
note: the lint level is defined here
--> $DIR/intra-links-anchors.rs:1:9
|
LL | #![deny(intra_doc_link_resolution_failures)]
LL | #![deny(intra_doc_resolution_failures)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: `hello#people#!` contains multiple anchors

View File

@ -4,7 +4,7 @@ warning: public documentation for `DocMe` links to private item `DontDocMe`
LL | /// docs [DontDocMe]
| ^^^^^^^^^ this item is private
|
= note: `#[warn(intra_doc_link_resolution_failures)]` on by default
= note: `#[warn(intra_doc_resolution_failures)]` on by default
= note: this link resolves only because you passed `--document-private-items`, but will break without
warning: 1 warning emitted

View File

@ -4,7 +4,7 @@ warning: public documentation for `DocMe` links to private item `DontDocMe`
LL | /// docs [DontDocMe]
| ^^^^^^^^^ this item is private
|
= note: `#[warn(intra_doc_link_resolution_failures)]` on by default
= note: `#[warn(intra_doc_resolution_failures)]` on by default
= note: this link will resolve properly if you pass `--document-private-items`
warning: 1 warning emitted

View File

@ -4,7 +4,7 @@ warning: unresolved link to `error`
LL | /// [error]
| ^^^^^ unresolved link
|
= note: `#[warn(intra_doc_link_resolution_failures)]` on by default
= note: `#[warn(intra_doc_resolution_failures)]` on by default
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
warning: unresolved link to `error1`

View File

@ -4,7 +4,7 @@ warning: unresolved link to `Foo::baz`
LL | //! Test with [Foo::baz], [Bar::foo], ...
| ^^^^^^^^ unresolved link
|
= note: `#[warn(intra_doc_link_resolution_failures)]` on by default
= note: `#[warn(intra_doc_resolution_failures)]` on by default
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
warning: unresolved link to `Bar::foo`

View File

@ -4,7 +4,7 @@ warning: public documentation for `public_item` links to private item `PrivateTy
LL | /// [`PrivateType`]
| ^^^^^^^^^^^^^ this item is private
|
= note: `#[warn(intra_doc_link_resolution_failures)]` on by default
= note: `#[warn(intra_doc_resolution_failures)]` on by default
= note: this link resolves only because you passed `--document-private-items`, but will break without
warning: 1 warning emitted

View File

@ -4,7 +4,7 @@ warning: public documentation for `public_item` links to private item `PrivateTy
LL | /// [`PrivateType`]
| ^^^^^^^^^^^^^ this item is private
|
= note: `#[warn(intra_doc_link_resolution_failures)]` on by default
= note: `#[warn(intra_doc_resolution_failures)]` on by default
= note: this link will resolve properly if you pass `--document-private-items`
warning: 1 warning emitted

View File

@ -39,7 +39,7 @@ note: the lint level is defined here
|
LL | #![deny(rustdoc)]
| ^^^^^^^
= note: `#[deny(intra_doc_link_resolution_failures)]` implied by `#[deny(rustdoc)]`
= note: `#[deny(intra_doc_resolution_failures)]` implied by `#[deny(rustdoc)]`
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
error: aborting due to 3 previous errors

View File

@ -4,7 +4,7 @@ warning: `[with#anchor#error]` has an issue with the link anchor.
LL | /// docs [label][with#anchor#error]
| ^^^^^^^^^^^^^^^^^ only one `#` is allowed in a link
|
= note: `#[warn(intra_doc_link_resolution_failures)]` on by default
= note: `#[warn(intra_doc_resolution_failures)]` on by default
warning: 1 warning emitted

View File

@ -1,6 +1,6 @@
// aux-build:additional_doc.rs
// build-aux-docs
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
extern crate my_rand;

View File

@ -1,5 +1,5 @@
#![crate_name = "my_rand"]
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
pub trait RngCore {}
/// Rng extends [`RngCore`].

View File

@ -1,5 +1,5 @@
#![crate_name = "hidden_dep"]
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
#[doc(hidden)]
pub mod __reexport {

View File

@ -1,5 +1,5 @@
#![crate_name = "a"]
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
pub struct Foo;

View File

@ -1,5 +1,5 @@
#![crate_name = "macro_inner"]
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
pub struct Foo;

View File

@ -1,5 +1,5 @@
#![crate_name = "module_inner"]
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
/// [SomeType] links to [bar]
pub struct SomeType;
pub trait SomeTrait {}

View File

@ -1,5 +1,5 @@
#![crate_name = "a"]
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
pub mod bar {
pub struct Bar;

View File

@ -1,5 +1,5 @@
#![crate_name = "bar"]
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
pub trait Foo {
/// [`Bar`] [`Baz`]

View File

@ -1,6 +1,6 @@
// aux-build:intra-doc-basic.rs
// build-aux-docs
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
// from https://github.com/rust-lang/rust/issues/65983
extern crate a;

View File

@ -1,6 +1,6 @@
// aux-build:hidden.rs
// build-aux-docs
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
// tests https://github.com/rust-lang/rust/issues/73363

View File

@ -2,7 +2,7 @@
// aux-build:macro_inner.rs
// aux-build:proc_macro.rs
// build-aux-docs
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
extern crate macro_inner;
extern crate proc_macro_inner;

View File

@ -1,7 +1,7 @@
// outer.rs
// aux-build: module.rs
// build-aux-docs
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
extern crate module_inner;
// @has 'module/bar/index.html' '//a[@href="../../module_inner/trait.SomeTrait.html"]' 'SomeTrait'
// @has 'module/bar/index.html' '//a[@href="../../module_inner/struct.SomeType.html"]' 'SomeType'

View File

@ -1,6 +1,6 @@
// aux-build:submodule-inner.rs
// build-aux-docs
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
extern crate a;

View File

@ -1,6 +1,6 @@
// aux-build:submodule-outer.rs
// edition:2018
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
extern crate bar as bar_;

View File

@ -3,7 +3,7 @@
// aux-build:traits.rs
// build-aux-docs
// ignore-tidy-line-length
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
extern crate inner;
use inner::SomeTrait;

View File

@ -1,6 +1,6 @@
// ignore-tidy-linelength
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
pub fn foo() {

View File

@ -4,6 +4,6 @@
// though they would never actually get displayed. This tripped intra-doc-link resolution failures,
// for items that aren't under our control, and not actually getting documented!
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
extern crate inner;

View File

@ -1,6 +1,6 @@
// we need to make sure that intra-doc links on trait impls get resolved in the right scope
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
pub mod inner {
pub struct SomethingOutOfScope;

View File

@ -1,3 +1,3 @@
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
pub use std::*;

View File

@ -4,7 +4,7 @@
// ignore-windows
// ignore-tidy-linelength
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
#![feature(no_core, lang_items)]
#![no_core]
#![crate_type = "rlib"]

View File

@ -1,4 +1,4 @@
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
#![feature(no_core, lang_items)]
#![no_core]
#![crate_type = "rlib"]

View File

@ -1,4 +1,4 @@
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
// ignore-tidy-linelength

View File

@ -1,5 +1,5 @@
// ignore-tidy-linelength
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
pub mod char {}

View File

@ -2,7 +2,7 @@
// These failures were legitimate, but not truly relevant - the docs in question couldn't be
// checked for accuracy anyway.
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
/// ooh, i'm a [rebel] just for kicks
struct SomeStruct;

View File

@ -1,6 +1,6 @@
// aux-build:intra-link-proc-macro-macro.rs
// build-aux-docs
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
extern crate intra_link_proc_macro_macro;

View File

@ -2,7 +2,7 @@
// ignore-cross-compile
#![crate_name = "outer"]
#![deny(intra_doc_link_resolution_failures)]
#![deny(intra_doc_resolution_failures)]
// using a trait that has intra-doc links on it from another crate (whether re-exporting or just
// implementing it) used to give spurious resolution failure warnings

View File

@ -1,6 +1,6 @@
// aux-build:through-proc-macro-aux.rs
// build-aux-docs
#![warn(intra_doc_link_resolution_failures)]
#![warn(intra_doc_resolution_failures)]
extern crate some_macros;
#[some_macros::second]