Skip to content

Exported-only outlines list pub methods of impl blocks for private Rust types #1587

Closed

Description

@alex09x

Residual of #1418 (PR #1586).

code_outline with exported_only treats a Rust impl block as having no visibility of its own: it passes on its owners' visibility (none at the top level), and its members are judged by their own pub. For

struct Hidden;
impl Hidden {
    pub fn new() -> Self { Hidden }
}

Hidden is left out, but new (in impl Hidden) is listed, although nothing outside the crate can reach it. That is because the impl's self type is not resolved to its declaration.

Expected: a member of impl T is exported only if T is. For example, look T up among the file's (or the analyzer's) symbols, and leave the member out when T is private. Trait impls (impl Trait for T) follow the trait and the type.

Reproduce with the fixture shape in crates/prod-code-mcp/tests/outline_exported_owners.rs: add a private struct with an impl holding a pub fn.

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

    bugSomething isn't workingmcpMCP tools for agents

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions