rust-analyzer expected Expr error
#[derive(Clone, serde::Serialize, serde::Deserialize, specta::Type)]
enum LaunchItemType {
App(String),
File(String),
}
On this code, I'm getting this weird rust-analyzer error: "expected Expr (rust-analyzer) macro-error". I'm new to the Rust world, is there anything I'm missing here?
ps: This error does not prevent from building nor running the app, just shows a red error on the IDE, and removing specta::Type from the derive makes the errors go away.
It's a bug with the rust-nightly rust analyzer as far as I'm aware. The latest commits in specta fixed this. If you rely on a library such as tauri-specta that hasn't been updated to support the latest commits, then I suggest you use this (terrible) workaround:
"rust-analyzer.diagnostics.disabled": [
"macro-error"
],
it'll unfortunately disable any errors coming any proc macros for rust-analyzer, though it shouldn't be a big problem (the rust compiler will throw errors if the proc macro does throw an error)
@LynithDev Yeah I decided to do that yesterday after almost going crazy with those errors. I trust more on the compiler than analyzer for showing those errors
Any advance on this?, I spent all the morning think that this was a misconfiguration on my rust-analyzer
I have also started running into this myself. Sadly I don't have the capcity to fix it right now.
Does anyone know why it happens? I can try and take a look at fixing, but if someone has any insights, they'd be appreciated.
The latest commits in specta fixed this.
Could we get another release so that tauri-specta can update? I tried to use [patch.crates-io] but it doesn't compile unfortunately.
Unfortunately that isn't as easy as it sounds. We have a lot of breaking changes on main which required work from Tauri Specta, rspc, TauRPC, etc to update.
At this stage i'm unable to work on Specta due to time constrains so without external help it's not going to be updated anytime soon.
without external help it's not going to be updated anytime soon.
Any pointers as to where one could start? There seem to be a few people here interested in this so perhaps we can make a collective effort to do this.
@oscartbeaumont @thomaseizinger +1, as I was gonna ask the same.
I will do my best to writeup some more information here when I find some time!
Does the difficulty of updating only apply to the 1.x releases, or can the 2.x-RC releases be updated to resolve this?
I haven't heard reports of people hitting this with Specta v1 but I think it's less used so it's possible it does have this bug.
In terms of releases Specta v1 is locked unless a massive security flaw is found. Specta v2 is where all of the focus is due to my limited ability to even just maintain Specta v2.
I'm hoping the next release of Rust Analyzer with the new trait solver is going to be able to fix this because it's unclear if a new Specta release will actually solve the problem, given as far as I know the Specta macros aren't at fault here.
Any pointers as to where one could start?
Sorry for the delayed response. At this stage I would likely be happy to release the new Specta if we can get Tauri Specta running against main so it's ready. I suspect this will be a non-trival amount of work sadly.
Would https://github.com/rust-lang/rust-analyzer/pull/11193 allow us to disable RA from including Specta? I'm not familiar enough with the ecosystem to know precisely what to configure, but maybe this is a solution that someone else could look into and report back with instructions?
I'm using this as a workaround:
// settings.json
"rust-analyzer.procMacro.ignored": {
"specta_macros": ["Type"]
}
Of course this is for VSCode but it applies to any editor - you just need to figure out how your editor's rust-analyzer extension is configured. It's important to use "specta_macros" as the key.
I personally also disable serde macro expansion for some easy performance gains:
"rust-analyzer.procMacro.ignored": {
"serde_derive": ["Serialize", "Deserialize"],
"specta_macros": ["Type"]
},