Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc is parsing email link literals in docs as intradoc links in the latest nightly #83859

Closed
lopopolo opened this issue Apr 4, 2021 · 16 comments · Fixed by #83865
Closed
Assignees
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Milestone

Comments

@lopopolo
Copy link
Contributor

lopopolo commented Apr 4, 2021

I tried this code:

/// Information about an Artichoke build.
///
/// Implementations of this trait are used to set global Ruby constants that
/// describe the current build.
pub trait ReleaseMetadata {
    /// Copyright information.
    ///
    /// This value will populate the `RUBY_COPYRIGHT` constant.
    ///
    /// # Examples
    ///
    /// > artichoke - Copyright (c) 2019-2020 Ryan Lopopolo <rjl@hyperbo.la>
    fn ruby_copyright(&self) -> &str;
}

I expected to see this happen: rustdoc parses the link as an email address and renders it as a mailto: link.

Instead, this happened:

error: unknown disambiguator `rjl`
  --> artichoke-core/src/release_metadata.rs:18:62
   |
18 |     /// > artichoke - Copyright (c) 2019-2020 Ryan Lopopolo <rjl@hyperbo.la>
   |                                                              ^^^
   |
   = note: requested on the command line with `-D rustdoc::broken-intra-doc-links`

Meta

/usr/share/rust/.cargo/bin/rustup show
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/runner/.rustup

