Skip to content

Commit 2755f1d

Browse files
committed
Stabilize lint_reasons in Clippy (RFC 2383)
1 parent 2852381 commit 2755f1d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+238
-273
lines changed

src/tools/clippy/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ Released 2022-05-19
183183
[#8218](https://github.com/rust-lang/rust-clippy/pull/8218)
184184
* [`needless_match`]
185185
[#8471](https://github.com/rust-lang/rust-clippy/pull/8471)
186-
* [`allow_attributes_without_reason`] (Requires `#![feature(lint_reasons)]`)
186+
* [`allow_attributes_without_reason`]
187187
[#8504](https://github.com/rust-lang/rust-clippy/pull/8504)
188188
* [`print_in_format_impl`]
189189
[#8253](https://github.com/rust-lang/rust-clippy/pull/8253)

src/tools/clippy/clippy_lints/src/attrs.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,22 +269,20 @@ declare_clippy_lint! {
269269
/// ### What it does
270270
/// Checks for attributes that allow lints without a reason.
271271
///
272-
/// (This requires the `lint_reasons` feature)
273-
///
274272
/// ### Why is this bad?
275273
/// Allowing a lint should always have a reason. This reason should be documented to
276274
/// ensure that others understand the reasoning
277275
///
278276
/// ### Example
279277
/// ```rust
280-
/// #![feature(lint_reasons)]
278+
/// # #![cfg_attr(bootstrap, feature(lint_reasons))]
281279
///
282280
/// #![allow(clippy::some_lint)]
283281
/// ```
284282
///
285283
/// Use instead:
286284
/// ```rust
287-
/// #![feature(lint_reasons)]
285+
/// # #![cfg_attr(bootstrap, feature(lint_reasons))]
288286
///
289287
/// #![allow(clippy::some_lint, reason = "False positive rust-lang/rust-clippy#1002020")]
290288
/// ```
@@ -450,11 +448,6 @@ fn check_clippy_lint_names(cx: &LateContext<'_>, name: Symbol, items: &[NestedMe
450448
}
451449

452450
fn check_lint_reason(cx: &LateContext<'_>, name: Symbol, items: &[NestedMetaItem], attr: &'_ Attribute) {
453-
// Check for the feature
454-
if !cx.tcx.sess.features_untracked().lint_reasons {
455-
return;
456-
}
457-
458451
// Check if the reason is present
459452
if let Some(item) = items.last().and_then(NestedMetaItem::meta_item)
460453
&& let MetaItemKind::NameValue(_) = &item.kind

src/tools/clippy/clippy_lints/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#![feature(iter_intersperse)]
77
#![cfg_attr(bootstrap, feature(let_chains))]
88
#![feature(let_else)]
9-
#![feature(lint_reasons)]
9+
#![cfg_attr(bootstrap, feature(lint_reasons))]
1010
#![feature(never_type)]
1111
#![feature(once_cell)]
1212
#![feature(rustc_private)]

src/tools/clippy/clippy_utils/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![feature(control_flow_enum)]
33
#![feature(let_else)]
44
#![cfg_attr(bootstrap, feature(let_chains))]
5-
#![feature(lint_reasons)]
5+
#![cfg_attr(bootstrap, feature(lint_reasons))]
66
#![feature(once_cell)]
77
#![feature(rustc_private)]
88
#![recursion_limit = "512"]

src/tools/clippy/tests/ui-cargo/duplicate_mod/fail/src/main.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(lint_reasons)]
2-
31
mod a;
42

53
mod b;

src/tools/clippy/tests/ui-cargo/duplicate_mod/fail/src/main.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: file is loaded as a module multiple times: `$DIR/b.rs`
2-
--> $DIR/main.rs:5:1
2+
--> $DIR/main.rs:3:1
33
|
44
LL | mod b;
55
| ^^^^^^ first loaded here
@@ -11,7 +11,7 @@ LL | | mod b2;
1111
= help: replace all but one `mod` item with `use` items
1212

1313
error: file is loaded as a module multiple times: `$DIR/c.rs`
14-
--> $DIR/main.rs:9:1
14+
--> $DIR/main.rs:7:1
1515
|
1616
LL | mod c;
1717
| ^^^^^^ first loaded here
@@ -25,7 +25,7 @@ LL | | mod c3;
2525
= help: replace all but one `mod` item with `use` items
2626

2727
error: file is loaded as a module multiple times: `$DIR/d.rs`
28-
--> $DIR/main.rs:18:1
28+
--> $DIR/main.rs:16:1
2929
|
3030
LL | mod d;
3131
| ^^^^^^ first loaded here
@@ -36,7 +36,7 @@ LL | | mod d2;
3636
= help: replace all but one `mod` item with `use` items
3737

3838
error: file is loaded as a module multiple times: `$DIR/from_other_module.rs`
39-
--> $DIR/main.rs:15:1
39+
--> $DIR/main.rs:13:1
4040
|
4141
LL | mod from_other_module;
4242
| ^^^^^^^^^^^^^^^^^^^^^^ first loaded here

src/tools/clippy/tests/ui/allow_attributes_without_reason.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(lint_reasons)]
21
#![deny(clippy::allow_attributes_without_reason)]
32

43
// These should trigger the lint

src/tools/clippy/tests/ui/allow_attributes_without_reason.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
error: `allow` attribute without specifying a reason
2-
--> $DIR/allow_attributes_without_reason.rs:5:1
2+
--> $DIR/allow_attributes_without_reason.rs:4:1
33
|
44
LL | #[allow(dead_code)]
55
| ^^^^^^^^^^^^^^^^^^^
66
|
77
note: the lint level is defined here
8-
--> $DIR/allow_attributes_without_reason.rs:2:9
8+
--> $DIR/allow_attributes_without_reason.rs:1:9
99
|
1010
LL | #![deny(clippy::allow_attributes_without_reason)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
= help: try adding a reason at the end with `, reason = ".."`
1313

1414
error: `allow` attribute without specifying a reason
15-
--> $DIR/allow_attributes_without_reason.rs:6:1
15+
--> $DIR/allow_attributes_without_reason.rs:5:1
1616
|
1717
LL | #[allow(dead_code, deprecated)]
1818
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

src/tools/clippy/tests/ui/async_yields_async.fixed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// run-rustfix
2-
#![feature(lint_reasons)]
32
#![feature(async_closure)]
43
#![warn(clippy::async_yields_async)]
54

src/tools/clippy/tests/ui/async_yields_async.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// run-rustfix
2-
#![feature(lint_reasons)]
32
#![feature(async_closure)]
43
#![warn(clippy::async_yields_async)]
54

0 commit comments

Comments
 (0)