Skip to content

Conversation

@camelid
Copy link
Member

@camelid camelid commented Sep 19, 2020

Fixes #62834.


The contents of the generics will be mostly ignored (except for warning
if fully-qualified syntax is used, which is currently unsupported in
intra-doc links - see issue #74563).

  • Allow links like Vec<T>, Result<T, E>, and Option<Box<T>>
  • Allow links like Vec::<T>::new()
  • Warn on
    • Unbalanced angle brackets (e.g. Vec<T or Vec<T>>)
    • Missing type to apply generics to (<T> or <Box<T>>)
    • Use of fully-qualified syntax (<Vec as IntoIterator>::into_iter)
    • Invalid path separator (Vec:<T>:new)
    • Too many angle brackets (Vec<<T>>)
    • Empty angle brackets (Vec<>)

Note that this implementation does allow some constructs that aren't
valid in the actual Rust syntax, for example Box::<T>new(). That may
not be supported in rustdoc in the future; it is an implementation
detail.

@rust-highfive
Copy link
Contributor

Some changes occurred in intra-doc-links.

cc @jyn514

@rustbot rustbot added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Sep 19, 2020
@rust-highfive
Copy link
Contributor

r? @ollie27

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 19, 2020
@camelid camelid force-pushed the rustdoc-allow-generic-params branch from c0b3814 to 8d7db03 Compare September 19, 2020 19:05
@jyn514
Copy link
Member

jyn514 commented Sep 19, 2020

r? @jyn514

@rust-highfive rust-highfive assigned jyn514 and unassigned ollie27 Sep 19, 2020
@jyn514 jyn514 added the A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name label Sep 19, 2020
@camelid
Copy link
Member Author

camelid commented Sep 19, 2020

I think all that's left to do is add some UI tests for the warning!

@camelid
Copy link
Member Author

camelid commented Sep 19, 2020

By the way, I would like to squash this a bit so the commit history is a bit nicer, so I would appreciate it if you could let me know before r+ing :)

@camelid camelid marked this pull request as ready for review September 19, 2020 22:44
@jyn514 jyn514 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 20, 2020
@jyn514

This comment has been minimized.

@jyn514
Copy link
Member

jyn514 commented Oct 10, 2020

error: unresolved link to `<Self as Trait>::MyAType: Eq, <Self as Trait>::MyAType: PartialEq<<Self as Trait>::MyAType>`
   --> compiler/rustc_middle/src/ty/query/plumbing.rs:522:17
    |
522 |             $($(#[$attr])*  $name: QueryState<
    |                 ^^^^^^^^
    | 
   ::: compiler/rustc_middle/src/ty/query/mod.rs:105:1
    |
105 | rustc_query_append! { [define_queries!][<'tcx>] }
    | ------------------------------------------------- in this macro invocation
    |
    = note: `-D broken-intra-doc-links` implied by `-D warnings`
    = note: see https://github.com/rust-lang/rust/issues/74563 for more information
    = note: fully-qualified syntax is unsupported
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

Looks like some queries aren't quoting code properly. The span is unhelpful, you can find the query docs at https://github.com/rust-lang/rust/blob/master/compiler/rustc_middle/src/query/mod.rs. You can test locally with x.py doc --stage 1 compiler/rustc_middle; you may want --keep-stage 0 to avoid rebuilding rustc_middle after a doc change.

@jyn514 jyn514 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 10, 2020
They were not formatted correctly, so rustdoc was interpreting some
parts as code. Also cleaned up some other query docs that weren't
causing issues, but were formatted incorrectly.
@jyn514
Copy link
Member

jyn514 commented Oct 10, 2020

@bors r+

@bors
Copy link
Collaborator

bors commented Oct 10, 2020

📌 Commit e2424a2 has been approved by jyn514

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 10, 2020
@bors
Copy link
Collaborator

bors commented Oct 10, 2020

⌛ Testing commit e2424a2 with merge b1af43b...

@bors
Copy link
Collaborator

bors commented Oct 10, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: jyn514
Pushing b1af43b to master...

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-enhancement Category: An issue proposing an enhancement or a PR with one. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow generic parameters in intra doc link

7 participants