RFC 2383: Stabilize lint_reasons
🎉
This commit is contained in:
parent
d929a42a66
commit
8b14e23dce
89 changed files with 177 additions and 257 deletions
|
@ -12,7 +12,7 @@
|
|||
#![feature(decl_macro)]
|
||||
#![feature(if_let_guard)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(lint_reasons)]
|
||||
#![cfg_attr(bootstrap, feature(lint_reasons))]
|
||||
#![feature(proc_macro_internals)]
|
||||
#![feature(proc_macro_quote)]
|
||||
#![feature(rustdoc_internals)]
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#![allow(internal_features)]
|
||||
#![allow(rustc::default_hash_types)]
|
||||
#![allow(rustc::potential_query_instability)]
|
||||
#![cfg_attr(bootstrap, feature(lint_reasons))]
|
||||
#![cfg_attr(not(parallel_compiler), feature(cell_leak))]
|
||||
#![deny(unsafe_op_in_unsafe_fn)]
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
|
||||
|
@ -24,7 +25,6 @@
|
|||
#![feature(extend_one)]
|
||||
#![feature(hash_raw_entry)]
|
||||
#![feature(hasher_prefixfree_extras)]
|
||||
#![feature(lint_reasons)]
|
||||
#![feature(macro_metavar_expr)]
|
||||
#![feature(map_try_insert)]
|
||||
#![feature(min_specialization)]
|
||||
|
|
|
@ -232,6 +232,8 @@ declare_features! (
|
|||
(accepted, label_break_value, "1.65.0", Some(48594)),
|
||||
/// Allows `let...else` statements.
|
||||
(accepted, let_else, "1.65.0", Some(87335)),
|
||||
/// Allows using `reason` in lint attributes and the `#[expect(lint)]` lint check.
|
||||
(accepted, lint_reasons, "CURRENT_RUSTC_VERSION", Some(54503)),
|
||||
/// Allows `break {expr}` with a value inside `loop`s.
|
||||
(accepted, loop_break_value, "1.19.0", Some(37339)),
|
||||
/// Allows use of `?` as the Kleene "at most one" operator in macros.
|
||||
|
|
|
@ -369,9 +369,9 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
|
|||
allow, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#),
|
||||
DuplicatesOk, EncodeCrossCrate::No,
|
||||
),
|
||||
gated!(
|
||||
expect, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#), DuplicatesOk,
|
||||
EncodeCrossCrate::No, lint_reasons, experimental!(expect)
|
||||
ungated!(
|
||||
expect, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#),
|
||||
DuplicatesOk, EncodeCrossCrate::No,
|
||||
),
|
||||
ungated!(
|
||||
forbid, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#),
|
||||
|
|
|
@ -512,8 +512,6 @@ declare_features! (
|
|||
/// Allows using `#[link(kind = "link-arg", name = "...")]`
|
||||
/// to pass custom arguments to the linker.
|
||||
(unstable, link_arg_attribute, "1.76.0", Some(99427)),
|
||||
/// Allows using `reason` in lint attributes and the `#[expect(lint)]` lint check.
|
||||
(unstable, lint_reasons, "1.31.0", Some(54503)),
|
||||
/// Give access to additional metadata about declarative macro meta-variables.
|
||||
(unstable, macro_metavar_expr, "1.61.0", Some(83527)),
|
||||
/// Provides a way to concatenate identifiers using metavariable expressions.
|
||||
|
|
|
@ -3,7 +3,6 @@ use rustc_middle::query::Providers;
|
|||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::lint::builtin::UNFULFILLED_LINT_EXPECTATIONS;
|
||||
use rustc_session::lint::LintExpectationId;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::Symbol;
|
||||
|
||||
pub(crate) fn provide(providers: &mut Providers) {
|
||||
|
@ -11,10 +10,6 @@ pub(crate) fn provide(providers: &mut Providers) {
|
|||
}
|
||||
|
||||
fn check_expectations(tcx: TyCtxt<'_>, tool_filter: Option<Symbol>) {
|
||||
if !tcx.features().active(sym::lint_reasons) {
|
||||
return;
|
||||
}
|
||||
|
||||
let lint_expectations = tcx.lint_expectations(());
|
||||
let fulfilled_expectations = tcx.dcx().steal_fulfilled_expectation_ids();
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ use rustc_session::lint::{
|
|||
},
|
||||
Level, Lint, LintExpectationId, LintId,
|
||||
};
|
||||
use rustc_session::parse::feature_err;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
|
@ -788,15 +787,6 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
|
|||
ast::MetaItemKind::NameValue(ref name_value) => {
|
||||
if item.path == sym::reason {
|
||||
if let ast::LitKind::Str(rationale, _) = name_value.kind {
|
||||
if !self.features.lint_reasons {
|
||||
feature_err(
|
||||
&self.sess,
|
||||
sym::lint_reasons,
|
||||
item.span,
|
||||
"lint reasons are experimental",
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
reason = Some(rationale);
|
||||
} else {
|
||||
sess.dcx().emit_err(MalformedAttribute {
|
||||
|
|
|
@ -608,13 +608,13 @@ declare_lint! {
|
|||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `unfulfilled_lint_expectations` lint detects lint trigger expectations
|
||||
/// that have not been fulfilled.
|
||||
/// The `unfulfilled_lint_expectations` lint warns if a lint expectation is
|
||||
/// unfulfilled.
|
||||
///
|
||||
/// ### Example
|
||||
///
|
||||
/// ```rust
|
||||
/// #![feature(lint_reasons)]
|
||||
/// #![cfg_attr(bootstrap, feature(lint_reasons))]
|
||||
///
|
||||
/// #[expect(unused_variables)]
|
||||
/// let x = 10;
|
||||
|
@ -625,24 +625,14 @@ declare_lint! {
|
|||
///
|
||||
/// ### Explanation
|
||||
///
|
||||
/// It was expected that the marked code would emit a lint. This expectation
|
||||
/// has not been fulfilled.
|
||||
/// The `#[expect]` attribute can be used to create a lint expectation. The
|
||||
/// expectation is fulfilled, if a `#[warn]` attribute at the same location
|
||||
/// would result in a lint emission. If the expectation is unfulfilled,
|
||||
/// because no lint was emitted, this lint will be emitted on the attribute.
|
||||
///
|
||||
/// The `expect` attribute can be removed if this is intended behavior otherwise
|
||||
/// it should be investigated why the expected lint is no longer issued.
|
||||
///
|
||||
/// In rare cases, the expectation might be emitted at a different location than
|
||||
/// shown in the shown code snippet. In most cases, the `#[expect]` attribute
|
||||
/// works when added to the outer scope. A few lints can only be expected
|
||||
/// on a crate level.
|
||||
///
|
||||
/// Part of RFC 2383. The progress is being tracked in [#54503]
|
||||
///
|
||||
/// [#54503]: https://github.com/rust-lang/rust/issues/54503
|
||||
pub UNFULFILLED_LINT_EXPECTATIONS,
|
||||
Warn,
|
||||
"unfulfilled lint expectation",
|
||||
@feature_gate = rustc_span::sym::lint_reasons;
|
||||
"unfulfilled lint expectation"
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue