Disable deprecated_cfg_attr lint for inner attributes
This commit is contained in:
parent
c0083e2b98
commit
ea7eb49b47
@ -511,18 +511,17 @@ impl EarlyLintPass for CfgAttrPass {
|
||||
// check for `rustfmt_skip` and `rustfmt::skip`
|
||||
if let Some(skip_item) = &items[1].meta_item();
|
||||
if skip_item.name() == "rustfmt_skip" || skip_item.name() == "skip";
|
||||
// Only lint outer attributes, because custom inner attributes are unstable
|
||||
// Tracking issue: https://github.com/rust-lang/rust/issues/54726
|
||||
if let AttrStyle::Outer = attr.style;
|
||||
then {
|
||||
let attr_style = match attr.style {
|
||||
AttrStyle::Outer => "#[",
|
||||
AttrStyle::Inner => "#![",
|
||||
};
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
DEPRECATED_CFG_ATTR,
|
||||
attr.span,
|
||||
"`cfg_attr` is deprecated for rustfmt and got replaced by tool_attributes",
|
||||
"use",
|
||||
format!("{}rustfmt::skip]", attr_style),
|
||||
"#[rustfmt::skip]".to_string(),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
|
31
tests/ui/cfg_attr_rustfmt.fixed
Normal file
31
tests/ui/cfg_attr_rustfmt.fixed
Normal file
@ -0,0 +1,31 @@
|
||||
// run-rustfix
|
||||
#![feature(stmt_expr_attributes)]
|
||||
|
||||
#![allow(unused, clippy::no_effect)]
|
||||
#![warn(clippy::deprecated_cfg_attr)]
|
||||
|
||||
// This doesn't get linted, see known problems
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
|
||||
#[rustfmt::skip]
|
||||
trait Foo
|
||||
{
|
||||
fn foo(
|
||||
);
|
||||
}
|
||||
|
||||
fn skip_on_statements() {
|
||||
#[rustfmt::skip]
|
||||
5+3;
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
fn main() {
|
||||
foo::f();
|
||||
}
|
||||
|
||||
mod foo {
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
|
||||
pub fn f() {}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
// run-rustfix
|
||||
#![feature(stmt_expr_attributes)]
|
||||
|
||||
#![allow(unused, clippy::no_effect)]
|
||||
#![warn(clippy::deprecated_cfg_attr)]
|
||||
|
||||
// This doesn't get linted, see known problems
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: `cfg_attr` is deprecated for rustfmt and got replaced by tool_attributes
|
||||
--> $DIR/cfg_attr_rustfmt.rs:16:5
|
||||
--> $DIR/cfg_attr_rustfmt.rs:18:5
|
||||
|
|
||||
LL | #[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]`
|
||||
@ -7,16 +7,10 @@ LL | #[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
= note: `-D clippy::deprecated-cfg-attr` implied by `-D warnings`
|
||||
|
||||
error: `cfg_attr` is deprecated for rustfmt and got replaced by tool_attributes
|
||||
--> $DIR/cfg_attr_rustfmt.rs:20:1
|
||||
--> $DIR/cfg_attr_rustfmt.rs:22:1
|
||||
|
|
||||
LL | #[cfg_attr(rustfmt, rustfmt_skip)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#[rustfmt::skip]`
|
||||
|
||||
error: `cfg_attr` is deprecated for rustfmt and got replaced by tool_attributes
|
||||
--> $DIR/cfg_attr_rustfmt.rs:26:5
|
||||
|
|
||||
LL | #![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use: `#![rustfmt::skip]`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user