Skip to content

Commit 219fbd9

Browse files
author
Ari Breitkreuz
committed
Turn off coverage where possible
1 parent 76c48f1 commit 219fbd9

File tree

7 files changed

+30
-0
lines changed

7 files changed

+30
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ spans = ["wasm-bindgen-macro/spans"]
2626
std = []
2727
serde-serialize = ["serde", "serde_json", "std"]
2828
enable-interning = ["std"]
29+
unstable-coverage = ["wasm-bindgen-macro/unstable-coverage"]
2930

3031
# Whether or not the `#[wasm_bindgen]` macro is strict and generates an error on
3132
# all unused attributes

crates/backend/src/codegen.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ impl ToTokens for ast::Struct {
173173
(quote! {
174174
#[automatically_derived]
175175
impl #wasm_bindgen::describe::WasmDescribe for #name {
176+
#[cfg_attr(feature = "unstable-coverage", allow_internal_unstable(coverage_attribute))]
176177
fn describe() {
177178
use #wasm_bindgen::__wbindgen_if_not_std;
178179
__wbindgen_if_not_std! {
@@ -835,6 +836,7 @@ impl ToTokens for ast::ImportType {
835836
use #wasm_bindgen::__rt::core;
836837

837838
impl WasmDescribe for #rust_name {
839+
#[cfg_attr(feature = "unstable-coverage", allow_internal_unstable(coverage_attribute))]
838840
fn describe() {
839841
#description
840842
}
@@ -1082,6 +1084,7 @@ impl ToTokens for ast::ImportEnum {
10821084
// It should really be using &str for all of these, but that requires some major changes to cli-support
10831085
#[automatically_derived]
10841086
impl #wasm_bindgen::describe::WasmDescribe for #name {
1087+
#[cfg_attr(feature = "unstable-coverage", allow_internal_unstable(coverage_attribute))]
10851088
fn describe() {
10861089
<#wasm_bindgen::JsValue as #wasm_bindgen::describe::WasmDescribe>::describe()
10871090
}
@@ -1441,6 +1444,7 @@ impl ToTokens for ast::Enum {
14411444

14421445
#[automatically_derived]
14431446
impl #wasm_bindgen::describe::WasmDescribe for #enum_name {
1447+
#[cfg_attr(feature = "unstable-coverage", allow_internal_unstable(coverage_attribute))]
14441448
fn describe() {
14451449
use #wasm_bindgen::describe::*;
14461450
inform(ENUM);
@@ -1606,6 +1610,7 @@ impl<'a, T: ToTokens> ToTokens for Descriptor<'a, T> {
16061610
#(#attrs)*
16071611
#[no_mangle]
16081612
#[doc(hidden)]
1613+
#[cfg_attr(feature = "unstable-coverage", allow_internal_unstable(coverage_attribute))]
16091614
pub extern "C" fn #name() {
16101615
use #wasm_bindgen::describe::*;
16111616
// See definition of `link_mem_intrinsics` for what this is doing

crates/macro/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ proc-macro = true
1919
spans = ["wasm-bindgen-macro-support/spans"]
2020
xxx_debug_only_print_generated_code = []
2121
strict-macro = ["wasm-bindgen-macro-support/strict-macro"]
22+
unstable-coverage = []
2223

2324
[dependencies]
2425
wasm-bindgen-macro-support = { path = "../macro-support", version = "=0.2.90" }

src/closure.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ impl<T> WasmDescribe for Closure<T>
465465
where
466466
T: WasmClosure + ?Sized,
467467
{
468+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
468469
fn describe() {
469470
inform(EXTERNREF);
470471
}
@@ -565,6 +566,7 @@ macro_rules! doit {
565566
where $($var: FromWasmAbi + 'static,)*
566567
R: ReturnWasmAbi + 'static,
567568
{
569+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
568570
fn describe() {
569571
#[allow(non_snake_case)]
570572
unsafe extern "C" fn invoke<$($var: FromWasmAbi,)* R: ReturnWasmAbi>(
@@ -622,6 +624,7 @@ macro_rules! doit {
622624
where $($var: FromWasmAbi + 'static,)*
623625
R: ReturnWasmAbi + 'static,
624626
{
627+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
625628
fn describe() {
626629
#[allow(non_snake_case)]
627630
unsafe extern "C" fn invoke<$($var: FromWasmAbi,)* R: ReturnWasmAbi>(
@@ -763,6 +766,7 @@ where
763766
A: RefFromWasmAbi,
764767
R: ReturnWasmAbi + 'static,
765768
{
769+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
766770
fn describe() {
767771
#[allow(non_snake_case)]
768772
unsafe extern "C" fn invoke<A: RefFromWasmAbi, R: ReturnWasmAbi>(
@@ -809,6 +813,7 @@ where
809813
A: RefFromWasmAbi,
810814
R: ReturnWasmAbi + 'static,
811815
{
816+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
812817
fn describe() {
813818
#[allow(non_snake_case)]
814819
unsafe extern "C" fn invoke<A: RefFromWasmAbi, R: ReturnWasmAbi>(

src/convert/closures.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ macro_rules! stack_closures {
5454
where $($var: FromWasmAbi,)*
5555
R: ReturnWasmAbi
5656
{
57+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
5758
fn describe() {
5859
inform(FUNCTION);
5960
inform($invoke::<$($var,)* R> as u32);
@@ -108,6 +109,7 @@ macro_rules! stack_closures {
108109
where $($var: FromWasmAbi,)*
109110
R: ReturnWasmAbi
110111
{
112+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
111113
fn describe() {
112114
inform(FUNCTION);
113115
inform($invoke_mut::<$($var,)* R> as u32);
@@ -177,6 +179,7 @@ where
177179
A: RefFromWasmAbi,
178180
R: ReturnWasmAbi,
179181
{
182+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
180183
fn describe() {
181184
inform(FUNCTION);
182185
inform(invoke1_ref::<A, R> as u32);
@@ -232,6 +235,7 @@ where
232235
A: RefFromWasmAbi,
233236
R: ReturnWasmAbi,
234237
{
238+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
235239
fn describe() {
236240
inform(FUNCTION);
237241
inform(invoke1_mut_ref::<A, R> as u32);

src/describe.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ pub trait WasmDescribeVector {
6666
macro_rules! simple {
6767
($($t:ident => $d:ident)*) => ($(
6868
impl WasmDescribe for $t {
69+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
6970
fn describe() { inform($d) }
7071
}
7172
)*)
@@ -103,32 +104,37 @@ cfg_if! {
103104
}
104105

105106
impl<T> WasmDescribe for *const T {
107+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
106108
fn describe() {
107109
inform(U32)
108110
}
109111
}
110112

111113
impl<T> WasmDescribe for *mut T {
114+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
112115
fn describe() {
113116
inform(U32)
114117
}
115118
}
116119

117120
impl<T: WasmDescribe> WasmDescribe for [T] {
121+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
118122
fn describe() {
119123
inform(SLICE);
120124
T::describe();
121125
}
122126
}
123127

124128
impl<'a, T: WasmDescribe + ?Sized> WasmDescribe for &'a T {
129+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
125130
fn describe() {
126131
inform(REF);
127132
T::describe();
128133
}
129134
}
130135

131136
impl<'a, T: WasmDescribe + ?Sized> WasmDescribe for &'a mut T {
137+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
132138
fn describe() {
133139
inform(REFMUT);
134140
T::describe();
@@ -166,46 +172,53 @@ if_std! {
166172
}
167173

168174
impl<T: WasmDescribeVector> WasmDescribe for Box<[T]> {
175+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
169176
fn describe() {
170177
T::describe_vector();
171178
}
172179
}
173180

174181
impl<T> WasmDescribe for Vec<T> where Box<[T]>: WasmDescribe {
182+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
175183
fn describe() {
176184
<Box<[T]>>::describe();
177185
}
178186
}
179187
}
180188

181189
impl<T: WasmDescribe> WasmDescribe for Option<T> {
190+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
182191
fn describe() {
183192
inform(OPTIONAL);
184193
T::describe();
185194
}
186195
}
187196

188197
impl WasmDescribe for () {
198+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
189199
fn describe() {
190200
inform(UNIT)
191201
}
192202
}
193203

194204
impl<T: WasmDescribe, E: Into<JsValue>> WasmDescribe for Result<T, E> {
205+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
195206
fn describe() {
196207
inform(RESULT);
197208
T::describe();
198209
}
199210
}
200211

201212
impl<T: WasmDescribe> WasmDescribe for Clamped<T> {
213+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
202214
fn describe() {
203215
inform(CLAMPED);
204216
T::describe();
205217
}
206218
}
207219

208220
impl WasmDescribe for JsError {
221+
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
209222
fn describe() {
210223
JsValue::describe();
211224
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#![no_std]
99
#![allow(coherence_leak_check)]
1010
#![doc(html_root_url = "https://docs.rs/wasm-bindgen/0.2")]
11+
#![cfg_attr(feature = "unstable-coverage", feature(coverage_attribute))]
1112

1213
use core::convert::TryFrom;
1314
use core::fmt;

0 commit comments

Comments
 (0)