Sitelet https://github.com/starkware-libs/cairo/pull/10220
Skip to content

bugfix(formatter): Made cairofmt::skip work properly for additional items. - #10220

Merged
orizi merged 1 commit into
mainfrom
orizi/07-20-bugfix_formatter_made_cairofmt_skip_work_properly_for_additional_items
Jul 20, 2026
Merged

orizi merged 1 commit into
mainfrom
orizi/07-20-bugfix_formatter_made_cairofmt_skip_work_properly_for_additional_items

Conversation

@orizi

@orizi orizi commented Jul 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Extends #[cairofmt::skip] support to TraitItemType, TraitItemConstant, TraitItemImpl, and ItemMacroDeclaration nodes. Previously, applying #[cairofmt::skip] to trait associated types, constants, or impls, as well as macro declarations, had no effect because these syntax kinds were not handled in QueryAttrs. The attribute lookup now returns their attributes correctly, allowing the formatter to respect the skip directive.


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

Why is this change needed?

#[cairofmt::skip] was silently ignored when placed on trait associated types (type Bar), trait associated constants (const FOO: i32), trait associated impls (impl Baz: MyTrait), and macro declarations (macro my_macro { ... }). This was because the QueryAttrs implementation for SyntaxNode did not include match arms for these syntax kinds, so their attributes were never surfaced to the formatter.


What was the behavior or documentation before?

Applying #[cairofmt::skip] to trait item types, constants, impls, or macro declarations had no effect — the formatter would reformat those items regardless of the attribute.


What is the behavior or documentation after?

#[cairofmt::skip] is now respected for TraitItemType, TraitItemConstant, TraitItemImpl, and ItemMacroDeclaration, preserving their original formatting as written.


Related issue or discussion (if any)

N/A


Additional context

Test cases covering all four newly supported node kinds have been added to fmt_skip.cairo and its corresponding expected output file.

@reviewable-StarkWare

Copy link
Copy Markdown

This change is Reviewable

orizi commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@orizi
orizi marked this pull request as ready for review July 20, 2026 07:49
@cursor

cursor Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Small, localized syntax-helper change plus formatter tests; no runtime or security impact.

Overview
#[cairofmt::skip] was ignored on trait associated const, type, and impl items and on macro declarations because QueryAttrs for SyntaxNode did not map those syntax kinds to their attribute lists.

This change adds TraitItemType, TraitItemConstant, TraitItemImpl, and ItemMacroDeclaration to that dispatch so the formatter can see the skip attribute and leave spacing as written. Formatter tests in fmt_skip.cairo cover all four cases.

Reviewed by Cursor Bugbot for commit 497f16a. Bugbot is set up for automated code reviews on this repo. Configure here.

@eytan-starkware eytan-starkware 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.

:lgtm:

@eytan-starkware reviewed 3 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on TomerStarkware).

@orizi
orizi added this pull request to the merge queue Jul 20, 2026
Merged via the queue into main with commit 7d5341b Jul 20, 2026
55 checks passed
@orizi
orizi deleted the orizi/07-20-bugfix_formatter_made_cairofmt_skip_work_properly_for_additional_items branch July 20, 2026 10:58
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.

3 participants