-
Notifications
You must be signed in to change notification settings - Fork 43
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
Rust-analyzer marks structs with snake-case warning #42
Comments
yup I get this too, would be good if we get a solution for this |
有一个办法,在文件第一行加上下面的代码,就可以不显示警告了。 #![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 |
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:
The text was updated successfully, but these errors were encountered: