Skip to content

Commit

Permalink
feat: use fully qualified syntax in trait call for field attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-mccarthy committed Dec 13, 2022
1 parent 0088b8b commit 38089be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dummy_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,16 @@ fn expose_field(f: &DummyField) -> proc_macro2::TokenStream {
}
} else {
let field_ty = &f.ty;
let fake = syn::parse_str::<syn::Expr>("fake::Fake").unwrap();

if let Some(ref expr) = f.faker {
let faker = syn::parse_str::<syn::Expr>(expr).unwrap();

quote! {
(#faker).fake_with_rng::<#field_ty, _>(rng)
#fake::fake_with_rng::<#field_ty, _>(&(#faker), rng)
}
} else {
let faker = syn::parse_str::<syn::Expr>("fake::Faker").unwrap();
let fake = syn::parse_str::<syn::Expr>("fake::Fake").unwrap();

quote! {
<#faker as #fake>::fake_with_rng::<#field_ty, _>(&#faker, rng)
Expand Down
6 changes: 6 additions & 0 deletions fake/tests/derive_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ mod test_trait_scope {
pub struct Outer {
pub message: String,
}

#[derive(fake::Dummy)]
pub struct Outer2 {
#[dummy(faker = "1000..2000")]
pub id: usize,
}
}
}
}

0 comments on commit 38089be

Please sign in to comment.