Skip to content

Commit ffa80f0

Browse files
committed
Auto merge of #74926 - Manishearth:rename-lint, r=jyn514
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
2 parents c058a8b + c17eb56 commit ffa80f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+89
-98
lines changed

library/alloc/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
#![warn(deprecated_in_future)]
7070
#![warn(missing_docs)]
7171
#![warn(missing_debug_implementations)]
72-
#![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings
7372
#![allow(explicit_outlives_requirements)]
7473
#![allow(incomplete_features)]
7574
#![deny(unsafe_op_in_unsafe_fn)]

library/core/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
#![warn(deprecated_in_future)]
6262
#![warn(missing_docs)]
6363
#![warn(missing_debug_implementations)]
64-
#![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings
6564
#![allow(explicit_outlives_requirements)]
6665
#![allow(incomplete_features)]
6766
#![feature(allow_internal_unstable)]
@@ -151,7 +150,6 @@
151150
#![feature(slice_ptr_get)]
152151
#![feature(no_niche)] // rust-lang/rust#68303
153152
#![feature(unsafe_block_in_unsafe_fn)]
154-
#![deny(intra_doc_link_resolution_failure)]
155153
#![deny(unsafe_op_in_unsafe_fn)]
156154

157155
#[prelude_import]

library/std/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@
212212
#![warn(deprecated_in_future)]
213213
#![warn(missing_docs)]
214214
#![warn(missing_debug_implementations)]
215-
#![deny(intra_doc_link_resolution_failure)] // rustdoc is run without -D warnings
216215
#![allow(explicit_outlives_requirements)]
217216
#![allow(unused_lifetimes)]
218217
// Tell the compiler to link to either panic_abort or panic_unwind

src/doc/rustdoc/src/lints.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ can use them like any other lints by doing this:
1111

1212
Here is the list of the lints provided by `rustdoc`:
1313

14-
## intra_doc_link_resolution_failure
14+
## broken_intra_doc_links
1515

1616
This lint **warns by default** and is **nightly-only**. This lint detects when
1717
an intra-doc link fails to get resolved. For example:

src/librustc_lint/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ use rustc_hir::def_id::LocalDefId;
6161
use rustc_middle::ty::query::Providers;
6262
use rustc_middle::ty::TyCtxt;
6363
use rustc_session::lint::builtin::{
64-
BARE_TRAIT_OBJECTS, ELIDED_LIFETIMES_IN_PATHS, EXPLICIT_OUTLIVES_REQUIREMENTS,
65-
INTRA_DOC_LINK_RESOLUTION_FAILURE, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_DOC_CODE_EXAMPLES,
64+
BARE_TRAIT_OBJECTS, BROKEN_INTRA_DOC_LINKS, ELIDED_LIFETIMES_IN_PATHS,
65+
EXPLICIT_OUTLIVES_REQUIREMENTS, INVALID_CODEBLOCK_ATTRIBUTES, MISSING_DOC_CODE_EXAMPLES,
6666
PRIVATE_DOC_TESTS,
6767
};
6868
use rustc_span::symbol::{Ident, Symbol};
@@ -303,7 +303,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
303303

