datafusion icon indicating copy to clipboard operation
datafusion copied to clipboard

cargo-fmt cannot format modules declared inside macros

Open jonahgao opened this issue 1 year ago • 0 comments

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: https://github.com/rust-lang/rustfmt/issues/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

jonahgao avatar Feb 20 '24 03:02 jonahgao