@@ -19,6 +19,8 @@ mod llvm_enzyme {
19
19
self as ast, AssocItemKind , BindingMode , FnRetTy , FnSig , Generics , ItemKind , MetaItemInner ,
20
20
PatKind , TyKind ,
21
21
} ;
22
+ use rustc_attr_parsing:: AttributeParser ;
23
+ // use rustc_hir::Attribute;
22
24
use rustc_expand:: base:: { Annotatable , ExtCtxt } ;
23
25
use rustc_span:: { Ident , Span , Symbol , kw, sym} ;
24
26
use thin_vec:: { ThinVec , thin_vec} ;
@@ -287,27 +289,61 @@ mod llvm_enzyme {
287
289
// Don't add it multiple times:
288
290
let orig_annotatable: Annotatable = match item {
289
291
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
+ } ) {
291
302
iitem. attrs . push ( attr) ;
292
303
}
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
+ {
294
314
iitem. attrs . push ( inline_never. clone ( ) ) ;
295
315
}
296
316
Annotatable :: Item ( iitem. clone ( ) )
297
317
}
298
318
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
+ } ) {
300
329
assoc_item. attrs . push ( attr) ;
301
330
}
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
+ {
303
340
assoc_item. attrs . push ( inline_never. clone ( ) ) ;
304
341
}
305
342
Annotatable :: AssocItem ( assoc_item. clone ( ) , i)
306
343
}
307
- _ => {
308
- unreachable ! ( "annotatable kind checked previously" )
309
- }
344
+ _ => unreachable ! ( "annotatable kind checked previously" ) ,
310
345
} ;
346
+
311
347
// Now update for d_fn
312
348
rustc_ad_attr. item . args = rustc_ast:: AttrArgs :: Delimited ( rustc_ast:: DelimArgs {
313
349
dspan : DelimSpan :: dummy ( ) ,
0 commit comments