Skip to content

Move skip parsing#74

Merged
blockiosaurus merged 1 commit into
masterfrom
fix/move-skip
Aug 21, 2025
Merged

Move skip parsing#74
blockiosaurus merged 1 commit into
masterfrom
fix/move-skip

Conversation

@blockiosaurus

Copy link
Copy Markdown
Contributor

Moving skip parsing to output check to parsing check so we don't parse unneeded fields

@blockiosaurus blockiosaurus requested a review from danenbm August 21, 2025 19:59
@coderabbitai

coderabbitai Bot commented Aug 21, 2025

Copy link
Copy Markdown

Summary by CodeRabbit

  • New Features
    • Improved handling of field attributes in IDL generation, ensuring consistent behavior with #[skip] and custom IDL names.
  • Bug Fixes
    • Correctly exclude skipped fields from IDL output across more field types (e.g., slices and complex types).
  • Tests
    • Added fixtures covering #[skip] on additional field types and custom IDL name mapping.
  • Chores
    • Version bump to 0.4.5 across packages for alignment.

Walkthrough

Bumps crate versions from 0.4.4 to 0.4.5 across workspace crates. Moves field skip filtering from IDL conversion to parsing stage, removing StructField::is_skipped, adding a private helper for #[skip] detection, and updating a test fixture to include skipped and renamed fields.

Changes

Cohort / File(s) Summary
Version bumps
shank/Cargo.toml, shank-cli/Cargo.toml, shank-idl/Cargo.toml, shank-macro/Cargo.toml, shank-macro-impl/Cargo.toml, shank-render/Cargo.toml
Increment versions to 0.4.5 and align internal dependency versions; no functional code changes.
Field filtering logic
shank-idl/src/idl_type_definition.rs, shank-macro-impl/src/parsed_struct/parsed_struct.rs
Remove filtering in IDL conversion; add filtering during parsing via #[skip] detection; remove public StructField::is_skipped; introduce private attribute check.
Test fixture updates
shank-idl/tests/fixtures/accounts/single_file/field_attributes.rs
Add #[skip]-annotated fields and an #[idl_name("customName")] on a field to validate parsing/IDL behavior.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant UserCode as User code (struct with fields)
  participant Macro as shank-macro-impl (parser)
  participant IDL as shank-idl (IDL conversion)

  rect rgb(238,245,255)
  note over Macro: New behavior (0.4.5)
  UserCode->>Macro: Parse ItemStruct
  Macro->>Macro: Filter fields with #[skip]
  Macro->>Macro: Build StructField(s) (no is_skipped)
  end

  Macro->>IDL: ParsedStruct (only non-skipped fields)
  IDL->>IDL: Convert to IdlTypeDefinition (no skip filtering)
  IDL-->>UserCode: IDL output
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • danenbm
  • pileks

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/move-skip

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@danenbm danenbm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you LGTM makes more sense to throw away before parsing since that's a place we'd want to use it for sure!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d9d1b7e and 857d486.

📒 Files selected for processing (9)
  • shank-cli/Cargo.toml (2 hunks)
  • shank-idl/Cargo.toml (2 hunks)
  • shank-idl/src/idl_type_definition.rs (0 hunks)
  • shank-idl/tests/fixtures/accounts/single_file/field_attributes.rs (1 hunks)
  • shank-macro-impl/Cargo.toml (1 hunks)
  • shank-macro-impl/src/parsed_struct/parsed_struct.rs (2 hunks)
  • shank-macro/Cargo.toml (2 hunks)
  • shank-render/Cargo.toml (2 hunks)
  • shank/Cargo.toml (1 hunks)
💤 Files with no reviewable changes (1)
  • shank-idl/src/idl_type_definition.rs
🔇 Additional comments (12)
shank-macro-impl/src/parsed_struct/parsed_struct.rs (1)

116-118: Moving skip filtering into parsing is the right call; add a test to cover “un-IDL-able” skipped types.

Early filtering prevents RustType conversion from choking on intentionally skipped fields (e.g., trait objects or complex generics). This aligns with the PR goal and reduces false negatives during parsing.

