Skip to content

Commit ba801cd

Browse files
committed
Use #[automatically_derived] instead of #[coverage(off)]
1 parent 275ba6d commit ba801cd

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
* Fixed incorrect deprecation warning when passing no parameter into `default()` (`init()`) or `initSync()`.
1212
[#4074](https://github.com/rustwasm/wasm-bindgen/pull/4074)
1313

14+
* Fixed many proc-macro generated `impl` blocks missing `#[automatically_derived]`, affecting test coverage.
15+
[#4078](https://github.com/rustwasm/wasm-bindgen/pull/4078)
16+
1417
--------------------------------------------------------------------------------
1518

1619
## [0.2.93](https://github.com/rustwasm/wasm-bindgen/compare/0.2.92...0.2.93)

crates/backend/src/codegen.rs

+24-6
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ impl ToTokens for ast::Struct {
222222
(quote! {
223223
#[automatically_derived]
224224
impl #wasm_bindgen::describe::WasmDescribe for #name {
225-
#[cfg_attr(wasm_bindgen_unstable_test_coverage, coverage(off))]
226225
fn describe() {
227226
use #wasm_bindgen::__wbindgen_if_not_std;
228227
use #wasm_bindgen::describe::*;
@@ -369,7 +368,7 @@ impl ToTokens for ast::Struct {
369368
fn is_none(abi: &Self::Abi) -> bool { *abi == 0 }
370369
}
371370

372-
#[allow(clippy::all)]
371+
#[automatically_derived]
373372
impl #wasm_bindgen::convert::TryFromJsValue for #name {
374373
type Error = #wasm_bindgen::JsValue;
375374

@@ -404,8 +403,8 @@ impl ToTokens for ast::Struct {
404403
}
405404
}
406405

406+
#[automatically_derived]
407407
impl #wasm_bindgen::describe::WasmDescribeVector for #name {
408-
#[cfg_attr(wasm_bindgen_unstable_test_coverage, coverage(off))]
409408
fn describe_vector() {
410409
use #wasm_bindgen::describe::*;
411410
inform(VECTOR);
@@ -415,6 +414,7 @@ impl ToTokens for ast::Struct {
415414
}
416415
}
417416

417+
#[automatically_derived]
418418
impl #wasm_bindgen::convert::VectorIntoWasmAbi for #name {
419419
type Abi = <
420420
#wasm_bindgen::__rt::alloc::boxed::Box<[#wasm_bindgen::JsValue]>
@@ -428,6 +428,7 @@ impl ToTokens for ast::Struct {
428428
}
429429
}
430430

431+
#[automatically_derived]
431432
impl #wasm_bindgen::convert::VectorFromWasmAbi for #name {
432433
type Abi = <
433434
#wasm_bindgen::__rt::alloc::boxed::Box<[#wasm_bindgen::JsValue]>
@@ -441,6 +442,7 @@ impl ToTokens for ast::Struct {
441442
}
442443
}
443444

445+
#[automatically_derived]
444446
impl #wasm_bindgen::__rt::VectorIntoJsValue for #name {
445447
fn vector_into_jsvalue(vector: #wasm_bindgen::__rt::alloc::boxed::Box<[#name]>) -> #wasm_bindgen::JsValue {
446448
#wasm_bindgen::__rt::js_value_vector_into_jsvalue(vector)
@@ -939,13 +941,14 @@ impl ToTokens for ast::ImportType {
939941
use #wasm_bindgen::{JsValue, JsCast, JsObject};
940942
use #wasm_bindgen::__rt::core;
941943

944+
#[automatically_derived]
942945
impl WasmDescribe for #rust_name {
943-
#[cfg_attr(wasm_bindgen_unstable_test_coverage, coverage(off))]
944946
fn describe() {
945947
#description
946948
}
947949
}
948950

951+
#[automatically_derived]
949952
impl IntoWasmAbi for #rust_name {
950953
type Abi = <JsValue as IntoWasmAbi>::Abi;
951954

@@ -955,20 +958,23 @@ impl ToTokens for ast::ImportType {
955958
}
956959
}
957960

961+
#[automatically_derived]
958962
impl OptionIntoWasmAbi for #rust_name {
959963
#[inline]
960964
fn none() -> Self::Abi {
961965
0
962966
}
963967
}
964968

969+
#[automatically_derived]
965970
impl<'a> OptionIntoWasmAbi for &'a #rust_name {
966971
#[inline]
967972
fn none() -> Self::Abi {
968973
0
969974
}
970975
}
971976

977+
#[automatically_derived]
972978
impl FromWasmAbi for #rust_name {
973979
type Abi = <JsValue as FromWasmAbi>::Abi;
974980

@@ -980,11 +986,13 @@ impl ToTokens for ast::ImportType {
980986
}
981987
}
982988