304304
add_lint_group!(
305305
"rustdoc",
306-
INTRA_DOC_LINK_RESOLUTION_FAILURE,
306+
BROKEN_INTRA_DOC_LINKS,
307307
INVALID_CODEBLOCK_ATTRIBUTES,
308308
MISSING_DOC_CODE_EXAMPLES,
309309
PRIVATE_DOC_TESTS
@@ -318,6 +318,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
318318
store.register_renamed("async_idents", "keyword_idents");
319319
store.register_renamed("exceeding_bitshifts", "arithmetic_overflow");
320320
store.register_renamed("redundant_semicolon", "redundant_semicolons");
321+
store.register_renamed("intra_doc_link_resolution_failure", "broken_intra_doc_links");
321322
store.register_removed("unknown_features", "replaced by an error");
322323
store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate");
323324
store.register_removed("negate_unsigned", "cast a signed value instead");

src/librustc_session/lint/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ declare_lint! {
398398
}
399399

400400
declare_lint! {
401-
pub INTRA_DOC_LINK_RESOLUTION_FAILURE,
401+
pub BROKEN_INTRA_DOC_LINKS,
402402
Warn,
403403
"failures in resolving intra-doc link targets"
404404
}
@@ -601,7 +601,7 @@ declare_lint_pass! {
601601
ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
602602
UNSTABLE_NAME_COLLISIONS,
603603
IRREFUTABLE_LET_PATTERNS,
604-
INTRA_DOC_LINK_RESOLUTION_FAILURE,
604+
BROKEN_INTRA_DOC_LINKS,
605605
INVALID_CODEBLOCK_ATTRIBUTES,
606606
MISSING_CRATE_LEVEL_DOCS,
607607
MISSING_DOC_CODE_EXAMPLES,

src/librustdoc/core.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
315315
let cpath = Some(input.clone());
316316
let input = Input::File(input);
317317

318-
let intra_link_resolution_failure_name = lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURE.name;
318+
let intra_link_resolution_failure_name = lint::builtin::BROKEN_INTRA_DOC_LINKS.name;
319319
let missing_docs = rustc_lint::builtin::MISSING_DOCS.name;
320320
let missing_doc_example = rustc_lint::builtin::MISSING_DOC_CODE_EXAMPLES.name;
321321
let private_doc_tests = rustc_lint::builtin::PRIVATE_DOC_TESTS.name;

src/librustdoc/passes/collect_intra_doc_links.rs

+30-36
Original file line numberDiff line numberDiff line change
@@ -867,46 +867,40 @@ fn report_diagnostic(
867867
let attrs = &item.attrs;
868868
let sp = span_of_attrs(attrs).unwrap_or(item.source.span());
869869

870-
cx.tcx.struct_span_lint_hir(
871-
lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURE,
872-
hir_id,
873-
sp,
874-
|lint| {
875-
let mut diag = lint.build(msg);
876-
877-
let span = link_range
878-
.as_ref()
879-
.and_then(|range| super::source_span_for_markdown_range(cx, dox, range, attrs));
880-
881-
if let Some(link_range) = link_range {
882-
if let Some(sp) = span {
883-
diag.set_span(sp);
884-
} else {
885-
// blah blah blah\nblah\nblah [blah] blah blah\nblah blah
886-
// ^ ~~~~
887-
// | link_range
888-
// last_new_line_offset
889-
let last_new_line_offset =
890-
dox[..link_range.start].rfind('\n').map_or(0, |n| n + 1);
891-
let line = dox[last_new_line_offset..].lines().next().unwrap_or("");
892-
893-
// Print the line containing the `link_range` and manually mark it with '^'s.
894-
diag.note(&format!(
895-
"the link appears in this line:\n\n{line}\n\
870+
cx.tcx.struct_span_lint_hir(lint::builtin::BROKEN_INTRA_DOC_LINKS, hir_id, sp, |lint| {
871+
let mut diag = lint.build(msg);
872+
873+
let span = link_range
874+
.as_ref()
875+
.and_then(|range| super::source_span_for_markdown_range(cx, dox, range, attrs));
876+
877+
if let Some(link_range) = link_range {
878+
if let Some(sp) = span {
879+
diag.set_span(sp);
880+
} else {
881+
// blah blah blah\nblah\nblah [blah] blah blah\nblah blah
882+
// ^ ~~~~
883+
// | link_range
884+
// last_new_line_offset
885+
let last_new_line_offset = dox[..link_range.start].rfind('\n').map_or(0, |n| n + 1);
886+
let line = dox[last_new_line_offset..].lines().next().unwrap_or("");
887+
888+
// Print the line containing the `link_range` and manually mark it with '^'s.
889+
diag.note(&format!(
890+
"the link appears in this line:\n\n{line}\n\
896891
{indicator: <before$}{indicator:^<found$}",
897-
line = line,
898-
indicator = "",
899-
before = link_range.start - last_new_line_offset,
900-
found = link_range.len(),
901-
));
902-
}
892+
line = line,
893+
indicator = "",
894+
before = link_range.start - last_new_line_offset,
895+
found = link_range.len(),
896+
));
903897
}
898+
}
904899

905-
decorate(&mut diag, span);
900+
decorate(&mut diag, span);
906901

907-
diag.emit();
908-
},
909-
);
902+
diag.emit();
903+
});
910904
}
911905

912906
fn resolution_failure(

src/test/run-make-fulldeps/exit-code/lint-failure.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(intra_doc_link_resolution_failure)]
1+
#![deny(broken_intra_doc_links)]
22

33
/// [intradoc::failure]
44
pub fn main() {
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(intra_doc_link_resolution_failure)]
1+
#![deny(broken_intra_doc_links)]
22

33
/// [v2] //~ ERROR
44
pub fn foo() {}

src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LL | /// [v2]
77
note: the lint level is defined here
88
--> $DIR/deny-intra-link-resolution-failure.rs:1:9
99
|
10-
LL | #![deny(intra_doc_link_resolution_failure)]
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
LL | #![deny(broken_intra_doc_links)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^
1212
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
1313

1414
error: aborting due to previous error

src/test/rustdoc-ui/intra-doc-alias-ice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(intra_doc_link_resolution_failure)]
1+
#![deny(broken_intra_doc_links)]
22

33
pub type TypeAlias = usize;
44

src/test/rustdoc-ui/intra-doc-alias-ice.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LL | /// [broken cross-reference](TypeAlias::hoge)
77
note: the lint level is defined here
88
--> $DIR/intra-doc-alias-ice.rs:1:9
99
|
10-
LL | #![deny(intra_doc_link_resolution_failure)]
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
LL | #![deny(broken_intra_doc_links)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^
1212
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
1313

1414
error: aborting due to previous error

src/test/rustdoc-ui/intra-link-span-ice-55723.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(intra_doc_link_resolution_failure)]
1+
#![deny(broken_intra_doc_links)]
22

33
// An error in calculating spans while reporting intra-doc link resolution errors caused rustdoc to
44
// attempt to slice in the middle of a multibyte character. See

src/test/rustdoc-ui/intra-link-span-ice-55723.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LL | /// (arr[i])
77
note: the lint level is defined here
88
--> $DIR/intra-link-span-ice-55723.rs:1:9
99
|
10-
LL | #![deny(intra_doc_link_resolution_failure)]
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
LL | #![deny(broken_intra_doc_links)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^
1212
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
1313

1414
error: aborting due to previous error

src/test/rustdoc-ui/intra-links-ambiguity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(intra_doc_link_resolution_failure)]
1+
#![deny(broken_intra_doc_links)]
22
#![allow(non_camel_case_types)]
33
#![allow(non_upper_case_globals)]
44

