From fa8ec6f86ff6c988d9be36dd68c81c34eb3d7e78 Mon Sep 17 00:00:00 2001 From: Techcable Date: Fri, 3 Sep 2021 12:33:30 -0700 Subject: [PATCH] Types marked #[zerogc(copy)] never need drops Derives was unessicarrily checking for this case... --- libs/derive/src/derive.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/derive/src/derive.rs b/libs/derive/src/derive.rs index b76eb17..09042c4 100644 --- a/libs/derive/src/derive.rs +++ b/libs/derive/src/derive.rs @@ -753,11 +753,13 @@ impl TraceDeriveInput { let traced_field_types = self.determine_field_types(false); let all_field_types = self.determine_field_types(true); let needs_trace = traced_field_types.iter().map(|ty| quote_spanned!(ty.span() => <#ty as zerogc::Trace>::NEEDS_TRACE)); - let needs_drop = all_field_types.iter().map(|ty| if traced_field_types.contains(ty) { + let needs_drop = if self.is_copy { + quote!(false) + } else if all_field_types.iter().map(|ty| if traced_field_types.contains(ty)) { quote_spanned!(ty.span() => <#ty as zerogc::Trace>::NEEDS_DROP) } else { quote_spanned!(ty.span() => core::mem::needs_drop::<#ty>()) - }); + }; let assoc_constants = if !immutable { Some(quote! { const NEEDS_TRACE: bool = #(#needs_trace || )* false /* NOTE: Default to *false* if we have no GC types inside */;