Skip to content

Commit

Permalink
Auto merge of #74926 - Manishearth:rename-lint, r=jyn514
Browse files Browse the repository at this point in the history
Rename intra_doc_link_resolution_failure

It should be plural to follow the conventions in https://github.com/rust-lang/rfcs/blob/master/text/0344-conventions-galore.md#lints
  • Loading branch information
bors committed Jul 31, 2020
2 parents c058a8b + c17eb56 commit ffa80f0
Show file tree
Hide file tree
Showing 54 changed files with 89 additions and 98 deletions.
1 change: 0 additions & 1 deletion library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
#![warn(deprecated_in_future)]
#![warn(missing_docs)]
#![warn(missing_debug_implementations)]
#![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings
#![allow(explicit_outlives_requirements)]
#![allow(incomplete_features)]
#![deny(unsafe_op_in_unsafe_fn)]
Expand Down
2 changes: 0 additions & 2 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
#![warn(deprecated_in_future)]
#![warn(missing_docs)]
#![warn(missing_debug_implementations)]
#![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings
#![allow(explicit_outlives_requirements)]
#![allow(incomplete_features)]
#![feature(allow_internal_unstable)]
Expand Down Expand Up @@ -151,7 +150,6 @@
#![feature(slice_ptr_get)]
#![feature(no_niche)] // rust-lang/rust#68303
#![feature(unsafe_block_in_unsafe_fn)]
#![deny(intra_doc_link_resolution_failure)]
#![deny(unsafe_op_in_unsafe_fn)]

#[prelude_import]
Expand Down
1 change: 0 additions & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@
#![warn(deprecated_in_future)]
#![warn(missing_docs)]
#![warn(missing_debug_implementations)]
#![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings
#![allow(explicit_outlives_requirements)]
#![allow(unused_lifetimes)]
// Tell the compiler to link to either panic_abort or panic_unwind
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustdoc/src/lints.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_failure
## broken_intra_doc_links

This lint **warns by default** and is **nightly-only**. This lint detects when
an intra-doc link fails to get resolved. For example:
Expand Down
7 changes: 4 additions & 3 deletions src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ use rustc_hir::def_id::LocalDefId;
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_FAILURE, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_DOC_CODE_EXAMPLES,
BARE_TRAIT_OBJECTS, BROKEN_INTRA_DOC_LINKS, ELIDED_LIFETIMES_IN_PATHS,
EXPLICIT_OUTLIVES_REQUIREMENTS, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_DOC_CODE_EXAMPLES,
PRIVATE_DOC_TESTS,
};
use rustc_span::symbol::{Ident, Symbol};
Expand Down Expand Up @@ -303,7 +303,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {

add_lint_group!(
"rustdoc",
INTRA_DOC_LINK_RESOLUTION_FAILURE,
BROKEN_INTRA_DOC_LINKS,
INVALID_CODEBLOCK_ATTRIBUTES,
MISSING_DOC_CODE_EXAMPLES,
PRIVATE_DOC_TESTS
Expand All @@ -318,6 +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", "broken_intra_doc_links");
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");
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_session/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ declare_lint! {
}

declare_lint! {
pub INTRA_DOC_LINK_RESOLUTION_FAILURE,
pub BROKEN_INTRA_DOC_LINKS,
Warn,
"failures in resolving intra-doc link targets"
}
Expand Down Expand Up @@ -601,7 +601,7 @@ declare_lint_pass! {
ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
UNSTABLE_NAME_COLLISIONS,
IRREFUTABLE_LET_PATTERNS,
INTRA_DOC_LINK_RESOLUTION_FAILURE,
BROKEN_INTRA_DOC_LINKS,
INVALID_CODEBLOCK_ATTRIBUTES,
MISSING_CRATE_LEVEL_DOCS,
MISSING_DOC_CODE_EXAMPLES,
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_FAILURE.name;
let intra_link_resolution_failure_name = lint::builtin::BROKEN_INTRA_DOC_LINKS.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;
Expand Down
66 changes: 30 additions & 36 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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_FAILURE,
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));

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\
cx.tcx.struct_span_lint_hir(lint::builtin::BROKEN_INTRA_DOC_LINKS, 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));

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\
{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(
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-make-fulldeps/exit-code/lint-failure.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![deny(intra_doc_link_resolution_failure)]
#![deny(broken_intra_doc_links)]

/// [intradoc::failure]
pub fn main() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/deny-intra-link-resolution-failure.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![deny(intra_doc_link_resolution_failure)]
#![deny(broken_intra_doc_links)]

/// [v2] //~ ERROR
pub fn foo() {}
4 changes: 2 additions & 2 deletions src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ LL | /// [v2]
note: the lint level is defined here
--> $DIR/deny-intra-link-resolution-failure.rs:1:9
|
LL | #![deny(intra_doc_link_resolution_failure)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #![deny(broken_intra_doc_links)]
| ^^^^^^^^^^^^^^^^^^^^^^
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: aborting due to previous error
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/intra-doc-alias-ice.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![deny(intra_doc_link_resolution_failure)]
#![deny(broken_intra_doc_links)]

pub type TypeAlias = usize;

Expand Down
4 changes: 2 additions & 2 deletions src/test/rustdoc-ui/intra-doc-alias-ice.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ 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_failure)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #![deny(broken_intra_doc_links)]
| ^^^^^^^^^^^^^^^^^^^^^^
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: aborting due to previous error
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/intra-link-span-ice-55723.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![deny(intra_doc_link_resolution_failure)]
#![deny(broken_intra_doc_links)]

// 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
Expand Down
4 changes: 2 additions & 2 deletions src/test/rustdoc-ui/intra-link-span-ice-55723.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ 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_failure)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #![deny(broken_intra_doc_links)]
| ^^^^^^^^^^^^^^^^^^^^^^
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: aborting due to previous error
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/intra-links-ambiguity.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![deny(intra_doc_link_resolution_failure)]
#![deny(broken_intra_doc_links)]
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]

