Open FredrikNoren opened 10 months ago
yup I get this too, would be good if we get a solution for this
有一个办法,在文件第一行加上下面的代码,就可以不显示警告了。
#![allow(non_snake_case)]
有一个办法,在文件第一行加上下面的代码,就可以不显示警告了。
#![allow(non_snake_case)]
this not a good approach and is overall discouraged by the community to change compiler settings
the solution is that the maintainers fix the underlying cause
Last code update has been 8 months ago, there are PR stuck since July, is this crate dead?
This seems like a rust-analyzer issue. The ___wbg_instanceof is from wasm-bindgen for JsCast
and the surrounding block has #[automatically_derived]
which should suppress this kind of warnings
This might be a workaround:
#[allow(non_snake_case)]
mod tsify_derive {
use super::*;
#[derive(Tsify, Serialize, Deserialize)]
#[tsify(into_wasm_abi, from_wasm_abi)]
pub struct MyStruct {
...
}
}
pub use tsify_derive::MyStruct;
Or make a proc macro that does this for you (I just typed it ad-hoc so there might be a few errors, but the idea is there)
use quote::quote;
use proc_macro2::{Ident, Span};
use syn::parse_macro_input;
#[proc_macro_attr]
pub fn suppress_derive_case_warnings(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let parsed = parse_macro_input!(input as DeriveInput);
let name = &parsed.ident;
let vis = &parsed.vis;
let mod_name = Ident::new(&format!("__tsify_mod_{}", name), Span::call_site());
let expanded = quote! {
#[allow(non_snake_case)]
#[automatically_derived]
mod #mod_name {
use super::*;
#parsed
}
#vis use #mod_name::#name;
};
expanded.into()
}
Then use it like this
#[suppress_derive_case_warnings]
#[derive(Tsify, Serialize, Deserialize)]
#[tsify(into_wasm_abi, from_wasm_abi)]
pub struct MyStruct {
...
}
I am only getting this error with rust-analyzer using VS Code, the error itself is not coming from my Rust installation.
I was able to suppress the error with the VS Code setting:
"rust-analyzer.diagnostics.disabled": ["non_snake_case"]
Also needed to restart the rust-analyzer language server.
I'm getting the following warning on all structs that have Tsify: