From 1907211ecadb3602e3090386de89ab20a0caf8b9 Mon Sep 17 00:00:00 2001 From: zhaoyvhan Date: Mon, 21 Sep 2026 13:34:33 +0800 Subject: [PATCH 1/2] red test --- dir-structure-tools/tests/async_tests.rs | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/dir-structure-tools/tests/async_tests.rs b/dir-structure-tools/tests/async_tests.rs index 1029ea4..351e09d 100644 --- a/dir-structure-tools/tests/async_tests.rs +++ b/dir-structure-tools/tests/async_tests.rs @@ -467,3 +467,40 @@ async fn versioned_doesnt_call_write_if_not_changed() { assert_eq!(std::fs::read_to_string(d.join("f1.txt")).unwrap(), "f2"); assert_eq!(dir.f1.count.load(Ordering::SeqCst), 1); } + +mod derive_where_clause { + //! Regression test: the future enums generated by `DirStructureAsync` must + //! inherit the derived struct's `where` clause. + //! + //! Compiling this module is the test: without the struct's bounds being + //! carried over into the generated code, the derive expansion fails with + //! `::Path: MyTrait is not satisfied`. + + use dir_structure::DirStructureAsync; + use dir_structure::traits::vfs::{PathType, VfsCore}; + use dir_structure_tools::dir_children::{DirChildren, Filter}; + + trait MyTrait {} + impl MyTrait for std::path::Path {} + + struct MyFilter; + impl

Filter

for MyFilter + where + P: PathType + MyTrait + ?Sized, + { + fn allows(_path: &P) -> bool { + true + } + } + + #[allow(dead_code)] + #[derive(DirStructureAsync)] + struct MyFilterDir + where + Vfs: VfsCore, + Vfs::Path: MyTrait, + { + #[dir_structure(path = self)] + children: DirChildren, + } +} From e3f9f0addcabb7d53e4f9412021f7cc287dbf400 Mon Sep 17 00:00:00 2001 From: zhaoyvhan Date: Mon, 21 Sep 2026 13:40:35 +0800 Subject: [PATCH 2/2] fix DirStructureAsync macros missing where clauses --- .../src/dir_structure_async/read_from_async.rs | 3 ++- .../src/dir_structure_async/write_to_async_ref.rs | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dir-structure-macros/src/dir_structure_async/read_from_async.rs b/dir-structure-macros/src/dir_structure_async/read_from_async.rs index 9402b25..e91d1c1 100644 --- a/dir-structure-macros/src/dir_structure_async/read_from_async.rs +++ b/dir-structure-macros/src/dir_structure_async/read_from_async.rs @@ -240,7 +240,8 @@ pub(super) fn future_impl_enum( let first_ty = &first.actual_field_ty_perform; let ty_name = &st.ident; - let where_clause_read_future = merge_where_clause(None, read_async.clauses.clone()); + let where_clause_read_future = + merge_where_clause(st.generics.where_clause.clone(), read_async.clauses.clone()); let vis = &st.vis; 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..9ee7abe 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 @@ -264,7 +264,10 @@ pub(super) fn future_impl_enum( quote! {} }; - let where_clause_write_future = merge_where_clause(None, write_async_ref.clauses.clone()); + let where_clause_write_future = merge_where_clause( + st.generics.where_clause.clone(), + write_async_ref.clauses.clone(), + ); let vis = &st.vis;