From 320833f84b002fa7a4406a48705a40c2dcb3a89b Mon Sep 17 00:00:00 2001 From: zhaoyvhan Date: Wed, 9 Sep 2026 21:44:01 +0800 Subject: [PATCH] fix(derive): avoid higher-ranked bounds on plain-field WriteToAsyncRef For plain (non-newtype) fields the derive emitted higher-ranked bounds of the form for<'trivial> #field_ty: WriteToAsyncRef<'vfs, Vfs> for<'trivial> <#field_ty as WriteToAsyncRef<'vfs, Vfs>>::Future<'fut>: Future + Send + Unpin + 'fut where the bound variable 'trivial is never actually used. The higher-ranked quantification forces rustc to perform uncached higher-ranked normalization over deeply nested derived structures, which can blow up compile times exponentially (blocking `cargo check` for minutes or even hitting an internal compiler error). Keep only a plain (non-higher-ranked) `WriteToAsyncRef<'vfs, Vfs>` bound on the impl header, and constrain the associated `Future` via a plain, non-higher-ranked `'fut` bound on the future enum's where clause. The redundant `Send` bound is dropped while the `Unpin` bound required by `poll` is kept. The newtype branch is unaffected. --- .../src/dir_structure_async/write_to_async_ref.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dir-structure-macros/src/dir_structure_async/write_to_async_ref.rs b/dir-structure-macros/src/dir_structure_async/write_to_async_ref.rs index 27754ac..3bd8c3c 100644 --- a/dir-structure-macros/src/dir_structure_async/write_to_async_ref.rs +++ b/dir-structure-macros/src/dir_structure_async/write_to_async_ref.rs @@ -93,13 +93,13 @@ pub(super) fn expand_dir_structure_for_field( async_write_ref_future.clauses_ref_vfs = true; let bound = vec![ parse_quote! { - for<'trivial> #actual_field_ty_perform: ::dir_structure::traits::asy::WriteToAsyncRef<'vfs, Vfs> - }, - parse_quote! { - for<'trivial> <#actual_field_ty_perform as ::dir_structure::traits::asy::WriteToAsyncRef<'vfs, Vfs>>::Future<'fut>: ::std::future::Future> + ::std::marker::Send + ::std::marker::Unpin + 'fut + #actual_field_ty_perform: ::dir_structure::traits::asy::WriteToAsyncRef<'vfs, Vfs> }, ]; async_write_ref_future.clauses.extend(bound.clone()); + async_write_ref_future.clauses.push(parse_quote! { + <#actual_field_ty_perform as ::dir_structure::traits::asy::WriteToAsyncRef<'vfs, Vfs>>::Future<'fut>: ::std::future::Future> + ::std::marker::Unpin + 'fut + }); async_write_ref_future.clauses.push(parse_quote! { 'vfs: 'fut });