Skip to content

Commit

Permalink
Turn off coverage where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
aDogCalledSpot committed Jan 16, 2024
1 parent 76c48f1 commit 219fbd9
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -26,6 +26,7 @@ spans = ["wasm-bindgen-macro/spans"]
std = []
serde-serialize = ["serde", "serde_json", "std"]
enable-interning = ["std"]
unstable-coverage = ["wasm-bindgen-macro/unstable-coverage"]

# Whether or not the `#[wasm_bindgen]` macro is strict and generates an error on
# all unused attributes
Expand Down
5 changes: 5 additions & 0 deletions crates/backend/src/codegen.rs
Expand Up @@ -173,6 +173,7 @@ impl ToTokens for ast::Struct {
(quote! {
#[automatically_derived]
impl #wasm_bindgen::describe::WasmDescribe for #name {
#[cfg_attr(feature = "unstable-coverage", allow_internal_unstable(coverage_attribute))]
fn describe() {
use #wasm_bindgen::__wbindgen_if_not_std;
__wbindgen_if_not_std! {
Expand Down Expand Up @@ -835,6 +836,7 @@ impl ToTokens for ast::ImportType {
use #wasm_bindgen::__rt::core;

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

#[automatically_derived]
impl #wasm_bindgen::describe::WasmDescribe for #enum_name {
#[cfg_attr(feature = "unstable-coverage", allow_internal_unstable(coverage_attribute))]
fn describe() {
use #wasm_bindgen::describe::*;
inform(ENUM);
Expand Down Expand Up @@ -1606,6 +1610,7 @@ impl<'a, T: ToTokens> ToTokens for Descriptor<'a, T> {
#(#attrs)*
#[no_mangle]
#[doc(hidden)]
#[cfg_attr(feature = "unstable-coverage", allow_internal_unstable(coverage_attribute))]
pub extern "C" fn #name() {
use #wasm_bindgen::describe::*;
// See definition of `link_mem_intrinsics` for what this is doing
Expand Down
1 change: 1 addition & 0 deletions crates/macro/Cargo.toml
Expand Up @@ -19,6 +19,7 @@ proc-macro = true
spans = ["wasm-bindgen-macro-support/spans"]
xxx_debug_only_print_generated_code = []
strict-macro = ["wasm-bindgen-macro-support/strict-macro"]
unstable-coverage = []

[dependencies]
wasm-bindgen-macro-support = { path = "../macro-support", version = "=0.2.90" }
Expand Down
5 changes: 5 additions & 0 deletions src/closure.rs
Expand Up @@ -465,6 +465,7 @@ impl<T> WasmDescribe for Closure<T>
where
T: WasmClosure + ?Sized,
{
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() {
inform(EXTERNREF);
}
Expand Down Expand Up @@ -565,6 +566,7 @@ macro_rules! doit {
where $($var: FromWasmAbi + 'static,)*
R: ReturnWasmAbi + 'static,
{
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() {
#[allow(non_snake_case)]
unsafe extern "C" fn invoke<$($var: FromWasmAbi,)* R: ReturnWasmAbi>(
Expand Down Expand Up @@ -622,6 +624,7 @@ macro_rules! doit {
where $($var: FromWasmAbi + 'static,)*
R: ReturnWasmAbi + 'static,
{
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() {
#[allow(non_snake_case)]
unsafe extern "C" fn invoke<$($var: FromWasmAbi,)* R: ReturnWasmAbi>(
Expand Down Expand Up @@ -763,6 +766,7 @@ where
A: RefFromWasmAbi,
R: ReturnWasmAbi + 'static,
{
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() {
#[allow(non_snake_case)]
unsafe extern "C" fn invoke<A: RefFromWasmAbi, R: ReturnWasmAbi>(
Expand Down Expand Up @@ -809,6 +813,7 @@ where
A: RefFromWasmAbi,
R: ReturnWasmAbi + 'static,
{
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() {
#[allow(non_snake_case)]
unsafe extern "C" fn invoke<A: RefFromWasmAbi, R: ReturnWasmAbi>(
Expand Down
4 changes: 4 additions & 0 deletions src/convert/closures.rs
Expand Up @@ -54,6 +54,7 @@ macro_rules! stack_closures {
where $($var: FromWasmAbi,)*
R: ReturnWasmAbi
{
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() {
inform(FUNCTION);
inform($invoke::<$($var,)* R> as u32);
Expand Down Expand Up @@ -108,6 +109,7 @@ macro_rules! stack_closures {
where $($var: FromWasmAbi,)*
R: ReturnWasmAbi
{
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() {
inform(FUNCTION);
inform($invoke_mut::<$($var,)* R> as u32);
Expand Down Expand Up @@ -177,6 +179,7 @@ where
A: RefFromWasmAbi,
R: ReturnWasmAbi,
{
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() {
inform(FUNCTION);
inform(invoke1_ref::<A, R> as u32);
Expand Down Expand Up @@ -232,6 +235,7 @@ where
A: RefFromWasmAbi,
R: ReturnWasmAbi,
{
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() {
inform(FUNCTION);
inform(invoke1_mut_ref::<A, R> as u32);
Expand Down
13 changes: 13 additions & 0 deletions src/describe.rs
Expand Up @@ -66,6 +66,7 @@ pub trait WasmDescribeVector {
macro_rules! simple {
($($t:ident => $d:ident)*) => ($(
impl WasmDescribe for $t {
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() { inform($d) }
}
)*)
Expand Down Expand Up @@ -103,32 +104,37 @@ cfg_if! {
}

impl<T> WasmDescribe for *const T {
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() {
inform(U32)
}
}

impl<T> WasmDescribe for *mut T {
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() {
inform(U32)
}
}

impl<T: WasmDescribe> WasmDescribe for [T] {
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() {
inform(SLICE);
T::describe();
}
}

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

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

impl<T: WasmDescribeVector> WasmDescribe for Box<[T]> {
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() {
T::describe_vector();
}
}

impl<T> WasmDescribe for Vec<T> where Box<[T]>: WasmDescribe {
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() {
<Box<[T]>>::describe();
}
}
}

impl<T: WasmDescribe> WasmDescribe for Option<T> {
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() {
inform(OPTIONAL);
T::describe();
}
}

impl WasmDescribe for () {
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() {
inform(UNIT)
}
}

impl<T: WasmDescribe, E: Into<JsValue>> WasmDescribe for Result<T, E> {
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() {
inform(RESULT);
T::describe();
}
}

impl<T: WasmDescribe> WasmDescribe for Clamped<T> {
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() {
inform(CLAMPED);
T::describe();
}
}

impl WasmDescribe for JsError {
#[cfg_attr(feature = "unstable-coverage", coverage(off))]
fn describe() {
JsValue::describe();
}
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Expand Up @@ -8,6 +8,7 @@
#![no_std]
#![allow(coherence_leak_check)]
#![doc(html_root_url = "https://docs.rs/wasm-bindgen/0.2")]
#![cfg_attr(feature = "unstable-coverage", feature(coverage_attribute))]

use core::convert::TryFrom;
use core::fmt;
Expand Down

0 comments on commit 219fbd9

Please sign in to comment.