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

Incorrectly adds space in macro parameters #6297

Open
k-bx opened this issue Aug 29, 2024 · 3 comments
Open

Incorrectly adds space in macro parameters #6297

k-bx opened this issue Aug 29, 2024 · 3 comments
Labels

Comments

@k-bx
Copy link

k-bx commented Aug 29, 2024

I'm using rust_cmd_lib to do some command execution, and on this simple command:

    let id = run_fun!(id -u).context(h!())?;

rustfmt formats it to:

    let id = run_fun!(id - u).context(h!())?;

Which is definitely not what I want.

@ytmimi
Copy link
Contributor

ytmimi commented Aug 29, 2024

Macro formatting is tough. It might be the case that id -u is getting parsed as a binary expression, and that's why it's getting formatted as id - u.

If you're using nightly rustfmt you can use the skip_macro_invocations config to disable formatting on the run_fun! macro calls.

@k-bx
Copy link
Author

k-bx commented Aug 29, 2024

Apologies for a newbie question. But can I disable rustfmt on per-module or per-function level somehow? It would solve most of the problems. Could not find solution via search.

@ytmimi
Copy link
Contributor

ytmimi commented Aug 29, 2024

You could probably add #![rustfmt::skip] to the files you want rustfmt to ignore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants