File tree Expand file tree Collapse file tree 4 files changed +40
-14
lines changed Expand file tree Collapse file tree 4 files changed +40
-14
lines changed Original file line number Diff line number Diff line change @@ -511,18 +511,17 @@ impl EarlyLintPass for CfgAttrPass {
511
511
// check for `rustfmt_skip` and `rustfmt::skip`
512
512
if let Some ( skip_item) = & items[ 1 ] . meta_item( ) ;
513
513
if skip_item. name( ) == "rustfmt_skip" || skip_item. name( ) == "skip" ;
514
+ // Only lint outer attributes, because custom inner attributes are unstable
515
+ // Tracking issue: https://github.com/rust-lang/rust/issues/54726
516
+ if let AttrStyle :: Outer = attr. style;
514
517
then {
515
- let attr_style = match attr. style {
516
- AttrStyle :: Outer => "#[" ,
517
- AttrStyle :: Inner => "#![" ,
518
- } ;
519
518
span_lint_and_sugg(
520
519
cx,
521
520
DEPRECATED_CFG_ATTR ,
522
521
attr. span,
523
522
"`cfg_attr` is deprecated for rustfmt and got replaced by tool_attributes" ,
524
523
"use" ,
525
- format! ( "{} rustfmt::skip]", attr_style ) ,
524
+ "#[ rustfmt::skip]". to_string ( ) ,
526
525
Applicability :: MachineApplicable ,
527
526
) ;
528
527
}
Original file line number Diff line number Diff line change
1
+ // run-rustfix
2
+ #![feature(stmt_expr_attributes)]
3
+
4
+ #![allow(unused, clippy::no_effect)]
5
+ #![warn(clippy::deprecated_cfg_attr)]
6
+
7
+ // This doesn't get linted, see known problems
8
+ #![cfg_attr(rustfmt, rustfmt_skip)]
9
+
10
+ #[rustfmt::skip]
11
+ trait Foo
12
+ {
13
+ fn foo(
14
+ );
15
+ }
16
+
17
+ fn skip_on_statements() {
18
+ #[rustfmt::skip]
19
+ 5+3;
20
+ }
21
+
22
+ #[rustfmt::skip]
23
+ fn main() {
24
+ foo::f();
25
+ }
26
+
27
+ mod foo {
28
+ #![cfg_attr(rustfmt, rustfmt_skip)]
29
+
30
+ pub fn f() {}
31
+ }
Original file line number Diff line number Diff line change
1
+ // run-rustfix
1
2
#![ feature( stmt_expr_attributes) ]
2
3
4
+ #![ allow( unused, clippy:: no_effect) ]
3
5
#![ warn( clippy:: deprecated_cfg_attr) ]
4
6
5
7
// This doesn't get linted, see known problems
Original file line number Diff line number Diff line change 1
1
error: `cfg_attr` is deprecated for rustfmt and got replaced by tool_attributes
2
- --> $DIR/cfg_attr_rustfmt.rs:16 :5
2
+ --> $DIR/cfg_attr_rustfmt.rs:18 :5
3
3
|
4
4
LL | #[cfg_attr(rustfmt, rustfmt::skip)]
5
5
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]`
6
6
|
7
7
= note: `-D clippy::deprecated-cfg-attr` implied by `-D warnings`
8
8
9
9
error: `cfg_attr` is deprecated for rustfmt and got replaced by tool_attributes
10
- --> $DIR/cfg_attr_rustfmt.rs:20 :1
10
+ --> $DIR/cfg_attr_rustfmt.rs:22 :1
11
11
|
12
12
LL | #[cfg_attr(rustfmt, rustfmt_skip)]
13
13
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]`
14
14
15
- error: `cfg_attr` is deprecated for rustfmt and got replaced by tool_attributes
16
- --> $DIR/cfg_attr_rustfmt.rs:26:5
17
- |
18
- LL | #![cfg_attr(rustfmt, rustfmt_skip)]
19
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#![rustfmt::skip]`
20
-
21
- error: aborting due to 3 previous errors
15
+ error: aborting due to 2 previous errors
22
16
You can’t perform that action at this time.
0 commit comments