1
Fork 0

Give a better error message when linking to a macro with the wrong disambiguator

Before:

```
warning: unresolved link to `m`
 --> m.rs:1:6
  |
1 | /// [value@m]
  |      ^^^^^^^
  |
  = note: `#[warn(broken_intra_doc_links)]` on by default
  = note: no item named `m` is in scope
  = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
```

After:

```
warning: unresolved link to `m`
 --> m.rs:1:6
  |
1 | /// [value@m]
  |      ^^^^^^^ help: to link to the macro, use its disambiguator: `m!`
  |
  = note: `#[warn(broken_intra_doc_links)]` on by default
  = note: this link resolves to the macro `m`, which is not in the value namespace
```
This commit is contained in:
Joshua Nelson 2020-08-21 16:37:31 -04:00
parent 6875220e1a
commit 418f6089e9
3 changed files with 142 additions and 50 deletions

View file

@ -12,16 +12,40 @@ LL | #![deny(broken_intra_doc_links)]
= note: no item named `path::to` is in scope
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
error: unresolved link to `f::A`
error: unresolved link to `std::io::not::here`
--> $DIR/intra-link-errors.rs:13:6
|
LL | /// [std::io::not::here]
| ^^^^^^^^^^^^^^^^^^
|
= note: the module `io` has no inner item named `not`
error: unresolved link to `std::io::Error::x`
--> $DIR/intra-link-errors.rs:17:6
|
LL | /// [std::io::Error::x]
| ^^^^^^^^^^^^^^^^^
|
= note: the struct `Error` has no field or associated item named `x`
error: unresolved link to `std::io::ErrorKind::x`
--> $DIR/intra-link-errors.rs:21:6
|
LL | /// [std::io::ErrorKind::x]
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: the enum `ErrorKind` has no variant or associated item named `x`
error: unresolved link to `f::A`
--> $DIR/intra-link-errors.rs:25:6
|
LL | /// [f::A]
| ^^^^
|
= note: `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:17:6
--> $DIR/intra-link-errors.rs:29:6
|
LL | /// [S::A]
| ^^^^
@ -29,7 +53,7 @@ LL | /// [S::A]
= note: the struct `S` has no field or associated item named `A`
error: unresolved link to `S::fmt`
--> $DIR/intra-link-errors.rs:21:6
--> $DIR/intra-link-errors.rs:33:6
|
LL | /// [S::fmt]
| ^^^^^^
@ -37,7 +61,7 @@ LL | /// [S::fmt]
= note: the struct `S` has no field or associated item named `fmt`
error: unresolved link to `E::D`
--> $DIR/intra-link-errors.rs:25:6
--> $DIR/intra-link-errors.rs:37:6
|
LL | /// [E::D]
| ^^^^
@ -45,7 +69,7 @@ LL | /// [E::D]
= note: the enum `E` has no variant or associated item named `D`
error: unresolved link to `u8::not_found`
--> $DIR/intra-link-errors.rs:29:6
--> $DIR/intra-link-errors.rs:41:6
|
LL | /// [u8::not_found]
| ^^^^^^^^^^^^^
@ -53,7 +77,7 @@ LL | /// [u8::not_found]
= note: the builtin type `u8` does not have an associated item named `not_found`
error: unresolved link to `S`
--> $DIR/intra-link-errors.rs:33:6
--> $DIR/intra-link-errors.rs:45:6
|
LL | /// [S!]
| ^^ help: to link to the struct, use its disambiguator: `struct@S`
@ -61,7 +85,7 @@ LL | /// [S!]
= note: this link resolves to the struct `S`, which is not in the macro namespace
error: unresolved link to `T::g`
--> $DIR/intra-link-errors.rs:51:6
--> $DIR/intra-link-errors.rs:63:6
|
LL | /// [type@T::g]
| ^^^^^^^^^ help: to link to the associated function, use its disambiguator: `T::g()`
@ -69,7 +93,7 @@ LL | /// [type@T::g]
= note: this link resolves to the associated function `g`, which is not in the type namespace
error: unresolved link to `T::h`
--> $DIR/intra-link-errors.rs:56:6
--> $DIR/intra-link-errors.rs:68:6
|
LL | /// [T::h!]
| ^^^^^
@ -78,12 +102,20 @@ LL | /// [T::h!]
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
error: unresolved link to `S::h`
--> $DIR/intra-link-errors.rs:43:6
--> $DIR/intra-link-errors.rs:55:6
|
LL | /// [type@S::h]
| ^^^^^^^^^ help: to link to the associated function, use its disambiguator: `S::h()`
|
= note: this link resolves to the associated function `h`, which is not in the type namespace
error: aborting due to 10 previous errors
error: unresolved link to `m`
--> $DIR/intra-link-errors.rs:76:6
|
LL | /// [m()]
| ^^^ help: to link to the macro, use its disambiguator: `m!`
|
= note: this link resolves to the macro `m`, which is not in the value namespace
error: aborting due to 14 previous errors