@@ -562,15 +562,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
562
562
codegen_fn_attrs
563
563
}
564
564
565
- /// If the provided DefId is a method in a trait impl, return the DefId of the method prototype.
566
- fn opt_trait_item ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> Option < DefId > {
567
- let impl_item = tcx. opt_associated_item ( def_id) ?;
568
- match impl_item. container {
569
- ty:: AssocItemContainer :: Impl => impl_item. trait_item_def_id ,
570
- _ => None ,
571
- }
572
- }
573
-
574
565
fn disabled_sanitizers_for ( tcx : TyCtxt < ' _ > , did : LocalDefId ) -> SanitizerSet {
575
566
// Backtrack to the crate root.
576
567
let mut disabled = match tcx. opt_local_parent ( did) {
@@ -600,14 +591,15 @@ fn disabled_sanitizers_for(tcx: TyCtxt<'_>, did: LocalDefId) -> SanitizerSet {
600
591
/// Checks if the provided DefId is a method in a trait impl for a trait which has track_caller
601
592
/// applied to the method prototype.
602
593
fn should_inherit_track_caller ( tcx : TyCtxt < ' _ > , def_id : DefId ) -> bool {
603
- let Some ( trait_item) = opt_trait_item ( tcx, def_id) else { return false } ;
604
- tcx. codegen_fn_attrs ( trait_item) . flags . intersects ( CodegenFnAttrFlags :: TRACK_CALLER )
594
+ tcx. trait_item_of ( def_id) . is_some_and ( |id| {
595
+ tcx. codegen_fn_attrs ( id) . flags . intersects ( CodegenFnAttrFlags :: TRACK_CALLER )
596
+ } )
605
597
}
606
598
607
599
/// If the provided DefId is a method in a trait impl, return the value of the `#[align]`
608
600
/// attribute on the method prototype (if any).
609
601
fn inherited_align < ' tcx > ( tcx : TyCtxt < ' tcx > , def_id : DefId ) -> Option < Align > {
610
- tcx. codegen_fn_attrs ( opt_trait_item ( tcx, def_id) ?) . alignment
602
+ tcx. codegen_fn_attrs ( tcx. trait_item_of ( def_id) ?) . alignment
611
603
}
612
604
613
605
/// We now check the #\[rustc_autodiff\] attributes which we generated from the #[autodiff(...)]
0 commit comments