Skip to content

Commit 7629a7f

Browse files
chore: mark TypeInfo derived impl as automatically_derived (#218)
* chore: mark TypeInfo derived impl as automatically_derived As per rust-lang/rust#120185, functions with their enclosing impl body marked as `#[automatically_derived]` won't be featured in coverage reports. * chore: elide lifetimes * Update tests.rs paritytech/parity-scale-codec/pull/653 disallowed duplicate indexes for variants. * fix: ui tests were outdated
1 parent 2582cc3 commit 7629a7f

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

derive/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ impl TypeInfoImpl {
110110
});
111111

112112
Ok(quote! {
113+
#[automatically_derived]
113114
impl #impl_generics #scale_info::TypeInfo for #ident #ty_generics #where_clause {
114115
type Identity = Self;
115116
fn type_info() -> #scale_info::Type {

derive/src/trait_bounds.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ fn type_contains_idents(ty: &Type, idents: &[Ident]) -> bool {
121121
idents: &'a [Ident],
122122
}
123123

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

148-
impl<'a, 'ast> Visit<'ast> for TypePathStartsWithIdent<'a> {
148+
impl<'ast> Visit<'ast> for TypePathStartsWithIdent<'_> {
149149
fn visit_type_path(&mut self, i: &'ast TypePath) {
150150
if i.qself.is_none() {
151151
if let Some(segment) = i.path.segments.first() {

src/tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ fn basic_enum_with_index() {
294294
#[allow(unused)]
295295
#[derive(Encode)]
296296
enum IndexedRustEnum {
297-
#[codec(index = 3)]
297+
#[codec(index = 4)]
298298
A(bool),
299299
#[codec(index = 0)]
300300
B {
@@ -312,7 +312,7 @@ fn basic_enum_with_index() {
312312
.variant(
313313
Variants::new()
314314
.variant("A", |v| {
315-
v.index(3).fields(
315+
v.index(4).fields(
316316
Fields::unnamed().field(|f| f.ty::<bool>().type_name("bool")),
317317
)
318318
})
@@ -338,7 +338,7 @@ fn basic_enum_with_index() {
338338
.variant(
339339
Variants::new()
340340
.variant("A", |v| {
341-
v.index(3)
341+
v.index(4)
342342
.fields(Fields::unnamed().field(|f| f.ty::<bool>().type_name("bool")))
343343
})
344344
.variant("B", |v| {

test_suite/tests/ui/fail_missing_derive.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0277]: the trait bound `PawType<u16>: TypeInfo` is not satisfied
22
--> tests/ui/fail_missing_derive.rs:19:24
33
|
44
19 | assert_type_info::<Cat<bool, u8, u16>>();
5-
| ^^^^^^^^^^^^^^^^^^ the trait `TypeInfo` is not implemented for `PawType<u16>`, which is required by `Cat<bool, u8, u16>: TypeInfo`
5+
| ^^^^^^^^^^^^^^^^^^ the trait `TypeInfo` is not implemented for `PawType<u16>`
66
|
77
= help: the following other types implement trait `TypeInfo`:
88
&T

0 commit comments

Comments
 (0)