Two follow-ups:

  • Add/expand tests to assert that fields like Box<dyn Any + Send + Sync> behind #[skip] do not cause parse errors.
  • Document that attributes on a skipped field (e.g., #[idl_name], #[idl_type]) are ignored, to avoid user confusion.
shank-idl/tests/fixtures/accounts/single_file/field_attributes.rs (2)

7-8: IDL rename fixture looks good; ensure the generated IDL key matches “customName”.

Great coverage for #[idl_name]. Ensure the corresponding test asserts that the output IDL contains customName and not renamed_field.


28-28: Wrapper type presence is helpful for #[idl_type] scenarios.

Having SomeWrapper<T> in the fixture ensures we continue to exercise the idl_type override path alongside the new skip behavior.

shank-render/Cargo.toml (2)

3-3: Version bump is aligned; adjust if you decide to honor SemVer with a minor bump.

If shank-macro-impl’s public API removal stands, consider bumping all workspace crates to 0.5.0 to reflect the breaking change; otherwise, re-introduce/deprecate the method and keep 0.4.5.


13-13: Dependency alignment on shank_macro_impl = 0.4.5 looks consistent.

Once the SemVer decision is finalized, ensure this dependency tracks the chosen version (0.4.5 with deprecation or 0.5.0 with a true break).

shank-cli/Cargo.toml (2)

7-7: CLI crate version bump is fine; keep it consistent with workspace SemVer decision.

If you move to 0.5.0 for a breaking change, update this crate as well. Otherwise, 0.4.5 is consistent.


20-20: All internal crate versions are aligned to 0.4.5

Verified across all Cargo.toml files using the provided ripgrep checks:

  • Every version = "0.4.x" entry is now "0.4.5"
  • Every shank_* internal dependency references version "0.4.5"

No remaining 0.4.4 references were found.

shank-macro/Cargo.toml (1)

3-3: Version bump to 0.4.5 looks good and aligns with the PR scope.

shank-idl/Cargo.toml (2)

3-3: Patch version bump acknowledged.


16-16: Dependency versions are synchronized

All shank crates consistently use version 0.4.5 and reference each other via path + version. Ensure you publish in the following order to satisfy these dependencies:

  • shank-macro-impl (v0.4.5)
  • shank-render (v0.4.5)
  • shank-macro (v0.4.5)
  • shank-idl (v0.4.5)
  • shank-cli (v0.4.5)

If shank_macro_impl introduced any breaking changes in this release, increment its major version (e.g. to 0.5.0) and update dependent crates accordingly before publishing.

Nitpick: consider adopting a workspace-managed versioning workflow or a release tool to centralize and automate these version bumps.

shank/Cargo.toml (2)

7-7: Crate version bump to 0.4.5 is consistent with the workspace.


12-12: All internal shank crates updated to v0.4.5; no stale 0.4.4 references remain

  • Confirm publishing order: publish shank_macro 0.4.5 before the main shank crate to prevent transient resolution failures.
  • Review any API changes introduced by the new skip-handling logic; if there are breaking changes, consider a major version bump (to 0.5.0) for this crate.

Comment on lines +21 to +25
#[skip]
pub slice_field: &[u8],

#[skip]
pub complex_skipped_field: Box<dyn std::any::Any + Send + Sync>,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Excellent additions to validate early-skip semantics.

Adding &[u8] and a Box<dyn Any + Send + Sync> behind #[skip] is precisely the kind of “un-IDL-able” type that benefits from early filtering.

Consider also adding one negative case (same fields without #[skip]) in a separate fixture to assert that parsing would fail as expected without the skip.

[package]
name = "shank_macro_impl"
version = "0.4.4"
version = "0.4.5"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

SemVer risk: public API removal elsewhere warrants a minor bump (0.5.0) or a deprecation path, not a patch bump.

Per the PR/AI summary, StructField::is_skipped (a public method) was removed in shank-macro-impl. Removing a public item is a breaking change. For 0.y.z crates, Cargo treats y as the “major”; breaking changes should bump 0.4.x → 0.5.0. Either:

  • Re-introduce the method and deprecate it (returning a constant), or
  • Bump all workspace crates to 0.5.0 and align internal dependency versions.

Run to confirm no remaining references and assess whether a deprecation path is preferable:


🏁 Script executed:

#!/bin/bash
# 1) Check for any usage of the removed method (should be empty)
rg -nP '\.is_skipped\s*\(' --type=rust -C2 || true

# 2) Check whether a `Skip` variant still exists and is now dead code
rg -nP '\benum\s+StructFieldAttr\b' --type=rust -C3 || true
rg -nP '\bStructFieldAttr::Skip\b' --type=rust -C2 || true

# 3) Quick sanity: verify internal crates are aligned on version 0.4.5 (or update all to 0.5.0 if you decide to bump)
fd Cargo.toml | xargs -I{} sh -c 'echo "== {} =="; rg -nP "^(version\s*=\s*|.*\{\s*version\s*=\s*)\"0\.(4|5)\.[0-9]+\"" "{}"'

Length of output: 2662


Bump to 0.5.0 or provide a deprecation for is_skipped to uphold SemVer

Verification summary:

  • No internal references to the removed StructField::is_skipped method were found, confirming its removal does not break the workspace’s own code.
  • The StructFieldAttr::Skip variant remains in use for attribute parsing.
  • Every workspace crate is currently at version 0.4.5, and all path-dependencies point to 0.4.5.【run_scripts】

Action required: choose one of the following to address the breaking change

• Option A – Minor-version bump (0.5.0)

  • Update the version = "0.4.5" line in every Cargo.toml under the workspace (e.g. root, shank, shank-cli, shank-idl, shank-macro, shank-macro-impl, shank-render) to version = "0.5.0".
  • Update all internal path-dependency version references from "0.4.5" to "0.5.0".

• Option B – Deprecation path (patch bump to 0.4.6)

  • Reintroduce StructField::is_skipped as a public method, e.g.:
    impl StructField {
        #[deprecated(note = "Use `attrs().any(|a| a == StructFieldAttr::Skip)` instead")]
        pub fn is_skipped(&self) -> bool {
            self.attrs().contains(&StructFieldAttr::Skip)
        }
    }
  • Release as version 0.4.6 to maintain backward compatibility while warning downstream users.

Either approach is critical to prevent accidental API breaks for consumers. Please implement your chosen path and synchronize all workspace crate versions accordingly.

🤖 Prompt for AI Agents
In shank-macro-impl/Cargo.toml around line 3, the crate version is still "0.4.5"
but a breaking removal of StructField::is_skipped requires a minor version bump;
update version = "0.4.5" to version = "0.5.0" in every Cargo.toml across the
workspace (root and all crates: shank, shank-cli, shank-idl, shank-macro,
shank-macro-impl, shank-render) and update all internal path-dependency version
references from "0.4.5" to "0.5.0" so workspace versions remain consistent.

Comment on lines +103 to +106
/// Helper function to check if a field has the skip attribute
fn field_has_skip_attr(field: &Field) -> bool {
field.attrs.iter().any(|attr| attr.path.is_ident("skip"))
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Make skip detection resilient and future-proof (namespaced attrs, meta forms).

Current check only matches #[skip] exactly. If we ever pivot to namespaced forms like #[shank(skip)], this will miss it. Optional refinement below preserves current behavior and adds resilience.

Apply within this helper:

-fn field_has_skip_attr(field: &Field) -> bool {
-    field.attrs.iter().any(|attr| attr.path.is_ident("skip"))
-}
+fn field_has_skip_attr(field: &Field) -> bool {
+    use syn::{Meta, NestedMeta};
+    field.attrs.iter().any(|attr| {
+        // Fast path: #[skip]
+        if attr.path.is_ident("skip") {
+            return true;
+        }
+        // Optional: handle #[shank(skip)] and other meta forms gracefully
+        attr.parse_meta().ok().map_or(false, |meta| match meta {
+            Meta::Path(path) => path.is_ident("skip"),
+            Meta::List(list) => {
+                // e.g. #[shank(skip)]
+                list.nested.iter().any(|nm| match nm {
+                    NestedMeta::Meta(Meta::Path(p)) => p.is_ident("skip"),
+                    _ => false,
+                })
+            }
+            Meta::NameValue(nv) => nv.path.is_ident("skip"),
+        })
+    })
+}

Note: This keeps compatibility with syn 1.x APIs we’re already using.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// Helper function to check if a field has the skip attribute
fn field_has_skip_attr(field: &Field) -> bool {
field.attrs.iter().any(|attr| attr.path.is_ident("skip"))
}
/// Helper function to check if a field has the skip attribute
fn field_has_skip_attr(field: &Field) -> bool {
use syn::{Meta, NestedMeta};
field.attrs.iter().any(|attr| {
// Fast path: #[skip]
if attr.path.is_ident("skip") {
return true;
}
// Optional: handle #[shank(skip)] and other meta forms gracefully
attr.parse_meta().ok().map_or(false, |meta| match meta {
Meta::Path(path) => path.is_ident("skip"),
Meta::List(list) => {
// e.g. #[shank(skip)]
list.nested.iter().any(|nm| match nm {
NestedMeta::Meta(Meta::Path(p)) => p.is_ident("skip"),
_ => false,
})
}
Meta::NameValue(nv) => nv.path.is_ident("skip"),
})
})
}
🤖 Prompt for AI Agents
In shank-macro-impl/src/parsed_struct/parsed_struct.rs around lines 103 to 106,
the helper currently only matches bare #[skip] and will miss namespaced or
nested forms (e.g. #[shank(skip)] or other meta shapes); update the function to
iterate attrs and return true if any attr.path.is_ident("skip") OR if parsing
the attr.meta yields a Meta::List whose path is a namespace ident like "shank"
(or any namespace you expect) and whose nested items contain a Meta::Path with
ident "skip" (also consider Meta::Path at top level); implement this using
attr.parse_meta(), match on Meta::Path and Meta::List, and check
nested.Meta::Path idents for "skip" so both #[skip] and #[shank(skip)] (and
similar meta forms) are detected while keeping syn 1.x APIs.

Comment thread shank-macro/Cargo.toml
Comment on lines +17 to +18
shank_macro_impl = { version = "0.4.5", path = "../shank-macro-impl" }
shank_render = { version = "0.4.5", path = "../shank-render" }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Confirm semver: if a public API was removed in shank_macro_impl, a 0.5.0 bump may be required.

PR context mentions removing a public is_skipped API in shank_macro_impl. If that function (or any item) was truly public to downstream crates, a breaking change under 0.y.z requires bumping the y component (i.e., 0.5.0), not just a patch to 0.4.5. Please verify exposure and external usage; if public, consider bumping all affected crates accordingly.

Run the following to sanity-check exposure and references:

If this is indeed a breaking change, apply a coordinated 0.5.0 bump across the workspace.

- version = "0.4.5"
+ version = "0.5.0"
- shank_macro_impl = { version = "0.4.5", path = "../shank-macro-impl" }
- shank_render = { version = "0.4.5", path = "../shank-render" }
+ shank_macro_impl = { version = "0.5.0", path = "../shank-macro-impl" }
+ shank_render = { version = "0.5.0", path = "../shank-render" }

🏁 Script executed:

#!/bin/bash
# 1) Was `is_skipped` public and removed?
rg -nP -C2 'pub\s+fn\s+is_skipped\s*\(' shank-macro-impl -g '!**/target/**' || echo "No public is_skipped() found (current tree)."

# 2) Any crates in the repo referencing it?
rg -nP '\bis_skipped\s*\(' -g '!**/target/**'

# 3) Any 0.4.4 leftovers across manifests?
rg -nP 'version\s*=\s*"0\.4\.4"|{[^}]*version\s*=\s*"0\.4\.4"' -g '**/Cargo.toml' -n

Length of output: 311


Semver bump required due to removed public is_skipped API

We’ve confirmed that the pub fn is_skipped(...) symbol no longer exists in shank-macro-impl and there are no in-repo references to it, which indicates that this was indeed removed. Removing a previously public API is a breaking change under semver, so you must bump the minor version (0.y.z → 0.5.0) for all affected crates.

Please apply the following coordinated version updates:

  • In shank-macro/Cargo.toml (root of the workspace), bump dependencies:
    - shank_macro_impl = { version = "0.4.5", path = "../shank-macro-impl" }
    - shank_render     = { version = "0.4.5", path = "../shank-render" }
    + shank_macro_impl = { version = "0.5.0", path = "../shank-macro-impl" }
    + shank_render     = { version = "0.5.0", path = "../shank-render" }
  • In shank-macro-impl/Cargo.toml, update the package version field from 0.4.5 to 0.5.0.
  • In shank-render/Cargo.toml, update the package version field from 0.4.5 to 0.5.0.

This ensures downstream consumers see the correct minor-version bump for the breaking change.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
shank_macro_impl = { version = "0.4.5", path = "../shank-macro-impl" }
shank_render = { version = "0.4.5", path = "../shank-render" }
shank_macro_impl = { version = "0.5.0", path = "../shank-macro-impl" }
shank_render = { version = "0.5.0", path = "../shank-render" }
🤖 Prompt for AI Agents
In shank-macro/Cargo.toml around lines 17-18, the dependencies still reference
version 0.4.5 while shank-macro-impl removed a public API and requires a semver
minor bump; update the dependency entries here to use version "0.5.0" and then
also open shank-macro-impl/Cargo.toml and shank-render/Cargo.toml and change
their package version fields from "0.4.5" to "0.5.0" so all workspace crates
reflect the coordinated minor-version bump.

@blockiosaurus blockiosaurus merged commit 5e1caff into master Aug 21, 2025
6 checks passed
@blockiosaurus blockiosaurus deleted the fix/move-skip branch August 21, 2025 20:13
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