fix(formatter): stop adding trailing separators in macro call token trees - #10354
Conversation
PR SummaryLow Risk Overview Implementation: Tests: New Reviewed by Cursor Bugbot for commit 796d776. Bugbot is set up for automated code reviews on this repo. Configure here. |
251de2e to
c8a4835
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c8a4835. Configure here.
orizi
left a comment
There was a problem hiding this comment.
@orizi+AGNT made 1 comment and resolved 1 discussion.
Reviewable status: 0 of 32 files reviewed, all discussions resolved (waiting on eytan-starkware).
eytan-starkware
left a comment
There was a problem hiding this comment.
@eytan-starkware reviewed 32 files and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on orizi).
corelib/src/test/language_features/const_test.cairo line 385 at r2 (raw file):
(starknet::ContractAddress, starknet::ClassHash), value::Const<starknet::ContractAddress, 1000>, value::Const<starknet::ClassHash, 1001>,
Why did this one disappear?
crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_component_diagnostics line 1455 at r2 (raw file):
use starknet::storage::Map as LegacyMap; #[cfg(target: 'test')] pub const TEST_CLASS_HASH: starknet::ClassHash = 0x215c44bbf0e7c3b987e93bf1597778322461e87fd0059894735b0464ce94aff.try_into().unwrap();
Why did this change?
orizi
left a comment
There was a problem hiding this comment.
@orizi+AGNT made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on eytan-starkware).
corelib/src/test/language_features/const_test.cairo line 385 at r2 (raw file):
Previously, eytan-starkware wrote…
Why did this one disappear?
It is this PR's change applied repo-wide: assert! is a macro call, so its arguments are a macro token tree, and the formatter no longer introduces a trailing comma when breaking one across lines. All the disappearing commas in this file (19 of them) are that - previously the formatter added them on the break; they were never written by hand. For assert! the comma was harmless, but the formatter cannot tell a plugin macro from a user-defined one, where the matcher sees the extra token.
crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_component_diagnostics line 1455 at r2 (raw file):
Previously, eytan-starkware wrote…
Why did this change?
Downstream of the same reformat: the component! call in this test's contract lost its formatter-added trailing comma, so the contract's source text changed - and TEST_CLASS_HASH is computed from that source, so re-blessing updated the hash (and the diagnostic snippet quoting the call).
eytan-starkware
left a comment
There was a problem hiding this comment.
@eytan-starkware made 1 comment and resolved 1 discussion.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on orizi+AGNT).
corelib/src/test/language_features/const_test.cairo line 385 at r2 (raw file):
Previously, orizi+AGNT (Agent AGNT for orizi) wrote…
It is this PR's change applied repo-wide:
assert!is a macro call, so its arguments are a macro token tree, and the formatter no longer introduces a trailing comma when breaking one across lines. All the disappearing commas in this file (19 of them) are that - previously the formatter added them on the break; they were never written by hand. Forassert!the comma was harmless, but the formatter cannot tell a plugin macro from a user-defined one, where the matcher sees the extra token.
But the comma I am talking about is in the generic arguments of const
c8a4835 to
b90a8cd
Compare
orizi
left a comment
There was a problem hiding this comment.
@orizi+AGNT made 3 comments.
Reviewable status: 1 of 32 files reviewed, 1 unresolved discussion (waiting on eytan-starkware).
corelib/src/test/language_features/const_test.cairo line 385 at r2 (raw file):
Previously, eytan-starkware wrote…
But the comma I am talking about is in the generic arguments of const
Update: the PR was reworked and this diff is gone. Ori's point stands - a comma the author wrote is just as matcher-visible as one the formatter would add - so the formatter now keeps a macro token tree's trailing separator exactly as written: never added, never removed. With that, the repo-wide reformat (including this file) vanished; the PR is down to the formatter change and its tests.
crates/cairo-lang-starknet/src/plugin/plugin_test_data/contracts/with_component_diagnostics line 1455 at r2 (raw file):
Previously, orizi+AGNT (Agent AGNT for orizi) wrote…
Downstream of the same reformat: the
component!call in this test's contract lost its formatter-added trailing comma, so the contract's source text changed - andTEST_CLASS_HASHis computed from that source, so re-blessing updated the hash (and the diagnostic snippet quoting the call).
Update: gone after the rework - the formatter now preserves the separator as written instead of normalizing it, so this golden (and its class hash) reverted to main.
eytan-starkware
left a comment
There was a problem hiding this comment.
@eytan-starkware reviewed 31 files and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on orizi).
crates/cairo-lang-formatter/src/formatter_impl.rs line 937 at r3 (raw file):
/// Whether the node being formatted came from a macro call's token tree. A trailing /// separator is meaningful to a user-defined macro's matcher - the rules decide whether to /// accept it - so the formatter keeps it exactly as written: one is neither introduced when
prosy
…ritten A trailing separator is meaningful to a user-defined macro's matcher - the rules decide whether to accept it - so the formatter neither introduces one when breaking the call across lines nor removes one the author wrote.
b90a8cd to
796d776
Compare
orizi
left a comment
There was a problem hiding this comment.
@orizi+AGNT made 1 comment.
Reviewable status: 31 of 32 files reviewed, 1 unresolved discussion (waiting on eytan-starkware).
crates/cairo-lang-formatter/src/formatter_impl.rs line 937 at r3 (raw file):
Previously, eytan-starkware wrote…
prosy
Tightened to two lines.
eytan-starkware
left a comment
There was a problem hiding this comment.
@eytan-starkware reviewed 1 file and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on orizi).


A trailing separator is meaningful to a user-defined macro's matcher -
the rules decide whether to accept it - so breaking a long macro call
across lines must not introduce one. Legacy plugin macros tolerate
either form, so the suppression applies to every token tree the
formatter routes through the arg-list rules.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com