Skip to content

Commit 3d83e77

Browse files
committed
Use absolute paths to refer to external types
Reduces possibility of macro outputs broken in various context by referencing external crates with ::<crate_name>.
1 parent a73f2ff commit 3d83e77

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

macros/src/gen_caster.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub fn generate_caster(ty: &impl ToTokens, trait_: &Path, sync: bool) -> TokenSt
1414
let fn_ident = format_ident!("{}", new_fn_name(&mut fn_buf));
1515
let new_caster = if sync {
1616
quote! {
17-
intertrait::Caster::<dyn #trait_>::new_sync(
17+
::intertrait::Caster::<dyn #trait_>::new_sync(
1818
|from| from.downcast_ref::<#ty>().unwrap(),
1919
|from| from.downcast_mut::<#ty>().unwrap(),
2020
|from| from.downcast::<#ty>().unwrap(),
@@ -24,7 +24,7 @@ pub fn generate_caster(ty: &impl ToTokens, trait_: &Path, sync: bool) -> TokenSt
2424
}
2525
} else {
2626
quote! {
27-
intertrait::Caster::<dyn #trait_>::new(
27+
::intertrait::Caster::<dyn #trait_>::new(
2828
|from| from.downcast_ref::<#ty>().unwrap(),
2929
|from| from.downcast_mut::<#ty>().unwrap(),
3030
|from| from.downcast::<#ty>().unwrap(),
@@ -34,9 +34,9 @@ pub fn generate_caster(ty: &impl ToTokens, trait_: &Path, sync: bool) -> TokenSt
3434
};
3535

3636
quote! {
37-
#[linkme::distributed_slice(intertrait::CASTERS)]
38-
fn #fn_ident() -> (std::any::TypeId, intertrait::BoxedCaster) {
39-
(std::any::TypeId::of::<#ty>(), Box::new(#new_caster))
37+
#[::linkme::distributed_slice(::intertrait::CASTERS)]
38+
fn #fn_ident() -> (::std::any::TypeId, ::intertrait::BoxedCaster) {
39+
(::std::any::TypeId::of::<#ty>(), Box::new(#new_caster))
4040
}
4141
}
4242
}

0 commit comments

Comments
 (0)