Skip to content

Commit

Permalink
Rollup merge of rust-lang#79321 - camelid:intra-doc-bang, r=Manishearth
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
Dylan-DPC committed Nov 24, 2020
2 parents 5b492c9 + 0b6537a commit 9a05fd6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ impl LinkCollector<'_, '_> {
(link.trim(), None)
};

if path_str.contains(|ch: char| !(ch.is_alphanumeric() || ":_<>, ".contains(ch))) {
if path_str.contains(|ch: char| !(ch.is_alphanumeric() || ":_<>, !".contains(ch))) {
return None;
}

Expand Down
3 changes: 3 additions & 0 deletions src/test/rustdoc/intra-doc-link-generic-params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
// @has foo/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html"]' 'with the generic, Option<T>'

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

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

0 comments on commit 9a05fd6

Please sign in to comment.