Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cargo-fmt cannot format modules declared inside macros #9281

Closed
jonahgao opened this issue Feb 20, 2024 · 1 comment · Fixed by #9390
Closed

cargo-fmt cannot format modules declared inside macros #9281

jonahgao opened this issue Feb 20, 2024 · 1 comment · Fixed by #9390
Assignees
Labels
bug Something isn't working

Comments

@jonahgao
Copy link
Member

jonahgao commented Feb 20, 2024

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

@alamb
Copy link
Contributor

alamb commented Feb 27, 2024

here is a proposed fix: #9367

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants