Skip to content

Support const static union#2

Merged
tzneal merged 2 commits intomainfrom
support-const-static-union
Mar 26, 2026
Merged

Support const static union#2
tzneal merged 2 commits intomainfrom
support-const-static-union

Conversation

@tzneal
Copy link
Copy Markdown
Owner

@tzneal tzneal commented Mar 26, 2026

No description provided.

Add visit_item_const, visit_item_static, and visit_item_union to the
ItemVisitor so rspeek can find these item kinds in dependency and
workspace crates.

Includes tests for const, static, union indexing and pub_only filtering.
When listing a crate's items with `rspeek <crate>`, the output now
includes direct dependencies and workspace members that aren't yet
deps. Helps LLMs discover what's already available before writing
code from scratch.

Crate name comparison normalizes hyphens/underscores to avoid
false positives in the available list.
@tzneal tzneal force-pushed the support-const-static-union branch from 39466f5 to 456fc4e Compare March 26, 2026 02:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands rspeek’s item indexing to include union, const, and static, and enhances the crate-overview output to include direct dependencies plus a list of workspace member crates.

Changes:

  • Index union, const, and static items (with new unit tests).
  • Add dependency + “available workspace members” fields to crate overview output (text + JSON).
  • Update CLI help/README to reflect the expanded item support and overview output.

Reviewed changes

Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/index.rs Adds syn visitor support for union/const/static and introduces tests for these kinds.
src/resolve.rs Extends ResolvedCrate with direct dependency names and adds Workspace::member_names().
src/main.rs Emits new overview fields in both JSON and text modes and updates --llm-help docs.
src/output.rs Extends JsonCrateOverview JSON schema with deps and available_workspace_members.
README.md Documents new supported item kinds and the enriched crate overview output.
Cargo.toml Adds tempfile as a dev-dependency for new tests.
Cargo.lock Lockfile updates from adding tempfile.
.gitignore Ignores .kiro/.
Comments suppressed due to low confidence (2)

src/main.rs:210

  • available_workspace_members is computed for every crate being overviewed. For non-workspace-member crates (i.e., registry dependencies), this will list essentially all workspace members because they’re not deps of that external crate, which makes the label “not yet deps” misleading. Consider only populating this field when c.is_workspace_member (otherwise leave it empty), or redefine it to be relative to a specific workspace crate.
                    crate_name: c.name.clone(),
                    crate_version: c.version.clone(),
                    src_dir: c
                        .source_dirs
                        .iter()
                        .map(|d| d.display().to_string())

src/main.rs:252

  • Same issue as the JSON branch: this computes and prints “Workspace members (not yet deps)” even when the crate being overviewed is not a workspace member, which can produce confusing output for registry crates. Gate this on c.is_workspace_member (or make the notion of “available members” relative to a chosen workspace crate).
                let items = index::list_items(&c.source_dirs, pub_only, c.out_dir.as_deref())
                    .map_err(|e| NotFound {
                        message: e.to_string(),
                        suggestions: vec![],
                    })?;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 101 to 103
let out_dir = find_out_dir(metadata.target_directory.as_std_path(), &pkg.name);
let deps: Vec<String> = node.deps.iter().map(|d| d.name.clone()).collect();
crates.push(ResolvedCrate {
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

node.deps from cargo_metadata includes dependency edges with kinds (normal/dev/build). Collecting only d.name here can cause the displayed deps list to include build- and dev-dependencies, which aren’t usable from the crate’s main code. If the intent is “what’s already usable in code,” filter to normal deps via dep_kinds, or include the kind in the stored data/output so the UI can distinguish them.

Copilot uses AI. Check for mistakes.
@tzneal tzneal merged commit b5e47c1 into main Mar 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants