@@ -562,15 +562,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
562562 codegen_fn_attrs
563563}
564564
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-
574565fn disabled_sanitizers_for ( tcx : TyCtxt < ' _ > , did : LocalDefId ) -> SanitizerSet {
575566 // Backtrack to the crate root.
576567 let mut disabled = match tcx. opt_local_parent ( did) {
@@ -600,14 +591,15 @@ fn disabled_sanitizers_for(tcx: TyCtxt<'_>, did: LocalDefId) -> SanitizerSet {
600591/// Checks if the provided DefId is a method in a trait impl for a trait which has track_caller
601592/// applied to the method prototype.
602593fn 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+ } )
605597}
606598
607599/// If the provided DefId is a method in a trait impl, return the value of the `#[align]`
608600/// attribute on the method prototype (if any).
609601fn 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
611603}
612604
613605/// We now check the #\[rustc_autodiff\] attributes which we generated from the #[autodiff(...)]
0 commit comments