Skip to content

chore: mark TypeInfo derived impl as automatically_derived #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ impl TypeInfoImpl {
});

Ok(quote! {
#[automatically_derived]
impl #impl_generics #scale_info::TypeInfo for #ident #ty_generics #where_clause {
type Identity = Self;
fn type_info() -> #scale_info::Type {
Expand Down
4 changes: 2 additions & 2 deletions derive/src/trait_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ fn type_contains_idents(ty: &Type, idents: &[Ident]) -> bool {
idents: &'a [Ident],
}

impl<'a, 'ast> Visit<'ast> for ContainIdents<'a> {
impl<'ast> Visit<'ast> for ContainIdents<'_> {
fn visit_ident(&mut self, i: &'ast Ident) {
if self.idents.iter().any(|id| id == i) {
self.result = true;
Expand All @@ -145,7 +145,7 @@ fn type_or_sub_type_path_starts_with_ident(ty: &Type, ident: &Ident) -> bool {
ident: &'a Ident,
}

impl<'a, 'ast> Visit<'ast> for TypePathStartsWithIdent<'a> {
impl<'ast> Visit<'ast> for TypePathStartsWithIdent<'_> {
fn visit_type_path(&mut self, i: &'ast TypePath) {
if i.qself.is_none() {
if let Some(segment) = i.path.segments.first() {
Expand Down
6 changes: 3 additions & 3 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ fn basic_enum_with_index() {
#[allow(unused)]
#[derive(Encode)]
enum IndexedRustEnum {
#[codec(index = 3)]
#[codec(index = 4)]
A(bool),
#[codec(index = 0)]
B {
Expand All @@ -312,7 +312,7 @@ fn basic_enum_with_index() {
.variant(
Variants::new()
.variant("A", |v| {
v.index(3).fields(
v.index(4).fields(
Fields::unnamed().field(|f| f.ty::<bool>().type_name("bool")),
)
})
Expand All @@ -338,7 +338,7 @@ fn basic_enum_with_index() {
.variant(
Variants::new()
.variant("A", |v| {
v.index(3)
v.index(4)
.fields(Fields::unnamed().field(|f| f.ty::<bool>().type_name("bool")))
})
.variant("B", |v| {
Expand Down
2 changes: 1 addition & 1 deletion test_suite/tests/ui/fail_missing_derive.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ error[E0277]: the trait bound `PawType<u16>: TypeInfo` is not satisfied
--> tests/ui/fail_missing_derive.rs:19:24
|
19 | assert_type_info::<Cat<bool, u8, u16>>();
| ^^^^^^^^^^^^^^^^^^ the trait `TypeInfo` is not implemented for `PawType<u16>`, which is required by `Cat<bool, u8, u16>: TypeInfo`
| ^^^^^^^^^^^^^^^^^^ the trait `TypeInfo` is not implemented for `PawType<u16>`
|
= help: the following other types implement trait `TypeInfo`:
&T
Expand Down
Loading