Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix derive(Traverse)
  • Loading branch information
youknowone committed Jul 14, 2025
commit 635b4afff1ca1ff4e488995e8a04f24cbbc9e19a
13 changes: 12 additions & 1 deletion derive-impl/src/pytraverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,19 @@ pub(crate) fn impl_pytraverse(mut item: DeriveInput) -> Result<TokenStream> {

let ty = &item.ident;

// Add Traverse bound to all type parameters
for param in &mut item.generics.params {
if let syn::GenericParam::Type(type_param) = param {
type_param
.bounds
.push(syn::parse_quote!(::rustpython_vm::object::Traverse));
}
}

let (impl_generics, ty_generics, where_clause) = item.generics.split_for_impl();

let ret = quote! {
unsafe impl ::rustpython_vm::object::Traverse for #ty {
unsafe impl #impl_generics ::rustpython_vm::object::Traverse for #ty #ty_generics #where_clause {
fn traverse(&self, tracer_fn: &mut ::rustpython_vm::object::TraverseFn) {
#trace_code
}
Expand Down