Skip to content

#[cfg_attr(rustfmt, rustfmt::skip::macros(...))] does not work #4156

New issue

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

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

Already on GitHub? # to your account

Closed
tmandry opened this issue May 2, 2020 · 2 comments
Closed

#[cfg_attr(rustfmt, rustfmt::skip::macros(...))] does not work #4156

tmandry opened this issue May 2, 2020 · 2 comments

Comments

@tmandry
Copy link
Member

tmandry commented May 2, 2020

Using #[rustfmt::skip::macros(gen)] successfully skips formatting in the following example. So does #[cfg_attr(rustfmt, rustfmt::skip)]. But combining these into #[cfg_attr(rustfmt, rustfmt::skip::macros(gen))] fails.

This also applies for #! attribute declarations. I want to use cfg_attr to avoid "unused attribute" lints on these.

Playground

fn example() {
    gen!(f, "
        trait $trait_name {
            fn $func_name(self, $args_sig);
        }
    ")?;
}
@jhpratt
Copy link
Member

jhpratt commented May 3, 2020

#![doc(test(attr(rustfmt::skip::macros(date))))] doesn't work either, presumably for similar reasons.

@topecongiro
Copy link
Contributor

#[cfg_attr(rustfmt, ...)] is deprecated, you should use #[rustfmt::...] instead.

I want to use cfg_attr to avoid "unused attribute" lints on these.

This seems like a compiler or a linter error to me. IIUC, the tool attribute has already been supported, and any attributes starting with rustfmt should trigger warnings or lints (cc rust-lang/rust#44690).

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

4 participants