@@ -19,6 +19,8 @@ mod llvm_enzyme {
1919 self as ast, AssocItemKind , BindingMode , FnRetTy , FnSig , Generics , ItemKind , MetaItemInner ,
2020 PatKind , TyKind ,
2121 } ;
22+ use rustc_attr_parsing:: AttributeParser ;
23+ // use rustc_hir::Attribute;
2224 use rustc_expand:: base:: { Annotatable , ExtCtxt } ;
2325 use rustc_span:: { Ident , Span , Symbol , kw, sym} ;
2426 use thin_vec:: { ThinVec , thin_vec} ;
@@ -287,27 +289,61 @@ mod llvm_enzyme {
287289 // Don't add it multiple times:
288290 let orig_annotatable: Annotatable = match item {
289291 Annotatable :: Item ( ref mut iitem) => {
290- if !iitem. attrs . iter ( ) . any ( |a| a. id == attr. id ) {
292+ if !AttributeParser :: parse_limited (
293+ ecx. sess ,
294+ & iitem. attrs ,
295+ sym:: rustc_autodiff,
296+ iitem. span ,
297+ true ,
298+ )
299+ . map_or ( false , |parsed| {
300+ parsed. path ( ) . len ( ) == 1 && parsed. path ( ) [ 0 ] == sym:: rustc_autodiff
301+ } ) {
291302 iitem. attrs . push ( attr) ;
292303 }
293- if !iitem. attrs . iter ( ) . any ( |a| a. id == inline_never. id ) {
304+
305+ if !AttributeParser :: parse_limited (
306+ ecx. sess ,
307+ & iitem. attrs ,
308+ sym:: inline,
309+ iitem. span ,
310+ true ,
311+ )
312+ . map_or ( false , |parsed| parsed. path ( ) . len ( ) == 1 && parsed. path ( ) [ 0 ] == sym:: inline)
313+ {
294314 iitem. attrs . push ( inline_never. clone ( ) ) ;
295315 }
296316 Annotatable :: Item ( iitem. clone ( ) )
297317 }
298318 Annotatable :: AssocItem ( ref mut assoc_item, i @ Impl ) => {
299- if !assoc_item. attrs . iter ( ) . any ( |a| a. id == attr. id ) {
319+ if !AttributeParser :: parse_limited (
320+ ecx. sess ,
321+ & assoc_item. attrs ,
322+ sym:: rustc_autodiff,
323+ assoc_item. span ,
324+ true ,
325+ )
326+ . map_or ( false , |parsed| {
327+ parsed. path ( ) . len ( ) == 1 && parsed. path ( ) [ 0 ] == sym:: rustc_autodiff
328+ } ) {
300329 assoc_item. attrs . push ( attr) ;
301330 }
302- if !assoc_item. attrs . iter ( ) . any ( |a| a. id == inline_never. id ) {
331+ if !AttributeParser :: parse_limited (
332+ ecx. sess ,
333+ & assoc_item. attrs ,
334+ sym:: inline,
335+ assoc_item. span ,
336+ true ,
337+ )
338+ . map_or ( false , |parsed| parsed. path ( ) . len ( ) == 1 && parsed. path ( ) [ 0 ] == sym:: inline)
339+ {
303340 assoc_item. attrs . push ( inline_never. clone ( ) ) ;
304341 }
305342 Annotatable :: AssocItem ( assoc_item. clone ( ) , i)
306343 }
307- _ => {
308- unreachable ! ( "annotatable kind checked previously" )
309- }
344+ _ => unreachable ! ( "annotatable kind checked previously" ) ,
310345 } ;
346+
311347 // Now update for d_fn
312348 rustc_ad_attr. item . args = rustc_ast:: AttrArgs :: Delimited ( rustc_ast:: DelimArgs {
313349 dspan : DelimSpan :: dummy ( ) ,
0 commit comments