From b267be921e3f95b96c7eafd6e47028822afe96e2 Mon Sep 17 00:00:00 2001 From: mejrs <59372212+mejrs@users.noreply.github.com> Date: Wed, 23 Sep 2026 12:03:41 +0200 Subject: [PATCH] Remove `suggestion_for_allocator_api` --- compiler/rustc_middle/src/middle/stability.rs | 62 +++---------------- compiler/rustc_resolve/src/macros.rs | 1 - compiler/rustc_span/src/symbol.rs | 1 - 3 files changed, 7 insertions(+), 57 deletions(-) diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs index 8213646b4625d..0235d5bb17224 100644 --- a/compiler/rustc_middle/src/middle/stability.rs +++ b/compiler/rustc_middle/src/middle/stability.rs @@ -7,7 +7,7 @@ use rustc_ast::NodeId; use rustc_attr_ir::{ ConstStability, DefaultBodyStability, DeprecatedSince, Deprecation, Stability, StabilityLevel, }; -use rustc_errors::{Applicability, Diag, Diagnostic, LintBuffer, msg}; +use rustc_errors::{Diag, Diagnostic, LintBuffer, msg}; use rustc_feature::GateIssue; use rustc_hir::def_id::{DefId, LocalDefId}; use rustc_hir::{self as hir, HirId}; @@ -62,7 +62,6 @@ pub fn report_unstable( feature: Symbol, reason: Option, issue: Option>, - suggestion: Option<(Span, String, String, Applicability)>, span: Span, kind: UnstableKind, ) { @@ -77,9 +76,6 @@ pub fn report_unstable( }; 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"); } @@ -260,42 +256,11 @@ pub enum EvalResult { Allow, /// We cannot use the item because it is unstable and we did not provide the /// corresponding feature gate. - Deny { - feature: Symbol, - reason: Option, - issue: Option>, - suggestion: Option<(Span, String, String, Applicability)>, - }, + Deny { feature: Symbol, reason: Option, issue: Option> }, /// The item does not have the `#[stable]` or `#[unstable]` marker assigned. Unmarked, } -// See issue #83250. -fn suggestion_for_allocator_api( - tcx: TyCtxt<'_>, - def_id: DefId, - span: Span, - feature: Symbol, -) -> Option<(Span, String, String, Applicability)> { - if feature == sym::allocator_api { - if let Some(trait_) = tcx.opt_parent(def_id) { - if tcx.is_diagnostic_item(sym::Vec, trait_) { - let sm = tcx.sess.psess.source_map(); - let inner_types = sm.span_extend_to_prev_char(span, '<', true); - if let Ok(snippet) = sm.span_to_snippet(inner_types) { - return Some(( - inner_types, - "consider wrapping the inner types in tuple".to_string(), - format!("({snippet})"), - Applicability::MaybeIncorrect, - )); - } - } - } - } - None -} - /// An override option for eval_stability. pub enum AllowUnstable { /// Don't emit an unstable error for the item @@ -425,8 +390,7 @@ impl<'tcx> TyCtxt<'tcx> { return EvalResult::Allow; } - let suggestion = suggestion_for_allocator_api(self, def_id, span, feature); - EvalResult::Deny { feature, reason: reason.to_opt_reason(), issue, suggestion } + EvalResult::Deny { feature, reason: reason.to_opt_reason(), issue } } Some(_) => { // Stable APIs are always ok to call and deprecated APIs are @@ -472,12 +436,7 @@ impl<'tcx> TyCtxt<'tcx> { return EvalResult::Allow; } - EvalResult::Deny { - feature, - reason: reason.to_opt_reason(), - issue, - suggestion: None, - } + EvalResult::Deny { feature, reason: reason.to_opt_reason(), issue } } Some(_) => { // Stable APIs are always ok to call @@ -559,15 +518,9 @@ impl<'tcx> TyCtxt<'tcx> { let is_allowed = matches!(eval_result, EvalResult::Allow); match eval_result { EvalResult::Allow => {} - EvalResult::Deny { feature, reason, issue, suggestion } => report_unstable( - self.sess, - feature, - reason, - issue, - suggestion, - span, - UnstableKind::Regular, - ), + EvalResult::Deny { feature, reason, issue } => { + report_unstable(self.sess, feature, reason, issue, span, UnstableKind::Regular) + } EvalResult::Unmarked => unmarked(span, def_id), } @@ -628,7 +581,6 @@ impl<'tcx> TyCtxt<'tcx> { feature, reason.to_opt_reason(), issue, - None, span, UnstableKind::Const(const_kw_span), ); diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index 24a52d4143493..823a66dcd5d93 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -1098,7 +1098,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { feature, reason.to_opt_reason(), issue, - None, span, stability::UnstableKind::Regular, ); diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index bd70e5acab4d7..f2ab04b41d938 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -413,7 +413,6 @@ symbols! { alloc_layout, alloc_zeroed, allocator, - allocator_api, allocator_internals, allow, allow_fail,