Undeprecate and use lint unstable_features

This commit is contained in:
León Orell Valerian Liehr 2023-12-05 08:56:30 +01:00
parent bf9229a2e3
commit c0a9f722c4
No known key found for this signature in database
GPG key ID: D17A07215F68E713
5 changed files with 35 additions and 13 deletions

View file

@ -20,8 +20,9 @@
//! [`rustc_parse::lexer`]: ../rustc_parse/lexer/index.html
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
// We want to be able to build this crate with a stable compiler, so no
// `#![feature]` attributes should be added.
// We want to be able to build this crate with a stable compiler,
// so no `#![feature]` attributes should be added.
#![deny(unstable_features)]
mod cursor;
pub mod unescape;

View file

@ -148,7 +148,7 @@ lint_builtin_unsafe_impl = implementation of an `unsafe` trait
lint_builtin_unsafe_trait = declaration of an `unsafe` trait
lint_builtin_unstable_features = unstable feature
lint_builtin_unstable_features = use of an unstable feature
lint_builtin_unused_doc_comment = unused doc comment
.label = rustdoc does not generate documentation for {$kind}

View file

@ -1233,10 +1233,30 @@ fn def_id_is_transmute(cx: &LateContext<'_>, def_id: DefId) -> bool {
}
declare_lint! {
/// The `unstable_features` is deprecated and should no longer be used.
/// The `unstable_features` lint detects uses of `#![feature]`.
///
/// ### Example
///
/// ```rust,compile_fail
/// #![deny(unstable_features)]
/// #![feature(test)]
/// ```
///
/// {{produces}}
///
/// ### Explanation
///
/// In larger nightly-based projects which
///
/// * consist of a multitude of crates where a subset of crates has to compile on
/// stable either unconditionally or depending on a `cfg` flag to for example
/// allow stable users to depend on them,
/// * don't use nightly for experimental features but for, e.g., unstable options only,
///
/// this lint may come in handy to enforce policies of these kinds.
UNSTABLE_FEATURES,
Allow,
"enabling unstable features (deprecated. do not use)"
"enabling unstable features"
}
declare_lint_pass!(
@ -1246,11 +1266,11 @@ fn def_id_is_transmute(cx: &LateContext<'_>, def_id: DefId) -> bool {
impl<'tcx> LateLintPass<'tcx> for UnstableFeatures {
fn check_attribute(&mut self, cx: &LateContext<'_>, attr: &ast::Attribute) {
if attr.has_name(sym::feature) {
if let Some(items) = attr.meta_item_list() {
for item in items {
cx.emit_spanned_lint(UNSTABLE_FEATURES, item.span(), BuiltinUnstableFeatures);
}
if attr.has_name(sym::feature)
&& let Some(items) = attr.meta_item_list()
{
for item in items {
cx.emit_spanned_lint(UNSTABLE_FEATURES, item.span(), BuiltinUnstableFeatures);
}
}
}

View file

@ -11,8 +11,9 @@
)]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
// WARNING: We want to be able to build this crate with a stable compiler,
// so no `#![feature]` attributes should be added!
// We want to be able to build this crate with a stable compiler,
// so no `#![feature]` attributes should be added.
#![deny(unstable_features)]
use rustc_lexer::unescape;
pub use Alignment::*;

View file

@ -1,4 +1,4 @@
error: unstable feature
error: use of an unstable feature
--> $DIR/feature-gate-feature-gate.rs:2:12
|
LL | #![feature(intrinsics)]