Skip to content

Commit

Permalink
Rollup merge of #75318 - jyn514:primitive, r=manishearth
Browse files Browse the repository at this point in the history
Resolve `char` as a primitive even if there is a module in scope

Closes #58699.
r? @Manishearth
  • Loading branch information
JohnTitor authored Aug 10, 2020
2 parents df2da46 + b11e2f2 commit 968740a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,11 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
return Ok((res, Some(path_str.to_owned())));
}
Res::Def(DefKind::Mod, _) => {
// This resolved to a module, but if we were passed `type@`,
// we want primitive types to take precedence instead.
if disambiguator == Some(Disambiguator::Namespace(Namespace::TypeNS)) {
// This resolved to a module, but we want primitive types to take precedence instead.
if matches!(
disambiguator,
None | Some(Disambiguator::Namespace(Namespace::TypeNS))
) {
if let Some(prim) = is_primitive(path_str, ns) {
if extra_fragment.is_some() {
return Err(ErrorKind::AnchorFailure(AnchorFailure::Primitive));
Expand Down
7 changes: 6 additions & 1 deletion src/test/rustdoc/intra-link-prim-precedence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@ pub mod char {}
pub struct MyString;

/// See also [char]
// @has intra_link_prim_precedence/struct.MyString2.html '//a/@href' 'intra_link_prim_precedence/char/index.html'
// @has intra_link_prim_precedence/struct.MyString2.html '//a/@href' 'https://doc.rust-lang.org/nightly/std/primitive.char.html'
pub struct MyString2;

/// See also [crate::char] and [mod@char]
// @has intra_link_prim_precedence/struct.MyString3.html '//*[@href="../intra_link_prim_precedence/char/index.html"]' 'crate::char'
// @has - '//*[@href="../intra_link_prim_precedence/char/index.html"]' 'mod@char'
pub struct MyString3;

0 comments on commit 968740a

Please sign in to comment.