Skip to content

fix(fmt): tune rustfmt rules for ink! macros - #852

Open
Tenny150 wants to merge 1 commit into
MettaChain:mainfrom
Tenny150:fix/783-rustfmt-ink-macros
Open

fix(fmt): tune rustfmt rules for ink! macros#852
Tenny150 wants to merge 1 commit into
MettaChain:mainfrom
Tenny150:fix/783-rustfmt-ink-macros

Conversation

@Tenny150

Copy link
Copy Markdown
Contributor

Summary

Fixes #783

#[ink::contract], #[ink::test] and propchain_traits::non_reentrant! macros were not being formatted according to project standards because the stable rustfmt does not support the format_macro_matchers option.

Changes

rust-toolchain.toml (new)

Pins the project to the nightly toolchain with explicit rustfmt and clippy components, ensuring every contributor and CI run uses the same formatter version that supports nightly-only options.

rustfmt.toml (new)

Option Value Reason
format_macro_matchers true Formats ink! attribute macros (#[ink::contract], #[ink::test], non_reentrant!)
format_macro_bodies true Formats macro_rules! definition bodies
edition "2021" Matches workspace edition
max_width 100 Accommodates verbose ink! contract bodies
imports_granularity "Crate" Consistent import grouping
group_imports "StdExternalCrate" std / external / crate ordering
fn_args_layout "Tall" Wraps overflowing function arguments
format_strings true Formats string literals
reorder_impl_items true Consistent impl block ordering

.github/workflows/smoke-ci.yml (updated)

  • Adds a dedicated step to install the nightly rustfmt component.
  • Replaces cargo fmt --check with cargo +nightly fmt --check.
  • The stable toolchain step is kept (and now only pulls clippy) for linting and testing.

Acceptance Criteria (from issue)

  • cargo +nightly fmt runs cleanly with macro formatting enabled
  • CI step uses nightly fmt (cargo +nightly fmt --check in smoke-ci.yml)

- Add rust-toolchain.toml pinning nightly channel with rustfmt and
  clippy components so every contributor uses the same formatter.
- Add rustfmt.toml with format_macro_matchers = true (nightly-only)
  so #[ink::contract], #[ink::test] and non_reentrant! macro calls
  are fully formatted.  Also sets format_macro_bodies, edition 2021,
  max_width 100 and a handful of import-ordering options.
- Update smoke-ci.yml: install nightly rustfmt in a dedicated step
  and run 'cargo +nightly fmt --check' instead of stable fmt.
  Stable toolchain is still used for clippy and tests.

Closes MettaChain#783
@drips-wave

drips-wave Bot commented Jul 28, 2026

Copy link
Copy Markdown

@Tenny150 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Tune rustfmt rules for ink! macros

1 participant