{"action":"opened","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/21775","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/21775/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/21775/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/21775/events","html_url":"https://github.com/rust-lang/rust/issues/21775","id":56019263,"number":21775,"title":"dead_code lint shouldn't warn about unused fields that implement Drop","user":{"login":"simias","id":7925386,"avatar_url":"https://avatars.githubusercontent.com/u/7925386?v=3","gravatar_id":"","url":"https://api.github.com/users/simias","html_url":"https://github.com/simias","followers_url":"https://api.github.com/users/simias/followers","following_url":"https://api.github.com/users/simias/following{/other_user}","gists_url":"https://api.github.com/users/simias/gists{/gist_id}","starred_url":"https://api.github.com/users/simias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simias/subscriptions","organizations_url":"https://api.github.com/users/simias/orgs","repos_url":"https://api.github.com/users/simias/repos","events_url":"https://api.github.com/users/simias/events{/privacy}","received_events_url":"https://api.github.com/users/simias/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-30T10:49:51Z","updated_at":"2015-01-30T10:49:51Z","closed_at":null,"body":"I have a use case similar to this:\r\n\r\n```rust\r\nstruct S(u32);\r\n\r\nimpl Drop for S {\r\n    fn drop(&mut self) {\r\n        println!(\"dropping {}\", self.0);\r\n    }\r\n}\r\n\r\nstruct Container {\r\n    s: S,\r\n}\r\n\r\nimpl Container {\r\n    fn new() -> Container {\r\n        let s = S(4);\r\n\r\n        Container { s: s } \r\n    }\r\n}\r\n\r\nfn main() {\r\n    Container::new();\r\n}\r\n```\r\n\r\nThe struct `S` is just a thin wrapper around a foreign object, it's just used to free the object in the Drop. The `dead_code` lint says:\r\n\r\n```rust\r\nwarning: struct field is never used: `s`, #[warn(dead_code)] on by default\r\n```\r\n\r\nIMHO that's bogus because it seems to imply that the member could be removed without changing the behaviour of the code which is clearly not the case. The whole point is that I want `s` to live as long as the `Container` object.\r\n\r\nTherefore I think the lint shouldn't trigger when a seemingly unused field implements `Drop`."}}