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 Self in docs when possible #77079

Merged
merged 3 commits into from
Sep 25, 2020
Merged

Conversation

poliorcetics
Copy link
Contributor

Fixes #76542.

I used rg '\s*//[!/]\s+fn [\w_]+\(&?self, ' . in library/ to find instances, I found some with that and some by manually checking.

@rustbot modify labels: C-enhancement T-doc

@rustbot rustbot added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools labels Sep 22, 2020
@rust-highfive
Copy link
Collaborator

r? @LukasKalbertodt

(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 22, 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 CI passing

Comment on lines -643 to +650
/// *self = BooleanVector(self.0
/// .iter()
/// .zip(rhs.0.iter())
/// .map(|(x, y)| *x && *y)
/// .collect());
/// *self = Self(self.0
/// .iter()
/// .zip(rhs.0.iter())
/// .map(|(x, y)| *x && *y)
/// .collect());
Copy link
Member

Choose a reason for hiding this comment

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

rustfmt continues to disappoint me in every way 😢

@jyn514
Copy link
Member

jyn514 commented Sep 22, 2020

Looks like it's already passing.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Sep 22, 2020

📌 Commit ec4e9cd 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 Sep 22, 2020
@pickfire
Copy link
Contributor

pickfire commented Sep 23, 2020

Would this be good? In the docs it is hard to identify what Self is, if there is multiple implementations Self could be a few things and it could confuse the readers. Maybe we should hold this off until we have a clearer way to identify Self?

If it is in docs it may be clearer to current reader but when the user write it in this way and there are multiple implementations, there may be an issue I mentioned above.

@jyn514
Copy link
Member

jyn514 commented Sep 23, 2020

@pickfire this is in doc-tests, so the types will still be shown in the documentation itself.

@poliorcetics
Copy link
Contributor Author

In doc tests blocks and functions are usually very short and contained so I don't think this is going to be a problem.

@pickfire
Copy link
Contributor

pickfire commented Sep 23, 2020

@pickfire this is in doc-tests, so the types will still be shown in the documentation itself.

Yes, I know doctests have less of this issue but it encourages others to write it this way, which in turn make the ecosystems' docs harder to read.

bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 25, 2020
…as-schievink

Rollup of 15 pull requests

Successful merges:

 - rust-lang#75438 (Use adaptive SVG favicon for rustdoc like other rust sites)
 - rust-lang#76304 (Make delegation methods of `std::net::IpAddr` unstably const)
 - rust-lang#76724 (Allow a unique name to be assigned to dataflow graphviz output)
 - rust-lang#76978 (Documented From impls in std/sync/mpsc/mod.rs)
 - rust-lang#77044 (Liballoc bench vec use mem take not replace)
 - rust-lang#77050 (Typo fix: "satsify" -> "satisfy")
 - rust-lang#77074 (add array::from_ref)
 - rust-lang#77078 (Don't use an if guard to check equality with a constant)
 - rust-lang#77079 (Use `Self` in docs when possible)
 - rust-lang#77081 (Merge two almost identical match arms)
 - rust-lang#77121 (Updated html_root_url for compiler crates)
 - rust-lang#77136 (Suggest `const_mut_refs`, not `const_fn` for mutable references in `const fn`)
 - rust-lang#77160 (Suggest `const_fn_transmute`, not `const_fn`)
 - rust-lang#77164 (Remove workaround for deref issue that no longer exists.)
 - rust-lang#77165 (Followup to rust-lang#76673)

Failed merges:

r? `@ghost`
@bors bors merged commit dc4f39c into rust-lang:master Sep 25, 2020
@rustbot rustbot added this to the 1.48.0 milestone Sep 25, 2020
@poliorcetics poliorcetics deleted the more-self-in-docs branch September 25, 2020 20:26
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-enhancement Category: An issue proposing an enhancement or a PR with one. 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.

More Self usage in PartialOrd trait docs example
7 participants