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

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: an async construct yields a type which is itself awaitable
2-
--> $DIR/async_yields_async.rs:39:9
2+
--> $DIR/async_yields_async.rs:38:9
33
|
44
LL | let _h = async {
55
| ____________________-
@@ -20,7 +20,7 @@ LL + }.await
2020
|
2121

2222
error: an async construct yields a type which is itself awaitable
23-
--> $DIR/async_yields_async.rs:44:9
23+
--> $DIR/async_yields_async.rs:43:9
2424
|
2525
LL | let _i = async {
2626
| ____________________-
@@ -33,7 +33,7 @@ LL | | };
3333
| |_____- outer async construct
3434

3535
error: an async construct yields a type which is itself awaitable
36-
--> $DIR/async_yields_async.rs:50:9
36+
--> $DIR/async_yields_async.rs:49:9
3737
|
3838
LL | let _j = async || {
3939
| _______________________-
@@ -53,7 +53,7 @@ LL + }.await
5353
|
5454

5555
error: an async construct yields a type which is itself awaitable
56-
--> $DIR/async_yields_async.rs:55:9
56+
--> $DIR/async_yields_async.rs:54:9
5757
|
5858
LL | let _k = async || {
5959
| _______________________-
@@ -66,7 +66,7 @@ LL | | };
6666
| |_____- outer async construct
6767

6868
error: an async construct yields a type which is itself awaitable
69-
--> $DIR/async_yields_async.rs:57:23
69+
--> $DIR/async_yields_async.rs:56:23
7070
|
7171
LL | let _l = async || CustomFutureType;
7272
| ^^^^^^^^^^^^^^^^
@@ -76,7 +76,7 @@ LL | let _l = async || CustomFutureType;
7676
| help: consider awaiting this value: `CustomFutureType.await`
7777

7878
error: an async construct yields a type which is itself awaitable
79-
--> $DIR/async_yields_async.rs:63:9
79+
--> $DIR/async_yields_async.rs:62:9
8080
|
8181
LL | let _m = async || {
8282
| _______________________-

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(box_syntax)]
2-
#![feature(lint_reasons)]
32
#![allow(
43
clippy::borrowed_box,
54
clippy::needless_pass_by_value,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
error: local variable doesn't need to be boxed here
2-
--> $DIR/boxed_local.rs:41:13
2+
--> $DIR/boxed_local.rs:40:13
33
|
44
LL | fn warn_arg(x: Box<A>) {
55
| ^
66
|
77
= note: `-D clippy::boxed-local` implied by `-D warnings`
88

99
error: local variable doesn't need to be boxed here
10-
--> $DIR/boxed_local.rs:132:12
10+
--> $DIR/boxed_local.rs:131:12
1111
|
1212
LL | pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {}
1313
| ^^^^^^^^^^^
1414

1515
error: local variable doesn't need to be boxed here
16-
--> $DIR/boxed_local.rs:196:44
16+
--> $DIR/boxed_local.rs:195:44
1717
|
1818
LL | fn default_impl_x(self: Box<Self>, x: Box<u32>) -> u32 {
1919
| ^
2020

2121
error: local variable doesn't need to be boxed here
22-
--> $DIR/boxed_local.rs:203:16
22+
--> $DIR/boxed_local.rs:202:16
2323
|
2424
LL | fn foo(x: Box<u32>) {}
2525
| ^

src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.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::panicking_unwrap, clippy::unnecessary_unwrap)]
32
#![allow(clippy::if_same_then_else, clippy::branches_sharing_code)]
43

0 commit comments

Comments
 (0)