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

Rustfmt breaks macros due to changes #4631

Closed
alexkazik opened this issue Jan 7, 2021 · 5 comments
Closed

Rustfmt breaks macros due to changes #4631

alexkazik opened this issue Jan 7, 2021 · 5 comments
Labels
a-macros bug Panic, non-idempotency, invalid code, etc. duplicate

Comments

@alexkazik
Copy link

Describe the bug

The contents of macros are changed.

Input:

test_macro!(pub fn test_fn(); "foobar");

Output:

test_macro!(fn test_fn();, "foobar");

Expected behavior

Unchanged, or "formatted" but not keywords/symbols removed/added.

Meta

  • rustfmt version: rustfmt 1.4.30-nightly (acd9486 2020-12-20)
  • From where did you install rustfmt?: rustup
  • How do you run rustfmt: cargo fmt --all
@alexkazik alexkazik added the bug Panic, non-idempotency, invalid code, etc. label Jan 7, 2021
@Ekleog
Copy link

Ekleog commented Jan 8, 2021

I have just hit a similar issue with rustfmt 1.4.29-nightly (70ce182 2020-12-04) (installed from the nixpkgs-mozilla overlay, that grabs from the rustup repository):

fn main() {
    quote!(type Foo: Bar;);
}

becomes

fn main() {
    quote!(
        type Foo: Bar = impl Bar;
    );
}

(where the result is not even valid stable rust code)

@zyctree
Copy link

zyctree commented Jan 15, 2021

the same,

could use {} like test_macro! { pub fn test_fn(); "foobar" }; to avoid this change

@alexkazik
Copy link
Author

Thanks for the tip with {}.

@JakkuSakura
Copy link

JakkuSakura commented Jul 2, 2021

debug!(meta ?= meta, "Ready to subscribe"); is being formatted as debug!(meta? = meta, "Ready to subscribe"); and thus breaking tracing-log
forward!(S<>) is formatted as forward!(S), breaking my macro.

@ytmimi
Copy link
Contributor

ytmimi commented Jul 26, 2022

closing this as a duplicate of #4375

@ytmimi ytmimi closed this as not planned Won't fix, can't repro, duplicate, stale Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-macros bug Panic, non-idempotency, invalid code, etc. duplicate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants