Skip to content

How to tame clippy field is never read? #1116

Closed Answered by obmarg
azzamsa asked this question in Q&A
Discussion options

You must be logged in to vote

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.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@azzamsa
Comment options

Answer selected by azzamsa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants