media-io / yaserde

Yet Another Serializer/Deserializer
MIT License
174 stars 58 forks source link

Non-local `impl` definition - 2024 edition #190

Open mibes404 opened 1 month ago

mibes404 commented 1 month ago

On Rust nightly (rustc 1.81.0-nightly (59e2c01c2 2024-06-17)) using yaserde version = 0.10.1, the YaSerialize and YaDeserialize macros throw a warning that may become a deny-by-default in the edition 2024.

[yaserde/examples] $ cargo build

warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
 --> examples/src/boscop.rs:4:35
  |
4 | #[derive(Debug, Clone, PartialEq, YaDeserialize)]
  |                                   ^------------
  |                                   |
  |                                   `YaDeserialize` is not local
  |                                   move the `impl` block outside of this constant `_IMPL_YA_DESERIALIZE_FOR_Layout`
5 | #[yaserde(root = "layout")]
6 | pub struct Layout {
  |            ------ `Layout` is not local
  |
  = note: the derive macro `YaDeserialize` defines the non-local `impl`, and may need to be changed
  = note: the derive macro `YaDeserialize` may come from an old version of the `yaserde_derive` crate, try updating your dependency with `cargo update -p yaserde_derive`
  = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
  = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
  = note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration
  = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
  = note: this warning originates in the derive macro `YaDeserialize` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
  --> examples/src/boscop.rs:20:35
   |
20 | #[derive(Debug, Clone, PartialEq, YaDeserialize)]
   |                                   ^------------
   |                                   |
   |                                   `YaDeserialize` is not local
   |                                   move the `impl` block outside of this constant `_IMPL_YA_DESERIALIZE_FOR_Tabpage`
21 | pub struct Tabpage {
   |            ------- `Tabpage` is not local
   |
   = note: the derive macro `YaDeserialize` defines the non-local `impl`, and may need to be changed
   = note: the derive macro `YaDeserialize` may come from an old version of the `yaserde_derive` crate, try updating your dependency with `cargo update -p yaserde_derive`
   = note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
   = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
   = note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration
   = note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
   = note: this warning originates in the derive macro `YaDeserialize` (in Nightly builds, run with -Z macro-backtrace for more info)