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

Use Intra-doc links for std::io::buffered #78006

Merged
merged 2 commits into from
Nov 6, 2020
Merged

Use Intra-doc links for std::io::buffered #78006

merged 2 commits into from
Nov 6, 2020

Conversation

pitaj
Copy link
Contributor

@pitaj pitaj commented Oct 16, 2020

Helps with #75080. I used the implicit link style for intrinsics, as that was what minnumf32 and others already had.

@rustbot modify labels: T-doc, A-intra-doc-links

r? @jyn514

@rustbot rustbot added A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools labels Oct 16, 2020
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @jyn514 (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 16, 2020
@jyn514 jyn514 changed the title Interdoc links core::intrinsics, std::io::buffered Use Intra-doc links for core::intrinsics, std::io::buffered Oct 16, 2020
Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this :)

library/core/src/intrinsics.rs Outdated Show resolved Hide resolved
library/std/src/io/buffered/bufreader.rs Outdated Show resolved Hide resolved
@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 16, 2020
@jyn514
Copy link
Member

jyn514 commented Oct 16, 2020

Looks great! r=me when CI passes (feel free to ping me tomorrow if I forget to ping bors).

@jyn514 jyn514 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 16, 2020
@pitaj
Copy link
Contributor Author

pitaj commented Oct 16, 2020

I'm guessing errors like the following here are caused by not yet having #77267 (as seen in #77875):

error: unresolved link to `f32::sqrt`
    --> library/core/src/intrinsics.rs:1175:54
     |
1175 |     /// The stabilized version of this intrinsic is [`f32::sqrt`].
     |                                                      ^^^^^^^^^^^ the builtin type `f32` has no associated item named `sqrt`

I made that last commit which fixes those (not sure if it's the style you'd like to see, but it works).

I figured out that these errors here are because I was looking at the wrong TcpStream:

error: unresolved link to `self::net::TcpStream::read`
  --> library/std/src/io/buffered/bufreader.rs:24:26
   |
24 | /// [`TcpStream::read`]: crate::net::TcpStream::read
   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the struct `TcpStream` has no field or associated item named `read`
   |
   = note: `-D broken-intra-doc-links` implied by `-D warnings`

error: unresolved link to `self::net::TcpStream::write`
  --> library/std/src/io/buffered/bufwriter.rs:62:27
   |
62 | /// [`TcpStream::write`]: crate::net::TcpStream::write
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the struct `TcpStream` has no field or associated item named `write`

error: unresolved link to `self::net::TcpStream::read`
  --> library/std/src/io/buffered/bufreader.rs:24:26
   |
24 | /// [`TcpStream::read`]: crate::net::TcpStream::read
   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the struct `TcpStream` has no field or associated item named `read`

I was looking at net_imp::TcpStream originally, but then I figured out that the TcpStream in tcp.rs is the real one. Except that one doesn't have its own read and write, instead it implements the traits:

So maybe those links should link to the trait methods as they already do? Because linking them like crate::net::TcpStream::write() doesn't work either:

error: unresolved link to `self::net::TcpStream::write`
  --> library/std/src/io/buffered/bufwriter.rs:62:27
   |
62 | /// [`TcpStream::write`]: crate::net::TcpStream::write()
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the struct `TcpStream` has no function named `write`

Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linking them like crate::net::TcpStream::write() doesn't work either

You probably need use crate::io::Write; trait items aren't resolved unless the trait is in scope.

I'm guessing errors like the following here are caused by not yet having #77267 (as seen in #77875)

Hmm, that seems like a separate bug - these aren't re-exports but just the primitives themselves. Did this happen with --stage 0 or --stage 1? (CI runs --stage 2, doc uses --stage 0 by default)

library/std/src/io/buffered/bufwriter.rs Show resolved Hide resolved
@pitaj
Copy link
Contributor Author

pitaj commented Oct 17, 2020

trait items aren't resolved unless the trait is in scope.

