Skip to content

Clippy suggests an unstable attribute instead of a deprecated one for #[cfg_attr(rustfmt, rustfmt_skip)] #88591

Open
@stephanemagnenat

Description

@stephanemagnenat

I'm disabling rustfmt for some lines of my code because I have functions with multiple arguments and for the sake of exposing the logical reasoning of the algorithm, I want to group them on multiple lines. Therefore, I am using:

#[cfg_attr(rustfmt, rustfmt_skip)]
...

Running cargo clippy tells me:

`cfg_attr` is deprecated for rustfmt and got replaced by tool attributes
...
help: use: `#[rustfmt::skip]`

However, if I replace these with #[rustfmt::skip], I'm getting the following error:

error[E0658]: attributes on expressions are experimental
...
note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information

I assume it is a bug for a tool in stable Rust to suggest to use an experimental code to replace valid (although deprecated) code.

Meta

rustc --version --verbose:

rustc 1.53.0 (53cb7b09b 2021-06-17)
binary: rustc
commit-hash: 53cb7b09b00cbea8754ffb78e7e3cb521cb8af4b
commit-date: 2021-06-17
host: x86_64-unknown-linux-gnu
release: 1.53.0
LLVM version: 12.0.1

Activity

changed the title [-]Clippy proposes an unstable attribute instead of a deprecated one for #[cfg_attr(rustfmt, rustfmt_skip)][/-] [+]Clippy suggests an unstable attribute instead of a deprecated one for #[cfg_attr(rustfmt, rustfmt_skip)][/+] on Sep 2, 2021
ibraheemdev

ibraheemdev commented on Sep 2, 2021

@ibraheemdev
Member

The attribute is not unstable, attributes are just not supported on expressions. You can put #[rustfmt::skip] on the outer function. I don't think this is a bug.

stephanemagnenat

stephanemagnenat commented on Sep 3, 2021

@stephanemagnenat
Author

I see, but #[cfg_attr(rustfmt, rustfmt_skip)] does work on expressions. So in that sense, it is a regression (shrinking) of the feature-set, isn't it?

added
A-attributesArea: Attributes (`#[…]`, `#![…]`)
S-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.
S-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.
and removed on Jan 25, 2024
fmease

fmease commented on Jan 25, 2024

@fmease
Member

In the future, please report Clippy-specific issues over at https://github.com/rust-lang/rust-clippy.

fmease

fmease commented on Jan 25, 2024

@fmease
Member

Could you provide a concrete reproducer? The ...s from the issue description are way too vague.

For example, let _ = #[cfg_attr(…)] 0; isn't a reproducer since it leads to an error and #[cfg_attr(...)] 0; (on a statement expression) isn't one either because it compiles with cfg_attr and with rustfmt::skip.

stephanemagnenat

stephanemagnenat commented on Jan 25, 2024

@stephanemagnenat
Author

Sorry for reporting to the wrong place.

This issue can be reproduced by commenting the line 44 of this file (after cloning the repository and before running clippy on it).

added
S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example
and removed
S-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.
S-needs-reproStatus: This issue has no reproduction and needs a reproduction to make progress.
S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issue
on Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)A-clippyArea: ClippyC-bugCategory: This is a bug.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @stephanemagnenat@ChrisDenton@fmease@ibraheemdev

        Issue actions

          Clippy suggests an unstable attribute instead of a deprecated one for #[cfg_attr(rustfmt, rustfmt_skip)] · Issue #88591 · rust-lang/rust