Skip to content

fix(mcp): exported-only Rust outlines leave out impl blocks of private types (#1587) - #1649

Merged
alex09x merged 1 commit into
mainfrom
fix/1587-outline-impl-of-private-type
Oct 27, 2026
Merged

alex09x merged 1 commit into
mainfrom
fix/1587-outline-impl-of-private-type

Conversation

@alex09x

@alex09x alex09x commented Oct 27, 2026

Copy link
Copy Markdown
Owner

Problem

code_outline with exported_only treats a Rust impl block as transparent (#1418): it passes on its owners' visibility, which at the top level is none. So for

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

the outline left Hidden out but listed impl Hidden and new, which nothing outside the crate can reach (#1587).

Change

tools/outline/render.rs:

  • A pre-pass records whether each type the file declares at the top level (struct, enum, trait, class) is exported.
  • A Rust impl header is read for its trait and self type by impl_types, which takes each by its last path segment, skips generics, and stops at where/{. Examples:
    • impl<T: Clone> Shown<T> → Shown;
    • impl fmt::Display for W<'a> → Display and W.
  • If either the trait or the self type is declared in the file and is not exported, the impl and its members are not exported.
  • A type the file does not declare is not judged, so the previous behaviour stands for it.

Reproduce and verify

New test tests/outline_exported_owners.rs::an_impl_of_a_private_type_exports_none_of_its_members. impl Hidden's new is left out, and impl<T: Clone> Shown<T>'s get is listed.

Before (the check disabled, a Linux build node):

new: Outline for src/lib.rs:
  [Symbol] impl Hidden (line 2)

After: passes. The two existing tests in that file still pass.

Measurements

None.

Checks

One gate on a Linux build node (default stable toolchain) covered this PR together with #1582, the other mcp fix merged with it. The two change disjoint files.

  • cargo test -p prod-code-mcp --no-fail-fast: exit 101. 134 of 134 binaries ran. The one failed target is --test encapsulate_preservation (context_review::rust_consuming_receiver_keeps_unconditional_rhs), the known environment failure of Two prod-code-mcp tests depend on the build node: /tmp as a workspace root and an unconditional zig probe #1567, unrelated.
  • cargo clippy -p prod-code-mcp --all-targets: exit 0. The one warning in a touched file, collapsible_if at tools/symbols/resolve.rs:367, is on a pre-existing line (main's line 361, moved by this change).
  • cargo fmt --all -- --check: exit 0.

Closes #1587

@alex09x alex09x added bug Something isn't working mcp MCP tools for agents labels Oct 27, 2026
@alex09x
alex09x merged commit dcd432a into main Oct 27, 2026
@alex09x
alex09x deleted the fix/1587-outline-impl-of-private-type branch October 27, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working mcp MCP tools for agents

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant