Rollup merge of #132748 - lolbinarycat:rustdoc-intra-doc-link-warn-more-54191, r=GuillaumeGomez
get rid of some false negatives in rustdoc::broken_intra_doc_links rustdoc will not try to do intra-doc linking if the "path" of a link looks too much like a "real url". however, only inline links (`[text](url)`) can actually contain a url, other types of links (reference links, shortcut links) contain a *reference* which is later resolved to an actual url. the "path" in this case cannot be a url, and therefore it should not be skipped due to looking like a url. fixes https://github.com/rust-lang/rust/issues/54191 to minimize the number of false positives that will be introduced, the following heuristic is used: If there's no backticks, be lenient revert to old behavior. This is to prevent churn by linting on stuff that isn't meant to be a link. only shortcut links have simple enough syntax that they are likely to be written accidentlly, collapsed and reference links need 4 metachars, and reference links will not usually use backticks in the reference name. therefore, only shortcut syntax gets the lenient behavior. here's a truth table for how link kinds that cannot be urls are handled: | | is shortcut link | not shortcut link | |--------------|--------------------|-------------------| | has backtick | never ignore | never ignore | | no backtick | ignore if url-like | never ignore |
This commit is contained in:
@@ -611,6 +611,7 @@ where
|
||||
///
|
||||
/// For example, with 3 fields, the drop ladder is
|
||||
///
|
||||
/// ```text
|
||||
/// .d0:
|
||||
/// ELAB(drop location.0 [target=.d1, unwind=.c1])
|
||||
/// .d1:
|
||||
@@ -621,8 +622,10 @@ where
|
||||
/// ELAB(drop location.1 [target=.c2])
|
||||
/// .c2:
|
||||
/// ELAB(drop location.2 [target=`self.unwind`])
|
||||
/// ```
|
||||
///
|
||||
/// For possible-async drops in coroutines we also need dropline ladder
|
||||
/// ```text
|
||||
/// .d0 (mainline):
|
||||
/// ELAB(drop location.0 [target=.d1, unwind=.c1, drop=.e1])
|
||||
/// .d1 (mainline):
|
||||
@@ -637,6 +640,7 @@ where
|
||||
/// ELAB(drop location.1 [target=.e2, unwind=.c2])
|
||||
/// .e2 (dropline):
|
||||
/// ELAB(drop location.2 [target=`self.drop`, unwind=`self.unwind`])
|
||||
/// ```
|
||||
///
|
||||
/// NOTE: this does not clear the master drop flag, so you need
|
||||
/// to point succ/unwind on a `drop_ladder_bottom`.
|
||||
|
||||
@@ -44,7 +44,7 @@ impl SleepData {
|
||||
/// jobs are published, and it either blocks threads or wakes them in response to these
|
||||
/// events. See the [`README.md`] in this module for more details.
|
||||
///
|
||||
/// [`README.md`] README.md
|
||||
/// [`README.md`]: README.md
|
||||
pub(super) struct Sleep {
|
||||
/// One "sleep state" per worker. Used to track if a worker is sleeping and to have
|
||||
/// them block.
|
||||
|
||||
@@ -941,13 +941,21 @@ fn preprocess_link(
|
||||
ori_link: &MarkdownLink,
|
||||
dox: &str,
|
||||
) -> Option<Result<PreprocessingInfo, PreprocessingError>> {
|
||||
// certain link kinds cannot have their path be urls,
|
||||
// so they should not be ignored, no matter how much they look like urls.
|
||||
// e.g. [https://example.com/] is not a link to example.com.
|
||||
let can_be_url = !matches!(
|
||||
ori_link.kind,
|
||||
LinkType::ShortcutUnknown | LinkType::CollapsedUnknown | LinkType::ReferenceUnknown
|
||||
);
|
||||
|
||||
// [] is mostly likely not supposed to be a link
|
||||
if ori_link.link.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
// Bail early for real links.
|
||||
if ori_link.link.contains('/') {
|
||||
if can_be_url && ori_link.link.contains('/') {
|
||||
return None;
|
||||
}
|
||||
|
||||
@@ -972,7 +980,7 @@ fn preprocess_link(
|
||||
Ok(None) => (None, link, link),
|
||||
Err((err_msg, relative_range)) => {
|
||||
// Only report error if we would not have ignored this link. See issue #83859.
|
||||
if !should_ignore_link_with_disambiguators(link) {
|
||||
if !(can_be_url && should_ignore_link_with_disambiguators(link)) {
|
||||
let disambiguator_range = match range_between_backticks(&ori_link.range, dox) {
|
||||
MarkdownLinkRange::Destination(no_backticks_range) => {
|
||||
MarkdownLinkRange::Destination(
|
||||
@@ -989,7 +997,25 @@ fn preprocess_link(
|
||||
}
|
||||
};
|
||||
|
||||
if should_ignore_link(path_str) {
|
||||
// If there's no backticks, be lenient and revert to the old behavior.
|
||||
// This is to prevent churn by linting on stuff that isn't meant to be a link.
|
||||
// only shortcut links have simple enough syntax that they
|
||||
// are likely to be written accidentally, collapsed and reference links
|
||||
// need 4 metachars, and reference links will not usually use
|
||||
// backticks in the reference name.
|
||||
// therefore, only shortcut syntax gets the lenient behavior.
|
||||
//
|
||||
// here's a truth table for how link kinds that cannot be urls are handled:
|
||||
//
|
||||
// |-------------------------------------------------------|
|
||||
// | | is shortcut link | not shortcut link |
|
||||
// |--------------|--------------------|-------------------|
|
||||
// | has backtick | never ignore | never ignore |
|
||||
// | no backtick | ignore if url-like | never ignore |
|
||||
// |-------------------------------------------------------|
|
||||
let ignore_urllike =
|
||||
can_be_url || (ori_link.kind == LinkType::ShortcutUnknown && !ori_link.link.contains('`'));
|
||||
if ignore_urllike && should_ignore_link(path_str) {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,67 +2,67 @@
|
||||
//@ normalize-stderr: "nightly|beta|1\.[0-9][0-9]\.[0-9]" -> "$$CHANNEL"
|
||||
|
||||
//! [struct@m!()] //~ WARN: unmatched disambiguator `struct` and suffix `!()`
|
||||
//! [struct@m!{}]
|
||||
//! [struct@m!{}] //~ WARN: unmatched disambiguator `struct` and suffix `!{}`
|
||||
//! [struct@m![]]
|
||||
//! [struct@f()] //~ WARN: unmatched disambiguator `struct` and suffix `()`
|
||||
//! [struct@m!] //~ WARN: unmatched disambiguator `struct` and suffix `!`
|
||||
//!
|
||||
//! [enum@m!()] //~ WARN: unmatched disambiguator `enum` and suffix `!()`
|
||||
//! [enum@m!{}]
|
||||
//! [enum@m!{}] //~ WARN: unmatched disambiguator `enum` and suffix `!{}`
|
||||
//! [enum@m![]]
|
||||
//! [enum@f()] //~ WARN: unmatched disambiguator `enum` and suffix `()`
|
||||
//! [enum@m!] //~ WARN: unmatched disambiguator `enum` and suffix `!`
|
||||
//!
|
||||
//! [trait@m!()] //~ WARN: unmatched disambiguator `trait` and suffix `!()`
|
||||
//! [trait@m!{}]
|
||||
//! [trait@m!{}] //~ WARN: unmatched disambiguator `trait` and suffix `!{}`
|
||||
//! [trait@m![]]
|
||||
//! [trait@f()] //~ WARN: unmatched disambiguator `trait` and suffix `()`
|
||||
//! [trait@m!] //~ WARN: unmatched disambiguator `trait` and suffix `!`
|
||||
//!
|
||||
//! [module@m!()] //~ WARN: unmatched disambiguator `module` and suffix `!()`
|
||||
//! [module@m!{}]
|
||||
//! [module@m!{}] //~ WARN: unmatched disambiguator `module` and suffix `!{}`
|
||||
//! [module@m![]]
|
||||
//! [module@f()] //~ WARN: unmatched disambiguator `module` and suffix `()`
|
||||
//! [module@m!] //~ WARN: unmatched disambiguator `module` and suffix `!`
|
||||
//!
|
||||
//! [mod@m!()] //~ WARN: unmatched disambiguator `mod` and suffix `!()`
|
||||
//! [mod@m!{}]
|
||||
//! [mod@m!{}] //~ WARN: unmatched disambiguator `mod` and suffix `!{}`
|
||||
//! [mod@m![]]
|
||||
//! [mod@f()] //~ WARN: unmatched disambiguator `mod` and suffix `()`
|
||||
//! [mod@m!] //~ WARN: unmatched disambiguator `mod` and suffix `!`
|
||||
//!
|
||||
//! [const@m!()] //~ WARN: unmatched disambiguator `const` and suffix `!()`
|
||||
//! [const@m!{}]
|
||||
//! [const@m!{}] //~ WARN: unmatched disambiguator `const` and suffix `!{}`
|
||||
//! [const@m![]]
|
||||
//! [const@f()] //~ WARN: incompatible link kind for `f`
|
||||
//! [const@m!] //~ WARN: unmatched disambiguator `const` and suffix `!`
|
||||
//!
|
||||
//! [constant@m!()] //~ WARN: unmatched disambiguator `constant` and suffix `!()`
|
||||
//! [constant@m!{}]
|
||||
//! [constant@m!{}] //~ WARN: unmatched disambiguator `constant` and suffix `!{}`
|
||||
//! [constant@m![]]
|
||||
//! [constant@f()] //~ WARN: incompatible link kind for `f`
|
||||
//! [constant@m!] //~ WARN: unmatched disambiguator `constant` and suffix `!`
|
||||
//!
|
||||
//! [static@m!()] //~ WARN: unmatched disambiguator `static` and suffix `!()`
|
||||
//! [static@m!{}]
|
||||
//! [static@m!{}] //~ WARN: unmatched disambiguator `static` and suffix `!{}`
|
||||
//! [static@m![]]
|
||||
//! [static@f()] //~ WARN: incompatible link kind for `f`
|
||||
//! [static@m!] //~ WARN: unmatched disambiguator `static` and suffix `!`
|
||||
//!
|
||||
//! [function@m!()] //~ WARN: unmatched disambiguator `function` and suffix `!()`
|
||||
//! [function@m!{}]
|
||||
//! [function@m!{}] //~ WARN: unmatched disambiguator `function` and suffix `!{}`
|
||||
//! [function@m![]]
|
||||
//! [function@f()]
|
||||
//! [function@m!] //~ WARN: unmatched disambiguator `function` and suffix `!`
|
||||
//!
|
||||
//! [fn@m!()] //~ WARN: unmatched disambiguator `fn` and suffix `!()`
|
||||
//! [fn@m!{}]
|
||||
//! [fn@m!{}] //~ WARN: unmatched disambiguator `fn` and suffix `!{}`
|
||||
//! [fn@m![]]
|
||||
//! [fn@f()]
|
||||
//! [fn@m!] //~ WARN: unmatched disambiguator `fn` and suffix `!`
|
||||
//!
|
||||
//! [method@m!()] //~ WARN: unmatched disambiguator `method` and suffix `!()`
|
||||
//! [method@m!{}]
|
||||
//! [method@m!{}] //~ WARN: unmatched disambiguator `method` and suffix `!{}`
|
||||
//! [method@m![]]
|
||||
//! [method@f()]
|
||||
//! [method@m!] //~ WARN: unmatched disambiguator `method` and suffix `!`
|
||||
@@ -74,13 +74,13 @@
|
||||
//! [derive@m!] //~ WARN: incompatible link kind for `m`
|
||||
//!
|
||||
//! [type@m!()] //~ WARN: unmatched disambiguator `type` and suffix `!()`
|
||||
//! [type@m!{}]
|
||||
//! [type@m!{}] //~ WARN: unmatched disambiguator `type` and suffix `!{}`
|
||||
//! [type@m![]]
|
||||
//! [type@f()] //~ WARN: unmatched disambiguator `type` and suffix `()`
|
||||
//! [type@m!] //~ WARN: unmatched disambiguator `type` and suffix `!`
|
||||
//!
|
||||
//! [value@m!()] //~ WARN: unmatched disambiguator `value` and suffix `!()`
|
||||
//! [value@m!{}]
|
||||
//! [value@m!{}] //~ WARN: unmatched disambiguator `value` and suffix `!{}`
|
||||
//! [value@m![]]
|
||||
//! [value@f()]
|
||||
//! [value@m!] //~ WARN: unmatched disambiguator `value` and suffix `!`
|
||||
@@ -92,13 +92,13 @@
|
||||
//! [macro@m!]
|
||||
//!
|
||||
//! [prim@m!()] //~ WARN: unmatched disambiguator `prim` and suffix `!()`
|
||||
//! [prim@m!{}]
|
||||
//! [prim@m!{}] //~ WARN: unmatched disambiguator `prim` and suffix `!{}`
|
||||
//! [prim@m![]]
|
||||
//! [prim@f()] //~ WARN: unmatched disambiguator `prim` and suffix `()`
|
||||
//! [prim@m!] //~ WARN: unmatched disambiguator `prim` and suffix `!`
|
||||
//!
|
||||
//! [primitive@m!()] //~ WARN: unmatched disambiguator `primitive` and suffix `!()`
|
||||
//! [primitive@m!{}]
|
||||
//! [primitive@m!{}] //~ WARN: unmatched disambiguator `primitive` and suffix `!{}`
|
||||
//! [primitive@m![]]
|
||||
//! [primitive@f()] //~ WARN: unmatched disambiguator `primitive` and suffix `()`
|
||||
//! [primitive@m!] //~ WARN: unmatched disambiguator `primitive` and suffix `!`
|
||||
|
||||
@@ -7,6 +7,14 @@ LL | //! [struct@m!()]
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
= note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
|
||||
|
||||
warning: unmatched disambiguator `struct` and suffix `!{}`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:5:6
|
||||
|
|
||||
LL | //! [struct@m!{}]
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `struct` and suffix `()`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:7:6
|
||||
|
|
||||
@@ -31,6 +39,14 @@ LL | //! [enum@m!()]
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `enum` and suffix `!{}`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:11:6
|
||||
|
|
||||
LL | //! [enum@m!{}]
|
||||
| ^^^^
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `enum` and suffix `()`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:13:6
|
||||
|
|
||||
@@ -55,6 +71,14 @@ LL | //! [trait@m!()]
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `trait` and suffix `!{}`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:17:6
|
||||
|
|
||||
LL | //! [trait@m!{}]
|
||||
| ^^^^^
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `trait` and suffix `()`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:19:6
|
||||
|
|
||||
@@ -79,6 +103,14 @@ LL | //! [module@m!()]
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `module` and suffix `!{}`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:23:6
|
||||
|
|
||||
LL | //! [module@m!{}]
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `module` and suffix `()`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:25:6
|
||||
|
|
||||
@@ -103,6 +135,14 @@ LL | //! [mod@m!()]
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `mod` and suffix `!{}`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:29:6
|
||||
|
|
||||
LL | //! [mod@m!{}]
|
||||
| ^^^
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `mod` and suffix `()`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:31:6
|
||||
|
|
||||
@@ -127,6 +167,14 @@ LL | //! [const@m!()]
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `const` and suffix `!{}`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:35:6
|
||||
|
|
||||
LL | //! [const@m!{}]
|
||||
| ^^^^^
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: incompatible link kind for `f`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:37:6
|
||||
|
|
||||
@@ -155,6 +203,14 @@ LL | //! [constant@m!()]
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `constant` and suffix `!{}`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:41:6
|
||||
|
|
||||
LL | //! [constant@m!{}]
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: incompatible link kind for `f`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:43:6
|
||||
|
|
||||
@@ -183,6 +239,14 @@ LL | //! [static@m!()]
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `static` and suffix `!{}`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:47:6
|
||||
|
|
||||
LL | //! [static@m!{}]
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: incompatible link kind for `f`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:49:6
|
||||
|
|
||||
@@ -211,6 +275,14 @@ LL | //! [function@m!()]
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `function` and suffix `!{}`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:53:6
|
||||
|
|
||||
LL | //! [function@m!{}]
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `function` and suffix `!`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:56:6
|
||||
|
|
||||
@@ -227,6 +299,14 @@ LL | //! [fn@m!()]
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `fn` and suffix `!{}`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:59:6
|
||||
|
|
||||
LL | //! [fn@m!{}]
|
||||
| ^^
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `fn` and suffix `!`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:62:6
|
||||
|
|
||||
@@ -243,6 +323,14 @@ LL | //! [method@m!()]
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `method` and suffix `!{}`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:65:6
|
||||
|
|
||||
LL | //! [method@m!{}]
|
||||
| ^^^^^^
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `method` and suffix `!`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:68:6
|
||||
|
|
||||
@@ -303,6 +391,14 @@ LL | //! [type@m!()]
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `type` and suffix `!{}`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:77:6
|
||||
|
|
||||
LL | //! [type@m!{}]
|
||||
| ^^^^
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `type` and suffix `()`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:79:6
|
||||
|
|
||||
@@ -327,6 +423,14 @@ LL | //! [value@m!()]
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `value` and suffix `!{}`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:83:6
|
||||
|
|
||||
LL | //! [value@m!{}]
|
||||
| ^^^^^
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `value` and suffix `!`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:86:6
|
||||
|
|
||||
@@ -351,6 +455,14 @@ LL | //! [prim@m!()]
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `prim` and suffix `!{}`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:95:6
|
||||
|
|
||||
LL | //! [prim@m!{}]
|
||||
| ^^^^
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `prim` and suffix `()`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:97:6
|
||||
|
|
||||
@@ -375,6 +487,14 @@ LL | //! [primitive@m!()]
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `primitive` and suffix `!{}`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:101:6
|
||||
|
|
||||
LL | //! [primitive@m!{}]
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: unmatched disambiguator `primitive` and suffix `()`
|
||||
--> $DIR/disambiguator-endswith-named-suffix.rs:103:6
|
||||
|
|
||||
@@ -391,5 +511,5 @@ LL | //! [primitive@m!]
|
||||
|
|
||||
= note: see https://doc.rust-lang.org/$CHANNEL/rustdoc/write-documentation/linking-to-items-by-name.html#namespaces-and-disambiguators for more info about disambiguators
|
||||
|
||||
warning: 46 warnings emitted
|
||||
warning: 61 warnings emitted
|
||||
|
||||
|
||||
15
tests/rustdoc-ui/intra-doc/bad-intra-doc.rs
Normal file
15
tests/rustdoc-ui/intra-doc/bad-intra-doc.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
#![no_std]
|
||||
#![deny(rustdoc::broken_intra_doc_links)]
|
||||
|
||||
// regression test for https://github.com/rust-lang/rust/issues/54191
|
||||
|
||||
/// this is not a link to [`example.com`] //~ERROR unresolved link
|
||||
///
|
||||
/// this link [`has spaces in it`].
|
||||
///
|
||||
/// attempted link to method: [`Foo.bar()`] //~ERROR unresolved link
|
||||
///
|
||||
/// classic broken intra-doc link: [`Bar`] //~ERROR unresolved link
|
||||
///
|
||||
/// no backticks, so we let this one slide: [Foo.bar()]
|
||||
pub struct Foo;
|
||||
31
tests/rustdoc-ui/intra-doc/bad-intra-doc.stderr
Normal file
31
tests/rustdoc-ui/intra-doc/bad-intra-doc.stderr
Normal file
@@ -0,0 +1,31 @@
|
||||
error: unresolved link to `example.com`
|
||||
--> $DIR/bad-intra-doc.rs:6:29
|
||||
|
|
||||
LL | /// this is not a link to [`example.com`]
|
||||
| ^^^^^^^^^^^ no item named `example.com` in scope
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
note: the lint level is defined here
|
||||
--> $DIR/bad-intra-doc.rs:2:9
|
||||
|
|
||||
LL | #![deny(rustdoc::broken_intra_doc_links)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unresolved link to `Foo.bar`
|
||||
--> $DIR/bad-intra-doc.rs:10:33
|
||||
|
|
||||
LL | /// attempted link to method: [`Foo.bar()`]
|
||||
| ^^^^^^^^^ no item named `Foo.bar` in scope
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
error: unresolved link to `Bar`
|
||||
--> $DIR/bad-intra-doc.rs:12:38
|
||||
|
|
||||
LL | /// classic broken intra-doc link: [`Bar`]
|
||||
| ^^^ no item named `Bar` in scope
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
@@ -65,7 +65,7 @@ pub struct XLinkToCloneWithStartSpace;
|
||||
/// [x][struct@Clone ] //~ERROR link
|
||||
pub struct XLinkToCloneWithEndSpace;
|
||||
|
||||
/// [x][Clone\(\)] not URL-shaped enough
|
||||
/// [x][Clone\(\)] //~ERROR link
|
||||
pub struct XLinkToCloneWithEscapedParens;
|
||||
|
||||
/// [x][`Clone`] not URL-shaped enough
|
||||
|
||||
@@ -123,6 +123,14 @@ LL - /// [x][struct@Clone ]
|
||||
LL + /// [x][trait@Clone ]
|
||||
|
|
||||
|
||||
error: unresolved link to `Clone\(\)`
|
||||
--> $DIR/weird-syntax.rs:68:9
|
||||
|
|
||||
LL | /// [x][Clone\(\)]
|
||||
| ^^^^^^^^^ no item named `Clone\(\)` in scope
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
error: unresolved link to `Clone`
|
||||
--> $DIR/weird-syntax.rs:74:9
|
||||
|
|
||||
@@ -299,5 +307,5 @@ LL | /// - [`SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER`]: the
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
error: aborting due to 27 previous errors
|
||||
error: aborting due to 28 previous errors
|
||||
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
//@ check-pass
|
||||
|
||||
/// [`…foo`] [`…bar`] [`Err`]
|
||||
/// [`…foo`] //~ WARN: unresolved link
|
||||
/// [`…bar`] //~ WARN: unresolved link
|
||||
/// [`Err`]
|
||||
pub struct Broken {}
|
||||
|
||||
/// [`…`] [`…`] [`Err`]
|
||||
/// [`…`] //~ WARN: unresolved link
|
||||
/// [`…`] //~ WARN: unresolved link
|
||||
/// [`Err`]
|
||||
pub struct Broken2 {}
|
||||
|
||||
/// [`…`][…] [`…`][…] [`Err`]
|
||||
/// [`…`][…] //~ WARN: unresolved link
|
||||
/// [`…`][…] //~ WARN: unresolved link
|
||||
/// [`Err`]
|
||||
pub struct Broken3 {}
|
||||
|
||||
/// […………………………][Broken3]
|
||||
pub struct Broken4 {}
|
||||
|
||||
/// [Broken3][…………………………]
|
||||
/// [Broken3][…………………………] //~ WARN: unresolved link
|
||||
pub struct Broken5 {}
|
||||
|
||||
pub struct Err;
|
||||
|
||||
59
tests/rustdoc-ui/lints/redundant_explicit_links-utf8.stderr
Normal file
59
tests/rustdoc-ui/lints/redundant_explicit_links-utf8.stderr
Normal file
@@ -0,0 +1,59 @@
|
||||
warning: unresolved link to `…foo`
|
||||
--> $DIR/redundant_explicit_links-utf8.rs:3:7
|
||||
|
|
||||
LL | /// [`…foo`]
|
||||
| ^^^^ no item named `…foo` in scope
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
= note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
|
||||
|
||||
warning: unresolved link to `…bar`
|
||||
--> $DIR/redundant_explicit_links-utf8.rs:4:7
|
||||
|
|
||||
LL | /// [`…bar`]
|
||||
| ^^^^ no item named `…bar` in scope
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
warning: unresolved link to `…`
|
||||
--> $DIR/redundant_explicit_links-utf8.rs:8:7
|
||||
|
|
||||
LL | /// [`…`]
|
||||
| ^ no item named `…` in scope
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
warning: unresolved link to `…`
|
||||
--> $DIR/redundant_explicit_links-utf8.rs:9:7
|
||||
|
|
||||
LL | /// [`…`]
|
||||
| ^ no item named `…` in scope
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
warning: unresolved link to `…`
|
||||
--> $DIR/redundant_explicit_links-utf8.rs:13:11
|
||||
|
|
||||
LL | /// [`…`][…]
|
||||
| ^ no item named `…` in scope
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
warning: unresolved link to `…`
|
||||
--> $DIR/redundant_explicit_links-utf8.rs:14:11
|
||||
|
|
||||
LL | /// [`…`][…]
|
||||
| ^ no item named `…` in scope
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
warning: unresolved link to `…………………………`
|
||||
--> $DIR/redundant_explicit_links-utf8.rs:21:15
|
||||
|
|
||||
LL | /// [Broken3][…………………………]
|
||||
| ^^^^^^^^^^ no item named `…………………………` in scope
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
warning: 7 warnings emitted
|
||||
|
||||
Reference in New Issue
Block a user