Skip to content

Commit 59dfb9e

Browse files
committed
remove concept of soft-unstable features
1 parent 3945997 commit 59dfb9e

File tree

20 files changed

+118
-217
lines changed

20 files changed

+118
-217
lines changed

compiler/rustc_attr_parsing/src/attributes/stability.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,6 @@ pub(crate) fn parse_unstability<S: Stage>(
376376
let mut reason = None;
377377
let mut issue = None;
378378
let mut issue_num = None;
379-
let mut is_soft = false;
380379
let mut implied_by = None;
381380
let mut old_name = None;
382381

@@ -423,12 +422,6 @@ pub(crate) fn parse_unstability<S: Stage>(
423422
},
424423
};
425424
}
426-
Some(sym::soft) => {
427-
if let Err(span) = args.no_args() {
428-
cx.emit_err(session_diagnostics::SoftNoArgs { span });
429-
}
430-
is_soft = true;
431-
}
432425
Some(sym::implied_by) => {
433426
insert_value_into_option_or_error(cx, &param, &mut implied_by, word.unwrap())?
434427
}
@@ -438,14 +431,7 @@ pub(crate) fn parse_unstability<S: Stage>(
438431
_ => {
439432
cx.expected_specific_argument(
440433
param.span(),
441-
&[
442-
sym::feature,
443-
sym::reason,
444-
sym::issue,
445-
sym::soft,
446-
sym::implied_by,
447-
sym::old_name,
448-
],
434+
&[sym::feature, sym::reason, sym::issue, sym::implied_by, sym::old_name],
449435
);
450436
return None;
451437
}
@@ -468,7 +454,6 @@ pub(crate) fn parse_unstability<S: Stage>(
468454
let level = StabilityLevel::Unstable {
469455
reason: UnstableReason::from_opt_reason(reason),
470456
issue: issue_num,
471-
is_soft,
472457
implied_by,
473458
old_name,
474459
};

compiler/rustc_attr_parsing/src/session_diagnostics.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,6 @@ pub(crate) struct InvalidSince {
374374
pub span: Span,
375375
}
376376

377-
#[derive(Diagnostic)]
378-
#[diag("`soft` should not have any arguments")]
379-
pub(crate) struct SoftNoArgs {
380-
#[primary_span]
381-
pub span: Span,
382-
}
383-
384377
#[derive(Diagnostic)]
385378
#[diag("unknown version literal format, assuming it refers to a future version")]
386379
pub(crate) struct UnknownVersionLiteral {

compiler/rustc_hir/src/stability.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ pub enum StabilityLevel {
112112
reason: UnstableReason,
113113
/// Relevant `rust-lang/rust` issue.
114114
issue: Option<NonZero<u32>>,
115-
is_soft: bool,
116115
/// If part of a feature is stabilized and a new feature is added for the remaining parts,
117116
/// then the `implied_by` attribute is used to indicate which now-stable feature previously
118117
/// contained an item.

compiler/rustc_lint/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ fn register_builtins(store: &mut LintStore) {
642642
see <https://github.com/rust-lang/rust/issues/40107> for more information",
643643
);
644644
store.register_removed("wasm_c_abi", "the wasm C ABI has been fixed");
645+
store.register_removed("soft_unstable", "the general soft-unstable mechanism has been removed");
645646
}
646647

647648
fn register_internals(store: &mut LintStore) {

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ declare_lint_pass! {
105105
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
106106
SHADOWING_SUPERTRAIT_ITEMS,
107107
SINGLE_USE_LIFETIMES,
108-
SOFT_UNSTABLE,
109108
STABLE_FEATURES,
110109
TAIL_EXPR_DROP_ORDER,
111110
TEST_UNSTABLE_LINT,
@@ -2317,22 +2316,6 @@ declare_lint! {
23172316
};
23182317
}
23192318

2320-
declare_lint! {
2321-
/// The `soft_unstable` lint detects unstable features that were unintentionally allowed on
2322-
/// stable. This is a [future-incompatible] lint to transition this to a hard error in the
2323-
/// future. See [issue #64266] for more details.
2324-
///
2325-
/// [issue #64266]: https://github.com/rust-lang/rust/issues/64266
2326-
/// [future-incompatible]: ../index.md#future-incompatible-lints
2327-
pub SOFT_UNSTABLE,
2328-
Deny,
2329-
"a feature gate that doesn't break dependent crates",
2330-
@future_incompatible = FutureIncompatibleInfo {
2331-
reason: fcw!(FutureReleaseError #64266),
2332-
report_in_deps: true,
2333-
};
2334-
}
2335-
23362319
declare_lint! {
23372320
/// The `inline_no_sanitize` lint detects incompatible use of
23382321
/// [`#[inline(always)]`][inline] and [`#[sanitize(xyz = "off")]`][sanitize].

compiler/rustc_middle/src/middle/stability.rs

Lines changed: 13 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
1111
use rustc_hir::{self as hir, ConstStability, DefaultBodyStability, HirId, Stability};
1212
use rustc_macros::{Decodable, Encodable, HashStable, Subdiagnostic};
1313
use rustc_session::Session;
14-
use rustc_session::lint::builtin::{DEPRECATED, DEPRECATED_IN_FUTURE, SOFT_UNSTABLE};
14+
use rustc_session::lint::builtin::{DEPRECATED, DEPRECATED_IN_FUTURE};
1515
use rustc_session::lint::{BuiltinLintDiag, DeprecatedSinceKind, Level, Lint};
1616
use rustc_session::parse::feature_err_issue;
1717
use rustc_span::{Span, Symbol, sym};
@@ -68,9 +68,7 @@ pub fn report_unstable(
6868
reason: Option<Symbol>,
6969
issue: Option<NonZero<u32>>,
7070
suggestion: Option<(Span, String, String, Applicability)>,
71-
is_soft: bool,
7271
span: Span,
73-
soft_handler: impl FnOnce(&'static Lint, Span, String),
7472
kind: UnstableKind,
7573
) {
7674
let qual = match kind {
@@ -83,18 +81,14 @@ pub fn report_unstable(
8381
None => format!("use of unstable{qual} library feature `{feature}`"),
8482
};
8583

86-
if is_soft {
87-
soft_handler(SOFT_UNSTABLE, span, msg)
88-
} else {
89-
let mut err = feature_err_issue(sess, feature, span, GateIssue::Library(issue), msg);
90-
if let Some((inner_types, msg, sugg, applicability)) = suggestion {
91-
err.span_suggestion(inner_types, msg, sugg, applicability);
92-
}
93-
if let UnstableKind::Const(kw) = kind {
94-
err.span_label(kw, "trait is not stable as const yet");
95-
}
96-
err.emit();
84+
let mut err = feature_err_issue(sess, feature, span, GateIssue::Library(issue), msg);
85+
if let Some((inner_types, msg, sugg, applicability)) = suggestion {
86+
err.span_suggestion(inner_types, msg, sugg, applicability);
9787
}
88+
if let UnstableKind::Const(kw) = kind {
89+
err.span_label(kw, "trait is not stable as const yet");
90+
}
91+
err.emit();
9892
}
9993

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

387380
match stability {
388381
Some(Stability {
389-
level: hir::StabilityLevel::Unstable { reason, issue, is_soft, implied_by, .. },
382+
level: hir::StabilityLevel::Unstable { reason, issue, implied_by, .. },
390383
feature,
391384
..
392385
}) => {
@@ -428,13 +421,7 @@ impl<'tcx> TyCtxt<'tcx> {
428421
}
429422

430423
let suggestion = suggestion_for_allocator_api(self, def_id, span, feature);
431-
EvalResult::Deny {
432-
feature,
433-
reason: reason.to_opt_reason(),
434-
issue,
435-
suggestion,
436-
is_soft,
437-
}
424+
EvalResult::Deny { feature, reason: reason.to_opt_reason(), issue, suggestion }
438425
}
439426
Some(_) => {
440427
// Stable APIs are always ok to call and deprecated APIs are
@@ -469,7 +456,7 @@ impl<'tcx> TyCtxt<'tcx> {
469456

470457
match stability {
471458
Some(DefaultBodyStability {
472-
level: hir::StabilityLevel::Unstable { reason, issue, is_soft, .. },
459+
level: hir::StabilityLevel::Unstable { reason, issue, .. },
473460
feature,
474461
}) => {
475462
if span.allows_unstable(feature) {
@@ -485,7 +472,6 @@ impl<'tcx> TyCtxt<'tcx> {
485472
reason: reason.to_opt_reason(),
486473
issue,
487474
suggestion: None,
488-
is_soft,
489475
}
490476
}
491477
Some(_) => {
@@ -563,30 +549,18 @@ impl<'tcx> TyCtxt<'tcx> {
563549
allow_unstable: AllowUnstable,
564550
unmarked: impl FnOnce(Span, DefId),
565551
) -> bool {
566-
let soft_handler = |lint, span, msg: String| {
567-
self.emit_node_span_lint(
568-
lint,
569-
id.unwrap_or(hir::CRATE_HIR_ID),
570-
span,
571-
rustc_errors::DiagDecorator(|lint| {
572-
lint.primary_message(msg);
573-
}),
574-
);
575-
};
576552
let eval_result =
577553
self.eval_stability_allow_unstable(def_id, id, span, method_span, allow_unstable);
578554
let is_allowed = matches!(eval_result, EvalResult::Allow);
579555
match eval_result {
580556
EvalResult::Allow => {}
581-
EvalResult::Deny { feature, reason, issue, suggestion, is_soft } => report_unstable(
557+
EvalResult::Deny { feature, reason, issue, suggestion } => report_unstable(
582558
self.sess,
583559
feature,
584560
reason,
585561
issue,
586562
suggestion,
587-
is_soft,
588563
span,
589-
soft_handler,
590564
UnstableKind::Regular,
591565
),
592566
EvalResult::Unmarked => unmarked(span, def_id),
@@ -623,12 +597,10 @@ impl<'tcx> TyCtxt<'tcx> {
623597

624598
match stability {
625599
Some(ConstStability {
626-
level: hir::StabilityLevel::Unstable { reason, issue, is_soft, implied_by, .. },
600+
level: hir::StabilityLevel::Unstable { reason, issue, implied_by, .. },
627601
feature,
628602
..
629603
}) => {
630-
assert!(!is_soft);
631-
632604
if span.allows_unstable(feature) {
633605
debug!("body stability: skipping span={:?} since it is internal", span);
634606
return;
@@ -652,9 +624,7 @@ impl<'tcx> TyCtxt<'tcx> {
652624
reason.to_opt_reason(),
653625
issue,
654626
None,
655-
false,
656627
span,
657-
|_, _, _| {},
658628
UnstableKind::Const(const_kw_span),
659629
);
660630
}

compiler/rustc_passes/src/stability.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ const FORCE_UNSTABLE: Stability = Stability {
131131
level: StabilityLevel::Unstable {
132132
reason: UnstableReason::Default,
133133
issue: NonZero::new(27812),
134-
is_soft: false,
135134
implied_by: None,
136135
old_name: None,
137136
},

compiler/rustc_resolve/src/errors.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_errors::codes::*;
22
use rustc_errors::formatting::DiagMessageAddArg;
33
use rustc_errors::{
4-
Applicability, Diag, DiagCtxtHandle, DiagMessage, Diagnostic, ElidedLifetimeInPathSubdiag,
4+
Applicability, Diag, DiagCtxtHandle, Diagnostic, ElidedLifetimeInPathSubdiag,
55
EmissionGuarantee, IntoDiagArg, Level, MultiSpan, Subdiagnostic, msg,
66
};
77
use rustc_macros::{Diagnostic, Subdiagnostic};
@@ -1454,17 +1454,6 @@ pub(crate) struct MacroRuleNeverUsed {
14541454
pub name: Symbol,
14551455
}
14561456

1457-
pub(crate) struct UnstableFeature {
1458-
pub msg: DiagMessage,
1459-
}
1460-
1461-
impl<'a> Diagnostic<'a, ()> for UnstableFeature {
1462-
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
1463-
let Self { msg } = self;
1464-
Diag::new(dcx, level, msg)
1465-
}
1466-
}
1467-
14681457
#[derive(Diagnostic)]
14691458
#[diag("`extern crate` is not idiomatic in the new edition")]
14701459
pub(crate) struct ExternCrateNotIdiomatic {

compiler/rustc_resolve/src/macros.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,34 +1064,21 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
10641064
) {
10651065
let span = path.span;
10661066
if let Some(stability) = &ext.stability
1067-
&& let StabilityLevel::Unstable { reason, issue, is_soft, implied_by, .. } =
1068-
stability.level
1067+
&& let StabilityLevel::Unstable { reason, issue, implied_by, .. } = stability.level
10691068
{
10701069
let feature = stability.feature;
10711070

10721071
let is_allowed =
10731072
|feature| self.tcx.features().enabled(feature) || span.allows_unstable(feature);
10741073
let allowed_by_implication = implied_by.is_some_and(|feature| is_allowed(feature));
10751074
if !is_allowed(feature) && !allowed_by_implication {
1076-
let lint_buffer = &mut self.lint_buffer;
1077-
let soft_handler = |lint, span, msg: String| {
1078-
lint_buffer.buffer_lint(
1079-
lint,
1080-
node_id,
1081-
span,
1082-
// FIXME make this translatable
1083-
errors::UnstableFeature { msg: msg.into() },
1084-
)
1085-
};
10861075
stability::report_unstable(
10871076
self.tcx.sess,
10881077
feature,
10891078
reason.to_opt_reason(),
10901079
issue,
10911080
None,
1092-
is_soft,
10931081
span,
1094-
soft_handler,
10951082
stability::UnstableKind::Regular,
10961083
);
10971084
}

compiler/rustc_span/src/symbol.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1914,7 +1914,6 @@ symbols! {
19141914
slice_len_fn,
19151915
slice_patterns,
19161916
slicing_syntax,
1917-
soft,
19181917
sparc,
19191918
sparc64,
19201919
sparc_target_feature,

0 commit comments

Comments
 (0)