Skip to content
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

Fails to build with rust 1.78 #37

Closed
nappa85 opened this issue May 2, 2024 · 5 comments
Closed

Fails to build with rust 1.78 #37

nappa85 opened this issue May 2, 2024 · 5 comments

Comments

@nappa85
Copy link

nappa85 commented May 2, 2024

Since upgrading to rust 1.78, every build fails with a lot of similar errors:

error: empty doc comment
   --> src/main.rs:139:14
    |
139 |     #[derive(tsify_next::Tsify)]
    |              ^^^^^^^^^^^^^^^^^
    |
    = help: consider removing or filling it
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_docs
    = note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info)
@siefkenj
Copy link
Owner

siefkenj commented May 2, 2024

Very strange. Can you run cargo expand on the source and compile that? It may point to the specific culprit.

@nappa85
Copy link
Author

nappa85 commented May 2, 2024

I need to correct myself, the warning originates from clippy, not any build, and it happens any clippy warning becomes an error in my CI, sorry for that.

I've tried with a simple example:

#[derive(tsify_next::Tsify)]
pub struct Identified<Id, Value> {
    pub id: Id,
    pub value: Value,
}

expands to

#![feature(prelude_import)]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;
pub struct Identified<Id, Value> {
    pub id: Id,
    pub value: Value,
}
#[automatically_derived]
const _: () = {
    use tsify_next::Tsify;
    use wasm_bindgen::{
        convert::{
            FromWasmAbi, IntoWasmAbi, OptionFromWasmAbi, OptionIntoWasmAbi,
            RefFromWasmAbi,
        },
        describe::WasmDescribe, prelude::*,
    };
    #[automatically_derived]
    ///
    #[repr(transparent)]
    pub struct JsType {
        obj: wasm_bindgen::JsValue,
    }
    #[automatically_derived]
    const _: () = {
        use wasm_bindgen::convert::TryFromJsValue;
        use wasm_bindgen::convert::{IntoWasmAbi, FromWasmAbi};
        use wasm_bindgen::convert::{OptionIntoWasmAbi, OptionFromWasmAbi};
        use wasm_bindgen::convert::{RefFromWasmAbi, LongRefFromWasmAbi};
        use wasm_bindgen::describe::WasmDescribe;
        use wasm_bindgen::{JsValue, JsCast, JsObject};
        use wasm_bindgen::__rt::core;
        impl WasmDescribe for JsType {
            fn describe() {
                use wasm_bindgen::describe::*;
                inform(NAMED_EXTERNREF);
                inform(10u32);
                inform(73u32);
                inform(100u32);
                inform(101u32);
                inform(110u32);
                inform(116u32);
                inform(105u32);
                inform(102u32);
                inform(105u32);
                inform(101u32);
                inform(100u32);
            }
        }
        impl IntoWasmAbi for JsType {
            type Abi = <JsValue as IntoWasmAbi>::Abi;
            #[inline]
            fn into_abi(self) -> Self::Abi {
                self.obj.into_abi()
            }
        }
        impl OptionIntoWasmAbi for JsType {
            #[inline]
            fn none() -> Self::Abi {
                0
            }
        }
        impl<'a> OptionIntoWasmAbi for &'a JsType {
            #[inline]
            fn none() -> Self::Abi {
                0
            }
        }
        impl FromWasmAbi for JsType {
            type Abi = <JsValue as FromWasmAbi>::Abi;
            #[inline]
            unsafe fn from_abi(js: Self::Abi) -> Self {
                JsType {
                    obj: JsValue::from_abi(js).into(),
                }
            }
        }
        impl OptionFromWasmAbi for JsType {
            #[inline]
            fn is_none(abi: &Self::Abi) -> bool {
                *abi == 0
            }
        }
        impl<'a> IntoWasmAbi for &'a JsType {
            type Abi = <&'a JsValue as IntoWasmAbi>::Abi;
            #[inline]
            fn into_abi(self) -> Self::Abi {
                (&self.obj).into_abi()
            }
        }
        impl RefFromWasmAbi for JsType {
            type Abi = <JsValue as RefFromWasmAbi>::Abi;
            type Anchor = core::mem::ManuallyDrop<JsType>;
            #[inline]
            unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor {
                let tmp = <JsValue as RefFromWasmAbi>::ref_from_abi(js);
                core::mem::ManuallyDrop::new(JsType {
                    obj: core::mem::ManuallyDrop::into_inner(tmp).into(),
                })
            }
        }
        impl LongRefFromWasmAbi for JsType {
            type Abi = <JsValue as LongRefFromWasmAbi>::Abi;
            type Anchor = JsType;
            #[inline]
            unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor {
                let tmp = <JsValue as LongRefFromWasmAbi>::long_ref_from_abi(js);
                JsType { obj: tmp.into() }
            }
        }
        impl From<JsValue> for JsType {
            #[inline]
            fn from(obj: JsValue) -> JsType {
                JsType { obj: obj.into() }
            }
        }
        impl AsRef<JsValue> for JsType {
            #[inline]
            fn as_ref(&self) -> &JsValue {
                self.obj.as_ref()
            }
        }
        impl AsRef<JsType> for JsType {
            #[inline]
            fn as_ref(&self) -> &JsType {
                self
            }
        }
        impl From<JsType> for JsValue {
            #[inline]
            fn from(obj: JsType) -> JsValue {
                obj.obj.into()
            }
        }
        impl JsCast for JsType {
            fn instanceof(val: &JsValue) -> bool {
                #[cfg(
                    not(
                        all(
                            target_arch = "wasm32",
                            not(any(target_os = "emscripten", target_os = "wasi"))
                        )
                    )
                )]
                unsafe fn __wbg_instanceof_JsType_d5b10ea09f1d9e1c(_: u32) -> u32 {
                    {
                        ::std::rt::begin_panic(
                            "cannot check instanceof on non-wasm targets",
                        );
                    };
                }
                unsafe {
                    let idx = val.into_abi();
                    __wbg_instanceof_JsType_d5b10ea09f1d9e1c(idx) != 0
                }
            }
            #[inline]
            fn unchecked_from_js(val: JsValue) -> Self {
                JsType { obj: val.into() }
            }
            #[inline]
            fn unchecked_from_js_ref(val: &JsValue) -> &Self {
                unsafe { &*(val as *const JsValue as *const JsType) }
            }
        }
        impl JsObject for JsType {}
    };
    #[automatically_derived]
    impl core::ops::Deref for JsType {
        type Target = wasm_bindgen::JsValue;
        #[inline]
        fn deref(&self) -> &wasm_bindgen::JsValue {
            &self.obj
        }
    }
    impl<Id, Value> Tsify for Identified<Id, Value> {
        type JsType = JsType;
        const DECL: &'static str = "export interface Identified<Id, Value> {\n    id: Id;\n    value: Value;\n}";
        const SERIALIZATION_CONFIG: tsify_next::SerializationConfig = tsify_next::SerializationConfig {
            missing_as_null: false,
            hashmap_as_object: false,
            large_number_types_as_bigints: false,
        };
    }
};

As you can see, there is an empty doc comment before struct JsType

    #[automatically_derived]
    ///
    #[repr(transparent)]
    pub struct JsType {
        obj: wasm_bindgen::JsValue,
    }

@siefkenj
Copy link
Owner

siefkenj commented May 2, 2024

I don't see that anywhere in the source of tsify. Maybe its a wasm_bindgen issue like clippy suggested? The closest place is

Perhaps #[wasm_bindgen(typescript_type = #typescript_type)] is doing the wrong thing?

@siefkenj
Copy link
Owner

siefkenj commented May 2, 2024

This just started happening in my CI as well. It must be a wasm_bindgen change because I didn't change anything else...

See: rustwasm/wasm-bindgen#3945

@nappa85
Copy link
Author

nappa85 commented May 3, 2024

Ok, I think we can close here

@nappa85 nappa85 closed this as completed May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants