Skip to content

Commit 35abae8

Browse files
committed
Undeprecate and use lint unstable_features
1 parent bf9229a commit 35abae8

File tree

5 files changed

+35
-13
lines changed

5 files changed

+35
-13
lines changed

compiler/rustc_lexer/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
//! [`rustc_parse::lexer`]: ../rustc_parse/lexer/index.html
2121
#![deny(rustc::untranslatable_diagnostic)]
2222
#![deny(rustc::diagnostic_outside_of_impl)]
23-
// We want to be able to build this crate with a stable compiler, so no
24-
// `#![feature]` attributes should be added.
23+
// We want to be able to build this crate with a stable compiler,
24+
// so no `#![feature]` attributes should be added.
25+
#![deny(unstable_features)]
2526

2627
mod cursor;
2728
pub mod unescape;

compiler/rustc_lint/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ lint_builtin_unsafe_impl = implementation of an `unsafe` trait
148148
149149
lint_builtin_unsafe_trait = declaration of an `unsafe` trait
150150
151-
lint_builtin_unstable_features = unstable feature
151+
lint_builtin_unstable_features = use of an unstable feature
152152
153153
lint_builtin_unused_doc_comment = unused doc comment
154154
.label = rustdoc does not generate documentation for {$kind}

compiler/rustc_lint/src/builtin.rs

+27-7
Original file line numberDiff line numberDiff line change
@@ -1233,10 +1233,30 @@ impl<'tcx> LateLintPass<'tcx> for MutableTransmutes {
12331233
}
12341234

12351235
declare_lint! {
1236-
/// The `unstable_features` is deprecated and should no longer be used.
1236+
/// The `unstable_features` lint detects uses of `#![feature]`.
1237+
///
1238+
/// ### Example
1239+
///
1240+
/// ```rust,compile_fail
1241+
/// #![deny(unstable_features)]
1242+
/// #![feature(test)]
1243+
/// ```
1244+
///
1245+
/// {{produces}}
1246+
///
1247+
/// ### Explanation
1248+
///
1249+
/// In larger nightly-based projects which
1250+
///
1251+
/// * consist of a multitude of crates where a subset of crates has to compile on
1252+
/// stable either unconditionally or depending on a `cfg` flag to for example
1253+
/// allow stable users to depend on them,
1254+
/// * don't use nightly for experimental features but for, e.g., unstable options only,
1255+
///
1256+
/// this lint may come in handy to enforce policies of this kind.
12371257
UNSTABLE_FEATURES,
12381258
Allow,
1239-
"enabling unstable features (deprecated. do not use)"
1259+
"enabling unstable features"
12401260
}
12411261

12421262
declare_lint_pass!(
@@ -1246,11 +1266,11 @@ declare_lint_pass!(
12461266

12471267
impl<'tcx> LateLintPass<'tcx> for UnstableFeatures {
12481268
fn check_attribute(&mut self, cx: &LateContext<'_>, attr: &ast::Attribute) {
1249-
if attr.has_name(sym::feature) {
1250-
if let Some(items) = attr.meta_item_list() {
1251-
for item in items {
1252-
cx.emit_spanned_lint(UNSTABLE_FEATURES, item.span(), BuiltinUnstableFeatures);
1253-
}
1269+
if attr.has_name(sym::feature)
1270+
&& let Some(items) = attr.meta_item_list()
1271+
{
1272+
for item in items {
1273+
cx.emit_spanned_lint(UNSTABLE_FEATURES, item.span(), BuiltinUnstableFeatures);
12541274
}
12551275
}
12561276
}

compiler/rustc_parse_format/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
)]
1212
#![deny(rustc::untranslatable_diagnostic)]
1313
#![deny(rustc::diagnostic_outside_of_impl)]
14-
// WARNING: We want to be able to build this crate with a stable compiler,
15-
// so no `#![feature]` attributes should be added!
14+
// We want to be able to build this crate with a stable compiler,
15+
// so no `#![feature]` attributes should be added.
16+
#![deny(unstable_features)]
1617

1718
use rustc_lexer::unescape;
1819
pub use Alignment::*;

tests/ui/feature-gates/feature-gate-feature-gate.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: unstable feature
1+
error: use of an unstable feature
22
--> $DIR/feature-gate-feature-gate.rs:2:12
33
|
44
LL | #![feature(intrinsics)]

0 commit comments

Comments
 (0)