Skip to content

Commit dd2b165

Browse files
committed
fix: fix CI
1 parent df84c71 commit dd2b165

File tree

4 files changed

+29
-54
lines changed

4 files changed

+29
-54
lines changed

src/dev/dir-structure-macros/src/dir_structure.rs

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::collections::HashSet;
2-
31
use proc_macro2::Ident;
42
use proc_macro2::TokenStream;
53
use quote::format_ident;
@@ -13,6 +11,7 @@ use syn::parse_quote;
1311
use crate::dir_structure_core::DirStructureCoreInfo;
1412
use crate::dir_structure_core::PathSpec;
1513
use crate::dir_structure_core::compile_attrs;
14+
use crate::merge_where_clause;
1615

1716
struct DirStructureForField {
1817
read_code: TokenStream,
@@ -220,8 +219,8 @@ pub fn expand_dir_structure(st: ItemStruct) -> syn::Result<TokenStream> {
220219

221220
let mut field_read_impls = Vec::new();
222221
let mut field_write_impls = Vec::new();
223-
let mut read_bounds_b = HashSet::new();
224-
let mut write_bounds_b = HashSet::new();
222+
let mut read_bounds_b = Vec::new();
223+
let mut write_bounds_b = Vec::new();
225224

226225
for field in &st.fields {
227226
let DirStructureForField {
@@ -242,8 +241,8 @@ pub fn expand_dir_structure(st: ItemStruct) -> syn::Result<TokenStream> {
242241
write_bounds_b.extend(write_bounds);
243242
}
244243

245-
let where_read_clause = merge_where_clauses(where_clause, read_bounds_b);
246-
let where_write_clause = merge_where_clauses(where_clause, write_bounds_b);
244+
let where_read_clause = merge_where_clause(where_clause.cloned(), read_bounds_b);
245+
let where_write_clause = merge_where_clause(where_clause.cloned(), write_bounds_b);
247246

248247
let expanded = quote! {
249248
#[automatically_derived]
@@ -270,26 +269,3 @@ pub fn expand_dir_structure(st: ItemStruct) -> syn::Result<TokenStream> {
270269

271270
Ok(expanded)
272271
}
273-
274-
fn merge_where_clauses(
275-
original: Option<&syn::WhereClause>,
276-
additional: HashSet<WherePredicate>,
277-
) -> Option<syn::WhereClause> {
278-
if original.is_none() && additional.is_empty() {
279-
return None;
280-
}
281-
let mut predicates = if let Some(wc) = original {
282-
wc.predicates.clone()
283-
} else {
284-
syn::punctuated::Punctuated::new()
285-
};
286-
for p in additional {
287-
if !predicates.iter().any(|q| q == &p) {
288-
predicates.push(p);
289-
}
290-
}
291-
Some(syn::WhereClause {
292-
where_token: Default::default(),
293-
predicates,
294-
})
295-
}

src/dev/dir-structure-macros/src/dir_structure_async/mod.rs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use syn::Expr;
66
use syn::Field;
77
use syn::ImplGenerics;
88
use syn::ItemStruct;
9-
use syn::Token;
109
use syn::Type;
1110
use syn::Variant;
1211
use syn::WherePredicate;
@@ -15,6 +14,7 @@ use syn::parse_quote;
1514
use crate::dir_structure_core::DirStructureCoreInfo;
1615
use crate::dir_structure_core::PathSpec;
1716
use crate::dir_structure_core::compile_attrs;
17+
use crate::merge_where_clause;
1818

1919
mod read_from_async;
2020
mod write_to_async_ref;
@@ -355,26 +355,3 @@ pub fn expand_dir_structure_async(st: ItemStruct) -> syn::Result<TokenStream> {
355355

356356
Ok(expanded)
357357
}
358-
359-
use syn::punctuated::Punctuated;
360-
361-
fn merge_where_clause(
362-
where_clause: Option<syn::WhereClause>,
363-
additional_bounds: Vec<syn::WherePredicate>,
364-
) -> Option<syn::WhereClause> {
365-
if let Some(mut where_clause) = where_clause {
366-
where_clause.predicates.extend(additional_bounds);
367-
Some(where_clause)
368-
} else {
369-
let mut where_clause = syn::WhereClause {
370-
where_token: <Token![where]>::default(),
371-
predicates: Punctuated::new(),
372-
};
373-
where_clause.predicates.extend(additional_bounds);
374-
if where_clause.predicates.is_empty() {
375-
None
376-
} else {
377-
Some(where_clause)
378-
}
379-
}
380-
}

src/dev/dir-structure-macros/src/lib.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use syn::ItemStruct;
2+
use syn::punctuated::Punctuated;
23

34
mod dir_structure;
45
#[cfg(feature = "async")]
@@ -73,3 +74,24 @@ pub fn include_dir_patched(input: proc_macro::TokenStream) -> proc_macro::TokenS
7374
let input = syn::parse_macro_input!(input as syn::LitStr);
7475
quote::quote! {::dir_structure::include_dir::include_dir!(#input)}.into()
7576
}
77+
78+
fn merge_where_clause(
79+
where_clause: Option<syn::WhereClause>,
80+
additional_bounds: Vec<syn::WherePredicate>,
81+
) -> Option<syn::WhereClause> {
82+
if let Some(mut where_clause) = where_clause {
83+
where_clause.predicates.extend(additional_bounds);
84+
Some(where_clause)
85+
} else {
86+
let mut where_clause = syn::WhereClause {
87+
where_token: <syn::Token![where]>::default(),
88+
predicates: Punctuated::new(),
89+
};
90+
where_clause.predicates.extend(additional_bounds);
91+
if where_clause.predicates.is_empty() {
92+
None
93+
} else {
94+
Some(where_clause)
95+
}
96+
}
97+
}

src/dev/dir-structure/src/traits/asy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub trait WriteToAsync<'a, Vfs: WriteSupportingVfsAsync + ?Sized + 'a> {
5757
///
5858
/// The difference between this and [`WriteToAsync`] is that this trait takes in
5959
/// a reference instead of owned data.
60-
///
60+
///
6161
/// This is an async equivalent of [`WriteTo`](crate::traits::sync::WriteTo).
6262
#[cfg(feature = "async")]
6363
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]

0 commit comments

Comments
 (0)