Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: collection is never read on #[derive(Deserialize)] #2789

Closed
epilys opened this issue Aug 7, 2024 · 2 comments · Fixed by #2791
Closed

error: collection is never read on #[derive(Deserialize)] #2789

epilys opened this issue Aug 7, 2024 · 2 comments · Fixed by #2791

Comments

@epilys
Copy link

epilys commented Aug 7, 2024

On both current stable 1.80.0 and nightly 1.82.0-nightly (2024-08-06 60d146580c10036ce89e)

sample code:

#![deny(clippy::collection_is_never_read)]

use serde::Deserialize;

#[derive(Deserialize)]
struct Options {
    a: bool,
}

#[derive(Deserialize)]
#[serde(untagged)]
enum Inner<'a> {
    Default {
        s: &'a str,
    },
    Builder {
        s: &'a str,
        #[serde(flatten)]
        o: Options,
    },
}

Getting:

error: collection is never read
  --> src/lib.rs:10:10
   |
10 | #[derive(Deserialize)]
   |          ^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collection_is_never_read
note: the lint level is defined here
  --> src/lib.rs:1:9
   |
1  | #![deny(clippy::collection_is_never_read)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)

Playground link

@dtolnay
Copy link
Member

dtolnay commented Aug 8, 2024

Thanks! Fixed in serde_derive 1.0.205.

@epilys
Copy link
Author

epilys commented Aug 8, 2024

Thank you, too, @dtolnay :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants