mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +01:00
Improve handling of trait bounds when deriving fmap-like traits
This commit is contained in:
parent
8101887d31
commit
efc852f6e3
12 changed files with 229 additions and 136 deletions
|
@ -30,14 +30,16 @@ pub fn derive(input: syn::DeriveInput) -> quote::Tokens {
|
|||
computations.append_all(iter.map(|(result, (this, other))| {
|
||||
let field_attrs = cg::parse_field_attrs::<AnimateFieldAttrs>(&result.field);
|
||||
if field_attrs.constant {
|
||||
if cg::is_parameterized(&result.field.ty, where_clause.params) {
|
||||
if cg::is_parameterized(&result.field.ty, where_clause.params, None) {
|
||||
where_clause.inner.predicates.push(cg::where_predicate(
|
||||
result.field.ty.clone(),
|
||||
&["std", "cmp", "PartialEq"],
|
||||
None,
|
||||
));
|
||||
where_clause.inner.predicates.push(cg::where_predicate(
|
||||
result.field.ty.clone(),
|
||||
&["std", "clone", "Clone"],
|
||||
None,
|
||||
));
|
||||
}
|
||||
quote! {
|
||||
|
@ -47,7 +49,7 @@ pub fn derive(input: syn::DeriveInput) -> quote::Tokens {
|
|||
let #result = ::std::clone::Clone::clone(#this);
|
||||
}
|
||||
} else {
|
||||
where_clause.add_trait_bound(result.field.ty.clone());
|
||||
where_clause.add_trait_bound(&result.field.ty);
|
||||
quote! {
|
||||
let #result =
|
||||
::values::animated::Animate::animate(#this, #other, procedure)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue