Skip to content

Rustdoc treats primitive disambiguators incorrectly #80559

Closed
@jyn514

Description

@jyn514

I tried this code:

//! [str::trim()]

I expected to see this happen: Rustdoc links to https://doc.rust-lang.org/nightly/std/primitive.str.html#method.trim.

Instead, this happened: Rustdoc gets confused that () means a function and thinks that the link is a primitive.

error: incompatible link kind for `str::trim`
   |
   |
57 | /// Using the [`str::trim()`] method ensures that no whitespace remains before parsing.
   |                ^^^^^^^^^^^^^ help: to link to the builtin type, prefix with `prim@`: ``prim@str::trim``
   |
   = note: `-D broken-intra-doc-links` implied by `-D warnings`
   = note: this link resolved to a builtin type, which is not a function

Meta

rustdoc --version:

rustdoc 1.50.0-beta.1 (05b602367 2020-12-29)

Relevant code:

report_mismatch(other, Disambiguator::Primitive);

I think the fix is just to add if self.kind_side_channel.is_none() as a match guard.

Metadata

Metadata

Assignees

Labels

A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameC-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions