{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rfcs/issues/1085","labels_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1085/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1085/comments","events_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1085/events","html_url":"https://github.com/rust-lang/rfcs/pull/1085","id":70270711,"number":1085,"title":"Leak and Destructor Guarantees","user":{"login":"reem","id":4745181,"avatar_url":"https://avatars.githubusercontent.com/u/4745181?v=3","gravatar_id":"","url":"https://api.github.com/users/reem","html_url":"https://github.com/reem","followers_url":"https://api.github.com/users/reem/followers","following_url":"https://api.github.com/users/reem/following{/other_user}","gists_url":"https://api.github.com/users/reem/gists{/gist_id}","starred_url":"https://api.github.com/users/reem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reem/subscriptions","organizations_url":"https://api.github.com/users/reem/orgs","repos_url":"https://api.github.com/users/reem/repos","events_url":"https://api.github.com/users/reem/events{/privacy}","received_events_url":"https://api.github.com/users/reem/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"nikomatsakis","id":155238,"avatar_url":"https://avatars.githubusercontent.com/u/155238?v=3","gravatar_id":"","url":"https://api.github.com/users/nikomatsakis","html_url":"https://github.com/nikomatsakis","followers_url":"https://api.github.com/users/nikomatsakis/followers","following_url":"https://api.github.com/users/nikomatsakis/following{/other_user}","gists_url":"https://api.github.com/users/nikomatsakis/gists{/gist_id}","starred_url":"https://api.github.com/users/nikomatsakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikomatsakis/subscriptions","organizations_url":"https://api.github.com/users/nikomatsakis/orgs","repos_url":"https://api.github.com/users/nikomatsakis/repos","events_url":"https://api.github.com/users/nikomatsakis/events{/privacy}","received_events_url":"https://api.github.com/users/nikomatsakis/received_events","type":"User","site_admin":false},"milestone":null,"comments":30,"created_at":"2015-04-23T00:39:21Z","updated_at":"2015-04-25T07:56:23Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rust-lang/rfcs/pulls/1085","html_url":"https://github.com/rust-lang/rfcs/pull/1085","diff_url":"https://github.com/rust-lang/rfcs/pull/1085.diff","patch_url":"https://github.com/rust-lang/rfcs/pull/1085.patch"},"body":"Add a new default unsafe trait, `Leak`. If a type does not implement `Leak` it can be\r\nmemory unsafe to fail to run the destructor of this type and continue execution of the\r\nprogram past this types lifetime.\r\n\r\nAdditionally, cause all panics in destructors to immediately abort the process,\r\nsolving two other notable bugs that allow leaking arbitrary data.\r\n\r\nAdd a safe variant of `mem::forget` (e.g. `mem::leak`) which requires `Leak`.\r\nThe existing `mem::forget` remains unbounded, but `unsafe`.\r\n\r\nThis proposal also requires a slight breaking change to a few `std` APIs to add\r\n`Leak` bounds where none exist currently. This is unfortunate so close to 1.0,\r\nbut in the author's opinion is better than dedicating to a safe unbounded `mem::forget`\r\nforever.\r\n\r\nThis RFC is largely an alternative to RFC PR 1066, which makes an unbounded `mem::forget`\r\nsafe.\r\n\r\nEDIT: An implementation of Leak, including std and compiler changes, can be found here: https://github.com/reem/rust/tree/leak"},"comment":{"url":"https://api.github.com/repos/rust-lang/rfcs/issues/comments/96148558","html_url":"https://github.com/rust-lang/rfcs/pull/1085#issuecomment-96148558","issue_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1085","id":96148558,"user":{"login":"comex","id":47517,"avatar_url":"https://avatars.githubusercontent.com/u/47517?v=3","gravatar_id":"","url":"https://api.github.com/users/comex","html_url":"https://github.com/comex","followers_url":"https://api.github.com/users/comex/followers","following_url":"https://api.github.com/users/comex/following{/other_user}","gists_url":"https://api.github.com/users/comex/gists{/gist_id}","starred_url":"https://api.github.com/users/comex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/comex/subscriptions","organizations_url":"https://api.github.com/users/comex/orgs","repos_url":"https://api.github.com/users/comex/repos","events_url":"https://api.github.com/users/comex/events{/privacy}","received_events_url":"https://api.github.com/users/comex/received_events","type":"User","site_admin":false},"created_at":"2015-04-25T07:56:23Z","updated_at":"2015-04-25T07:56:23Z","body":"I claim that for 99% of use cases of `scoped`, you want to create a bunch of threads and have them all join at the end of the scope, if not earlier.  If the number of threads is fixed, you use local variables.  If it's not, you use a `Vec<JoinGuard>` and let it go out of scope.  For any use case this doesn't work for, you can always create a `Vec` and use indices into it instead of the guards themselves.  (Is there a library to easily manage a free list of Vec indices yet?  Vec-as-heap is a general pattern.)  Join guards are just not important enough to make a lot of unsafe code worry about them.\r\n\r\nIn other words, make Leak work like Sized, allow !Leak in Vec and maybe a *small* number of other types, and tell everyone else to suck it (and hope this sets a precedent not to include `?Leak` all over the place)."}}