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 fa8ec6f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libs/derive/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 */;
Expand Down

0 comments on commit fa8ec6f

Please sign in to comment.