Skip to content

Commit e0d31a8

Browse files
committed
Stabilize lint_reasons in rustc (RFC 2383)
1 parent ed91732 commit e0d31a8

File tree

52 files changed

+96
-202
lines changed

Some content is hidden

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

52 files changed

+96
-202
lines changed

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ declare_features! (
188188
(accepted, item_like_imports, "1.15.0", Some(35120), None),
189189
/// Allows `if/while p && let q = r && ...` chains.
190190
(accepted, let_chains, "1.64.0", Some(53667), None),
191+
/// Allows using `reason` in lint attributes and the `#[expect(lint)]` lint check.
192+
(accepted, lint_reasons, "1.64.0", Some(54503), None),
191193
/// Allows `break {expr}` with a value inside `loop`s.
192194
(accepted, loop_break_value, "1.19.0", Some(37339), None),
193195
/// Allows use of `?` as the Kleene "at most one" operator in macros.

compiler/rustc_feature/src/active.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,6 @@ declare_features! (
428428
(active, let_else, "1.56.0", Some(87335), None),
429429
/// Allows `#[link(..., cfg(..))]`.
430430
(active, link_cfg, "1.14.0", Some(37406), None),
431-
/// Allows using `reason` in lint attributes and the `#[expect(lint)]` lint check.
432-
(active, lint_reasons, "1.31.0", Some(54503), None),
433431
/// Give access to additional metadata about declarative macro meta-variables.
434432
(active, macro_metavar_expr, "1.61.0", Some(83527), None),
435433
/// Allows `#[marker]` on certain traits allowing overlapping implementations.

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,8 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
301301
ungated!(
302302
allow, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#), DuplicatesOk
303303
),
304-
gated!(
305-
expect, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#), DuplicatesOk,
306-
lint_reasons, experimental!(expect)
304+
ungated!(
305+
expect, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#), DuplicatesOk
307306
),
308307
ungated!(
309308
forbid, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#), DuplicatesOk

compiler/rustc_lint/src/expect.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,13 @@ use rustc_hir::HirId;
44
use rustc_middle::ty::query::Providers;
55
use rustc_middle::{lint::LintExpectation, ty::TyCtxt};
66
use rustc_session::lint::LintExpectationId;
7-
use rustc_span::symbol::sym;
87
use rustc_span::Symbol;
98

109
pub(crate) fn provide(providers: &mut Providers) {
1110
*providers = Providers { check_expectations, ..*providers };
1211
}
1312

1413
fn check_expectations(tcx: TyCtxt<'_>, tool_filter: Option<Symbol>) {
15-
if !tcx.sess.features_untracked().enabled(sym::lint_reasons) {
16-
return;
17-
}
18-
1914
let fulfilled_expectations = tcx.sess.diagnostic().steal_fulfilled_expectation_ids();
2015
let lint_expectations = &tcx.lint_levels(()).lint_expectations;
2116

compiler/rustc_lint/src/levels.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_session::lint::{
1717
builtin::{self, FORBIDDEN_LINT_GROUPS, SINGLE_USE_LIFETIMES, UNFULFILLED_LINT_EXPECTATIONS},
1818
Level, Lint, LintExpectationId, LintId,
1919
};
20-
use rustc_session::parse::{add_feature_diagnostics, feature_err};
20+
use rustc_session::parse::add_feature_diagnostics;
2121
use rustc_session::Session;
2222
use rustc_span::symbol::{sym, Symbol};
2323
use rustc_span::{Span, DUMMY_SP};
@@ -306,15 +306,6 @@ impl<'s> LintLevelsBuilder<'s> {
306306
ast::MetaItemKind::NameValue(ref name_value) => {
307307
if item.path == sym::reason {
308308
if let ast::LitKind::Str(rationale, _) = name_value.kind {
309-
if !self.sess.features_untracked().lint_reasons {
310-
feature_err(
311-
&self.sess.parse_sess,
312-
sym::lint_reasons,
313-
item.span,
314-
"lint reasons are experimental",
315-
)
316-
.emit();
317-
}
318309
reason = Some(rationale);
319310
} else {
320311
bad_attr(name_value.span)

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,6 @@ declare_lint! {
503503
/// ### Example
504504
///
505505
/// ```rust
506-
/// #![feature(lint_reasons)]
507-
///
508506
/// #[expect(unused_variables)]
509507
/// let x = 10;
510508
/// println!("{}", x);
@@ -530,8 +528,7 @@ declare_lint! {
530528
/// [#54503]: https://github.com/rust-lang/rust/issues/54503
531529
pub UNFULFILLED_LINT_EXPECTATIONS,
532530
Warn,
533-
"unfulfilled lint expectation",
534-
@feature_gate = rustc_span::sym::lint_reasons;
531+
"unfulfilled lint expectation"
535532
}
536533

537534
declare_lint! {

src/test/ui/empty/empty-attributes.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
#![deny(unused_attributes)]
42
#![allow()] //~ ERROR unused attribute
53
#![expect()] //~ ERROR unused attribute

src/test/ui/empty/empty-attributes.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
11
error: unused attribute
2-
--> $DIR/empty-attributes.rs:11:1
2+
--> $DIR/empty-attributes.rs:9:1
33
|
44
LL | #[repr()]
55
| ^^^^^^^^^ help: remove this attribute
66
|
77
note: the lint level is defined here
8-
--> $DIR/empty-attributes.rs:3:9
8+
--> $DIR/empty-attributes.rs:1:9
99
|
1010
LL | #![deny(unused_attributes)]
1111
| ^^^^^^^^^^^^^^^^^
1212
= note: attribute `repr` with an empty list has no effect
1313

1414
error: unused attribute
15-
--> $DIR/empty-attributes.rs:14:1
15+
--> $DIR/empty-attributes.rs:12:1
1616
|
1717
LL | #[target_feature()]
1818
| ^^^^^^^^^^^^^^^^^^^ help: remove this attribute
1919
|
2020
= note: attribute `target_feature` with an empty list has no effect
2121

2222
error: unused attribute
23-
--> $DIR/empty-attributes.rs:4:1
23+
--> $DIR/empty-attributes.rs:2:1
2424
|
2525
LL | #![allow()]
2626
| ^^^^^^^^^^^ help: remove this attribute
2727
|
2828
= note: attribute `allow` with an empty list has no effect
2929

3030
error: unused attribute
31-
--> $DIR/empty-attributes.rs:5:1
31+
--> $DIR/empty-attributes.rs:3:1
3232
|
3333
LL | #![expect()]
3434
| ^^^^^^^^^^^^ help: remove this attribute
3535
|
3636
= note: attribute `expect` with an empty list has no effect
3737

3838
error: unused attribute
39-
--> $DIR/empty-attributes.rs:6:1
39+
--> $DIR/empty-attributes.rs:4:1
4040
|
4141
LL | #![warn()]
4242
| ^^^^^^^^^^ help: remove this attribute
4343
|
4444
= note: attribute `warn` with an empty list has no effect
4545

4646
error: unused attribute
47-
--> $DIR/empty-attributes.rs:7:1
47+
--> $DIR/empty-attributes.rs:5:1
4848
|
4949
LL | #![deny()]
5050
| ^^^^^^^^^^ help: remove this attribute
5151
|
5252
= note: attribute `deny` with an empty list has no effect
5353

5454
error: unused attribute
55-
--> $DIR/empty-attributes.rs:8:1
55+
--> $DIR/empty-attributes.rs:6:1
5656
|
5757
LL | #![forbid()]
5858
| ^^^^^^^^^^^^ help: remove this attribute
5959
|
6060
= note: attribute `forbid` with an empty list has no effect
6161

6262
error: unused attribute
63-
--> $DIR/empty-attributes.rs:9:1
63+
--> $DIR/empty-attributes.rs:7:1
6464
|
6565
LL | #![feature()]
6666
| ^^^^^^^^^^^^^ help: remove this attribute

src/test/ui/feature-gates/feature-gate-lint-reasons.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/test/ui/feature-gates/feature-gate-lint-reasons.stderr

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)