info: syncing channel updates for '1.51.0-x86_64-unknown-linux-gnu'
info: latest update on 2021-03-25, rust version 1.51.0 (2fd73fabe 2021-03-23)
info: downloading component 'cargo'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: installing component 'cargo'
info: using up to 500.0 MiB of RAM to unpack components
info: installing component 'rust-std'
info: installing component 'rustc'
1.51.0-x86_64-unknown-linux-gnu (overridden by '/home/runner/work/artichoke/artichoke/rust-toolchain')
rustc 1.51.0 (2fd73fabe 2021-03-23)
/usr/share/rust/.cargo/bin/rustup -V
rustup 1.23.1 (3df2264a9 2020-11-30)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.51.0 (2fd73fabe 2021-03-23)`
Installed rustup 1.23.1 support profiles
/usr/share/rust/.cargo/bin/rustup set profile minimal
info: profile set to 'minimal'
/usr/share/rust/.cargo/bin/rustup toolchain install nightly
info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu'
info: latest update on 2021-04-04, rust version 1.53.0-nightly (0b417ab5c 2021-04-03)
info: downloading component 'cargo'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: installing component 'cargo'
info: using up to 500.0 MiB of RAM to unpack components
info: installing component 'rust-std'
info: installing component 'rustc'

  nightly-x86_64-unknown-linux-gnu installed - rustc 1.53.0-nightly (0b417ab5c 2021-04-03)

info: checking for self-updates
/usr/share/rust/.cargo/bin/rustup override set nightly
info: using existing install for 'nightly-x86_64-unknown-linux-gnu'
info: override toolchain for '/home/runner/work/artichoke/artichoke' set to 'nightly-x86_64-unknown-linux-gnu'

  nightly-x86_64-unknown-linux-gnu unchanged - rustc 1.53.0-nightly (0b417ab5c 2021-04-03)

(from a GitHub Actions run, the latest nightly won't install on my Arch box due to broken components)

@lopopolo
Copy link
Contributor Author

lopopolo commented Apr 4, 2021

This turned out to be a bug in my docs; I didn't intend for this to be rendered as a mailto: link, but I was hoping for a better error message.

@jonas-schievink jonas-schievink added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Apr 4, 2021
@lopopolo
Copy link
Contributor Author

lopopolo commented Apr 4, 2021

I think this PR introduced this new behavior: #83543.

@jyn514 jyn514 added the A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name label Apr 4, 2021
@jyn514
Copy link
Member

jyn514 commented Apr 4, 2021

This is weird - rustdoc should be ignoring any link that has . in it:

if path_str.contains(|ch: char| !(ch.is_alphanumeric() || ":_<>, !*&;".contains(ch))) {

@jyn514
Copy link
Member

jyn514 commented Apr 4, 2021

Ah I see the issue - disambiguator_error should only be reported if the link isn't ignored. @camelid do you have time to fix it? It should be as simple as adding the same check here:

disambiguator_error(self.cx, &item, dox, disambiguator_range, &err_msg);

@jyn514 jyn514 added the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Apr 4, 2021
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Apr 4, 2021
@camelid camelid self-assigned this Apr 4, 2021
@camelid
Copy link
Member

camelid commented Apr 4, 2021

Assigning P-medium and removing I-prioritize as discussed in the prioritization working group.

@rustbot label: +P-medium -I-prioritize

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Apr 4, 2021
@lopopolo
Copy link
Contributor Author

lopopolo commented Apr 4, 2021

@jyn514 @camelid can part of the fix here be to improve the error message?

"Unknown disambiguator" doesn't tell me much about what is wrong or how to fix it.

@jyn514
Copy link
Member

jyn514 commented Apr 4, 2021

@lopopolo I'm confused. After #83865 there won't be an error message, because the link shouldn't have been treated as an intra-doc link in the first place. Are you asking for a lint that warns about docs that will be rendered as mailto: links? I'm not sure how useful that is, mailto: links are normal and reasonable to write.

@lopopolo
Copy link
Contributor Author

lopopolo commented Apr 4, 2021

@jyn514 based on the UI tests that are checked in, if I actually intend to use an intradoc link with a disambiguator and fat finger mod@ as nod@, the error message is not super friendly.

@jyn514
Copy link
Member

jyn514 commented Apr 4, 2021

Hmm, what would you like to see instead? There's quite a few valid disambiguators, I'm not sure it makes sense to list them all. Maybe we could add a header to the disambiguator section of https://doc.rust-lang.org/rustdoc/linking-to-items-by-name.html and link there?

@lopopolo
Copy link
Contributor Author

lopopolo commented Apr 4, 2021

Ideally I'd like to see a suggestion to use a disambiguator that corresponds to an item that is currently in scope or otherwise resolvable via the path after the invalid disambiguator.

@jyn514
Copy link
Member

jyn514 commented Apr 4, 2021

Hmm, that seems useful, although I think it should be a separate issue. Maybe we could try resolving without a disambiguator and see if there are any results? That would need a pretty significant overhaul of how it works currently, right now all the errors are emitted eagerly which would end up with a lot more verbose output that might not be relevant.

What would you expect to see if the link isn't valid even without the disambiguator?

@lopopolo
Copy link
Contributor Author

lopopolo commented Apr 4, 2021

@jyn514 I think an extra note to more docs on intradoc link disambiguators would be helpful per your previous comment.

The idea to attempt to resolve items for all invalid disambiguators feels similar to the Ruby CLI and REPL's "did you mean" feature, which I find quite useful.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 5, 2021
Don't report disambiguator error if link would have been ignored

Fixes rust-lang#83859.

This prevents us from warning on links such as `<hello@example.com>`.
Note that we still warn on links such as `<hello@localhost>` because
they have no dots in them. However, the links will still work, even
though a warning is reported.

r? ``@jyn514``
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 5, 2021
Don't report disambiguator error if link would have been ignored

Fixes rust-lang#83859.

This prevents us from warning on links such as `<hello@example.com>`.
Note that we still warn on links such as `<hello@localhost>` because
they have no dots in them. However, the links will still work, even
though a warning is reported.

r? `@jyn514`
jyn514 pushed a commit to jyn514/rust that referenced this issue Apr 5, 2021
Don't report disambiguator error if link would have been ignored

Fixes rust-lang#83859.

This prevents us from warning on links such as `<hello@example.com>`.
Note that we still warn on links such as `<hello@localhost>` because
they have no dots in them. However, the links will still work, even
though a warning is reported.

r? ```@jyn514```
@bors bors closed this as completed in 3ca197e Apr 5, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Apr 7, 2021
rustdoc: Link to the docs on namespaces when an unknown disambiguator is found

cc rust-lang#83859

`@lopopolo` does this look about like what you expected?

r? `@camelid`
bors added a commit to rust-lang-ci/rust that referenced this issue Apr 8, 2021
rustdoc: Link to the docs on namespaces when an unknown disambiguator is found

cc rust-lang#83859

`@lopopolo` does this look about like what you expected?

r? `@camelid`
@pietroalbini
Copy link
Member

The PR improving the diagnostics is being reverted in #84950, reopening the issue.

@pietroalbini pietroalbini reopened this May 5, 2021
@pietroalbini pietroalbini added regression-from-stable-to-beta Performance or correctness regression from stable to beta. and removed regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. labels May 6, 2021
@pietroalbini pietroalbini added this to the 1.53.0 milestone May 6, 2021
@camelid
Copy link
Member

camelid commented May 6, 2021

@pietroalbini I don't think this is still a regression; the diagnostics improvement was not part of the fix for the regression. (The regression was fixed in #83865.)

@jyn514
Copy link
Member

jyn514 commented May 6, 2021

Yeah, #83866 never had a tracking issue.

@jyn514 jyn514 closed this as completed May 6, 2021
@jyn514
Copy link
Member

jyn514 commented Jul 2, 2021

#83866 was relanded in #85052.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name C-bug Category: This is a bug. P-medium Medium priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants