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