Skip to content

Commit

Permalink
Types marked #[zerogc(copy)] never need drops
Browse files Browse the repository at this point in the history
Derives was unessicarrily checking for this case...
  • Loading branch information
Techcable committed Sep 3, 2021
1 parent dcfdd14 commit d8fa323
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions libs/derive/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,11 +753,17 @@ 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) {
quote_spanned!(ty.span() => <#ty as zerogc::Trace>::NEEDS_DROP)
let needs_drop = if self.is_copy {
vec![quote!(false)]
} else {
quote_spanned!(ty.span() => core::mem::needs_drop::<#ty>())
});
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>())
}
}).collect::<Vec<_>>()
};
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 */;
Expand Down

0 comments on commit d8fa323

Please sign in to comment.