Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove HasCompact::Type bounds
A speculative PR to see whether I can remove some `HasCompact::Type: TypeInfo` bounds I had to add to some impls in substrate.
  • Loading branch information
ascjones committed Apr 12, 2021
commit 53d0d64b26a23ed99700646d98e31e3d7780cc02
3 changes: 0 additions & 3 deletions derive/src/trait_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ pub fn make_where_clause<'a>(
where_clause
.predicates
.push(parse_quote!(#ty : :: #parity_scale_codec ::HasCompact));
where_clause
.predicates
.push(parse_quote!(<#ty as :: #parity_scale_codec ::HasCompact>::Type : :: #scale_info ::TypeInfo + 'static));
} else {
where_clause
.predicates
Expand Down
6 changes: 2 additions & 4 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ impl FieldsBuilder<NamedFields> {
/// Add a named, [`Compact`] field of type `T`.
pub fn compact_of<T>(mut self, name: &'static str, type_name: &'static str) -> Self
where
T: scale::HasCompact,
<T as scale::HasCompact>::Type: TypeInfo + 'static,
T: scale::HasCompact + TypeInfo + 'static,
{
self.fields
.push(Field::compact_of::<T>(Some(name), type_name));
Expand All @@ -285,8 +284,7 @@ impl FieldsBuilder<UnnamedFields> {
/// Add an unnamed, [`Compact`] field of type `T`.
pub fn compact_of<T>(mut self, type_name: &'static str) -> Self
where
T: scale::HasCompact,
<T as scale::HasCompact>::Type: TypeInfo + 'static,
T: scale::HasCompact + TypeInfo + 'static,
{
self.fields.push(Field::compact_of::<T>(None, type_name));
self
Expand Down
5 changes: 2 additions & 3 deletions src/ty/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,9 @@ impl Field {
/// Creates a new [`Compact`] field.
pub fn compact_of<T>(name: Option<&'static str>, type_name: &'static str) -> Field
where
T: HasCompact,
<T as HasCompact>::Type: TypeInfo + 'static,
T: HasCompact + TypeInfo + 'static,
{
Self::new(name, MetaType::new::<<T as HasCompact>::Type>(), type_name)
Self::new(name, MetaType::new::<scale::Compact<T>>(), type_name)
}
}

Expand Down