Skip to content

Document impl block visibility #79878

Closed
Closed

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

  1. changed the title [-]Missing/misleading documentation on impl block visibility[/-] [+]Document impl block visibility[/+] on Dec 10, 2020
  2. 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
  3. pierwill commented on Dec 16, 2020

    @pierwill
    Contributor

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

  4. 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.

  5. added a commit that references this issue on Feb 11, 2025
  6. added a commit that references this issue on Feb 12, 2025
  7. added 2 commits that reference this issue on Mar 11, 2025
  8. Dylan-DPC commented on Jan 28, 2026

    @Dylan-DPC
    Member

    Fixed by #136354

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

      Issue actions