Skip to content
Merged
Show file tree
Hide file tree
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 @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
37 changes: 37 additions & 0 deletions dir-structure-tools/tests/async_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
//! `<Vfs as VfsCore>::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<P> Filter<P> for MyFilter
where
P: PathType + MyTrait + ?Sized,
{
fn allows(_path: &P) -> bool {
true
}
}

#[allow(dead_code)]
#[derive(DirStructureAsync)]
struct MyFilterDir<Vfs>
where
Vfs: VfsCore,
Vfs::Path: MyTrait,
{
#[dir_structure(path = self)]
children: DirChildren<String, MyFilter, Vfs::Path>,
}
}
Loading