Skip to content

Commit e0c2636

Browse files
committed
remove clones
1 parent c53af1c commit e0c2636

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

compiler/rustc_builtin_macros/src/autodiff.rs

+10-19
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ mod llvm_enzyme {
286286
let orig_annotatable: Annotatable = match item {
287287
Annotatable::Item(ref mut iitem) => {
288288
if !iitem.attrs.iter().any(|a| a.id == attr.id) {
289-
iitem.attrs.push(attr.clone());
289+
iitem.attrs.push(attr);
290290
}
291291
if !iitem.attrs.iter().any(|a| a.id == inline_never.id) {
292292
iitem.attrs.push(inline_never.clone());
@@ -295,7 +295,7 @@ mod llvm_enzyme {
295295
}
296296
Annotatable::AssocItem(ref mut assoc_item, i @ Impl) => {
297297
if !assoc_item.attrs.iter().any(|a| a.id == attr.id) {
298-
assoc_item.attrs.push(attr.clone());
298+
assoc_item.attrs.push(attr);
299299
}
300300
if !assoc_item.attrs.iter().any(|a| a.id == inline_never.id) {
301301
assoc_item.attrs.push(inline_never.clone());
@@ -322,7 +322,7 @@ mod llvm_enzyme {
322322
let d_annotatable = if is_impl {
323323
let assoc_item: AssocItemKind = ast::AssocItemKind::Fn(asdf);
324324
let d_fn = P(ast::AssocItem {
325-
attrs: thin_vec![d_attr.clone(), inline_never],
325+
attrs: thin_vec![d_attr, inline_never],
326326
id: ast::DUMMY_NODE_ID,
327327
span,
328328
vis,
@@ -332,12 +332,8 @@ mod llvm_enzyme {
332332
});
333333
Annotatable::AssocItem(d_fn, Impl)
334334
} else {
335-
let mut d_fn = ecx.item(
336-
span,
337-
d_ident,
338-
thin_vec![d_attr.clone(), inline_never],
339-
ItemKind::Fn(asdf),
340-
);
335+
let mut d_fn =
336+
ecx.item(span, d_ident, thin_vec![d_attr, inline_never], ItemKind::Fn(asdf));
341337
d_fn.vis = vis;
342338
Annotatable::Item(d_fn)
343339
};
@@ -446,7 +442,7 @@ mod llvm_enzyme {
446442

447443
if primal_ret && n_active == 0 && x.mode.is_rev() {
448444
// We only have the primal ret.
449-
body.stmts.push(ecx.stmt_expr(black_box_primal_call.clone()));
445+
body.stmts.push(ecx.stmt_expr(black_box_primal_call));
450446
return body;
451447
}
452448

@@ -471,7 +467,7 @@ mod llvm_enzyme {
471467
if primal_ret {
472468
// We have both primal ret and active floats.
473469
// primal ret is first, by construction.
474-
exprs.push(primal_call.clone());
470+
exprs.push(primal_call);
475471
}
476472

477473
// Now construct default placeholder for each active float.
@@ -538,16 +534,11 @@ mod llvm_enzyme {
538534
return body;
539535
}
540536
[arg] => {
541-
ret = ecx.expr_call(
542-
new_decl_span,
543-
blackbox_call_expr.clone(),
544-
thin_vec![arg.clone()],
545-
);
537+
ret = ecx.expr_call(new_decl_span, blackbox_call_expr, thin_vec![arg.clone()]);
546538
}
547539
args => {
548540
let ret_tuple: P<ast::Expr> = ecx.expr_tuple(span, args.into());
549-
ret =
550-
ecx.expr_call(new_decl_span, blackbox_call_expr.clone(), thin_vec![ret_tuple]);
541+
ret = ecx.expr_call(new_decl_span, blackbox_call_expr, thin_vec![ret_tuple]);
551542
}
552543
}
553544
assert!(has_ret(&d_sig.decl.output));
@@ -567,7 +558,7 @@ mod llvm_enzyme {
567558
let args: ThinVec<_> =
568559
idents[1..].iter().map(|arg| ecx.expr_path(ecx.path_ident(span, *arg))).collect();
569560
let self_expr = ecx.expr_self(span);
570-
ecx.expr_method_call(span, self_expr, primal, args.clone())
561+
ecx.expr_method_call(span, self_expr, primal, args)
571562
} else {
572563
let args: ThinVec<_> =
573564
idents.iter().map(|arg| ecx.expr_path(ecx.path_ident(span, *arg))).collect();

0 commit comments

Comments
 (0)