Expand Down
4 changes: 2 additions & 2 deletions src/test/rustdoc-ui/intra-links-ambiguity.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ LL | /// [`ambiguous`] is ambiguous.
note: the lint level is defined here
--> $DIR/intra-links-ambiguity.rs:1:9
|
LL | #![deny(intra_doc_link_resolution_failure)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #![deny(broken_intra_doc_links)]
| ^^^^^^^^^^^^^^^^^^^^^^
help: to link to the struct, prefix with the item type
|
LL | /// [`struct@ambiguous`] is ambiguous.
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/intra-links-anchors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![deny(intra_doc_link_resolution_failure)]
#![deny(broken_intra_doc_links)]

// A few tests on anchors.

Expand Down
4 changes: 2 additions & 2 deletions src/test/rustdoc-ui/intra-links-anchors.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ 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_failure)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #![deny(broken_intra_doc_links)]
| ^^^^^^^^^^^^^^^^^^^^^^

error: `hello#people#!` contains multiple anchors
--> $DIR/intra-links-anchors.rs:31:28
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/intra-links-private.private.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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_failure)]` on by default
= note: `#[warn(broken_intra_doc_links)]` on by default
= note: this link resolves only because you passed `--document-private-items`, but will break without

warning: 1 warning emitted
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/intra-links-private.public.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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_failure)]` on by default
= note: `#[warn(broken_intra_doc_links)]` on by default
= note: this link will resolve properly if you pass `--document-private-items`

warning: 1 warning emitted
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/intra-links-warning-crlf.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ warning: unresolved link to `error`
LL | /// [error]
| ^^^^^ unresolved link
|
= note: `#[warn(intra_doc_link_resolution_failure)]` on by default
= note: `#[warn(broken_intra_doc_links)]` on by default
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

warning: unresolved link to `error1`
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/intra-links-warning.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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_failure)]` on by default
= note: `#[warn(broken_intra_doc_links)]` on by default
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

warning: unresolved link to `Bar::foo`
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/issue-74134.private.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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_failure)]` on by default
= note: `#[warn(broken_intra_doc_links)]` on by default
= note: this link resolves only because you passed `--document-private-items`, but will break without

warning: 1 warning emitted
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/issue-74134.public.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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_failure)]` on by default
= note: `#[warn(broken_intra_doc_links)]` on by default
= note: this link will resolve properly if you pass `--document-private-items`

warning: 1 warning emitted
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/lint-group.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ note: the lint level is defined here
|
LL | #![deny(rustdoc)]
| ^^^^^^^
= note: `#[deny(intra_doc_link_resolution_failure)]` implied by `#[deny(rustdoc)]`
= note: `#[deny(broken_intra_doc_links)]` implied by `#[deny(rustdoc)]`
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

error: aborting due to 3 previous errors
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc-ui/reference-link-has-one-warning.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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_failure)]` on by default
= note: `#[warn(broken_intra_doc_links)]` on by default

warning: 1 warning emitted

2 changes: 1 addition & 1 deletion src/test/rustdoc/intra-doc-crate/additional_doc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// aux-build:additional_doc.rs
// build-aux-docs
#![deny(intra_doc_link_resolution_failure)]
#![deny(broken_intra_doc_links)]

extern crate my_rand;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![crate_name = "my_rand"]
#![deny(intra_doc_link_resolution_failure)]
#![deny(broken_intra_doc_links)]

pub trait RngCore {}
/// Rng extends [`RngCore`].
Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![crate_name = "hidden_dep"]
#![deny(intra_doc_link_resolution_failure)]
#![deny(broken_intra_doc_links)]

#[doc(hidden)]
pub mod __reexport {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![crate_name = "a"]
#![deny(intra_doc_link_resolution_failure)]
#![deny(broken_intra_doc_links)]

pub struct Foo;

Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![crate_name = "macro_inner"]
#![deny(intra_doc_link_resolution_failure)]
#![deny(broken_intra_doc_links)]

pub struct Foo;

Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/intra-doc-crate/auxiliary/module.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![crate_name = "module_inner"]
#![deny(intra_doc_link_resolution_failure)]
#![deny(broken_intra_doc_links)]
/// [SomeType] links to [bar]
pub struct SomeType;
pub trait SomeTrait {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![crate_name = "a"]
#![deny(intra_doc_link_resolution_failure)]
#![deny(broken_intra_doc_links)]

pub mod bar {
pub struct Bar;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![crate_name = "bar"]
#![deny(intra_doc_link_resolution_failure)]
#![deny(broken_intra_doc_links)]

pub trait Foo {
/// [`Bar`] [`Baz`]
Expand Down
Loading

0 comments on commit ffa80f0

Please sign in to comment.