@@ -7,7 +7,7 @@ use rustc_ast::NodeId;
77use rustc_attr_ir:: {
88 ConstStability , DefaultBodyStability , DeprecatedSince , Deprecation , Stability , StabilityLevel ,
99} ;
10- use rustc_errors:: { Applicability , Diag , Diagnostic , LintBuffer , msg} ;
10+ use rustc_errors:: { Diag , Diagnostic , LintBuffer , msg} ;
1111use rustc_feature:: GateIssue ;
1212use rustc_hir:: def_id:: { DefId , LocalDefId } ;
1313use rustc_hir:: { self as hir, HirId } ;
@@ -62,7 +62,6 @@ pub fn report_unstable(
6262 feature : Symbol ,
6363 reason : Option < Symbol > ,
6464 issue : Option < NonZero < u32 > > ,
65- suggestion : Option < ( Span , String , String , Applicability ) > ,
6665 span : Span ,
6766 kind : UnstableKind ,
6867) {
@@ -77,9 +76,6 @@ pub fn report_unstable(
7776 } ;
7877
7978 let mut err = feature_err_issue ( sess, feature, span, GateIssue :: Library ( issue) , msg) ;
80- if let Some ( ( inner_types, msg, sugg, applicability) ) = suggestion {
81- err. span_suggestion ( inner_types, msg, sugg, applicability) ;
82- }
8379 if let UnstableKind :: Const ( kw) = kind {
8480 err. span_label ( kw, "trait is not stable as const yet" ) ;
8581 }
@@ -260,42 +256,11 @@ pub enum EvalResult {
260256 Allow ,
261257 /// We cannot use the item because it is unstable and we did not provide the
262258 /// corresponding feature gate.
263- Deny {
264- feature : Symbol ,
265- reason : Option < Symbol > ,
266- issue : Option < NonZero < u32 > > ,
267- suggestion : Option < ( Span , String , String , Applicability ) > ,
268- } ,
259+ Deny { feature : Symbol , reason : Option < Symbol > , issue : Option < NonZero < u32 > > } ,
269260 /// The item does not have the `#[stable]` or `#[unstable]` marker assigned.
270261 Unmarked ,
271262}
272263
273- // See issue #83250.
274- fn suggestion_for_allocator_api (
275- tcx : TyCtxt < ' _ > ,
276- def_id : DefId ,
277- span : Span ,
278- feature : Symbol ,
279- ) -> Option < ( Span , String , String , Applicability ) > {
280- if feature == sym:: allocator_api {
281- if let Some ( trait_) = tcx. opt_parent ( def_id) {
282- if tcx. is_diagnostic_item ( sym:: Vec , trait_) {
283- let sm = tcx. sess . psess . source_map ( ) ;
284- let inner_types = sm. span_extend_to_prev_char ( span, '<' , true ) ;
285- if let Ok ( snippet) = sm. span_to_snippet ( inner_types) {
286- return Some ( (
287- inner_types,
288- "consider wrapping the inner types in tuple" . to_string ( ) ,
289- format ! ( "({snippet})" ) ,
290- Applicability :: MaybeIncorrect ,
291- ) ) ;
292- }
293- }
294- }
295- }
296- None
297- }
298-
299264/// An override option for eval_stability.
300265pub enum AllowUnstable {
301266 /// Don't emit an unstable error for the item
@@ -425,8 +390,7 @@ impl<'tcx> TyCtxt<'tcx> {
425390 return EvalResult :: Allow ;
426391 }
427392
428- let suggestion = suggestion_for_allocator_api ( self , def_id, span, feature) ;
429- EvalResult :: Deny { feature, reason : reason. to_opt_reason ( ) , issue, suggestion }
393+ EvalResult :: Deny { feature, reason : reason. to_opt_reason ( ) , issue }
430394 }
431395 Some ( _) => {
432396 // Stable APIs are always ok to call and deprecated APIs are
@@ -472,12 +436,7 @@ impl<'tcx> TyCtxt<'tcx> {
472436 return EvalResult :: Allow ;
473437 }
474438
475- EvalResult :: Deny {
476- feature,
477- reason : reason. to_opt_reason ( ) ,
478- issue,
479- suggestion : None ,
480- }
439+ EvalResult :: Deny { feature, reason : reason. to_opt_reason ( ) , issue }
481440 }
482441 Some ( _) => {
483442 // Stable APIs are always ok to call
@@ -559,15 +518,9 @@ impl<'tcx> TyCtxt<'tcx> {
559518 let is_allowed = matches ! ( eval_result, EvalResult :: Allow ) ;
560519 match eval_result {
561520 EvalResult :: Allow => { }
562- EvalResult :: Deny { feature, reason, issue, suggestion } => report_unstable (
563- self . sess ,
564- feature,
565- reason,
566- issue,
567- suggestion,
568- span,
569- UnstableKind :: Regular ,
570- ) ,
521+ EvalResult :: Deny { feature, reason, issue } => {
522+ report_unstable ( self . sess , feature, reason, issue, span, UnstableKind :: Regular )
523+ }
571524 EvalResult :: Unmarked => unmarked ( span, def_id) ,
572525 }
573526
@@ -628,7 +581,6 @@ impl<'tcx> TyCtxt<'tcx> {
628581 feature,
629582 reason. to_opt_reason ( ) ,
630583 issue,
631- None ,
632584 span,
633585 UnstableKind :: Const ( const_kw_span) ,
634586 ) ;
0 commit comments