Auto merge of #75756 - jyn514:diagnostic-suggestions, r=estebank
Improve suggestions for broken intra-doc links ~~Depends on #74489 and should not be merged before that PR.~~ Merged 🎉 ~~Depends on #75916 and should not be merged before.~~ Merged Fixes https://github.com/rust-lang/rust/issues/75305. This does a lot of different things 😆. - Add `PerNS::into_iter()` so I didn't have to keep rewriting hacks around it. Also add `PerNS::iter()` for consistency. Let me know if this should be `impl IntoIterator` instead. - Make `ResolutionFailure` an enum instead of a unit variant. This was most of the changes: everywhere that said `ErrorKind::ResolutionFailure` now has to say _why_ the link failed to resolve. - Store the resolution in case of an anchor failure. Previously this was implemented as variants on `AnchorFailure` which was prone to typos and had inconsistent output compared to the rest of the diagnostics. - Turn some `Err`ors into unwrap() or panic()s, because they're rustdoc bugs and not user error. These have comments as to why they're bugs (in particular this would have caught #76073 as a bug a while ago). - If an item is not in scope at all, say the first segment in the path that failed to resolve - If an item exists but not in the current namespaces, say that and suggests linking to that namespace. - If there is a partial resolution for an item (part of the segments resolved, but not all of them), say the partial resolution and why the following segment didn't resolve. - Add the `DefId` of associated items to `kind_side_channel` so it can be used for diagnostics (tl;dr of the hack: the rest of rustdoc expects the id of the item, but for diagnostics we need the associated item). - No longer suggests escaping the brackets for every link that failed to resolve; this was pretty obnoxious. Now it only suggests `\[ \]` if no segment resolved and there is no `::` in the link. - Add `Suggestion`, which says _what_ to prefix the link with, not just 'prefix with the item kind'. Places where this is currently buggy: <details><summary>All outdated</summary> ~~1. When the link has the wrong namespace:~~ Now fixed. <details> ```rust /// [type@S::h] impl S { pub fn h() {} } /// [type@T::g] pub trait T { fn g() {} } ``` ``` error: unresolved link to `T::g` --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:53:6 | 53 | /// [type@T::g] | ^^^^^^^^^ | = note: this link partially resolves to the trait `T`, = note: `T` has no field, variant, or associated item named `g` error: unresolved link to `S::h` --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:48:6 | 48 | /// [type@S::h] | ^^^^^^^^^ | = note: this link partially resolves to the struct `S`, = note: `S` has no field, variant, or associated item named `h` ``` Instead it should suggest changing the disambiguator, the way it currently does for macros: ``` error: unresolved link to `S` --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:38:6 | 38 | /// [S!] | ^^ help: to link to the unit struct, use its disambiguator: `value@S` | = note: this link resolves to the unit struct `S`, which is not in the macro namespace ``` </details> 2. ~~Associated items for values. It says that the value isn't in scope; instead it should say that values can't have associated items.~~ Fixed. <details> ``` error: unresolved link to `f::A` --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:14:6 | 14 | /// [f::A] | ^^^^ | = note: no item named `f` is in scope = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` ``` This is _mostly_ fixed, it now says ```rust warning: unresolved link to `f::A` --> /home/joshua/test-rustdoc/f.rs:1:6 | 1 | /// [f::A] | ^^^^ | = note: this link partially resolves to the function `f` = note: `f` is a function, not a module ``` 'function, not a module' seems awfully terse when what I actually mean is '`::` isn't allowed here', though. </details> It looks a lot nicer now, it says ``` error: unresolved link to `f::A` --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:13:6 | 13 | /// [f::A] | ^^^^ | = note: `f` is a function, not a module or type, and cannot have associated items ``` 3. ~~I'm also not very happy with the second note for this error:~~ <details> ``` error: unresolved link to `S::A` --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:19:6 | 19 | /// [S::A] | ^^^^ | = note: this link partially resolves to the struct `S`, = note: `S` has no field, variant, or associated item named `A` ``` but I'm not sure how better to word it. I ended up going with 'no `A` in `S`' to match `rustc_resolve` but that seems terse as well. </details> This now says ``` error: unresolved link to `S::A` --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:17:6 | 17 | /// [S::A] | ^^^^ | = note: the struct `S` has no field or associated item named `A` ``` which I think looks pretty good :) 4. This is minor, but it would be nice to say that `path` wasn't found instead of the full thing: ``` error: unresolved link to `path::to::nonexistent::module` --> /home/joshua/rustc/src/test/rustdoc-ui/intra-link-errors.rs:8:6 | 8 | /// [path::to::nonexistent::module] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ``` It will now look at most 3 paths up (so it reports `path::to` as not in scope), but it doesn't work with arbitrarily many paths. </details> ~~I recommend only reviewing the last few commits - the first 7 are all from #74489.~~ Rebased so that only the relevant commits are shown. Let me know if I should squash the history some more. r? `@estebank`
This commit is contained in:
commit
0f5c769513
18 changed files with 876 additions and 281 deletions
|
@ -6,6 +6,7 @@ use rustc_ast::NodeId;
|
|||
use rustc_macros::HashStable_Generic;
|
||||
use rustc_span::hygiene::MacroKind;
|
||||
|
||||
use std::array::IntoIter;
|
||||
use std::fmt::Debug;
|
||||
|
||||
/// Encodes if a `DefKind::Ctor` is the constructor of an enum variant or a struct.
|
||||
|
@ -291,6 +292,14 @@ impl<T> PerNS<T> {
|
|||
pub fn map<U, F: FnMut(T) -> U>(self, mut f: F) -> PerNS<U> {
|
||||
PerNS { value_ns: f(self.value_ns), type_ns: f(self.type_ns), macro_ns: f(self.macro_ns) }
|
||||
}
|
||||
|
||||
pub fn into_iter(self) -> IntoIter<T, 3> {
|
||||
IntoIter::new([self.value_ns, self.type_ns, self.macro_ns])
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> IntoIter<&T, 3> {
|
||||
IntoIter::new([&self.value_ns, &self.type_ns, &self.macro_ns])
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> ::std::ops::Index<Namespace> for PerNS<T> {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
//!
|
||||
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html
|
||||
|
||||
#![feature(array_value_iter)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(const_fn)] // For the unsizing cast on `&[]`
|
||||
#![feature(const_panic)]
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2,14 +2,13 @@ error: unresolved link to `S::fmt`
|
|||
--> $DIR/assoc-item-not-in-scope.rs:4:14
|
||||
|
|
||||
LL | /// Link to [`S::fmt`]
|
||||
| ^^^^^^^^ unresolved link
|
||||
| ^^^^^^^^ the struct `S` has no field or associated item named `fmt`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/assoc-item-not-in-scope.rs:1:9
|
||||
|
|
||||
LL | #![deny(broken_intra_doc_links)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ error: unresolved link to `v2`
|
|||
--> $DIR/deny-intra-link-resolution-failure.rs:3:6
|
||||
|
|
||||
LL | /// [v2]
|
||||
| ^^ unresolved link
|
||||
| ^^ no item named `v2` in `deny_intra_link_resolution_failure`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/deny-intra-link-resolution-failure.rs:1:9
|
||||
|
|
|
@ -2,14 +2,13 @@ error: unresolved link to `TypeAlias::hoge`
|
|||
--> $DIR/intra-doc-alias-ice.rs:5:30
|
||||
|
|
||||
LL | /// [broken cross-reference](TypeAlias::hoge)
|
||||
| ^^^^^^^^^^^^^^^ unresolved link
|
||||
| ^^^^^^^^^^^^^^^ the type alias `TypeAlias` has no associated item named `hoge`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/intra-doc-alias-ice.rs:1:9
|
||||
|
|
||||
LL | #![deny(broken_intra_doc_links)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
88
src/test/rustdoc-ui/intra-link-errors.rs
Normal file
88
src/test/rustdoc-ui/intra-link-errors.rs
Normal file
|
@ -0,0 +1,88 @@
|
|||
#![deny(broken_intra_doc_links)]
|
||||
//~^ NOTE lint level is defined
|
||||
|
||||
// FIXME: this should say that it was skipped (maybe an allowed by default lint?)
|
||||
/// [<invalid syntax>]
|
||||
|
||||
/// [path::to::nonexistent::module]
|
||||
//~^ ERROR unresolved link
|
||||
//~| NOTE no item named `path` in `intra_link_errors`
|
||||
|
||||
/// [path::to::nonexistent::macro!]
|
||||
//~^ ERROR unresolved link
|
||||
//~| NOTE no item named `path` in `intra_link_errors`
|
||||
|
||||
/// [type@path::to::nonexistent::type]
|
||||
//~^ ERROR unresolved link
|
||||
//~| NOTE no item named `path` in `intra_link_errors`
|
||||
|
||||
/// [std::io::not::here]
|
||||
//~^ ERROR unresolved link
|
||||
//~| NOTE the module `io` has no inner item
|
||||
|
||||
/// [std::io::Error::x]
|
||||
//~^ ERROR unresolved link
|
||||
//~| NOTE the struct `Error` has no field
|
||||
|
||||
/// [std::io::ErrorKind::x]
|
||||
//~^ ERROR unresolved link
|
||||
//~| NOTE the enum `ErrorKind` has no variant
|
||||
|
||||
/// [f::A]
|
||||
//~^ ERROR unresolved link
|
||||
//~| NOTE `f` is a function, not a module
|
||||
|
||||
/// [S::A]
|
||||
//~^ ERROR unresolved link
|
||||
//~| NOTE struct `S` has no field or associated item
|
||||
|
||||
/// [S::fmt]
|
||||
//~^ ERROR unresolved link
|
||||
//~| NOTE struct `S` has no field or associated item
|
||||
|
||||
/// [E::D]
|
||||
//~^ ERROR unresolved link
|
||||
//~| NOTE enum `E` has no variant or associated item
|
||||
|
||||
/// [u8::not_found]
|
||||
//~^ ERROR unresolved link
|
||||
//~| NOTE the builtin type `u8` does not have an associated item named `not_found`
|
||||
|
||||
/// [S!]
|
||||
//~^ ERROR unresolved link
|
||||
//~| HELP to link to the struct, prefix with `struct@`
|
||||
//~| NOTE this link resolves to the struct `S`
|
||||
pub fn f() {}
|
||||
#[derive(Debug)]
|
||||
pub struct S;
|
||||
|
||||
pub enum E { A, B, C }
|
||||
|
||||
/// [type@S::h]
|
||||
//~^ ERROR unresolved link
|
||||
//~| HELP to link to the associated function
|
||||
//~| NOTE not in the type namespace
|
||||
impl S {
|
||||
pub fn h() {}
|
||||
}
|
||||
|
||||
/// [type@T::g]
|
||||
//~^ ERROR unresolved link
|
||||
//~| HELP to link to the associated function
|
||||
//~| NOTE not in the type namespace
|
||||
|
||||
/// [T::h!]
|
||||
//~^ ERROR unresolved link
|
||||
//~| NOTE `T` has no macro named `h`
|
||||
pub trait T {
|
||||
fn g() {}
|
||||
}
|
||||
|
||||
/// [m()]
|
||||
//~^ ERROR unresolved link
|
||||
//~| HELP to link to the macro
|
||||
//~| NOTE not in the value namespace
|
||||
#[macro_export]
|
||||
macro_rules! m {
|
||||
() => {};
|
||||
}
|
116
src/test/rustdoc-ui/intra-link-errors.stderr
Normal file
116
src/test/rustdoc-ui/intra-link-errors.stderr
Normal file
|
@ -0,0 +1,116 @@
|
|||
error: unresolved link to `path::to::nonexistent::module`
|
||||
--> $DIR/intra-link-errors.rs:7:6
|
||||
|
|
||||
LL | /// [path::to::nonexistent::module]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `path` in `intra_link_errors`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/intra-link-errors.rs:1:9
|
||||
|
|
||||
LL | #![deny(broken_intra_doc_links)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: unresolved link to `path::to::nonexistent::macro`
|
||||
--> $DIR/intra-link-errors.rs:11:6
|
||||
|
|
||||
LL | /// [path::to::nonexistent::macro!]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `path` in `intra_link_errors`
|
||||
|
||||
error: unresolved link to `path::to::nonexistent::type`
|
||||
--> $DIR/intra-link-errors.rs:15:6
|
||||
|
|
||||
LL | /// [type@path::to::nonexistent::type]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no item named `path` in `intra_link_errors`
|
||||
|
||||
error: unresolved link to `std::io::not::here`
|
||||
--> $DIR/intra-link-errors.rs:19:6
|
||||
|
|
||||
LL | /// [std::io::not::here]
|
||||
| ^^^^^^^^^^^^^^^^^^ the module `io` has no inner item named `not`
|
||||
|
||||
error: unresolved link to `std::io::Error::x`
|
||||
--> $DIR/intra-link-errors.rs:23:6
|
||||
|
|
||||
LL | /// [std::io::Error::x]
|
||||
| ^^^^^^^^^^^^^^^^^ the struct `Error` has no field or associated item named `x`
|
||||
|
||||
error: unresolved link to `std::io::ErrorKind::x`
|
||||
--> $DIR/intra-link-errors.rs:27:6
|
||||
|
|
||||
LL | /// [std::io::ErrorKind::x]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ the enum `ErrorKind` has no variant or associated item named `x`
|
||||
|
||||
error: unresolved link to `f::A`
|
||||
--> $DIR/intra-link-errors.rs:31:6
|
||||
|
|
||||
LL | /// [f::A]
|
||||
| ^^^^ `f` is a function, not a module or type, and cannot have associated items
|
||||
|
||||
error: unresolved link to `S::A`
|
||||
--> $DIR/intra-link-errors.rs:35:6
|
||||
|
|
||||
LL | /// [S::A]
|
||||
| ^^^^ the struct `S` has no field or associated item named `A`
|
||||
|
||||
error: unresolved link to `S::fmt`
|
||||
--> $DIR/intra-link-errors.rs:39:6
|
||||
|
|
||||
LL | /// [S::fmt]
|
||||
| ^^^^^^ the struct `S` has no field or associated item named `fmt`
|
||||
|
||||
error: unresolved link to `E::D`
|
||||
--> $DIR/intra-link-errors.rs:43:6
|
||||
|
|
||||
LL | /// [E::D]
|
||||
| ^^^^ the enum `E` has no variant or associated item named `D`
|
||||
|
||||
error: unresolved link to `u8::not_found`
|
||||
--> $DIR/intra-link-errors.rs:47:6
|
||||
|
|
||||
LL | /// [u8::not_found]
|
||||
| ^^^^^^^^^^^^^ the builtin type `u8` does not have an associated item named `not_found`
|
||||
|
||||
error: unresolved link to `S`
|
||||
--> $DIR/intra-link-errors.rs:51:6
|
||||
|
|
||||
LL | /// [S!]
|
||||
| ^^
|
||||
| |
|
||||
| this link resolves to the struct `S`, which is not in the macro namespace
|
||||
| help: to link to the struct, prefix with `struct@`: `struct@S`
|
||||
|
||||
error: unresolved link to `T::g`
|
||||
--> $DIR/intra-link-errors.rs:69:6
|
||||
|
|
||||
LL | /// [type@T::g]
|
||||
| ^^^^^^^^^
|
||||
| |
|
||||
| this link resolves to the associated function `g`, which is not in the type namespace
|
||||
| help: to link to the associated function, add parentheses: `T::g()`
|
||||
|
||||
error: unresolved link to `T::h`
|
||||
--> $DIR/intra-link-errors.rs:74:6
|
||||
|
|
||||
LL | /// [T::h!]
|
||||
| ^^^^^ the trait `T` has no macro named `h`
|
||||
|
||||
error: unresolved link to `S::h`
|
||||
--> $DIR/intra-link-errors.rs:61:6
|
||||
|
|
||||
LL | /// [type@S::h]
|
||||
| ^^^^^^^^^
|
||||
| |
|
||||
| this link resolves to the associated function `h`, which is not in the type namespace
|
||||
| help: to link to the associated function, add parentheses: `S::h()`
|
||||
|
||||
error: unresolved link to `m`
|
||||
--> $DIR/intra-link-errors.rs:81:6
|
||||
|
|
||||
LL | /// [m()]
|
||||
| ^^^
|
||||
| |
|
||||
| this link resolves to the macro `m`, which is not in the value namespace
|
||||
| help: to link to the macro, add an exclamation mark: `m!`
|
||||
|
||||
error: aborting due to 16 previous errors
|
||||
|
|
@ -18,13 +18,13 @@
|
|||
|
||||
/// [struct@char]
|
||||
//~^ ERROR incompatible link
|
||||
//~| HELP prefix with the item kind
|
||||
//~| HELP prefix with `mod@`
|
||||
//~| NOTE resolved to a module
|
||||
pub mod char {}
|
||||
|
||||
pub mod inner {
|
||||
//! [struct@char]
|
||||
//~^ ERROR incompatible link
|
||||
//~| HELP prefix with the item kind
|
||||
//~| HELP prefix with `prim@`
|
||||
//~| NOTE resolved to a builtin type
|
||||
}
|
||||
|
|
|
@ -9,11 +9,11 @@ note: the lint level is defined here
|
|||
|
|
||||
LL | #![deny(broken_intra_doc_links)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: to link to the module, prefix with the item kind
|
||||
help: to link to the module, prefix with `mod@`
|
||||
|
|
||||
LL | /// [mod@char]
|
||||
| ^^^^^^^^
|
||||
help: to link to the builtin type, prefix with the item kind
|
||||
help: to link to the builtin type, prefix with `prim@`
|
||||
|
|
||||
LL | /// [prim@char]
|
||||
| ^^^^^^^^^
|
||||
|
@ -24,11 +24,11 @@ error: `char` is both a module and a builtin type
|
|||
LL | /// [type@char]
|
||||
| ^^^^^^^^^ ambiguous link
|
||||
|
|
||||
help: to link to the module, prefix with the item kind
|
||||
help: to link to the module, prefix with `mod@`
|
||||
|
|
||||
LL | /// [mod@char]
|
||||
| ^^^^^^^^
|
||||
help: to link to the builtin type, prefix with the item kind
|
||||
help: to link to the builtin type, prefix with `prim@`
|
||||
|
|
||||
LL | /// [prim@char]
|
||||
| ^^^^^^^^^
|
||||
|
@ -37,25 +37,17 @@ error: incompatible link kind for `char`
|
|||
--> $DIR/intra-link-prim-conflict.rs:19:6
|
||||
|
|
||||
LL | /// [struct@char]
|
||||
| ^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^ help: to link to the module, prefix with `mod@`: `mod@char`
|
||||
|
|
||||
= note: this link resolved to a module, which is not a struct
|
||||
help: to link to the module, prefix with the item kind
|
||||
|
|
||||
LL | /// [mod@char]
|
||||
| ^^^^^^^^
|
||||
|
||||
error: incompatible link kind for `char`
|
||||
--> $DIR/intra-link-prim-conflict.rs:26:10
|
||||
|
|
||||
LL | //! [struct@char]
|
||||
| ^^^^^^^^^^^
|
||||
| ^^^^^^^^^^^ help: to link to the builtin type, prefix with `prim@`: `prim@char`
|
||||
|
|
||||
= note: this link resolved to a builtin type, which is not a struct
|
||||
help: to link to the builtin type, prefix with the item kind
|
||||
|
|
||||
LL | //! [prim@char]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ error: unresolved link to `i`
|
|||
--> $DIR/intra-link-span-ice-55723.rs:9:10
|
||||
|
|
||||
LL | /// (arr[i])
|
||||
| ^ unresolved link
|
||||
| ^ no item named `i` in `intra_link_span_ice_55723`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/intra-link-span-ice-55723.rs:1:9
|
||||
|
|
|
@ -9,7 +9,7 @@ note: the lint level is defined here
|
|||
|
|
||||
LL | #![deny(broken_intra_doc_links)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: to link to the struct, prefix with the item kind
|
||||
help: to link to the struct, prefix with `struct@`
|
||||
|
|
||||
LL | /// [`struct@ambiguous`] is ambiguous.
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
@ -24,7 +24,7 @@ error: `ambiguous` is both a struct and a function
|
|||
LL | /// [ambiguous] is ambiguous.
|
||||
| ^^^^^^^^^ ambiguous link
|
||||
|
|
||||
help: to link to the struct, prefix with the item kind
|
||||
help: to link to the struct, prefix with `struct@`
|
||||
|
|
||||
LL | /// [struct@ambiguous] is ambiguous.
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
@ -39,7 +39,7 @@ error: `multi_conflict` is a struct, a function, and a macro
|
|||
LL | /// [`multi_conflict`] is a three-way conflict.
|
||||
| ^^^^^^^^^^^^^^^^ ambiguous link
|
||||
|
|
||||
help: to link to the struct, prefix with the item kind
|
||||
help: to link to the struct, prefix with `struct@`
|
||||
|
|
||||
LL | /// [`struct@multi_conflict`] is a three-way conflict.
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -58,11 +58,11 @@ error: `type_and_value` is both a module and a constant
|
|||
LL | /// Ambiguous [type_and_value].
|
||||
| ^^^^^^^^^^^^^^ ambiguous link
|
||||
|
|
||||
help: to link to the module, prefix with the item kind
|
||||
help: to link to the module, prefix with `mod@`
|
||||
|
|
||||
LL | /// Ambiguous [mod@type_and_value].
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
help: to link to the constant, prefix with the item kind
|
||||
help: to link to the constant, prefix with `const@`
|
||||
|
|
||||
LL | /// Ambiguous [const@type_and_value].
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -73,7 +73,7 @@ error: `foo::bar` is both an enum and a function
|
|||
LL | /// Ambiguous non-implied shortcut link [`foo::bar`].
|
||||
| ^^^^^^^^^^ ambiguous link
|
||||
|
|
||||
help: to link to the enum, prefix with the item kind
|
||||
help: to link to the enum, prefix with `enum@`
|
||||
|
|
||||
LL | /// Ambiguous non-implied shortcut link [`enum@foo::bar`].
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
error: `Foo::f#hola` contains an anchor, but links to struct fields are already anchored
|
||||
error: `Foo::f#hola` contains an anchor, but links to fields are already anchored
|
||||
--> $DIR/intra-links-anchors.rs:25:15
|
||||
|
|
||||
LL | /// Or maybe [Foo::f#hola].
|
||||
|
@ -16,13 +16,13 @@ error: `hello#people#!` contains multiple anchors
|
|||
LL | /// Another anchor error: [hello#people#!].
|
||||
| ^^^^^^^^^^^^^^ contains invalid anchor
|
||||
|
||||
error: `Enum::A#whatever` contains an anchor, but links to enum variants are already anchored
|
||||
error: `Enum::A#whatever` contains an anchor, but links to variants are already anchored
|
||||
--> $DIR/intra-links-anchors.rs:37:28
|
||||
|
|
||||
LL | /// Damn enum's variants: [Enum::A#whatever].
|
||||
| ^^^^^^^^^^^^^^^^ contains invalid anchor
|
||||
|
||||
error: `u32#hello` contains an anchor, but links to primitive types are already anchored
|
||||
error: `u32#hello` contains an anchor, but links to builtin types are already anchored
|
||||
--> $DIR/intra-links-anchors.rs:43:6
|
||||
|
|
||||
LL | /// [u32#hello]
|
||||
|
|
|
@ -14,27 +14,27 @@ trait T {}
|
|||
/// Link to [struct@S]
|
||||
//~^ ERROR incompatible link kind for `S`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP prefix with the item kind
|
||||
//~| HELP prefix with `enum@`
|
||||
|
||||
/// Link to [mod@S]
|
||||
//~^ ERROR incompatible link kind for `S`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP prefix with the item kind
|
||||
//~| HELP prefix with `enum@`
|
||||
|
||||
/// Link to [union@S]
|
||||
//~^ ERROR incompatible link kind for `S`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP prefix with the item kind
|
||||
//~| HELP prefix with `enum@`
|
||||
|
||||
/// Link to [trait@S]
|
||||
//~^ ERROR incompatible link kind for `S`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP prefix with the item kind
|
||||
//~| HELP prefix with `enum@`
|
||||
|
||||
/// Link to [struct@T]
|
||||
//~^ ERROR incompatible link kind for `T`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP prefix with the item kind
|
||||
//~| HELP prefix with `trait@`
|
||||
|
||||
/// Link to [derive@m]
|
||||
//~^ ERROR incompatible link kind for `m`
|
||||
|
@ -44,22 +44,22 @@ trait T {}
|
|||
/// Link to [const@s]
|
||||
//~^ ERROR incompatible link kind for `s`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP prefix with the item kind
|
||||
//~| HELP prefix with `static@`
|
||||
|
||||
/// Link to [static@c]
|
||||
//~^ ERROR incompatible link kind for `c`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP prefix with the item kind
|
||||
//~| HELP prefix with `const@`
|
||||
|
||||
/// Link to [fn@c]
|
||||
//~^ ERROR incompatible link kind for `c`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP prefix with the item kind
|
||||
//~| HELP prefix with `const@`
|
||||
|
||||
/// Link to [c()]
|
||||
//~^ ERROR incompatible link kind for `c`
|
||||
//~| NOTE this link resolved
|
||||
//~| HELP prefix with the item kind
|
||||
//~| HELP prefix with `const@`
|
||||
|
||||
/// Link to [const@f]
|
||||
//~^ ERROR incompatible link kind for `f`
|
||||
|
|
|
@ -2,7 +2,7 @@ error: incompatible link kind for `S`
|
|||
--> $DIR/intra-links-disambiguator-mismatch.rs:14:14
|
||||
|
|
||||
LL | /// Link to [struct@S]
|
||||
| ^^^^^^^^
|
||||
| ^^^^^^^^ help: to link to the enum, prefix with `enum@`: `enum@S`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:1:9
|
||||
|
@ -10,58 +10,38 @@ note: the lint level is defined here
|
|||
LL | #![deny(broken_intra_doc_links)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: this link resolved to an enum, which is not a struct
|
||||
help: to link to the enum, prefix with the item kind
|
||||
|
|
||||
LL | /// Link to [enum@S]
|
||||
| ^^^^^^
|
||||
|
||||
error: incompatible link kind for `S`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:19:14
|
||||
|
|
||||
LL | /// Link to [mod@S]
|
||||
| ^^^^^
|
||||
| ^^^^^ help: to link to the enum, prefix with `enum@`: `enum@S`
|
||||
|
|
||||
= note: this link resolved to an enum, which is not a module
|
||||
help: to link to the enum, prefix with the item kind
|
||||
|
|
||||
LL | /// Link to [enum@S]
|
||||
| ^^^^^^
|
||||
|
||||
error: incompatible link kind for `S`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:24:14
|
||||
|
|
||||
LL | /// Link to [union@S]
|
||||
| ^^^^^^^
|
||||
| ^^^^^^^ help: to link to the enum, prefix with `enum@`: `enum@S`
|
||||
|
|
||||
= note: this link resolved to an enum, which is not a union
|
||||
help: to link to the enum, prefix with the item kind
|
||||
|
|
||||
LL | /// Link to [enum@S]
|
||||
| ^^^^^^
|
||||
|
||||
error: incompatible link kind for `S`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:29:14
|
||||
|
|
||||
LL | /// Link to [trait@S]
|
||||
| ^^^^^^^
|
||||
| ^^^^^^^ help: to link to the enum, prefix with `enum@`: `enum@S`
|
||||
|
|
||||
= note: this link resolved to an enum, which is not a trait
|
||||
help: to link to the enum, prefix with the item kind
|
||||
|
|
||||
LL | /// Link to [enum@S]
|
||||
| ^^^^^^
|
||||
|
||||
error: incompatible link kind for `T`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:34:14
|
||||
|
|
||||
LL | /// Link to [struct@T]
|
||||
| ^^^^^^^^
|
||||
| ^^^^^^^^ help: to link to the trait, prefix with `trait@`: `trait@T`
|
||||
|
|
||||
= note: this link resolved to a trait, which is not a struct
|
||||
help: to link to the trait, prefix with the item kind
|
||||
|
|
||||
LL | /// Link to [trait@T]
|
||||
| ^^^^^^^
|
||||
|
||||
error: incompatible link kind for `m`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:39:14
|
||||
|
@ -75,49 +55,33 @@ error: incompatible link kind for `s`
|
|||
--> $DIR/intra-links-disambiguator-mismatch.rs:44:14
|
||||
|
|
||||
LL | /// Link to [const@s]
|
||||
| ^^^^^^^
|
||||
| ^^^^^^^ help: to link to the static, prefix with `static@`: `static@s`
|
||||
|
|
||||
= note: this link resolved to a static, which is not a constant
|
||||
help: to link to the static, prefix with the item kind
|
||||
|
|
||||
LL | /// Link to [static@s]
|
||||
| ^^^^^^^^
|
||||
|
||||
error: incompatible link kind for `c`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:49:14
|
||||
|
|
||||
LL | /// Link to [static@c]
|
||||
| ^^^^^^^^
|
||||
| ^^^^^^^^ help: to link to the constant, prefix with `const@`: `const@c`
|
||||
|
|
||||
= note: this link resolved to a constant, which is not a static
|
||||
help: to link to the constant, prefix with the item kind
|
||||
|
|
||||
LL | /// Link to [const@c]
|
||||
| ^^^^^^^
|
||||
|
||||
error: incompatible link kind for `c`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:54:14
|
||||
|
|
||||
LL | /// Link to [fn@c]
|
||||
| ^^^^
|
||||
| ^^^^ help: to link to the constant, prefix with `const@`: `const@c`
|
||||
|
|
||||
= note: this link resolved to a constant, which is not a function
|
||||
help: to link to the constant, prefix with the item kind
|
||||
|
|
||||
LL | /// Link to [const@c]
|
||||
| ^^^^^^^
|
||||
|
||||
error: incompatible link kind for `c`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:59:14
|
||||
|
|
||||
LL | /// Link to [c()]
|
||||
| ^^^
|
||||
| ^^^ help: to link to the constant, prefix with `const@`: `const@c`
|
||||
|
|
||||
= note: this link resolved to a constant, which is not a function
|
||||
help: to link to the constant, prefix with the item kind
|
||||
|
|
||||
LL | /// Link to [const@c]
|
||||
| ^^^^^^^
|
||||
|
||||
error: incompatible link kind for `f`
|
||||
--> $DIR/intra-links-disambiguator-mismatch.rs:64:14
|
||||
|
|
|
@ -2,7 +2,7 @@ warning: unresolved link to `error`
|
|||
--> $DIR/intra-links-warning-crlf.rs:7:6
|
||||
|
|
||||
LL | /// [error]
|
||||
| ^^^^^ unresolved link
|
||||
| ^^^^^ no item named `error` in `intra_links_warning_crlf`
|
||||
|
|
||||
= note: `#[warn(broken_intra_doc_links)]` on by default
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
@ -11,7 +11,7 @@ warning: unresolved link to `error1`
|
|||
--> $DIR/intra-links-warning-crlf.rs:12:11
|
||||
|
|
||||
LL | /// docs [error1]
|
||||
| ^^^^^^ unresolved link
|
||||
| ^^^^^^ no item named `error1` in `intra_links_warning_crlf`
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
|
@ -19,7 +19,7 @@ warning: unresolved link to `error2`
|
|||
--> $DIR/intra-links-warning-crlf.rs:15:11
|
||||
|
|
||||
LL | /// docs [error2]
|
||||
| ^^^^^^ unresolved link
|
||||
| ^^^^^^ no item named `error2` in `intra_links_warning_crlf`
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
|
@ -27,7 +27,7 @@ warning: unresolved link to `error`
|
|||
--> $DIR/intra-links-warning-crlf.rs:23:20
|
||||
|
|
||||
LL | * It also has an [error].
|
||||
| ^^^^^ unresolved link
|
||||
| ^^^^^ no item named `error` in `intra_links_warning_crlf`
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
|
|
|
@ -2,56 +2,45 @@ warning: unresolved link to `Foo::baz`
|
|||
--> $DIR/intra-links-warning.rs:3:23
|
||||
|
|
||||
LL | //! Test with [Foo::baz], [Bar::foo], ...
|
||||
| ^^^^^^^^ unresolved link
|
||||
| ^^^^^^^^ the struct `Foo` has no field or associated item named `baz`
|
||||
|
|
||||
= 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`
|
||||
--> $DIR/intra-links-warning.rs:3:35
|
||||
|
|
||||
LL | //! Test with [Foo::baz], [Bar::foo], ...
|
||||
| ^^^^^^^^ unresolved link
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
| ^^^^^^^^ no item named `Bar` in `intra_links_warning`
|
||||
|
||||
warning: unresolved link to `Uniooon::X`
|
||||
--> $DIR/intra-links-warning.rs:6:13
|
||||
|
|
||||
LL | //! , [Uniooon::X] and [Qux::Z].
|
||||
| ^^^^^^^^^^ unresolved link
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
| ^^^^^^^^^^ no item named `Uniooon` in `intra_links_warning`
|
||||
|
||||
warning: unresolved link to `Qux::Z`
|
||||
--> $DIR/intra-links-warning.rs:6:30
|
||||
|
|
||||
LL | //! , [Uniooon::X] and [Qux::Z].
|
||||
| ^^^^^^ unresolved link
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
| ^^^^^^ no item named `Qux` in `intra_links_warning`
|
||||
|
||||
warning: unresolved link to `Uniooon::X`
|
||||
--> $DIR/intra-links-warning.rs:10:14
|
||||
|
|
||||
LL | //! , [Uniooon::X] and [Qux::Z].
|
||||
| ^^^^^^^^^^ unresolved link
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
| ^^^^^^^^^^ no item named `Uniooon` in `intra_links_warning`
|
||||
|
||||
warning: unresolved link to `Qux::Z`
|
||||
--> $DIR/intra-links-warning.rs:10:31
|
||||
|
|
||||
LL | //! , [Uniooon::X] and [Qux::Z].
|
||||
| ^^^^^^ unresolved link
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
| ^^^^^^ no item named `Qux` in `intra_links_warning`
|
||||
|
||||
warning: unresolved link to `Qux:Y`
|
||||
--> $DIR/intra-links-warning.rs:14:13
|
||||
|
|
||||
LL | /// [Qux:Y]
|
||||
| ^^^^^ unresolved link
|
||||
| ^^^^^ no item named `Qux:Y` in `intra_links_warning`
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
|
@ -59,7 +48,7 @@ warning: unresolved link to `error`
|
|||
--> $DIR/intra-links-warning.rs:58:30
|
||||
|
|
||||
LL | * time to introduce a link [error]*/
|
||||
| ^^^^^ unresolved link
|
||||
| ^^^^^ no item named `error` in `intra_links_warning`
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
|
@ -67,7 +56,7 @@ warning: unresolved link to `error`
|
|||
--> $DIR/intra-links-warning.rs:64:30
|
||||
|
|
||||
LL | * time to introduce a link [error]
|
||||
| ^^^^^ unresolved link
|
||||
| ^^^^^ no item named `error` in `intra_links_warning`
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
|
@ -81,6 +70,7 @@ LL | #[doc = "single line [error]"]
|
|||
|
||||
single line [error]
|
||||
^^^^^
|
||||
= note: no item named `error` in `intra_links_warning`
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
warning: unresolved link to `error`
|
||||
|
@ -93,6 +83,7 @@ LL | #[doc = "single line with \"escaping\" [error]"]
|
|||
|
||||
single line with "escaping" [error]
|
||||
^^^^^
|
||||
= note: no item named `error` in `intra_links_warning`
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
warning: unresolved link to `error`
|
||||
|
@ -107,13 +98,14 @@ LL | | /// [error]
|
|||
|
||||
[error]
|
||||
^^^^^
|
||||
= note: no item named `error` in `intra_links_warning`
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
warning: unresolved link to `error1`
|
||||
--> $DIR/intra-links-warning.rs:80:11
|
||||
|
|
||||
LL | /// docs [error1]
|
||||
| ^^^^^^ unresolved link
|
||||
| ^^^^^^ no item named `error1` in `intra_links_warning`
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
|
@ -121,7 +113,7 @@ warning: unresolved link to `error2`
|
|||
--> $DIR/intra-links-warning.rs:82:11
|
||||
|
|
||||
LL | /// docs [error2]
|
||||
| ^^^^^^ unresolved link
|
||||
| ^^^^^^ no item named `error2` in `intra_links_warning`
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
|
@ -129,7 +121,7 @@ warning: unresolved link to `BarA`
|
|||
--> $DIR/intra-links-warning.rs:21:10
|
||||
|
|
||||
LL | /// bar [BarA] bar
|
||||
| ^^^^ unresolved link
|
||||
| ^^^^ no item named `BarA` in `intra_links_warning`
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
|
@ -137,7 +129,7 @@ warning: unresolved link to `BarB`
|
|||
--> $DIR/intra-links-warning.rs:27:9
|
||||
|
|
||||
LL | * bar [BarB] bar
|
||||
| ^^^^ unresolved link
|
||||
| ^^^^ no item named `BarB` in `intra_links_warning`
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
|
@ -145,7 +137,7 @@ warning: unresolved link to `BarC`
|
|||
--> $DIR/intra-links-warning.rs:34:6
|
||||
|
|
||||
LL | bar [BarC] bar
|
||||
| ^^^^ unresolved link
|
||||
| ^^^^ no item named `BarC` in `intra_links_warning`
|
||||
|
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
|
@ -159,6 +151,7 @@ LL | #[doc = "Foo\nbar [BarD] bar\nbaz"]
|
|||
|
||||
bar [BarD] bar
|
||||
^^^^
|
||||
= note: no item named `BarD` in `intra_links_warning`
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
|
||||
warning: unresolved link to `BarF`
|
||||
|
@ -174,6 +167,7 @@ LL | f!("Foo\nbar [BarF] bar\nbaz");
|
|||
|
||||
bar [BarF] bar
|
||||
^^^^
|
||||
= note: no item named `BarF` in `intra_links_warning`
|
||||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
|
||||
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ error: unresolved link to `error`
|
|||
--> $DIR/lint-group.rs:9:29
|
||||
|
|
||||
LL | /// what up, let's make an [error]
|
||||
| ^^^^^ unresolved link
|
||||
| ^^^^^ no item named `error` in `lint_group`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/lint-group.rs:7:9
|
||||
|
|
Loading…
Add table
Reference in a new issue