Skip to content

Commit 9a05fd6

Browse files
authored
Rollup merge of rust-lang#79321 - camelid:intra-doc-bang, r=Manishearth
Accept '!' in intra-doc links This will allow linking to things like `Result<T, !>`. *See <https://github.com/rust-lang/rust/pull/77832#discussion_r528409079>.* r? `@jyn514`
2 parents 5b492c9 + 0b6537a commit 9a05fd6

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/librustdoc/passes/collect_intra_doc_links.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ impl LinkCollector<'_, '_> {
10221022
(link.trim(), None)
10231023
};
10241024

1025-
if path_str.contains(|ch: char| !(ch.is_alphanumeric() || ":_<>, ".contains(ch))) {
1025+
if path_str.contains(|ch: char| !(ch.is_alphanumeric() || ":_<>, !".contains(ch))) {
10261026
return None;
10271027
}
10281028

src/test/rustdoc/intra-doc-link-generic-params.rs

+3
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html"]' 'with the generic, Option<T>'
1616

1717
//! We should also try linking to [`Result<T, E>`]; it has *two* generics!
18+
//! And [`Result<T, !>`] and [`Result<!, E>`].
1819
//!
1920
// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html"]' 'Result<T, E>'
21+
// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html"]' 'Result<T, !>'
22+
// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html"]' 'Result<!, E>'
2023

2124
//! Now let's test a trickier case: [`Vec::<T>::new`], or you could write it
2225
//! [with parentheses as `Vec::<T>::new()`][Vec::<T>::new()].

0 commit comments

Comments
 (0)