Skip to content

Commit

Permalink
Corrected type generics computation.
Browse files Browse the repository at this point in the history
  • Loading branch information
azriel91 committed Oct 17, 2018
1 parent 84b82f4 commit 2b710f7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 21 deletions.
10 changes: 4 additions & 6 deletions src/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ pub fn derive_copy(input: &ast::Input) -> Result<proc_macro2::TokenStream, Strin
}

let copy_trait_path = copy_trait_path();
let (_impl_generics, ty_generics, _where_clause) = input.generics.split_for_impl();
let impl_generics = utils::build_impl_generics(
let generics = utils::build_impl_generics(
input,
&copy_trait_path,
|attrs| attrs.copy_bound().is_none(),
|field| field.copy_bound(),
|input| input.copy_bound(),
);
let where_clause = &impl_generics.where_clause;
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();

Ok(quote! {
#[allow(unused_qualifications)]
Expand All @@ -34,15 +33,14 @@ pub fn derive_clone(input: &ast::Input) -> proc_macro2::TokenStream {
let name = &input.ident;

let clone_trait_path = clone_trait_path();
let (_impl_generics, ty_generics, _where_clause) = input.generics.split_for_impl();
let impl_generics = utils::build_impl_generics(
let generics = utils::build_impl_generics(
input,
&clone_trait_path,
needs_clone_bound,
|field| field.clone_bound(),
|input| input.clone_bound(),
);
let where_clause = &impl_generics.where_clause;
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();

let is_copy = input.attrs.rustc_copy_clone_marker() || input.attrs.copy.is_some();
if is_copy && input.generics.type_params().count() == 0 {
Expand Down
10 changes: 4 additions & 6 deletions src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ pub fn derive_eq(input: &ast::Input) -> proc_macro2::TokenStream {
let name = &input.ident;

let eq_trait_path = eq_trait_path();
let (_impl_generics, ty_generics, _where_clause) = input.generics.split_for_impl();
let impl_generics = utils::build_impl_generics(
let generics = utils::build_impl_generics(
input,
&eq_trait_path,
|attrs| attrs.eq_bound().is_none(),
|field| field.eq_bound(),
|input| input.eq_bound(),
);
let where_clause = &impl_generics.where_clause;
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();

quote! {
#[allow(unused_qualifications)]
Expand Down Expand Up @@ -75,15 +74,14 @@ pub fn derive_partial_eq(input: &ast::Input) -> Result<proc_macro2::TokenStream,
let name = &input.ident;

let partial_eq_trait_path = partial_eq_trait_path();
let (_impl_generics, ty_generics, _where_clause) = input.generics.split_for_impl();
let impl_generics = utils::build_impl_generics(
let generics = utils::build_impl_generics(
input,
&partial_eq_trait_path,
|attrs| attrs.partial_eq_bound().is_none(),
|field| field.partial_eq_bound(),
|input| input.partial_eq_bound(),
);
let where_clause = &impl_generics.where_clause;
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();

Ok(quote! {
#[allow(unused_qualifications)]
Expand Down
5 changes: 2 additions & 3 deletions src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,14 @@ pub fn derive(input: &ast::Input) -> proc_macro2::TokenStream {
let name = &input.ident;

let debug_trait_path = debug_trait_path();
let (_impl_generics, ty_generics, _where_clause) = input.generics.split_for_impl();
let impl_generics = utils::build_impl_generics(
let generics = utils::build_impl_generics(
input,
&debug_trait_path,
needs_debug_bound,
|field| field.debug_bound(),
|input| input.debug_bound(),
);
let where_clause = &impl_generics.where_clause;
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();

quote! {
#[allow(unused_qualifications)]
Expand Down
5 changes: 2 additions & 3 deletions src/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,14 @@ pub fn derive(input: &ast::Input, default: &attr::InputDefault) -> proc_macro2::

let name = &input.ident;
let default_trait_path = default_trait_path();
let (_impl_generics, ty_generics, _where_clause) = input.generics.split_for_impl();
let impl_generics = utils::build_impl_generics(
let generics = utils::build_impl_generics(
input,
&default_trait_path,
|attrs| attrs.default_bound().is_none(),
|field| field.default_bound(),
|input| input.default_bound(),
);
let where_clause = &impl_generics.where_clause;
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();

let body = match input.body {
ast::Body::Enum(ref data) => {
Expand Down
5 changes: 2 additions & 3 deletions src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,14 @@ pub fn derive(input: &ast::Input) -> proc_macro2::TokenStream {
);

let name = &input.ident;
let (_impl_generics, ty_generics, _where_clause) = input.generics.split_for_impl();
let impl_generics = utils::build_impl_generics(
let generics = utils::build_impl_generics(
input,
&hash_trait_path,
needs_hash_bound,
|field| field.hash_bound(),
|input| input.hash_bound(),
);
let where_clause = &impl_generics.where_clause;
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();

let hasher_ty_parameter = utils::hygienic_type_parameter(input, "__H");
quote! {
Expand Down

0 comments on commit 2b710f7

Please sign in to comment.