diff options
| author | binarycat <binarycat@envs.net> | 2024-11-07 15:33:45 -0600 |
|---|---|---|
| committer | binarycat <binarycat@envs.net> | 2025-07-24 11:17:13 -0500 |
| commit | 5ae2d42a8c80807c7e3ae7e8aff165fb4d8e046f (patch) | |
| tree | 3e4ff5bfac0215c2ea4d450589257287c34031a5 /tests/rustdoc-ui | |
| parent | fc5af1813307d25a84d633f21e2e53c9376eb547 (diff) | |
| download | rust-5ae2d42a8c80807c7e3ae7e8aff165fb4d8e046f.tar.gz rust-5ae2d42a8c80807c7e3ae7e8aff165fb4d8e046f.zip | |
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. Co-authored-by: Michael Howell <michael@notriddle.com>
Diffstat (limited to 'tests/rustdoc-ui')
| -rw-r--r-- | tests/rustdoc-ui/bad-intra-doc.rs | 13 | ||||
| -rw-r--r-- | tests/rustdoc-ui/bad-intra-doc.stderr | 31 |
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/rustdoc-ui/bad-intra-doc.rs b/tests/rustdoc-ui/bad-intra-doc.rs new file mode 100644 index 00000000000..7bc55756e67 --- /dev/null +++ b/tests/rustdoc-ui/bad-intra-doc.rs @@ -0,0 +1,13 @@ +#![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 +pub struct Foo; diff --git a/tests/rustdoc-ui/bad-intra-doc.stderr b/tests/rustdoc-ui/bad-intra-doc.stderr new file mode 100644 index 00000000000..9533792b35b --- /dev/null +++ b/tests/rustdoc-ui/bad-intra-doc.stderr @@ -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 + |
