@@ -224,16 +224,18 @@ mod llvm_enzyme {
224224 }
225225 _ => None ,
226226 } ,
227- Annotatable :: AssocItem ( assoc_item, Impl { of_trait : _ } ) => match & assoc_item. kind {
228- ast:: AssocItemKind :: Fn ( box ast:: Fn { sig, ident, generics, .. } ) => Some ( (
229- assoc_item. vis . clone ( ) ,
230- sig. clone ( ) ,
231- ident. clone ( ) ,
232- generics. clone ( ) ,
233- true ,
234- ) ) ,
235- _ => None ,
236- } ,
227+ Annotatable :: AssocItem ( assoc_item, _ctxt @ ( Impl { of_trait : _ } | Trait ) ) => {
228+ match & assoc_item. kind {
229+ ast:: AssocItemKind :: Fn ( box ast:: Fn { sig, ident, generics, .. } ) => Some ( (
230+ assoc_item. vis . clone ( ) ,
231+ sig. clone ( ) ,
232+ ident. clone ( ) ,
233+ generics. clone ( ) ,
234+ true ,
235+ ) ) ,
236+ _ => None ,
237+ }
238+ }
237239 _ => None ,
238240 } ) else {
239241 dcx. emit_err ( errors:: AutoDiffInvalidApplication { span : item. span ( ) } ) ;
@@ -393,14 +395,14 @@ mod llvm_enzyme {
393395 }
394396 Annotatable :: Item ( iitem. clone ( ) )
395397 }
396- Annotatable :: AssocItem ( ref mut assoc_item, i @ Impl { .. } ) => {
398+ Annotatable :: AssocItem ( ref mut assoc_item, ctxt @ ( Impl { .. } | Trait ) ) => {
397399 if !assoc_item. attrs . iter ( ) . any ( |a| same_attribute ( & a. kind , & attr. kind ) ) {
398400 assoc_item. attrs . push ( attr) ;
399401 }
400402 if assoc_item. attrs . iter ( ) . any ( |a| same_attribute ( & a. kind , & inline_never. kind ) ) {
401403 has_inline_never = true ;
402404 }
403- Annotatable :: AssocItem ( assoc_item. clone ( ) , i )
405+ Annotatable :: AssocItem ( assoc_item. clone ( ) , ctxt )
404406 }
405407 Annotatable :: Stmt ( ref mut stmt) => {
406408 match stmt. kind {
@@ -441,7 +443,7 @@ mod llvm_enzyme {
441443 }
442444
443445 let d_annotatable = match & item {
444- Annotatable :: AssocItem ( _, _ ) => {
446+ Annotatable :: AssocItem ( _, ctxt ) => {
445447 let assoc_item: AssocItemKind = ast:: AssocItemKind :: Fn ( d_fn) ;
446448 let d_fn = Box :: new ( ast:: AssocItem {
447449 attrs : d_attrs,
@@ -451,7 +453,7 @@ mod llvm_enzyme {
451453 kind : assoc_item,
452454 tokens : None ,
453455 } ) ;
454- Annotatable :: AssocItem ( d_fn, Impl { of_trait : false } )
456+ Annotatable :: AssocItem ( d_fn, * ctxt )
455457 }
456458 Annotatable :: Item ( _) => {
457459 let mut d_fn = ecx. item ( span, d_attrs, ItemKind :: Fn ( d_fn) ) ;
0 commit comments