src/test/rustdoc-ui/intra-links-ambiguity.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LL | /// [`ambiguous`] is ambiguous.
77
note: the lint level is defined here
88
--> $DIR/intra-links-ambiguity.rs:1:9
99
|
10-
LL | #![deny(intra_doc_link_resolution_failure)]
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
LL | #![deny(broken_intra_doc_links)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^
1212
help: to link to the struct, prefix with the item type
1313
|
1414
LL | /// [`struct@ambiguous`] is ambiguous.

src/test/rustdoc-ui/intra-links-anchors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![deny(intra_doc_link_resolution_failure)]
1+
#![deny(broken_intra_doc_links)]
22

33
// A few tests on anchors.
44

src/test/rustdoc-ui/intra-links-anchors.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ LL | /// Or maybe [Foo::f#hola].
77
note: the lint level is defined here
88
--> $DIR/intra-links-anchors.rs:1:9
99
|
10-
LL | #![deny(intra_doc_link_resolution_failure)]
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
LL | #![deny(broken_intra_doc_links)]
11+
| ^^^^^^^^^^^^^^^^^^^^^^
1212

1313
error: `hello#people#!` contains multiple anchors
1414
--> $DIR/intra-links-anchors.rs:31:28

src/test/rustdoc-ui/intra-links-private.private.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: public documentation for `DocMe` links to private item `DontDocMe`
44
LL | /// docs [DontDocMe]
55
| ^^^^^^^^^ this item is private
66
|
7-
= note: `#[warn(intra_doc_link_resolution_failure)]` on by default
7+
= note: `#[warn(broken_intra_doc_links)]` on by default
88
= note: this link resolves only because you passed `--document-private-items`, but will break without
99

1010
warning: 1 warning emitted

src/test/rustdoc-ui/intra-links-private.public.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: public documentation for `DocMe` links to private item `DontDocMe`
44
LL | /// docs [DontDocMe]
55
| ^^^^^^^^^ this item is private
66
|
7-
= note: `#[warn(intra_doc_link_resolution_failure)]` on by default
7+
= note: `#[warn(broken_intra_doc_links)]` on by default
88
= note: this link will resolve properly if you pass `--document-private-items`
99

1010
warning: 1 warning emitted

src/test/rustdoc-ui/intra-links-warning-crlf.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unresolved link to `error`
44
LL | /// [error]
55
| ^^^^^ unresolved link
66
|
7-
= note: `#[warn(intra_doc_link_resolution_failure)]` on by default
7+
= note: `#[warn(broken_intra_doc_links)]` on by default
88
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
99

1010
warning: unresolved link to `error1`

src/test/rustdoc-ui/intra-links-warning.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unresolved link to `Foo::baz`
44
LL | //! Test with [Foo::baz], [Bar::foo], ...
55
| ^^^^^^^^ unresolved link
66
|
7-
= note: `#[warn(intra_doc_link_resolution_failure)]` on by default
7+
= note: `#[warn(broken_intra_doc_links)]` on by default
88
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
99

