Skip to content
Open
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -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>

@dnbln dnbln Sep 9, 2026 •

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bound is still necessary when #actual_field_ty_perform isn't a trivial type, as its part of the bounds that make it on the impl WriteToAsyncRef for YourStructure where ..., and if YourStructure has generics itself that might become a problem (edit: this comment applies to the other bound with the future, I see this one is still there).

I'd do this a bit differently:

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..fb397ef 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
@@ -91,18 +91,27 @@ pub(super) fn expand_dir_structure_for_field(
             }
             None => {
                 async_write_ref_future.clauses_ref_vfs = true;
+                let write_to_async_ref_bound: WherePredicate = parse_quote! {
+                    #actual_field_ty_perform: ::dir_structure::traits::asy::WriteToAsyncRef<'vfs, Vfs>
+                };
+                let fut_clause = quote! {
+                    <#actual_field_ty_perform as ::dir_structure::traits::asy::WriteToAsyncRef<'vfs, Vfs>>::Future<'fut>: ::std::future::Future<Output = ::dir_structure::error::VfsResult<(), Vfs>> + ::std::marker::Unpin + 'fut
+                };
                 let bound = vec![
+                    write_to_async_ref_bound.clone(),
                     parse_quote! {
-                        for<'trivial> #actual_field_ty_perform: ::dir_structure::traits::asy::WriteToAsyncRef<'vfs, Vfs>
+                        for<'fut> #fut_clause
                     },
+                ];
+                async_write_ref_future.clauses.extend([
+                    write_to_async_ref_bound,
                     parse_quote! {
-                        for<'trivial> <#actual_field_ty_perform as ::dir_structure::traits::asy::WriteToAsyncRef<'vfs, Vfs>>::Future<'fut>: ::std::future::Future<Output = ::dir_structure::error::VfsResult<(), Vfs>> + ::std::marker::Send + ::std::marker::Unpin + 'fut
+                        #fut_clause
                     },
-                ];
-                async_write_ref_future.clauses.extend(bound.clone());
-                async_write_ref_future.clauses.push(parse_quote! {
-                    'vfs: 'fut
-                });
+                    parse_quote! {
+                        'vfs: 'fut
+                    },
+                ]);
 
                 (
                     quote! {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review and the suggestions! This is my first PR, so I truly appreciate your guidance and apologize for any non-standard practices.
Also, I have to say this library is fantastic, it's been a huge help for my project's protocol design.

I've pushed the requested changes here.

One thing to note: in my real-world use case, this specific implementation causes compilation times to spike to ~20 minutes.
For comparison, the version in this branch finishes in under 1 minute.

I’ve included a test script to help you reproduce/verify this compilation bottleneck.
dir-structure.rs.sh

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to look into this a bit more

},
parse_quote! {
for<'trivial> <#actual_field_ty_perform as ::dir_structure::traits::asy::WriteToAsyncRef<'vfs, Vfs>>::Future<'fut>: ::std::future::Future<Output = ::dir_structure::error::VfsResult<(), Vfs>> + ::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<Output = ::dir_structure::error::VfsResult<(), Vfs>> + ::std::marker::Unpin + 'fut
});
async_write_ref_future.clauses.push(parse_quote! {
'vfs: 'fut
});
Expand Down
Loading