Skip to content

cargo-fmt cannot format modules declared inside macros #9281

Closed
@jonahgao

Description

@jonahgao

Describe the bug

Found in #9271 and occurred in the 'datafusion-functions' package.

cargo-fmt starts at the crate root and traverses submodules to find files, but it does not parse modules declared inside macros, thus files within these modules will not be processed. Additionally, only certain macros are exceptions, such as cfg_if.

We are using the make_package macro in the functions package to define modules.
https://github.com/apache/arrow-datafusion/blob/cf92f3b01ff064308c5e7ca2e15c20770d48a88a/datafusion/functions/src/macros.rs#L102-L107

Upstream issue: rust-lang/rustfmt#3253

To Reproduce

Run the shell commands under the repo directory.

rustfmt datafusion/functions/src/*/*.rs
git status

And here is also a minimal repo to reproduce it.

Expected behavior

All rust files should be formatted.

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions