Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

Warning is emitted when a struct contains a deprecated field #632

@ian-h-chamberlain

Description

@ian-h-chamberlain

Hi! my team is in the process of upgrading to 0.8 and I encountered a very minor issue, kinda similar to #561 but with a #[deprecated] struct field. Example:

use rkyv::{Archive, Deserialize, Serialize};

#[derive(Clone, Debug, Archive, Serialize, Deserialize)]
pub struct Foo {
    #[deprecated]
    pub bar: i32,
    pub baz: Option<i32>,
}
warning: use of deprecated field `Foo::bar`
 --> src/main.rs:3:24
  |
3 | #[derive(Clone, Debug, Archive, Serialize, Deserialize)]
  |                        ^^^^^^^
  |
  = note: `#[warn(deprecated)]` on by default
  = note: this warning originates in the macro `::core::mem::offset_of` which comes from the expansion of the derive macro `Archive` (in Nightly builds, run with -Z macro-backtrace for more info)

This can be worked around by moving the struct into a module, adding #![allow(deprecated)] and re-exporting it, but it would be nice if either

  • the lint was not emitted in the first place
  • or we could inject an attribute somewhere somehow (on the impl, or associated const, or somewhere else?)

I also noticed that the rustc docs state that #[automatically_derived] should be placed on impls and may have no effect in other positions.

When I looked at the expansion of #[derive(Archive)], it looks like the #[automatically_derived] is being placed on the derived structs, but not e.g. impl rkyv::Archive for Foo (which is where this lint is firing) nor impl Portable for ArchivedFoo. So maybe a simple fix is just to add #[automatically_derived] onto those impls?

Thanks for this really cool library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions