Use fully-qualified type names in proc macro. (#3544)

Modifies the code emitted by `derive_label` to use fully-qualified type
names (e.g. `std::boxed::Box` instead of `Box`).

# Objective

- Using unqualified types here causes errors when the proc macro is used in contexts that locally define types with conflicting names (e.g. a local definition of `Box`).

## Solution

- Fully qualify standard types emitted by the proc macro code.
This commit is contained in:
Michael Nett 2022-01-04 19:49:37 +00:00
parent 3bb50443d4
commit 1a2646ecc4

View file

@ -86,8 +86,8 @@ pub fn derive_label(input: syn::DeriveInput, trait_path: syn::Path) -> TokenStre
(quote! {
impl #impl_generics #trait_path for #ident #ty_generics #where_clause {
fn dyn_clone(&self) -> Box<dyn #trait_path> {
Box::new(Clone::clone(self))
fn dyn_clone(&self) -> std::boxed::Box<dyn #trait_path> {
std::boxed::Box::new(std::clone::Clone::clone(self))
}
}
})