Skip to content

Document impl block visibility #79878

Open
@Subsentient

Description

@Subsentient

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.

Activity

changed the title [-]Missing/misleading documentation on impl block visibility[/-] [+]Document impl block visibility[/+] on Dec 10, 2020
added
A-visibilityArea: Visibility / privacy
C-enhancementCategory: An issue proposing an enhancement or a PR with one.
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and tools
T-langRelevant to the language team
and removed
C-bugCategory: This is a bug.
on Dec 10, 2020
pierwill

pierwill commented on Dec 16, 2020

@pierwill
Member

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

hkBst

hkBst commented on Jan 30, 2025

@hkBst
Member

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.

added a commit that references this issue on Feb 11, 2025

Rollup merge of rust-lang#136354 - hkBst:patch-34, r=ibraheemdev

45a0ec8
added a commit that references this issue on Feb 12, 2025
added 2 commits that reference this issue on Mar 11, 2025

Rollup merge of rust-lang#136354 - hkBst:patch-34, r=ibraheemdev

Rollup merge of rust-lang#136354 - hkBst:patch-34, r=ibraheemdev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-visibilityArea: Visibility / privacyC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Subsentient@pierwill@hkBst@camelid

        Issue actions

          Document impl block visibility · Issue #79878 · rust-lang/rust