Skip to content

Commit e54da7b

Browse files
committed
allow differentiating a fnc multiple times
1 parent 4c2a59f commit e54da7b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/rustc_builtin_macros/src/autodiff.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ pub fn expand(
109109
style: ast::AttrStyle::Outer,
110110
span,
111111
};
112-
orig_item.attrs.push(attr.clone());
112+
// don't add it multiple times:
113+
if !orig_item.iter().any(|a| a.id == attr.id) {
114+
orig_item.attrs.push(attr.clone());
115+
}
113116

114117
// Now update for d_fn
115118
rustc_ad_attr.item.args = rustc_ast::AttrArgs::Delimited(rustc_ast::DelimArgs {

0 commit comments

Comments
 (0)