@@ -25,6 +25,16 @@ mod llvm_enzyme {
25
25
26
26
use crate :: errors;
27
27
28
+ pub ( crate ) fn outer_normal_attr (
29
+ kind : & P < rustc_ast:: NormalAttr > ,
30
+ id : rustc_ast:: AttrId ,
31
+ span : Span ,
32
+ ) -> rustc_ast:: Attribute {
33
+ let style = rustc_ast:: AttrStyle :: Outer ;
34
+ let kind = rustc_ast:: AttrKind :: Normal ( kind. clone ( ) ) ;
35
+ rustc_ast:: Attribute { kind, id, style, span }
36
+ }
37
+
28
38
// If we have a default `()` return type or explicitley `()` return type,
29
39
// then we often can skip doing some work.
30
40
fn has_ret ( ty : & FnRetTy ) -> bool {
@@ -268,19 +278,9 @@ mod llvm_enzyme {
268
278
} ;
269
279
let inline_never_attr = P ( ast:: NormalAttr { item : inline_item, tokens : None } ) ;
270
280
let new_id = ecx. sess . psess . attr_id_generator . mk_attr_id ( ) ;
271
- let attr: ast:: Attribute = ast:: Attribute {
272
- kind : ast:: AttrKind :: Normal ( rustc_ad_attr. clone ( ) ) ,
273
- id : new_id,
274
- style : ast:: AttrStyle :: Outer ,
275
- span,
276
- } ;
281
+ let attr = outer_normal_attr ( & rustc_ad_attr, new_id, span) ;
277
282
let new_id = ecx. sess . psess . attr_id_generator . mk_attr_id ( ) ;
278
- let inline_never: ast:: Attribute = ast:: Attribute {
279
- kind : ast:: AttrKind :: Normal ( inline_never_attr) ,
280
- id : new_id,
281
- style : ast:: AttrStyle :: Outer ,
282
- span,
283
- } ;
283
+ let inline_never = outer_normal_attr ( & inline_never_attr, new_id, span) ;
284
284
285
285
// We're avoid duplicating the attributes `#[rustc_autodiff]` and `#[inline(never)]`.
286
286
fn same_attribute ( attr : & ast:: AttrKind , item : & ast:: AttrKind ) -> bool {
@@ -325,13 +325,7 @@ mod llvm_enzyme {
325
325
delim : rustc_ast:: token:: Delimiter :: Parenthesis ,
326
326
tokens : ts,
327
327
} ) ;
328
- let d_attr: ast:: Attribute = ast:: Attribute {
329
- kind : ast:: AttrKind :: Normal ( rustc_ad_attr. clone ( ) ) ,
330
- id : new_id,
331
- style : ast:: AttrStyle :: Outer ,
332
- span,
333
- } ;
334
-
328
+ let d_attr = outer_normal_attr ( & rustc_ad_attr, new_id, span) ;
335
329
let d_annotatable = if is_impl {
336
330
let assoc_item: AssocItemKind = ast:: AssocItemKind :: Fn ( asdf) ;
337
331
let d_fn = P ( ast:: AssocItem {
0 commit comments