Don't lint rustfmt deprecated_cfg_attr on expr
@profetia is already working on this.
Since Apr 14, 2025.
Assessment
This issue has not been assessed yet.
Description
Summary
If repairing with lint help, an error will be triggered
error[E0658]: attributes on expressions are experimental
--> src/main.rs:3:9
|
3 | #[rustfmt::skip]
| ^^^^^^^^^^^^^^^^
|
= note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information
= help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
= note: this compiler was built on 2025-04-01; consider upgrading it if it is out of date
For more information about this error, try `rustc --explain E0658`.
Lint Name
deprecated_cfg_attr
Reproducer
I tried this code:
fn main() {
let _n = {
#[cfg_attr(rustfmt, rustfmt::skip)]
(
1
)
};
}
I saw this happen:
warning: `cfg_attr` is deprecated for rustfmt and got replaced by tool attributes
--> src/main.rs:3:9
|
3 | #[cfg_attr(rustfmt, rustfmt::skip)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#deprecated_cfg_attr
= note: `#[warn(clippy::deprecated_cfg_attr)]` on by default
I expected to see this happen:
no warnings
Version
rustc 1.88.0-nightly (e2014e876 2025-04-01)
binary: rustc
commit-hash: e2014e876e3efaa69bf51c19579adb16c3df5f81
commit-date: 2025-04-01
host: aarch64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.1
Additional Labels
No response
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rust-lang/rust-clippy
-
C-bug L-suggestion
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
rust-lang/rust-clippy#17674 · 5 comments ·
-
C-bug L-suggestion
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
rust-lang/rust-clippy#17673 · 3 comments ·
-
C-bug I-false-positive
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
rust-lang/rust-clippy#17566 ·
-
A-documentation
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
rust-lang/rust-clippy#17259 · 3 comments ·
-
A-documentation A-website C-bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
rust-lang/rust-clippy#16981 · 1 reaction ·
All issues in rust-lang/rust-clippy
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100