Refer to std derives by absolute path

This prevents hijacking if the caller's crate has a macro in
scope (via #[macro_use]) with the same name.
This commit is contained in:
David Tolnay 2020-11-27 12:52:10 -08:00
parent 2c24e5cb84
commit 0521373464
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -164,10 +164,15 @@ fn expand_enum(enm: &Enum) -> TokenStream {
pub const #variant_ident: Self = #ident { repr: #discriminant };
})
});
let derives = quote! {
// Required to be derived in order for the enum's "variants" to be
// usable in patterns.
#[derive(::std::cmp::PartialEq, ::std::cmp::Eq)]
};
quote! {
#doc
#[derive(PartialEq, Eq)] // required to be derived in order to be usable in patterns
#derives
#[repr(transparent)]
pub struct #ident {
pub repr: #repr,