GREsau / schemars

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

schemars_derive breaks with version serde_derive_internals 0.29.0 #278

Closed Nilsonfsilva closed 3 months ago

Nilsonfsilva commented 5 months ago

Hi! I am a Debian maintainer of serde_derive_internals, I am unable to upload a new update, because schemars_derive breaks with version .0.29.0 of serde_derive_internals.

The error log follows:

af021f2df.rlib --extern serde_derive_internals=/pkgs/RUST/debcargo-conf/build/schemars-derive/target/debug/deps/libserde_derive_internals-213e028c94b03221.rlib --extern syn=/pkgs/RUST/debcargo-conf/build/schemars-derive/target/debug/deps/libsyn-86b0ae76c069f0ee.rlib --extern proc_macro` error[E0308]: mismatched types --> src/ast/from_serde.rs:28:23 28 generics: serde.generics.clone(), ^^^^^^^^^^^^^^^^^^^^^^ expected Generics, found syn::generics::Generics
= note: syn::generics::Generics and Generics have similar names, but are actually distinct types note: syn::generics::Generics is defined in crate syn --> /pkgs/RUST/debcargo-conf/build/schemars-derive/debian/cargo_registry/syn-2.0.48/src/generics.rs:9:1 9 / ast_struct! { 10 /// Lifetimes and type parameters attached to a declaration of a function, 11 /// enum, trait, etc. 12 /// ... 25 } 26 } _^ note: Generics is defined in crate syn --> /pkgs/RUST/debcargo-conf/build/schemars-derive/debian/cargo_registry/syn-1.0.109/src/generics.rs:8:1
8 / ast_struct! {
9 /// Lifetimes and type parameters attached to a declaration of a function,
10 /// enum, trait, etc.
11 ///
...
20 }
21 }
_^

= note: perhaps two different versions of crate syn are being used? = note: this error originates in the macro ast_struct (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types --> src/ast/from_serde.rs:29:23 29 original: serde.original, ^^^^^^^^^^^^^^ expected DeriveInput, found syn::derive::DeriveInput
= note: syn::derive::DeriveInput and DeriveInput have similar names, but are actually distinct types note: syn::derive::DeriveInput is defined in crate syn --> /pkgs/RUST/debcargo-conf/build/schemars-derive/debian/cargo_registry/syn-2.0.48/src/derive.rs:4:1 4 / ast_struct! { 5 /// Data structure sent to a proc_macro_derive macro. 6 #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))] 7 pub struct DeriveInput { ... 13 } 14 } _^ note: DeriveInput is defined in crate syn --> /pkgs/RUST/debcargo-conf/build/schemars-derive/debian/cargo_registry/syn-1.0.109/src/derive.rs:4:1
4 / ast_struct! {
5 /// Data structure sent to a proc_macro_derive macro.
6 ///
7 /// This type is available only if Syn is built with the "derive" feature.
...
24 }
25 }
_^

= note: perhaps two different versions of crate syn are being used? = note: this error originates in the macro ast_struct (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types --> src/ast/from_serde.rs:31:31 31 attrs: Attrs::new(&serde.original.attrs, errors), ---------- ^^^^^^^^^^^^^^^^^^^^^ expected &[Attribute], found &Vec<Attribute>
arguments to this function are incorrect

= note: expected reference &[Attribute] found reference &Vec<syn::attr::Attribute> note: associated function defined here --> src/attr/mod.rs:40:12 | 40 | pub fn new(attrs: &[syn::Attribute], errors: &Ctxt) -> Self { | ^^^ ------------------------

error[E0308]: mismatched types --> src/ast/from_serde.rs:60:23 60 original: serde.original, ^^^^^^^^^^^^^^ expected syn::Variant, found syn::data::Variant
= note: syn::data::Variant and syn::Variant have similar names, but are actually distinct types note: syn::data::Variant is defined in crate syn --> /pkgs/RUST/debcargo-conf/build/schemars-derive/debian/cargo_registry/syn-2.0.48/src/data.rs:4:1 4 / ast_struct! { 5 /// An enum variant. 6 #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] 7 pub struct Variant { ... 18 } 19 } _^ note: syn::Variant is defined in crate syn --> /pkgs/RUST/debcargo-conf/build/schemars-derive/debian/cargo_registry/syn-1.0.109/src/data.rs:4:1
4 / ast_struct! {
5 /// An enum variant.
6 ///
7 /// *This type is available only if Syn is built with the "derive" or "full"
...
22 }
23 }
_^

= note: perhaps two different versions of crate syn are being used? = note: this error originates in the macro ast_struct (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types --> src/ast/from_serde.rs:61:31 61 attrs: Attrs::new(&serde.original.attrs, errors), ---------- ^^^^^^^^^^^^^^^^^^^^^ expected &[Attribute], found &Vec<Attribute>
arguments to this function are incorrect

= note: expected reference &[Attribute] found reference &Vec<syn::attr::Attribute> note: associated function defined here --> src/attr/mod.rs:40:12 | 40 | pub fn new(attrs: &[syn::Attribute], errors: &Ctxt) -> Self { | ^^^ ------------------------

error[E0308]: mismatched types --> src/ast/from_serde.rs:71:21 71 member: serde.member, ^^^^^^^^^^^^ expected Member, found syn::expr::Member
= note: `syn::expr::Member` and `Member` have similar names, but are actually distinct types
note: syn::expr::Member is defined in crate syn --> /pkgs/RUST/debcargo-conf/build/schemars-derive/debian/cargo_registry/syn-2.0.48/src/expr.rs:735:1 735 / ast_enum! { 736 /// A struct or tuple struct field accessed in a struct literal or field 737 /// expression. 738 #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] ... 744 } 745 } _^ note: Member is defined in crate syn --> /pkgs/RUST/debcargo-conf/build/schemars-derive/debian/cargo_registry/syn-1.0.109/src/expr.rs:844:1
844 / ast_enum! {
845 /// A struct or tuple struct field accessed in a struct literal or field
846 /// expression.
847 ///
...
856 }
857 }
_^
= note: perhaps two different versions of crate `syn` are being used?
= note: this error originates in the macro `ast_enum` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types --> src/ast/from_serde.rs:73:17 73 ty: serde.ty, ^^^^^^^^ expected syn::Type, found syn::ty::Type
= note: syn::ty::Type and syn::Type have similar names, but are actually distinct types note: syn::ty::Type is defined in crate syn --> /pkgs/RUST/debcargo-conf/build/schemars-derive/debian/cargo_registry/syn-2.0.48/src/ty.rs:5:1 5 / ast_enum_of_structs! { 6 /// The possible types that a Rust value could have. 7 /// 8 /// # Syntax tree enum ... 81 } 82 } _^ note: syn::Type is defined in crate syn --> /pkgs/RUST/debcargo-conf/build/schemars-derive/debian/cargo_registry/syn-1.0.109/src/ty.rs:5:1
5 / ast_enum_of_structs! {
6 /// The possible types that a Rust value could have.
7 ///
8 /// *This type is available only if Syn is built with the "derive" or "full"
...
88 }
89 }
_^

= note: perhaps two different versions of crate syn are being used? = note: this error originates in the macro ast_enum_of_structs (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types --> src/ast/from_serde.rs:74:23 74 original: serde.original, ^^^^^^^^^^^^^^ expected syn::Field, found syn::data::Field
= note: `syn::data::Field` and `syn::Field` have similar names, but are actually distinct types
note: syn::data::Field is defined in crate syn --> /pkgs/RUST/debcargo-conf/build/schemars-derive/debian/cargo_registry/syn-2.0.48/src/data.rs:135:1 135 / ast_struct! { 136 /// A field of a struct or enum variant. 137 #[cfg_attr(doc_cfg, doc(cfg(any(feature = "full", feature = "derive"))))] 138 pub struct Field { ... 153 } 154 } _^ note: syn::Field is defined in crate syn --> /pkgs/RUST/debcargo-conf/build/schemars-derive/debian/cargo_registry/syn-1.0.109/src/data.rs:148:1
148 / ast_struct! {
149 /// A field of a struct or enum variant.
150 ///
151 /// *This type is available only if Syn is built with the "derive" or "full"
...
170 }
171 }
_^
= note: perhaps two different versions of crate `syn` are being used?
= note: this error originates in the macro `ast_struct` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types --> src/ast/from_serde.rs:75:31 75 attrs: Attrs::new(&serde.original.attrs, errors), ---------- ^^^^^^^^^^^^^^^^^^^^^ expected &[Attribute], found &Vec<Attribute>
arguments to this function are incorrect

= note: expected reference &[Attribute] found reference &Vec<syn::attr::Attribute> note: associated function defined here --> src/attr/mod.rs:40:12 | 40 | pub fn new(attrs: &[syn::Attribute], errors: &Ctxt) -> Self { | ^^^ ------------------------

error[E0308]: mismatched types --> src/ast/from_serde.rs:76:52 76 validation_attrs: ValidationAttrs::new(&serde.original.attrs, errors), -------------------- ^^^^^^^^^^^^^^^^^^^^^ expected &[Attribute], found &Vec<Attribute>
arguments to this function are incorrect

= note: expected reference &[Attribute] found reference &Vec<syn::attr::Attribute> note: associated function defined here --> src/attr/validation.rs:50:12 | 50 | pub fn new(attrs: &[syn::Attribute], errors: &Ctxt) -> Self { | ^^^ ------------------------

error[E0308]: mismatched types --> src/ast/mod.rs:43:60 43 let result = serde_ast::Container::from_ast(&ctxt, item, Derive::Deserialize) ------------------------------ ^^^^ expected syn::derive::DeriveInput, found DeriveInput
arguments to this function are incorrect
= note: DeriveInput and syn::derive::DeriveInput have similar names, but are actually distinct types note: DeriveInput is defined in crate syn --> /pkgs/RUST/debcargo-conf/build/schemars-derive/debian/cargo_registry/syn-1.0.109/src/derive.rs:4:1 4 / ast_struct! { 5 /// Data structure sent to a proc_macro_derive macro. 6 /// 7 /// This type is available only if Syn is built with the "derive" feature. ... 24 } 25 } _^ note: syn::derive::DeriveInput is defined in crate syn --> /pkgs/RUST/debcargo-conf/build/schemars-derive/debian/cargo_registry/syn-2.0.48/src/derive.rs:4:1
4 / ast_struct! {
5 /// Data structure sent to a proc_macro_derive macro.
6 #[cfg_attr(doc_cfg, doc(cfg(feature = "derive")))]
7 pub struct DeriveInput {
...
13 }
14 }
_^

= note: perhaps two different versions of crate syn are being used? note: associated function defined here --> /pkgs/RUST/debcargo-conf/build/schemars-derive/debian/cargo_registry/serde_derive_internals-0.29.0/src/ast.rs:61:12 | 61 | pub fn from_ast( | ^^^^^^^^ = note: this error originates in the macro strip_attrs_pub which comes from the expansion of the macro ast_struct (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types --> src/ast/mod.rs:47:9 41 pub fn from_ast(item: &'a syn::DeriveInput) -> Result<Container<'a>, Vec> { -------------------------------------- expected Result<ast::Container<'a>, Vec<syn::Error>> because of return type ... 47 / ctxt.check() 48 .map( _ result.expect("from_ast set no errors on Ctxt, so should have returned Ok")) ____^ expected `Result<Container<'>, Vec>, foundResult<Container<'_>, Error>`

= note: expected enum Result<ast::Container<'a>, Vec<syn::Error>> found enum Result<ast::Container<'_>, syn::error::Error>

error[E0308]: mismatched types --> src/ast/mod.rs:52:9 51 pub fn name(&self) -> String { ------ expected std::string::String because of return type 52 self.serde_attrs.name().deserialize_name() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- help: try using a conversion method: .to_string()
expected String, found &str
error[E0308]: mismatched types --> src/ast/mod.rs:68:9 67 pub fn name(&self) -> String { ------ expected std::string::String because of return type 68 self.serde_attrs.name().deserialize_name() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- help: try using a conversion method: .to_string()
expected String, found &str
error[E0308]: mismatched types --> src/ast/mod.rs:78:9 77 pub fn name(&self) -> String { ------ expected std::string::String because of return type 78 self.serde_attrs.name().deserialize_name() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- help: try using a conversion method: .to_string()
expected String, found &str
error[E0308]: mismatched types --> src/attr/schemars_to_serde.rs:44:5 35 pub fn process_serde_attrs(input: &mut syn::DeriveInput) -> Result<(), Vec> { --------------------------- expected Result<(), Vec<syn::Error>> because of return type ... 44 ctxt.check() ^^^^^^^^^^^^ expected Result<(), Vec<Error>>, found Result<(), Error>

= note: expected enum Result<_, Vec<syn::Error>> found enum Result<_, syn::error::Error>

error[E0277]: the trait bound syn::punctuated::Punctuated<WherePredicate, Comma>: Extend<syn::generics::WherePredicate> is not satisfied --> src/lib.rs:199:33 199 where_clause.predicates.extend(bounds.iter().cloned()); ^^^^^^ the trait Extend<syn::generics::WherePredicate> is not implemented for syn::punctuated::Punctuated<WherePredicate, Comma>
= help: the following other types implement trait `Extend<A>`:
          <syn::punctuated::Punctuated<T, P> as Extend<Pair<T, P>>>
          <syn::punctuated::Punctuated<T, P> as Extend<T>>

Some errors have detailed explanations: E0277, E0308. For more information about an error, try rustc --explain E0277. error: could not compile schemars_derive due to 17 previous errors

GREsau commented 3 months ago

This is fixed in 1.0.0-alpha.1 (and alpha.2)

Please be aware this this version contains breaking changes (see changelog), and further breaking changes are possible until 1.0.0 proper is released. Rather than making further changes to schemars 0.8, I'm focusing on v1, although I'm afraid I have no ETA