summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_builtin_macros/src/deriving/clone.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_builtin_macros/src/deriving/clone.rs')
-rw-r--r--compiler/rustc_builtin_macros/src/deriving/clone.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/rustc_builtin_macros/src/deriving/clone.rs b/compiler/rustc_builtin_macros/src/deriving/clone.rs
index ef5a75f42..dfee2d3ce 100644
--- a/compiler/rustc_builtin_macros/src/deriving/clone.rs
+++ b/compiler/rustc_builtin_macros/src/deriving/clone.rs
@@ -6,7 +6,7 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::Span;
-use thin_vec::thin_vec;
+use thin_vec::{thin_vec, ThinVec};
pub fn expand_deriving_clone(
cx: &mut ExtCtxt<'_>,
@@ -73,6 +73,7 @@ pub fn expand_deriving_clone(
span,
path: path_std!(clone::Clone),
skip_path_as_bound: false,
+ needs_copy_as_bound_if_packed: true,
additional_bounds: bounds,
supports_unions: true,
methods: vec![MethodDef {
@@ -99,7 +100,7 @@ fn cs_clone_simple(
substr: &Substructure<'_>,
is_union: bool,
) -> BlockOrExpr {
- let mut stmts = Vec::new();
+ let mut stmts = ThinVec::new();
let mut seen_type_names = FxHashSet::default();
let mut process_variant = |variant: &VariantData| {
for field in variant.fields() {
@@ -161,7 +162,7 @@ fn cs_clone(
let all_fields;
let fn_path = cx.std_path(&[sym::clone, sym::Clone, sym::clone]);
let subcall = |cx: &mut ExtCtxt<'_>, field: &FieldInfo| {
- let args = vec![field.self_expr.clone()];
+ let args = thin_vec![field.self_expr.clone()];
cx.expr_call_global(field.span, fn_path.clone(), args)
};
@@ -199,7 +200,7 @@ fn cs_clone(
let call = subcall(cx, field);
cx.field_imm(field.span, ident, call)
})
- .collect::<Vec<_>>();
+ .collect::<ThinVec<_>>();
cx.expr_struct(trait_span, ctor_path, fields)
}