Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions compiler/rustc_attr_parsing/src/attributes/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ pub(crate) fn parse_unstability<S: Stage>(
let mut reason = None;
let mut issue = None;
let mut issue_num = None;
let mut is_soft = false;
let mut implied_by = None;
let mut old_name = None;

Expand Down Expand Up @@ -423,12 +422,6 @@ pub(crate) fn parse_unstability<S: Stage>(
},
};
}
Some(sym::soft) => {
if let Err(span) = args.no_args() {
cx.emit_err(session_diagnostics::SoftNoArgs { span });
}
is_soft = true;
}
Some(sym::implied_by) => {
insert_value_into_option_or_error(cx, &param, &mut implied_by, word.unwrap())?
}
Expand All @@ -438,14 +431,7 @@ pub(crate) fn parse_unstability<S: Stage>(
_ => {
cx.expected_specific_argument(
param.span(),
&[
sym::feature,
sym::reason,
sym::issue,
sym::soft,
sym::implied_by,
sym::old_name,
],
&[sym::feature, sym::reason, sym::issue, sym::implied_by, sym::old_name],
);
return None;
}
Expand All @@ -468,7 +454,6 @@ pub(crate) fn parse_unstability<S: Stage>(
let level = StabilityLevel::Unstable {
reason: UnstableReason::from_opt_reason(reason),
issue: issue_num,
is_soft,
implied_by,
old_name,
};
Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_attr_parsing/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,6 @@ pub(crate) struct InvalidSince {
pub span: Span,
}

#[derive(Diagnostic)]
#[diag("`soft` should not have any arguments")]
pub(crate) struct SoftNoArgs {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag("unknown version literal format, assuming it refers to a future version")]
pub(crate) struct UnknownVersionLiteral {
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ pub enum StabilityLevel {
reason: UnstableReason,
/// Relevant `rust-lang/rust` issue.
issue: Option<NonZero<u32>>,
is_soft: bool,
/// If part of a feature is stabilized and a new feature is added for the remaining parts,
/// then the `implied_by` attribute is used to indicate which now-stable feature previously
/// contained an item.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ fn register_builtins(store: &mut LintStore) {
see <https://github.com/rust-lang/rust/issues/40107> for more information",
);
store.register_removed("wasm_c_abi", "the wasm C ABI has been fixed");
store.register_removed("soft_unstable", "the general soft-unstable mechanism has been removed");
}

fn register_internals(store: &mut LintStore) {
Expand Down
17 changes: 0 additions & 17 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ declare_lint_pass! {
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
SHADOWING_SUPERTRAIT_ITEMS,
SINGLE_USE_LIFETIMES,
SOFT_UNSTABLE,
STABLE_FEATURES,
TAIL_EXPR_DROP_ORDER,
TEST_UNSTABLE_LINT,
Expand Down Expand Up @@ -2317,22 +2316,6 @@ declare_lint! {
};
}

declare_lint! {
/// The `soft_unstable` lint detects unstable features that were unintentionally allowed on
/// stable. This is a [future-incompatible] lint to transition this to a hard error in the
/// future. See [issue #64266] for more details.
///
/// [issue #64266]: https://github.com/rust-lang/rust/issues/64266
/// [future-incompatible]: ../index.md#future-incompatible-lints
pub SOFT_UNSTABLE,
Deny,
"a feature gate that doesn't break dependent crates",
@future_incompatible = FutureIncompatibleInfo {
reason: fcw!(FutureReleaseError #64266),
report_in_deps: true,
};
}

declare_lint! {
/// The `inline_no_sanitize` lint detects incompatible use of
/// [`#[inline(always)]`][inline] and [`#[sanitize(xyz = "off")]`][sanitize].
Expand Down
56 changes: 13 additions & 43 deletions compiler/rustc_middle/src/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::{self as hir, ConstStability, DefaultBodyStability, HirId, Stability};
use rustc_macros::{Decodable, Encodable, HashStable, Subdiagnostic};
use rustc_session::Session;
use rustc_session::lint::builtin::{DEPRECATED, DEPRECATED_IN_FUTURE, SOFT_UNSTABLE};
use rustc_session::lint::builtin::{DEPRECATED, DEPRECATED_IN_FUTURE};
use rustc_session::lint::{BuiltinLintDiag, DeprecatedSinceKind, Level, Lint};
use rustc_session::parse::feature_err_issue;
use rustc_span::{Span, Symbol, sym};
Expand Down Expand Up @@ -68,9 +68,7 @@ pub fn report_unstable(
reason: Option<Symbol>,
issue: Option<NonZero<u32>>,
suggestion: Option<(Span, String, String, Applicability)>,
is_soft: bool,
span: Span,
soft_handler: impl FnOnce(&'static Lint, Span, String),
kind: UnstableKind,
) {
let qual = match kind {
Expand All @@ -83,18 +81,14 @@ pub fn report_unstable(
None => format!("use of unstable{qual} library feature `{feature}`"),
};

if is_soft {
soft_handler(SOFT_UNSTABLE, span, msg)
} else {
let mut err = feature_err_issue(sess, feature, span, GateIssue::Library(issue), msg);
if let Some((inner_types, msg, sugg, applicability)) = suggestion {
err.span_suggestion(inner_types, msg, sugg, applicability);
}
if let UnstableKind::Const(kw) = kind {
err.span_label(kw, "trait is not stable as const yet");
}
err.emit();
let mut err = feature_err_issue(sess, feature, span, GateIssue::Library(issue), msg);
if let Some((inner_types, msg, sugg, applicability)) = suggestion {
err.span_suggestion(inner_types, msg, sugg, applicability);
}
if let UnstableKind::Const(kw) = kind {
err.span_label(kw, "trait is not stable as const yet");
}
err.emit();
}

fn deprecation_lint(is_in_effect: bool) -> &'static Lint {
Expand Down Expand Up @@ -266,7 +260,6 @@ pub enum EvalResult {
reason: Option<Symbol>,
issue: Option<NonZero<u32>>,
suggestion: Option<(Span, String, String, Applicability)>,
is_soft: bool,
},
/// The item does not have the `#[stable]` or `#[unstable]` marker assigned.
Unmarked,
Expand Down Expand Up @@ -386,7 +379,7 @@ impl<'tcx> TyCtxt<'tcx> {

match stability {
Some(Stability {
level: hir::StabilityLevel::Unstable { reason, issue, is_soft, implied_by, .. },
level: hir::StabilityLevel::Unstable { reason, issue, implied_by, .. },
feature,
..
}) => {
Expand Down Expand Up @@ -428,13 +421,7 @@ impl<'tcx> TyCtxt<'tcx> {
}

let suggestion = suggestion_for_allocator_api(self, def_id, span, feature);
EvalResult::Deny {
feature,
reason: reason.to_opt_reason(),
issue,
suggestion,
is_soft,
}
EvalResult::Deny { feature, reason: reason.to_opt_reason(), issue, suggestion }
}
Some(_) => {
// Stable APIs are always ok to call and deprecated APIs are
Expand Down Expand Up @@ -469,7 +456,7 @@ impl<'tcx> TyCtxt<'tcx> {

match stability {
Some(DefaultBodyStability {
level: hir::StabilityLevel::Unstable { reason, issue, is_soft, .. },
level: hir::StabilityLevel::Unstable { reason, issue, .. },
feature,
}) => {
if span.allows_unstable(feature) {
Expand All @@ -485,7 +472,6 @@ impl<'tcx> TyCtxt<'tcx> {
reason: reason.to_opt_reason(),
issue,
suggestion: None,
is_soft,
}
}
Some(_) => {
Expand Down Expand Up @@ -563,30 +549,18 @@ impl<'tcx> TyCtxt<'tcx> {
allow_unstable: AllowUnstable,
unmarked: impl FnOnce(Span, DefId),
) -> bool {
let soft_handler = |lint, span, msg: String| {
self.emit_node_span_lint(
lint,
id.unwrap_or(hir::CRATE_HIR_ID),
span,
rustc_errors::DiagDecorator(|lint| {
lint.primary_message(msg);
}),
);
};
let eval_result =
self.eval_stability_allow_unstable(def_id, id, span, method_span, allow_unstable);
let is_allowed = matches!(eval_result, EvalResult::Allow);
match eval_result {
EvalResult::Allow => {}
EvalResult::Deny { feature, reason, issue, suggestion, is_soft } => report_unstable(
EvalResult::Deny { feature, reason, issue, suggestion } => report_unstable(
self.sess,
feature,
reason,
issue,
suggestion,
is_soft,
span,
soft_handler,
UnstableKind::Regular,
),
EvalResult::Unmarked => unmarked(span, def_id),
Expand Down Expand Up @@ -623,12 +597,10 @@ impl<'tcx> TyCtxt<'tcx> {

match stability {
Some(ConstStability {
level: hir::StabilityLevel::Unstable { reason, issue, is_soft, implied_by, .. },
level: hir::StabilityLevel::Unstable { reason, issue, implied_by, .. },
feature,
..
}) => {
assert!(!is_soft);

if span.allows_unstable(feature) {
debug!("body stability: skipping span={:?} since it is internal", span);
return;
Expand All @@ -652,9 +624,7 @@ impl<'tcx> TyCtxt<'tcx> {
reason.to_opt_reason(),
issue,
None,
false,
span,
|_, _, _| {},
UnstableKind::Const(const_kw_span),
);
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_passes/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ const FORCE_UNSTABLE: Stability = Stability {
level: StabilityLevel::Unstable {
reason: UnstableReason::Default,
issue: NonZero::new(27812),
is_soft: false,
implied_by: None,
old_name: None,
},
Expand Down
13 changes: 1 addition & 12 deletions compiler/rustc_resolve/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rustc_errors::codes::*;
use rustc_errors::formatting::DiagMessageAddArg;
use rustc_errors::{
Applicability, Diag, DiagCtxtHandle, DiagMessage, Diagnostic, ElidedLifetimeInPathSubdiag,
Applicability, Diag, DiagCtxtHandle, Diagnostic, ElidedLifetimeInPathSubdiag,
EmissionGuarantee, IntoDiagArg, Level, MultiSpan, Subdiagnostic, msg,
};
use rustc_macros::{Diagnostic, Subdiagnostic};
Expand Down Expand Up @@ -1454,17 +1454,6 @@ pub(crate) struct MacroRuleNeverUsed {
pub name: Symbol,
}

pub(crate) struct UnstableFeature {
pub msg: DiagMessage,
}

impl<'a> Diagnostic<'a, ()> for UnstableFeature {
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
let Self { msg } = self;
Diag::new(dcx, level, msg)
}
}

#[derive(Diagnostic)]
#[diag("`extern crate` is not idiomatic in the new edition")]
pub(crate) struct ExternCrateNotIdiomatic {
Expand Down
15 changes: 1 addition & 14 deletions compiler/rustc_resolve/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1064,34 +1064,21 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
) {
let span = path.span;
if let Some(stability) = &ext.stability
&& let StabilityLevel::Unstable { reason, issue, is_soft, implied_by, .. } =
stability.level
&& let StabilityLevel::Unstable { reason, issue, implied_by, .. } = stability.level
{
let feature = stability.feature;

let is_allowed =
|feature| self.tcx.features().enabled(feature) || span.allows_unstable(feature);
let allowed_by_implication = implied_by.is_some_and(|feature| is_allowed(feature));
if !is_allowed(feature) && !allowed_by_implication {
let lint_buffer = &mut self.lint_buffer;
let soft_handler = |lint, span, msg: String| {
lint_buffer.buffer_lint(
lint,
node_id,
span,
// FIXME make this translatable
errors::UnstableFeature { msg: msg.into() },
)
};
stability::report_unstable(
self.tcx.sess,
feature,
reason.to_opt_reason(),
issue,
None,
is_soft,
span,
soft_handler,
stability::UnstableKind::Regular,
);
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,6 @@ symbols! {
slice_len_fn,
slice_patterns,
slicing_syntax,
soft,
sparc,
sparc64,
sparc_target_feature,
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2430,7 +2430,7 @@ mod size_asserts {
static_assert_size!(GenericParamDef, 40);
static_assert_size!(Generics, 16);
static_assert_size!(Item, 8);
static_assert_size!(ItemInner, 144);
static_assert_size!(ItemInner, 136);
static_assert_size!(ItemKind, 48);
static_assert_size!(PathSegment, 32);
static_assert_size!(Type, 32);
Expand Down
1 change: 0 additions & 1 deletion tests/ui/feature-gates/issue-43106-gating-of-test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// The non-crate level cases are in issue-43106-gating-of-builtin-attrs.rs.

#![allow(soft_unstable)]
#![test = "4200"]
//~^ ERROR `test` attribute cannot be used at crate level
fn main() {}
2 changes: 1 addition & 1 deletion tests/ui/feature-gates/issue-43106-gating-of-test.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: `test` attribute cannot be used at crate level
--> $DIR/issue-43106-gating-of-test.rs:4:1
--> $DIR/issue-43106-gating-of-test.rs:3:1
|
LL | #![test = "4200"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion tests/ui/imports/issue-28134.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ compile-flags: --test

#![allow(soft_unstable)]
#![test]
//~^ ERROR `test` attribute cannot be used at crate level
2 changes: 1 addition & 1 deletion tests/ui/imports/issue-28134.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: `test` attribute cannot be used at crate level
--> $DIR/issue-28134.rs:4:1
--> $DIR/issue-28134.rs:3:1
|
LL | #![test]
| ^^^^^^^^
Expand Down
Loading
Loading