From 38089be0d7be66163efb2e53cbf7212b8fb485ac Mon Sep 17 00:00:00 2001 From: Kyle McCarthy Date: Mon, 12 Dec 2022 22:04:40 -0600 Subject: [PATCH] feat: use fully qualified syntax in trait call for field attrs --- dummy_derive/src/lib.rs | 4 ++-- fake/tests/derive_macros.rs | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dummy_derive/src/lib.rs b/dummy_derive/src/lib.rs index 4757688..616be42 100644 --- a/dummy_derive/src/lib.rs +++ b/dummy_derive/src/lib.rs @@ -209,16 +209,16 @@ fn expose_field(f: &DummyField) -> proc_macro2::TokenStream { } } else { let field_ty = &f.ty; + let fake = syn::parse_str::("fake::Fake").unwrap(); if let Some(ref expr) = f.faker { let faker = syn::parse_str::(expr).unwrap(); quote! { - (#faker).fake_with_rng::<#field_ty, _>(rng) + #fake::fake_with_rng::<#field_ty, _>(&(#faker), rng) } } else { let faker = syn::parse_str::("fake::Faker").unwrap(); - let fake = syn::parse_str::("fake::Fake").unwrap(); quote! { <#faker as #fake>::fake_with_rng::<#field_ty, _>(&#faker, rng) diff --git a/fake/tests/derive_macros.rs b/fake/tests/derive_macros.rs index 322bd7a..6367f03 100644 --- a/fake/tests/derive_macros.rs +++ b/fake/tests/derive_macros.rs @@ -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, + } } } }