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 should only include &self methods from Deref target #39550

Closed
Storyyeller opened this issue Feb 5, 2017 · 5 comments
Closed

rustdoc should only include &self methods from Deref target #39550

Storyyeller opened this issue Feb 5, 2017 · 5 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Storyyeller
Copy link
Contributor

Currently, if Foo impls Deref<Target=Bar>, then the generated documentation for Foo will include every method defined on Bar, regardless of receiver type. &mut self methods should only be included if DerefMut is impled, and self methods shouldn't be included at all.

It may also be worth excluding methods on the Deref target from the generated documentation if a method of the same name is defined on the original type, since that's the one that will be called under normal circumstances.

@durka
Copy link
Contributor

durka commented Feb 6, 2017

This is a dupe of #35169 which was supposedly fixed in #36266, has it regressed?

@Storyyeller
Copy link
Contributor Author

For example, https://docs.rs/easy_strings/0.1.0/easy_strings/struct.EZString.html#method.into_bytes

into_bytes(self) is included, despite taking self by value. Perhaps it only filters out &mut self methods, but doesn't filter self methods?

@durka
Copy link
Contributor

durka commented Feb 6, 2017

Yeah, I guess the work in #36266 needs to be extended to also filter out methods with by-value receivers.

@ollie27
Copy link
Member

ollie27 commented Feb 7, 2017

Removing by-value methods was attempted and rejected in #33396.

@steveklabnik steveklabnik added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Feb 7, 2017
@steveklabnik steveklabnik added T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. and removed T-tools labels May 18, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 27, 2017
@QuietMisdreavus
Copy link
Member

The issue that's causing this is that DerefMut confuses the check that rustdoc does right here. If DerefMut is implemented, then that allows anything that's not self: Box<Self>, where it should also check that it's not a by-value self as well. Extending this to add another by_value condition (which should only be true in that _ branch, which corresponds to SelfTy::SelfValue) which further masks the bool that's handed to render_method_item in the above scope, will solve this.

@QuietMisdreavus QuietMisdreavus added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Sep 29, 2017
bors added a commit that referenced this issue Nov 20, 2017
Make rustdoc not include self-by-value methods from Deref target

Fixes #39550
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants