@@ -555,15 +555,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
555555 codegen_fn_attrs
556556}
557557
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-
567558fn disabled_sanitizers_for ( tcx : TyCtxt < ' _ > , did : LocalDefId ) -> SanitizerSet {
568559 // Backtrack to the crate root.
569560 let mut disabled = match tcx. opt_local_parent ( did) {
@@ -593,14 +584,15 @@ fn disabled_sanitizers_for(tcx: TyCtxt<'_>, did: LocalDefId) -> SanitizerSet {
593584/// Checks if the provided DefId is a method in a trait impl for a trait which has track_caller
594585/// applied to the method prototype.
595586fn 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+ } )
598590}
599591
600592/// If the provided DefId is a method in a trait impl, return the value of the `#[align]`
601593/// attribute on the method prototype (if any).
602594fn 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
604596}
605597
606598/// We now check the #\[rustc_autodiff\] attributes which we generated from the #[autodiff(...)]
0 commit comments