From f32a095868104f9d67054f96e43450b794f6c04a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Sun, 30 Aug 2026 12:46:31 +0200 Subject: [PATCH] Remove unneeded clone in macro deriving --- compiler/rustc_builtin_macros/src/deriving/generic/mod.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index fd72007bdb643..6a53dafd396df 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -494,7 +494,7 @@ impl<'a> TraitDef<'a> { Some(Attribute::Parsed(AttributeKind::Repr { reprs, .. })) if reprs.iter().any(|(x, _)| matches!(x, ReprPacked(..))) ); - let newitem = match &item.kind { + let mut newitem = match &item.kind { ast::ItemKind::Struct(ident, generics, struct_def) => self.expand_struct_def( cx, struct_def, @@ -530,8 +530,7 @@ impl<'a> TraitDef<'a> { }; // Keep the lint attributes of the previous item to control how the // generated implementations are linted - let mut attrs = newitem.attrs.clone(); - attrs.extend( + newitem.attrs.extend( item.attrs .iter() .filter(|a| { @@ -546,7 +545,7 @@ impl<'a> TraitDef<'a> { }) .cloned(), ); - push(Annotatable::Item(Box::new(ast::Item { attrs, ..(*newitem).clone() }))) + push(Annotatable::Item(newitem)) } _ => unreachable!(), }