1010
warning: unresolved link to `Bar::foo`

src/test/rustdoc-ui/issue-74134.private.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: public documentation for `public_item` links to private item `PrivateTy
44
LL | /// [`PrivateType`]
55
| ^^^^^^^^^^^^^ this item is private
66
|
7-
= note: `#[warn(intra_doc_link_resolution_failure)]` on by default
7+
= note: `#[warn(broken_intra_doc_links)]` on by default
88
= note: this link resolves only because you passed `--document-private-items`, but will break without
99

1010
warning: 1 warning emitted

src/test/rustdoc-ui/issue-74134.public.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: public documentation for `public_item` links to private item `PrivateTy
44
LL | /// [`PrivateType`]
55
| ^^^^^^^^^^^^^ this item is private
66
|
7-
= note: `#[warn(intra_doc_link_resolution_failure)]` on by default
7+
= note: `#[warn(broken_intra_doc_links)]` on by default
88
= note: this link will resolve properly if you pass `--document-private-items`
99

1010
warning: 1 warning emitted

src/test/rustdoc-ui/lint-group.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ note: the lint level is defined here
3939
|
4040
LL | #![deny(rustdoc)]
4141
| ^^^^^^^
42-
= note: `#[deny(intra_doc_link_resolution_failure)]` implied by `#[deny(rustdoc)]`
42+
= note: `#[deny(broken_intra_doc_links)]` implied by `#[deny(rustdoc)]`
4343
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
4444

4545
error: aborting due to 3 previous errors

src/test/rustdoc-ui/reference-link-has-one-warning.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: `[with#anchor#error]` has an issue with the link anchor.
44
LL | /// docs [label][with#anchor#error]
55
| ^^^^^^^^^^^^^^^^^ only one `#` is allowed in a link
66
|
7-
= note: `#[warn(intra_doc_link_resolution_failure)]` on by default
7+
= note: `#[warn(broken_intra_doc_links)]` on by default
88

99
warning: 1 warning emitted
1010

src/test/rustdoc/intra-doc-crate/additional_doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// aux-build:additional_doc.rs
22
// build-aux-docs
3-
#![deny(intra_doc_link_resolution_failure)]
3+
#![deny(broken_intra_doc_links)]
44

55
extern crate my_rand;
66

src/test/rustdoc/intra-doc-crate/auxiliary/additional_doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![crate_name = "my_rand"]
2-
#![deny(intra_doc_link_resolution_failure)]
2+
#![deny(broken_intra_doc_links)]
33

44
pub trait RngCore {}
55
/// Rng extends [`RngCore`].

src/test/rustdoc/intra-doc-crate/auxiliary/hidden.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![crate_name = "hidden_dep"]
2-
#![deny(intra_doc_link_resolution_failure)]
2+
#![deny(broken_intra_doc_links)]
33

44
#[doc(hidden)]
55
pub mod __reexport {

src/test/rustdoc/intra-doc-crate/auxiliary/intra-doc-basic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![crate_name = "a"]
2-
#![deny(intra_doc_link_resolution_failure)]
2+
#![deny(broken_intra_doc_links)]
33

44
pub struct Foo;
55

src/test/rustdoc/intra-doc-crate/auxiliary/macro_inner.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![crate_name = "macro_inner"]
2-
#![deny(intra_doc_link_resolution_failure)]
2+
#![deny(broken_intra_doc_links)]
33

44
pub struct Foo;
55

src/test/rustdoc/intra-doc-crate/auxiliary/module.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![crate_name = "module_inner"]
2-
#![deny(intra_doc_link_resolution_failure)]
2+
#![deny(broken_intra_doc_links)]
33
/// [SomeType] links to [bar]
44
pub struct SomeType;
55
pub trait SomeTrait {}

src/test/rustdoc/intra-doc-crate/auxiliary/submodule-inner.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![crate_name = "a"]
2-
#![deny(intra_doc_link_resolution_failure)]
2+
#![deny(broken_intra_doc_links)]
33

44
pub mod bar {
55
pub struct Bar;

src/test/rustdoc/intra-doc-crate/auxiliary/submodule-outer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![crate_name = "bar"]
2-
#![deny(intra_doc_link_resolution_failure)]
2+
#![deny(broken_intra_doc_links)]
33

44
pub trait Foo {
55
/// [`Bar`] [`Baz`]

0 commit comments

Comments
 (0)