Skip to content

Document impl block visibility #79878

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

Open
Subsentient opened this issue Dec 10, 2020 · 2 comments
Open

Document impl block visibility #79878

Subsentient opened this issue Dec 10, 2020 · 2 comments
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-visibility Area: Visibility / privacy C-enhancement Category: An issue proposing an enhancement or a PR with one. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@Subsentient
Copy link

It seems that if the type is visible, an impl's pub methods can be used, even if such an impl is encased in multiple private modules.

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2015&gist=bf21f358b4b57075d1243a3b07d93da9

I cannot find anywhere in the documentation, hell, even Google, where this behaviour is documented correctly. Only after opening #79876 did I find out that this is the expected behaviour.

@Subsentient Subsentient added the C-bug Category: This is a bug. label Dec 10, 2020
@camelid camelid changed the title Missing/misleading documentation on impl block visibility Document impl block visibility Dec 10, 2020
@camelid camelid added A-visibility Area: Visibility / privacy 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 T-lang Relevant to the language team, which will review and decide on the PR/issue. and removed C-bug Category: This is a bug. labels Dec 10, 2020
@pierwill
Copy link
Member

Would this be something for the API docs here, or the Reference, or both? 🤔

@hkBst
Copy link
Member

hkBst commented Jan 30, 2025

The path to an associated item is any path to the implementing type, followed by the associated item’s identifier as the final path component.Rust reference

I think that would imply that it does not matter where the impl block is, since the path to its items only depends on where the type is defined.

But https://doc.rust-lang.org/std/keyword.impl.html could I think use some clarification.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 11, 2025
Update docs for impl keyword

This started as a fix for rust-lang#79878, but also introduces some structure (headings), and elaborates a tiny bit on impl Trait syntax.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 12, 2025
Rollup merge of rust-lang#136354 - hkBst:patch-34, r=ibraheemdev

Update docs for impl keyword

This started as a fix for rust-lang#79878, but also introduces some structure (headings), and elaborates a tiny bit on impl Trait syntax.
github-actions bot pushed a commit to tautschnig/verify-rust-std that referenced this issue Mar 11, 2025
Update docs for impl keyword

This started as a fix for rust-lang#79878, but also introduces some structure (headings), and elaborates a tiny bit on impl Trait syntax.
github-actions bot pushed a commit to tautschnig/verify-rust-std that referenced this issue Mar 11, 2025
Update docs for impl keyword

This started as a fix for rust-lang#79878, but also introduces some structure (headings), and elaborates a tiny bit on impl Trait syntax.
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-visibility Area: Visibility / privacy C-enhancement Category: An issue proposing an enhancement or a PR with one. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants