[NFC] use outer_normal_attr helper
This commit is contained in:
parent
f9d0a14639
commit
5f7ff88853
1 changed files with 13 additions and 19 deletions
|
@ -25,6 +25,16 @@ mod llvm_enzyme {
|
||||||
|
|
||||||
use crate::errors;
|
use crate::errors;
|
||||||
|
|
||||||
|
pub(crate) fn outer_normal_attr(
|
||||||
|
kind: &P<rustc_ast::NormalAttr>,
|
||||||
|
id: rustc_ast::AttrId,
|
||||||
|
span: Span,
|
||||||
|
) -> rustc_ast::Attribute {
|
||||||
|
let style = rustc_ast::AttrStyle::Outer;
|
||||||
|
let kind = rustc_ast::AttrKind::Normal(kind.clone());
|
||||||
|
rustc_ast::Attribute { kind, id, style, span }
|
||||||
|
}
|
||||||
|
|
||||||
// If we have a default `()` return type or explicitley `()` return type,
|
// If we have a default `()` return type or explicitley `()` return type,
|
||||||
// then we often can skip doing some work.
|
// then we often can skip doing some work.
|
||||||
fn has_ret(ty: &FnRetTy) -> bool {
|
fn has_ret(ty: &FnRetTy) -> bool {
|
||||||
|
@ -268,19 +278,9 @@ mod llvm_enzyme {
|
||||||
};
|
};
|
||||||
let inline_never_attr = P(ast::NormalAttr { item: inline_item, tokens: None });
|
let inline_never_attr = P(ast::NormalAttr { item: inline_item, tokens: None });
|
||||||
let new_id = ecx.sess.psess.attr_id_generator.mk_attr_id();
|
let new_id = ecx.sess.psess.attr_id_generator.mk_attr_id();
|
||||||
let attr: ast::Attribute = ast::Attribute {
|
let attr = outer_normal_attr(&rustc_ad_attr, new_id, span);
|
||||||
kind: ast::AttrKind::Normal(rustc_ad_attr.clone()),
|
|
||||||
id: new_id,
|
|
||||||
style: ast::AttrStyle::Outer,
|
|
||||||
span,
|
|
||||||
};
|
|
||||||
let new_id = ecx.sess.psess.attr_id_generator.mk_attr_id();
|
let new_id = ecx.sess.psess.attr_id_generator.mk_attr_id();
|
||||||
let inline_never: ast::Attribute = ast::Attribute {
|
let inline_never = outer_normal_attr(&inline_never_attr, new_id, span);
|
||||||
kind: ast::AttrKind::Normal(inline_never_attr),
|
|
||||||
id: new_id,
|
|
||||||
style: ast::AttrStyle::Outer,
|
|
||||||
span,
|
|
||||||
};
|
|
||||||
|
|
||||||
// We're avoid duplicating the attributes `#[rustc_autodiff]` and `#[inline(never)]`.
|
// We're avoid duplicating the attributes `#[rustc_autodiff]` and `#[inline(never)]`.
|
||||||
fn same_attribute(attr: &ast::AttrKind, item: &ast::AttrKind) -> bool {
|
fn same_attribute(attr: &ast::AttrKind, item: &ast::AttrKind) -> bool {
|
||||||
|
@ -325,13 +325,7 @@ mod llvm_enzyme {
|
||||||
delim: rustc_ast::token::Delimiter::Parenthesis,
|
delim: rustc_ast::token::Delimiter::Parenthesis,
|
||||||
tokens: ts,
|
tokens: ts,
|
||||||
});
|
});
|
||||||
let d_attr: ast::Attribute = ast::Attribute {
|
let d_attr = outer_normal_attr(&rustc_ad_attr, new_id, span);
|
||||||
kind: ast::AttrKind::Normal(rustc_ad_attr.clone()),
|
|
||||||
id: new_id,
|
|
||||||
style: ast::AttrStyle::Outer,
|
|
||||||
span,
|
|
||||||
};
|
|
||||||
|
|
||||||
let d_annotatable = if is_impl {
|
let d_annotatable = if is_impl {
|
||||||
let assoc_item: AssocItemKind = ast::AssocItemKind::Fn(asdf);
|
let assoc_item: AssocItemKind = ast::AssocItemKind::Fn(asdf);
|
||||||
let d_fn = P(ast::AssocItem {
|
let d_fn = P(ast::AssocItem {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue