-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #74528 - euclio:intra-link-errors, r=jyn514
refactor and reword intra-doc link errors This commit refactors intra-doc link error reporting to deduplicate code and decouple error construction from the type of error. This greatly improves flexibility at each error construction site, while reducing the complexity of the diagnostic creation. This commit also rewords the diagnostics for clarity and style: - Diagnostics should not end in periods. - It's unnecessary to say "ignoring it". Since this is a warning by default, it's already clear that the link is ignored.
- Loading branch information
Showing
17 changed files
with
290 additions
and
298 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
src/test/rustdoc-ui/deny-intra-link-resolution-failure.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
error: `[v2]` cannot be resolved, ignoring it. | ||
error: unresolved link to `v2` | ||
--> $DIR/deny-intra-link-resolution-failure.rs:3:6 | ||
| | ||
LL | /// [v2] | ||
| ^^ cannot be resolved, ignoring | ||
| ^^ unresolved link | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/deny-intra-link-resolution-failure.rs:1:9 | ||
| | ||
LL | #![deny(intra_doc_link_resolution_failure)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` | ||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
error: `[TypeAlias::hoge]` cannot be resolved, ignoring it. | ||
error: unresolved link to `TypeAlias::hoge` | ||
--> $DIR/intra-doc-alias-ice.rs:5:30 | ||
| | ||
LL | /// [broken cross-reference](TypeAlias::hoge) | ||
| ^^^^^^^^^^^^^^^ cannot be resolved, ignoring | ||
| ^^^^^^^^^^^^^^^ unresolved link | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/intra-doc-alias-ice.rs:1:9 | ||
| | ||
LL | #![deny(intra_doc_link_resolution_failure)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` | ||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
error: `[i]` cannot be resolved, ignoring it. | ||
error: unresolved link to `i` | ||
--> $DIR/intra-link-span-ice-55723.rs:9:10 | ||
| | ||
LL | /// (arr[i]) | ||
| ^ cannot be resolved, ignoring | ||
| ^ unresolved link | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/intra-link-span-ice-55723.rs:1:9 | ||
| | ||
LL | #![deny(intra_doc_link_resolution_failure)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` | ||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
error: `[Foo::f#hola]` has an issue with the link anchor. | ||
error: `Foo::f#hola` contains an anchor, but links to struct fields are already anchored | ||
--> $DIR/intra-links-anchors.rs:25:15 | ||
| | ||
LL | /// Or maybe [Foo::f#hola]. | ||
| ^^^^^^^^^^^ struct fields cannot be followed by anchors | ||
| ^^^^^^^^^^^ contains invalid anchor | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/intra-links-anchors.rs:1:9 | ||
| | ||
LL | #![deny(intra_doc_link_resolution_failure)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: `[hello#people#!]` has an issue with the link anchor. | ||
error: `hello#people#!` contains multiple anchors | ||
--> $DIR/intra-links-anchors.rs:31:28 | ||
| | ||
LL | /// Another anchor error: [hello#people#!]. | ||
| ^^^^^^^^^^^^^^ only one `#` is allowed in a link | ||
| ^^^^^^^^^^^^^^ contains invalid anchor | ||
|
||
error: `[Enum::A#whatever]` has an issue with the link anchor. | ||
error: `Enum::A#whatever` contains an anchor, but links to enum variants are already anchored | ||
--> $DIR/intra-links-anchors.rs:37:28 | ||
| | ||
LL | /// Damn enum's variants: [Enum::A#whatever]. | ||
| ^^^^^^^^^^^^^^^^ variants cannot be followed by anchors | ||
| ^^^^^^^^^^^^^^^^ contains invalid anchor | ||
|
||
error: `[u32#hello]` has an issue with the link anchor. | ||
error: `u32#hello` contains an anchor, but links to primitive types are already anchored | ||
--> $DIR/intra-links-anchors.rs:43:6 | ||
| | ||
LL | /// [u32#hello] | ||
| ^^^^^^^^^ primitive types cannot be followed by anchors | ||
| ^^^^^^^^^ contains invalid anchor | ||
|
||
error: aborting due to 4 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
warning: `[error]` cannot be resolved, ignoring it. | ||
warning: unresolved link to `error` | ||
--> $DIR/intra-links-warning-crlf.rs:7:6 | ||
| | ||
LL | /// [error] | ||
| ^^^^^ cannot be resolved, ignoring | ||
| ^^^^^ unresolved link | ||
| | ||
= note: `#[warn(intra_doc_link_resolution_failure)]` on by default | ||
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` | ||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` | ||
|
||
warning: `[error1]` cannot be resolved, ignoring it. | ||
warning: unresolved link to `error1` | ||
--> $DIR/intra-links-warning-crlf.rs:12:11 | ||
| | ||
LL | /// docs [error1] | ||
| ^^^^^^ cannot be resolved, ignoring | ||
| ^^^^^^ unresolved link | ||
| | ||
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` | ||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` | ||
|
||
warning: `[error2]` cannot be resolved, ignoring it. | ||
warning: unresolved link to `error2` | ||
--> $DIR/intra-links-warning-crlf.rs:15:11 | ||
| | ||
LL | /// docs [error2] | ||
| ^^^^^^ cannot be resolved, ignoring | ||
| ^^^^^^ unresolved link | ||
| | ||
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` | ||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` | ||
|
||
warning: `[error]` cannot be resolved, ignoring it. | ||
warning: unresolved link to `error` | ||
--> $DIR/intra-links-warning-crlf.rs:23:20 | ||
| | ||
LL | * It also has an [error]. | ||
| ^^^^^ cannot be resolved, ignoring | ||
| ^^^^^ unresolved link | ||
| | ||
= help: to escape `[` and `]` characters, just add '\' before them like `\[` or `\]` | ||
= help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]` | ||
|
||
warning: 4 warnings emitted | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.