-
Hi, 👋🏽 I am using The mod schema {
cynic::use_schema!("tests/schema.graphql");
}
#[cynic::schema_for_derives(file = "tests/schema.graphql", module = "schema")]
pub mod queries {
use super::schema;
#[derive(cynic::QueryFragment, Debug)]
#[cynic(graphql_type = "Query")]
pub struct MetaQuery {
pub meta: Meta,
}
#[derive(cynic::QueryFragment, Debug)]
pub struct Meta {
pub build: String,
pub version: String,
}
} It is used in my code, but clippy doesn't say so. warning: field `meta` is never read
--> tests/meta/graphql.rs:12:13
|
11 | pub struct MetaQuery {
| --------- field in this struct
12 | pub meta: Meta,
| ^^^^
|
= note: `MetaQuery` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
= note: `#[warn(dead_code)]` on by default
warning: field `build` is never read
--> tests/meta/graphql.rs:17:13
|
16 | pub struct Meta {
| ---- field in this struct
17 | pub build: String,
| ^^^^^
|
= note: `Meta` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis Do you have any suggestion to tame clippy? I don't think using Thanks for Cynic 🍩 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, so this is quite a tricky question to answer generally. I wouldn't be that against just adding an However, depending on your use case there might be something better you can do: it seems like you're using cynic in your tests - could you assert on the values that you're getting back from your tests somehow? Either a manual assert on the fields that clippy thinks are unused, or maybe something more sophisticated like a snapshot test with insta? That might be enough for clippy to see that the fields of the struct are actually used. |
Beta Was this translation helpful? Give feedback.
Hi, so this is quite a tricky question to answer generally. I wouldn't be that against just adding an
#[expect(dead_code)]
on the individual structs personally - that is what I've done when I've encountered this in cynic example code.However, depending on your use case there might be something better you can do: it seems like you're using cynic in your tests - could you assert on the values that you're getting back from your tests somehow? Either a manual assert on the fields that clippy thinks are unused, or maybe something more sophisticated like a snapshot test with insta? That might be enough for clippy to see that the fields of the struct are actually used.