Feature request: Omit warnings for serde attributes that can safely be ignored
Is your feature request related to a problem? Please describe. Currently, ts-rs outputs warnings when a field has some attributes that it doesn't know how to handle:
warning: failed to parse serde attribute
|
| borrow
|
= note: ts-rs failed to parse this attribute. It will be ignored.
But #[serde(borrow)] is a fairly common attribute, for serializing without cloning the value, specially for String and &str.
Describe the solution you'd like For attributes that we know can safely be ignored, ideally the warnings would not be emitted.
Describe alternatives you've considered The alternative would be to use the hide all warnings option, but I think this would be even worse than having some warnings that we know are not breaking the generation.
Additional context Example code:
use serde::Serialize;
use ts_rs::TS;
#[derive(Serialize, TS)]
struct Wibble<'a> {
#[serde(borrow)]
wobble: &'a str,
}
fn main() {}
Outputs:
$ cargo b
Compiling sandbox v0.1.0 (--)
warning: failed to parse serde attribute
|
| borrow
|
= note: ts-rs failed to parse this attribute. It will be ignored.
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.39s
Thanks for ts-rs! It's really useful.
Hey @prscoelho! You can run cargo test --features no-serde-warnings to silence all warnings related to serde compatibility
The alternative would be to use the hide all warnings option, but I think this would be even worse than having some warnings that we know are not breaking the generation.
Nevermind, I just read this part lol. In general you don't need to worry about this though, when something actually breaks the type generation it will usually cause a compiler error
If you think using no-serde-warnings is fine I'll use it! I was afraid of hiding real problems, but if they show up as actual compilation errors if there's issues then it should be fine.
I just hate that we STILL don't have a diagnostic API for proc macros..
it might make sense to actually parse #[serde(borrow)] though, since it won't affect the bindings.