@@ -391,32 +391,38 @@ fn is_const_fn(tcx: TyCtxt<'_>, def_id: DefId, msrv: &Msrv) -> bool {
391
391
392
392
#[ expect( clippy:: similar_names) ] // bit too pedantic
393
393
fn is_ty_const_destruct < ' tcx > ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > , body : & Body < ' tcx > ) -> bool {
394
- // Avoid selecting for simple cases, such as builtin types.
395
- if ty:: util:: is_trivially_const_drop ( ty) {
396
- return true ;
397
- }
394
+ // FIXME(effects, fee1-dead) revert to const destruct once it works again
395
+ #[ expect( unused) ]
396
+ fn is_ty_const_destruct_unused < ' tcx > ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > , body : & Body < ' tcx > ) -> bool {
397
+ // Avoid selecting for simple cases, such as builtin types.
398
+ if ty:: util:: is_trivially_const_drop ( ty) {
399
+ return true ;
400
+ }
398
401
399
- let obligation = Obligation :: new (
400
- tcx,
401
- ObligationCause :: dummy_with_span ( body. span ) ,
402
- ConstCx :: new ( tcx, body) . param_env ,
403
- TraitRef :: from_lang_item ( tcx, LangItem :: Destruct , body. span , [ ty] ) . with_constness ( BoundConstness :: ConstIfConst ) ,
404
- ) ;
402
+ let obligation = Obligation :: new (
403
+ tcx,
404
+ ObligationCause :: dummy_with_span ( body. span ) ,
405
+ ConstCx :: new ( tcx, body) . param_env ,
406
+ TraitRef :: from_lang_item ( tcx, LangItem :: Destruct , body. span , [ ty] ) . with_constness ( BoundConstness :: ConstIfConst ) ,
407
+ ) ;
405
408
406
- let infcx = tcx. infer_ctxt ( ) . build ( ) ;
407
- let mut selcx = SelectionContext :: new ( & infcx) ;
408
- let Some ( impl_src) = selcx. select ( & obligation) . ok ( ) . flatten ( ) else {
409
- return false ;
410
- } ;
409
+ let infcx = tcx. infer_ctxt ( ) . build ( ) ;
410
+ let mut selcx = SelectionContext :: new ( & infcx) ;
411
+ let Some ( impl_src) = selcx. select ( & obligation) . ok ( ) . flatten ( ) else {
412
+ return false ;
413
+ } ;
414
+
415
+ if !matches ! (
416
+ impl_src,
417
+ ImplSource :: Builtin ( BuiltinImplSource :: Misc , _) | ImplSource :: Param ( ty:: BoundConstness :: ConstIfConst , _)
418
+ ) {
419
+ return false ;
420
+ }
411
421
412
- if !matches ! (
413
- impl_src,
414
- ImplSource :: Builtin ( BuiltinImplSource :: Misc , _) | ImplSource :: Param ( ty:: BoundConstness :: ConstIfConst , _)
415
- ) {
416
- return false ;
422
+ let ocx = ObligationCtxt :: new ( & infcx) ;
423
+ ocx. register_obligations ( impl_src. nested_obligations ( ) ) ;
424
+ ocx. select_all_or_error ( ) . is_empty ( )
417
425
}
418
426
419
- let ocx = ObligationCtxt :: new ( & infcx) ;
420
- ocx. register_obligations ( impl_src. nested_obligations ( ) ) ;
421
- ocx. select_all_or_error ( ) . is_empty ( )
427
+ !ty. needs_drop ( tcx, ConstCx :: new ( tcx, body) . param_env )
422
428
}
0 commit comments