Skip to content

Commit fa8ec6f

Browse files
committed
Types marked #[zerogc(copy)] never need drops
Derives was unessicarrily checking for this case...
1 parent dcfdd14 commit fa8ec6f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

libs/derive/src/derive.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -753,11 +753,13 @@ impl TraceDeriveInput {
753753
let traced_field_types = self.determine_field_types(false);
754754
let all_field_types = self.determine_field_types(true);
755755
let needs_trace = traced_field_types.iter().map(|ty| quote_spanned!(ty.span() => <#ty as zerogc::Trace>::NEEDS_TRACE));
756-
let needs_drop = all_field_types.iter().map(|ty| if traced_field_types.contains(ty) {
756+
let needs_drop = if self.is_copy {
757+
quote!(false)
758+
} else if all_field_types.iter().map(|ty| if traced_field_types.contains(ty)) {
757759
quote_spanned!(ty.span() => <#ty as zerogc::Trace>::NEEDS_DROP)
758760
} else {
759761
quote_spanned!(ty.span() => core::mem::needs_drop::<#ty>())
760-
});
762+
};
761763
let assoc_constants = if !immutable {
762764
Some(quote! {
763765
const NEEDS_TRACE: bool = #(#needs_trace || )* false /* NOTE: Default to *false* if we have no GC types inside */;

0 commit comments

Comments
 (0)