{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rfcs/issues/744","labels_url":"https://api.github.com/repos/rust-lang/rfcs/issues/744/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rfcs/issues/744/comments","events_url":"https://api.github.com/repos/rust-lang/rfcs/issues/744/events","html_url":"https://github.com/rust-lang/rfcs/issues/744","id":55643591,"number":744,"title":"should struct fields and array elements be dropped in reverse declaration order (a la C++)","user":{"login":"steveklabnik","id":27786,"avatar_url":"https://avatars.githubusercontent.com/u/27786?v=3","gravatar_id":"","url":"https://api.github.com/users/steveklabnik","html_url":"https://github.com/steveklabnik","followers_url":"https://api.github.com/users/steveklabnik/followers","following_url":"https://api.github.com/users/steveklabnik/following{/other_user}","gists_url":"https://api.github.com/users/steveklabnik/gists{/gist_id}","starred_url":"https://api.github.com/users/steveklabnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/steveklabnik/subscriptions","organizations_url":"https://api.github.com/users/steveklabnik/orgs","repos_url":"https://api.github.com/users/steveklabnik/repos","events_url":"https://api.github.com/users/steveklabnik/events{/privacy}","received_events_url":"https://api.github.com/users/steveklabnik/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rfcs/labels/A-wishlist","name":"A-wishlist","color":"d7e101"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":44,"created_at":"2015-01-27T16:55:03Z","updated_at":"2015-09-01T21:27:08Z","closed_at":null,"body":"<a href=\"https://github.com/pnkfelix\"><img src=\"https://avatars.githubusercontent.com/u/173127?v=3\" align=\"left\" width=\"96\" height=\"96\" hspace=\"10\"></img></a> **Issue by [pnkfelix](https://github.com/pnkfelix)**\r\n_Thursday Aug 21, 2014 at 23:34 GMT_\r\n\r\n_For earlier discussion, see https://github.com/rust-lang/rust/issues/16661_\r\n\r\n_This issue was labelled with:  in the Rust repository_\r\n\r\n----\r\n\r\nshould struct fields and array elements be dropped in reverse declaration order (a la C++) ?\r\n\r\nhttps://github.com/rust-lang/rust/pull/16493 made us internally consistent with respect to struct fields, but chose to make the drops follow declaration order.\r\n\r\nNote struct construction follows the order of the fields given at the construction site, so there's no way to ensure that the drop order is the reverse of the order used at the construction site.\r\n\r\nBut we should still think about whether we should change that.  That is, if local variables are dropped in reverse declaration order (even though they can be initialized in any order), then it seems like it would make sense to do the same thing for struct fields.\r\n"},"comment":{"url":"https://api.github.com/repos/rust-lang/rfcs/issues/comments/136865786","html_url":"https://github.com/rust-lang/rfcs/issues/744#issuecomment-136865786","issue_url":"https://api.github.com/repos/rust-lang/rfcs/issues/744","id":136865786,"user":{"login":"pnkfelix","id":173127,"avatar_url":"https://avatars.githubusercontent.com/u/173127?v=3","gravatar_id":"","url":"https://api.github.com/users/pnkfelix","html_url":"https://github.com/pnkfelix","followers_url":"https://api.github.com/users/pnkfelix/followers","following_url":"https://api.github.com/users/pnkfelix/following{/other_user}","gists_url":"https://api.github.com/users/pnkfelix/gists{/gist_id}","starred_url":"https://api.github.com/users/pnkfelix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pnkfelix/subscriptions","organizations_url":"https://api.github.com/users/pnkfelix/orgs","repos_url":"https://api.github.com/users/pnkfelix/repos","events_url":"https://api.github.com/users/pnkfelix/events{/privacy}","received_events_url":"https://api.github.com/users/pnkfelix/received_events","type":"User","site_admin":false},"created_at":"2015-09-01T21:27:08Z","updated_at":"2015-09-01T21:27:08Z","body":"@nikomatsakis of course the cases you describe only arise either 1. in the struct's own module or 2. when the struct's fields are all public.\r\n\r\nI.e., it is certainly still quite possible for a struct designer to *enforce* a drop order via the order of field definition in the struct, if the language were to actually provide a defined drop order.  (Because the struct designer can simply make the fields private, and then audit their own code to make sure the construction orders all make sense.)"}}