989+
#[automatically_derived]
983990
impl OptionFromWasmAbi for #rust_name {
984991
#[inline]
985992
fn is_none(abi: &Self::Abi) -> bool { *abi == 0 }
986993
}
987994

995+
#[automatically_derived]
988996
impl<'a> IntoWasmAbi for &'a #rust_name {
989997
type Abi = <&'a JsValue as IntoWasmAbi>::Abi;
990998

@@ -994,6 +1002,7 @@ impl ToTokens for ast::ImportType {
9941002
}
9951003
}
9961004

1005+
#[automatically_derived]
9971006
impl RefFromWasmAbi for #rust_name {
9981007
type Abi = <JsValue as RefFromWasmAbi>::Abi;
9991008
type Anchor = core::mem::ManuallyDrop<#rust_name>;
@@ -1007,6 +1016,7 @@ impl ToTokens for ast::ImportType {
10071016
}
10081017
}
10091018

1019+
#[automatically_derived]
10101020
impl LongRefFromWasmAbi for #rust_name {
10111021
type Abi = <JsValue as LongRefFromWasmAbi>::Abi;
10121022
type Anchor = #rust_name;
@@ -1019,31 +1029,36 @@ impl ToTokens for ast::ImportType {
10191029
}
10201030

10211031
// TODO: remove this on the next major version
1032+
#[automatically_derived]
10221033
impl From<JsValue> for #rust_name {
10231034
#[inline]
10241035
fn from(obj: JsValue) -> #rust_name {
10251036
#rust_name { obj: obj.into() }
10261037
}
10271038
}
10281039

1040+
#[automatically_derived]
10291041
impl AsRef<JsValue> for #rust_name {
10301042
#[inline]
10311043
fn as_ref(&self) -> &JsValue { self.obj.as_ref() }
10321044
}
10331045

1046+
#[automatically_derived]
10341047
impl AsRef<#rust_name> for #rust_name {
10351048
#[inline]
10361049
fn as_ref(&self) -> &#rust_name { self }
10371050
}
10381051

10391052

1053+
#[automatically_derived]
10401054
impl From<#rust_name> for JsValue {
10411055
#[inline]
10421056
fn from(obj: #rust_name) -> JsValue {
10431057
obj.obj.into()
10441058
}
10451059
}
10461060

1061+
#[automatically_derived]
10471062
impl JsCast for #rust_name {
10481063
fn instanceof(val: &JsValue) -> bool {
10491064
#[link(wasm_import_module = "__wbindgen_placeholder__")]
@@ -1592,7 +1607,7 @@ impl ToTokens for ast::Enum {
15921607
}
15931608
}
15941609

1595-
#[allow(clippy::all)]
1610+
#[automatically_derived]
15961611
impl #wasm_bindgen::convert::TryFromJsValue for #enum_name {
15971612
type Error = #wasm_bindgen::JsValue;
15981613

@@ -1609,15 +1624,16 @@ impl ToTokens for ast::Enum {
16091624
}
16101625
}
16111626

1627+
#[automatically_derived]
16121628
impl #wasm_bindgen::describe::WasmDescribeVector for #enum_name {
1613-
#[cfg_attr(wasm_bindgen_unstable_test_coverage, coverage(off))]
16141629
fn describe_vector() {
16151630
use #wasm_bindgen::describe::*;
16161631
inform(VECTOR);
16171632
<#wasm_bindgen::JsValue as #wasm_bindgen::describe::WasmDescribe>::describe();
16181633
}
16191634
}
16201635

1636+
#[automatically_derived]
16211637
impl #wasm_bindgen::convert::VectorIntoWasmAbi for #enum_name {
16221638
type Abi = <
16231639
#wasm_bindgen::__rt::alloc::boxed::Box<[#wasm_bindgen::JsValue]>
@@ -1631,6 +1647,7 @@ impl ToTokens for ast::Enum {
16311647
}
16321648
}
16331649

1650+
#[automatically_derived]
16341651
impl #wasm_bindgen::convert::VectorFromWasmAbi for #enum_name {
16351652
type Abi = <
16361653
#wasm_bindgen::__rt::alloc::boxed::Box<[#wasm_bindgen::JsValue]>
@@ -1644,6 +1661,7 @@ impl ToTokens for ast::Enum {
16441661
}
16451662
}
16461663

1664+
#[automatically_derived]
16471665
impl #wasm_bindgen::__rt::VectorIntoJsValue for #enum_name {
16481666
fn vector_into_jsvalue(vector: #wasm_bindgen::__rt::alloc::boxed::Box<[#enum_name]>) -> #wasm_bindgen::JsValue {
16491667
#wasm_bindgen::__rt::js_value_vector_into_jsvalue(vector)

0 commit comments

Comments
 (0)