{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rfcs/issues/1346","labels_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1346/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1346/comments","events_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1346/events","html_url":"https://github.com/rust-lang/rfcs/pull/1346","id":114150051,"number":1346,"title":"Unsafe expressions","user":{"login":"arcnmx","id":13426784,"avatar_url":"https://avatars.githubusercontent.com/u/13426784?v=3","gravatar_id":"","url":"https://api.github.com/users/arcnmx","html_url":"https://github.com/arcnmx","followers_url":"https://api.github.com/users/arcnmx/followers","following_url":"https://api.github.com/users/arcnmx/following{/other_user}","gists_url":"https://api.github.com/users/arcnmx/gists{/gist_id}","starred_url":"https://api.github.com/users/arcnmx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arcnmx/subscriptions","organizations_url":"https://api.github.com/users/arcnmx/orgs","repos_url":"https://api.github.com/users/arcnmx/repos","events_url":"https://api.github.com/users/arcnmx/events{/privacy}","received_events_url":"https://api.github.com/users/arcnmx/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rfcs/labels/T-lang","name":"T-lang","color":"bfd4f2"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-29T21:19:28Z","updated_at":"2015-10-29T21:36:09Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rust-lang/rfcs/pulls/1346","html_url":"https://github.com/rust-lang/rfcs/pull/1346","diff_url":"https://github.com/rust-lang/rfcs/pull/1346.diff","patch_url":"https://github.com/rust-lang/rfcs/pull/1346.patch"},"body":"Yes the example is terrible, Idunno I just grep'd for `unsafe` and used the first thing I found ._.\r\n\r\ntl;dr\r\n\r\n```rust\r\nunsafe some_unsafe_func()\r\n```\r\n\r\ninstead of\r\n\r\n```rust\r\nunsafe {\r\n    some_unsafe_func()\r\n}\r\n```\r\n\r\n[Rendered](https://github.com/arcnmx/rust-rfcs/blob/unsafe-expr/text/0000-unsafe-expressions.md)"},"comment":{"url":"https://api.github.com/repos/rust-lang/rfcs/issues/comments/152335154","html_url":"https://github.com/rust-lang/rfcs/pull/1346#issuecomment-152335154","issue_url":"https://api.github.com/repos/rust-lang/rfcs/issues/1346","id":152335154,"user":{"login":"arcnmx","id":13426784,"avatar_url":"https://avatars.githubusercontent.com/u/13426784?v=3","gravatar_id":"","url":"https://api.github.com/users/arcnmx","html_url":"https://github.com/arcnmx","followers_url":"https://api.github.com/users/arcnmx/followers","following_url":"https://api.github.com/users/arcnmx/following{/other_user}","gists_url":"https://api.github.com/users/arcnmx/gists{/gist_id}","starred_url":"https://api.github.com/users/arcnmx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arcnmx/subscriptions","organizations_url":"https://api.github.com/users/arcnmx/orgs","repos_url":"https://api.github.com/users/arcnmx/repos","events_url":"https://api.github.com/users/arcnmx/events{/privacy}","received_events_url":"https://api.github.com/users/arcnmx/received_events","type":"User","site_admin":false},"created_at":"2015-10-29T21:36:09Z","updated_at":"2015-10-29T21:36:09Z","body":"While I don't necessarily disagree, I dislike doing that because it feels like there's a danger of accidentally slipping in something unsafe when it wasn't intended. I see `unsafe` as \"something that takes potentially unchecked inputs, and does something scary with them\". For example, take the implementation of [`slice::IndexMut`](https://github.com/rust-lang/rust/blob/master/src/libcore/slice.rs#L560):\r\n\r\n```rust\r\n    fn index_mut(&mut self, index: usize) -> &mut T {\r\n        assert!(index < self.len());\r\n        unsafe { self.get_unchecked_mut(index) }\r\n    }\r\n```\r\n\r\nThe assertion, which is very dangerous if wrong, is not included in the `unsafe` block. And in the example above, that includes covering the **entire** match statement in `unsafe`, where the whole `_ => {}` block could have entirely unrelated code in it."}}