Is there something special I have to do to import item for use with intra-doc links? Both look to be in scope to me:

Hmm, that seems like a separate bug - these aren't re-exports but just the primitives themselves. Did this happen with --stage 0 or --stage 1?

The "the builtin type f64 has no associated item named sqrt" errors occur for stage 0, stage 1, and stage 2.

These errors are all from CI. The "here" links link to CI logs. It looks to me like CI runs with --stage 0: https://github.com/rust-lang/rust/pull/78006/checks?check_run_id=1262780047#step:24:1769

@jyn514
Copy link
Member

jyn514 commented Oct 23, 2020

FYI I haven't forgotten about this but I don't have time to investigate all the bugs right now. I think the way forward is to file issues for the things that seem like they should work and revert the relevant changes for now.

@jyn514
Copy link
Member

jyn514 commented Nov 1, 2020

@pitaj I can't reproduce this failure locally.

$ cat tcp.rs
//! [`TcpStream::write`](std::net::TcpStream::write)
//! [`TcpStream::read`](std::net::TcpStream::read)
use std::io::{Read, Write};
$ rustdoc +rustc2 tcp.rs  # no output

Do you think you could try to make an example smaller than the full standard library?

Also, since this is only in the standard library, #54172 is definitely the wrong issue for this.

@pitaj
Copy link
Contributor Author

pitaj commented Nov 2, 2020

@jyn514 I have been able to reproduce this in a crate by copying bufreader.rs and reexporting some things from std.

https://github.com/pitaj/rustdoc-78006-repro

I'll work tomorrow and see if I can prune it down some more.

@pitaj pitaj changed the title Use Intra-doc links for core::intrinsics, std::io::buffered Use Intra-doc links for std::io::buffered Nov 6, 2020
Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me with nit fixed

library/std/src/io/buffered/bufreader.rs Show resolved Hide resolved
library/std/src/io/buffered/bufwriter.rs Show resolved Hide resolved
@jyn514
Copy link
Member

jyn514 commented Nov 6, 2020

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Nov 6, 2020

📌 Commit 8d48e3b has been approved by jyn514

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 6, 2020
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Nov 6, 2020
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Nov 6, 2020
Use Intra-doc links for std::io::buffered

Helps with rust-lang#75080. I used the implicit link style for intrinsics, as that was what `minnumf32` and others already had.

`@rustbot` modify labels: T-doc, A-intra-doc-links

r? `@jyn514`
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 6, 2020
Rollup of 15 pull requests

Successful merges:

 - rust-lang#74979 (`#![deny(unsafe_op_in_unsafe_fn)]` in sys/hermit)
 - rust-lang#78006 (Use Intra-doc links for std::io::buffered)
 - rust-lang#78167 (Fix unreachable sub-branch detection in or-patterns)
 - rust-lang#78514 (Allow using 1/2/3/4 for `x.py setup` options)
 - rust-lang#78538 (BTreeMap: document a curious assumption in test cases)
 - rust-lang#78559 (Add LLVM upgrades from 7 to 10 to RELEASES.md)
 - rust-lang#78666 (Fix shellcheck error)
 - rust-lang#78705 (Print a summary of which test suite failed)
 - rust-lang#78726 (Add link to rust website)
 - rust-lang#78730 (Expand explanation of reverse_bits)
 - rust-lang#78760 (`deny(invalid_codeblock_attributes)` for rustc_error_codes)
 - rust-lang#78771 (inliner: Copy unevaluated constants only after successful inlining)
 - rust-lang#78794 (rustc_expand: use collect_bang helper instead of manual reimplementation)
 - rust-lang#78795 (The renumber pass is long gone)
 - rust-lang#78798 (Fixing Spelling Typos)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 0e71fc7 into rust-lang:master Nov 6, 2020
@rustbot rustbot added this to the 1.49.0 milestone Nov 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools A-intra-doc-links Area: Intra-doc links, the ability to link to items in docs by name S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants