GREsau / schemars

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

0.8.18 regression - "type annotations needed" on variantless enum #287

Closed kmdreko closed 4 months ago

kmdreko commented 4 months ago

This code fails with version 0.8.18 of schemars:

use schemars::JsonSchema;

#[derive(JsonSchema)]
pub enum MyEnum {}
error[E0282]: type annotations needed
   --> src/main.rs:3:10
    |
698 | #[derive(JsonSchema)]
    |          ^^^^^^^^^^ cannot infer type
    |
    = note: this error originates in the derive macro `JsonSchema` (in Nightly builds, run with -Z macro-backtrace for more info)

Discovered from scale-info library: https://github.com/paritytech/scale-info/blob/3082edc2ae96de53c1ba104b8423451a9a485d1b/src/form.rs#L64-L67

GREsau commented 4 months ago

Thanks for the report, this should now be fixed in 0.8.19 🙂