GREsau / schemars

Generate JSON Schema documents from Rust code
https://graham.cool/schemars/
MIT License
826 stars 229 forks source link

Rust-analyzer lsp server now gives me macro error #329

Closed miseyu closed 2 months ago

miseyu commented 2 months ago

Overview

unexpected token rust-analyzer[macro-error](https://rust-analyzer.github.io/manual.html#macro-error)
#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)]
#[serde(rename_all = "camelCase")]
pub(super) struct Operation {
    pub(super) attribute: String,
    pub(super) method: Method,
    pub(super) value: Option<Expr>,
}
GREsau commented 2 months ago

I can reproduce this with both schemars 0.8 and 1.0.0-alpha, but only when using rust-analyzer v0.3.2086. When replacing the derive with the code that it expands to, rust-analyzer has no problems parsing it, which suggests to me that this is a bug in rust-analyzer.

I've raised this as an issue in rust-analyzer here: https://github.com/rust-lang/rust-analyzer/issues/17968

For now, the only workaround I can suggest is to downgrade rust-analyzer to the previous version (v0.3.2078), which does not have this problem.

miseyu commented 2 months ago

@GREsau Thank you for your confirmation! Also, thanks for creating the issue! The compilation passes, so there is no problem once it is done! CI will try to support it by lowering the version. Thank you for your patience!

GREsau commented 2 months ago

rust-analyzer v0.3.2089 is now available which no longer has this problem 🙂