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 more std:: instead of core:: in docs for consistency #79611

Merged
merged 1 commit into from
Dec 4, 2020

Conversation

poliorcetics
Copy link
Contributor

@poliorcetics poliorcetics commented Dec 1, 2020

@rustbot label T-doc

Some cleanup work to use std:: instead of core:: in docs as much as possible. This helps with terminology and consistency, especially for newcomers from other languages that have often heard of std to describe the standard library but not of core.

Edit: I also added more intra doc links when I saw the opportunity.

@rustbot rustbot added the A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools label Dec 1, 2020
@rust-highfive
Copy link
Collaborator

r? @withoutboats

(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 Dec 1, 2020
@jyn514 jyn514 added C-cleanup Category: PRs that clean code up or issues documenting cleanup. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Dec 1, 2020
@jyn514
Copy link
Member

jyn514 commented Dec 1, 2020

---- src/future/poll_fn.rs - future::poll_fn::poll_fn (line 12) stdout ----
error[E0432]: unresolved import `std::future::poll_fn`
 --> src/future/poll_fn.rs:15:5
  |
6 | use std::future::poll_fn;
  |     ^^^^^^^^^^^^^^^^^^^^ no `poll_fn` in `future`

I think this function might only be in core?

r=me once you get CI passing.

@jyn514 jyn514 assigned jyn514 and unassigned withoutboats Dec 1, 2020
@poliorcetics
Copy link
Contributor Author

It's only in core yes, but why ? unstable functions or not, shouldn't all pub items in core be reexported through std ?

@jyn514
Copy link
Member

jyn514 commented Dec 2, 2020

It should be, but it's not currently: #79174

@jyn514
Copy link
Member

jyn514 commented Dec 2, 2020

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Dec 2, 2020

📌 Commit 4eb76fc 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-review Status: Awaiting review from the assignee but also interested parties. labels Dec 2, 2020
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Dec 3, 2020
Use more std:: instead of core:: in docs for consistency

`@rustbot` label T-doc

Some cleanup work to use `std::` instead of `core::` in docs as much as possible. This helps with terminology and consistency, especially for newcomers from other languages that have often heard of `std` to describe the standard library but not of `core`.

Edit: I also added more intra doc links when I saw the opportunity.
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 4, 2020
Rollup of 11 pull requests

Successful merges:

 - rust-lang#77686 (Render Markdown in search results)
 - rust-lang#79541 (Doc keyword lint pass)
 - rust-lang#79602 (Fix SGX CI)
 - rust-lang#79611 (Use more std:: instead of core:: in docs for consistency)
 - rust-lang#79623 (Pass around Symbols instead of Idents in doctree)
 - rust-lang#79627 (Update cargo)
 - rust-lang#79631 (disable a ptr equality test on Miri)
 - rust-lang#79638 (Use `item_name` instead of pretty printing for resolving `Self` on intra-doc links)
 - rust-lang#79646 (rustc_metadata: Remove some dead code)
 - rust-lang#79664 (move interpret::MemoryKind::Heap to const eval)
 - rust-lang#79678 (Fix some clippy lints)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 88f0c72 into rust-lang:master Dec 4, 2020
@rustbot rustbot added this to the 1.50.0 milestone Dec 4, 2020
@therealprof
Copy link
Contributor

therealprof commented Dec 4, 2020

It feels very weird to have doc examples in libcore which reference std. I appreciate this might confuse std users but there're also plenty of #[no_std] users out there who love a good and relevant example without being thrown off by the use of a library they can't use.

@poliorcetics poliorcetics deleted the use-std-in-docs branch December 4, 2020 10:35
@poliorcetics
Copy link
Contributor Author

It feels very weird to have doc examples in libcore which reference std.

This was already the case for the vast majority of the examples, this PR made it more consistent.

I also feel like no_std users are more "advanced" and certainly know to change std to core in their code.

There is also the problem that items in core are reexported in std so they end up with a documentation example on core::Something when they are looking at std::Something.

@therealprof
Copy link
Contributor

I also feel like no_std users are more "advanced" and certainly know to change std to core in their code.

Not necessarily. With no_std becoming more popular due to wasm and embedded I totally expect that in the future even more people will jump in directly without knowing too much about the distinction.

There is also the problem that items in core are reexported in std so they end up with a documentation example on core::Something when they are looking at std::Something.

It would be great if there was a more general solution to properly handling re-exports, e.g. by rewriting re-exports automatically to the namespace at hand.

@poliorcetics
Copy link
Contributor Author

due to wasm

True, I forgot about wasm.

It would be great if there was a more general solution to properly handling re-exports, e.g. by rewriting re-exports automatically to the namespace at hand.

Merging alloc/core and std is the optimal solution and it is often discussed but it cannot be done so easily. I'm not sure I would want rustdoc to change the code in examples too, it seems brittle.

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 C-cleanup Category: PRs that clean code up or issues documenting cleanup. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants