{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/23611","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/23611/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/23611/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/23611/events","html_url":"https://github.com/rust-lang/rust/issues/23611","id":63559455,"number":23611,"title":"Member destructor is always executed even if self is replaced in `Drop`","user":{"login":"nwin","id":949560,"avatar_url":"https://avatars.githubusercontent.com/u/949560?v=3","gravatar_id":"","url":"https://api.github.com/users/nwin","html_url":"https://github.com/nwin","followers_url":"https://api.github.com/users/nwin/followers","following_url":"https://api.github.com/users/nwin/following{/other_user}","gists_url":"https://api.github.com/users/nwin/gists{/gist_id}","starred_url":"https://api.github.com/users/nwin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nwin/subscriptions","organizations_url":"https://api.github.com/users/nwin/orgs","repos_url":"https://api.github.com/users/nwin/repos","events_url":"https://api.github.com/users/nwin/events{/privacy}","received_events_url":"https://api.github.com/users/nwin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-22T18:05:24Z","updated_at":"2015-03-22T18:12:43Z","closed_at":null,"body":"The following code prints \"Dropping!\" although the corresponding variant had been removed and forgotten. Same happens if it is overwritten instead.\r\n\r\n    use std::mem;\r\n    use std::ptr;\r\n    \r\n    struct Noisy;\r\n    impl Drop for Noisy {\r\n        fn drop(&mut self) { println!(\"Dropping!\") }\r\n    }\r\n    \r\n    enum Foo {\r\n        Bar(Noisy),\r\n        Baz\r\n    }\r\n    use Foo::*;\r\n    \r\n    impl Drop for Foo {\r\n        fn drop(&mut self) {\r\n            match *self {\r\n                Bar(_) => {\r\n                    //unsafe { ptr::write(self, Foo::Baz) }\r\n                    unsafe { mem::forget(mem::replace(self, Foo::Baz)) }\r\n                }\r\n                Baz => ()\r\n            }\r\n        }\r\n    }\r\n    \r\n    fn main() {\r\n        let _ = Foo::Bar(Noisy);\r\n    }\r\n\r\nI’m not sure if this is a bug or intended behavior but it is not obvious to me that this would happen and might be documented in more detail."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/84668102","html_url":"https://github.com/rust-lang/rust/issues/23611#issuecomment-84668102","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/23611","id":84668102,"user":{"login":"sfackler","id":1455697,"avatar_url":"https://avatars.githubusercontent.com/u/1455697?v=3","gravatar_id":"","url":"https://api.github.com/users/sfackler","html_url":"https://github.com/sfackler","followers_url":"https://api.github.com/users/sfackler/followers","following_url":"https://api.github.com/users/sfackler/following{/other_user}","gists_url":"https://api.github.com/users/sfackler/gists{/gist_id}","starred_url":"https://api.github.com/users/sfackler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sfackler/subscriptions","organizations_url":"https://api.github.com/users/sfackler/orgs","repos_url":"https://api.github.com/users/sfackler/repos","events_url":"https://api.github.com/users/sfackler/events{/privacy}","received_events_url":"https://api.github.com/users/sfackler/received_events","type":"User","site_admin":false},"created_at":"2015-03-22T18:12:43Z","updated_at":"2015-03-22T18:12:43Z","body":"cc @pnkfelix "}}