{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/comments/70187924","id":70187924,"diff_hunk":"@@ -278,17 +278,200 @@ extern \"rust-intrinsic\" {\n     /// Moves a value out of scope without running drop glue.\n     pub fn forget<T>(_: T) -> ();\n \n-    /// Unsafely transforms a value of one type into a value of another type.\n+    /// Reinterprets the bits of a value of one type as another type; both types\n+    /// must have the same size. Neither the original, nor the result, may be an\n+    /// [invalid value] (../../nomicon/meet-safe-and-unsafe.html).\n     ///\n-    /// Both types must have the same size.\n+    /// `transmute` is semantically equivalent to a bitwise move of one type\n+    /// into another. It copies the bits from the destination type into the\n+    /// source type, then forgets the original. If you know C or C++, it's like\n+    /// `memcpy` under the hood.\n+    ///\n+    /// `transmute` is incredibly unsafe. There are a vast number of ways to\n+    /// cause undefined behavior with this function. `transmute` should be\n+    /// the absolute last resort.\n+    ///\n+    /// The [nomicon](../../nomicon/transmutes.html) has additional\n+    /// documentation.\n     ///\n     /// # Examples\n     ///\n+    /// There are a few things that `transmute` is really useful for.\n+    ///\n+    /// Getting the bitpattern of a floating point type (or, more generally,\n+    /// type punning, when T and U aren't pointers):\n+    ///\n     /// ```\n-    /// use std::mem;\n+    /// let bitpattern = unsafe {\n+    ///     std::mem::transmute::<f32, u32>(1.0)\n+    /// };\n+    /// assert_eq!(bitpattern, 0x3F800000);\n+    /// ```\n+    ///\n+    /// Turning a pointer into a function pointer:\n+    ///\n+    /// ```\n+    /// fn foo() -> i32 {\n+    ///     0\n+    /// }\n+    /// let pointer = foo as *const ();\n+    /// let function = unsafe {\n+    ///     std::mem::transmute::<*const (), fn() -> i32>(pointer)\n+    /// };\n+    /// assert_eq!(function(), 0);\n+    /// ```\n+    ///\n+    /// Extending a lifetime, or shortening an invariant lifetime; this is\n+    /// advanced, very unsafe rust:\n+    ///\n+    /// ```\n+    /// struct R<'a>(&'a i32);\n+    /// unsafe fn extend_lifetime<'b>(r: R<'b>) -> R<'static> {\n+    ///     std::mem::transmute::<R<'b>, R<'static>>(r)\n+    /// }\n+    ///\n+    /// unsafe fn shorten_invariant_lifetime<'b, 'c>(r: &'b mut R<'static>)\n+    ///                                              -> &'b mut R<'c> {\n+    ///     std::mem::transmute::<&'b mut R<'static>, &'b mut R<'c>>(r)\n+    /// }\n+    /// ```\n+    ///\n+    /// # Alternatives\n+    ///\n+    /// However, many uses of `transmute` can be achieved through other means.\n+    /// This is unfortunate because either `transmute` isn't guaranteed to work\n+    /// in that case, and only does because of rustc's current implemenation;","path":"src/libcore/intrinsics.rs","position":69,"original_position":69,"commit_id":"97003e56991d3e475f2d4bb18a88c768018041e9","original_commit_id":"97003e56991d3e475f2d4bb18a88c768018041e9","user":{"login":"alexandermerritt","id":3632069,"avatar_url":"https://avatars.githubusercontent.com/u/3632069?v=3","gravatar_id":"","url":"https://api.github.com/users/alexandermerritt","html_url":"https://github.com/alexandermerritt","followers_url":"https://api.github.com/users/alexandermerritt/followers","following_url":"https://api.github.com/users/alexandermerritt/following{/other_user}","gists_url":"https://api.github.com/users/alexandermerritt/gists{/gist_id}","starred_url":"https://api.github.com/users/alexandermerritt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexandermerritt/subscriptions","organizations_url":"https://api.github.com/users/alexandermerritt/orgs","repos_url":"https://api.github.com/users/alexandermerritt/repos","events_url":"https://api.github.com/users/alexandermerritt/events{/privacy}","received_events_url":"https://api.github.com/users/alexandermerritt/received_events","type":"User","site_admin":false},"body":"\"implemenation\"","created_at":"2016-07-10T20:36:12Z","updated_at":"2016-07-10T20:36:12Z","html_url":"https://github.com/rust-lang/rust/pull/34609#discussion_r70187924","pull_request_url":"https://api.github.com/repos/rust-lang/rust/pulls/34609","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments/70187924"},"html":{"href":"https://github.com/rust-lang/rust/pull/34609#discussion_r70187924"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/34609"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/34609","id":76057717,"html_url":"https://github.com/rust-lang/rust/pull/34609","diff_url":"https://github.com/rust-lang/rust/pull/34609.diff","patch_url":"https://github.com/rust-lang/rust/pull/34609.patch","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/34609","number":34609,"state":"open","locked":false,"title":"Add more docs - mostly warnings - to std::mem::transmute","user":{"login":"ubsan","id":3479021,"avatar_url":"https://avatars.githubusercontent.com/u/3479021?v=3","gravatar_id":"","url":"https://api.github.com/users/ubsan","html_url":"https://github.com/ubsan","followers_url":"https://api.github.com/users/ubsan/followers","following_url":"https://api.github.com/users/ubsan/following{/other_user}","gists_url":"https://api.github.com/users/ubsan/gists{/gist_id}","starred_url":"https://api.github.com/users/ubsan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubsan/subscriptions","organizations_url":"https://api.github.com/users/ubsan/orgs","repos_url":"https://api.github.com/users/ubsan/repos","events_url":"https://api.github.com/users/ubsan/events{/privacy}","received_events_url":"https://api.github.com/users/ubsan/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-07-02T06:34:53Z","updated_at":"2016-07-10T20:36:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8091a5ae56ae7329335aec47ac108a50adc667a7","assignee":{"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},"assignees":[{"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}],"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rust/pulls/34609/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rust/pulls/34609/comments","review_comment_url":"https://api.github.com/repos/rust-lang/rust/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/34609/comments","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/97003e56991d3e475f2d4bb18a88c768018041e9","head":{"label":"ubsan:transmute_docs","ref":"transmute_docs","sha":"97003e56991d3e475f2d4bb18a88c768018041e9","user":{"login":"ubsan","id":3479021,"avatar_url":"https://avatars.githubusercontent.com/u/3479021?v=3","gravatar_id":"","url":"https://api.github.com/users/ubsan","html_url":"https://github.com/ubsan","followers_url":"https://api.github.com/users/ubsan/followers","following_url":"https://api.github.com/users/ubsan/following{/other_user}","gists_url":"https://api.github.com/users/ubsan/gists{/gist_id}","starred_url":"https://api.github.com/users/ubsan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubsan/subscriptions","organizations_url":"https://api.github.com/users/ubsan/orgs","repos_url":"https://api.github.com/users/ubsan/repos","events_url":"https://api.github.com/users/ubsan/events{/privacy}","received_events_url":"https://api.github.com/users/ubsan/received_events","type":"User","site_admin":false},"repo":{"id":44891860,"name":"rust","full_name":"ubsan/rust","owner":{"login":"ubsan","id":3479021,"avatar_url":"https://avatars.githubusercontent.com/u/3479021?v=3","gravatar_id":"","url":"https://api.github.com/users/ubsan","html_url":"https://github.com/ubsan","followers_url":"https://api.github.com/users/ubsan/followers","following_url":"https://api.github.com/users/ubsan/following{/other_user}","gists_url":"https://api.github.com/users/ubsan/gists{/gist_id}","starred_url":"https://api.github.com/users/ubsan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ubsan/subscriptions","organizations_url":"https://api.github.com/users/ubsan/orgs","repos_url":"https://api.github.com/users/ubsan/repos","events_url":"https://api.github.com/users/ubsan/events{/privacy}","received_events_url":"https://api.github.com/users/ubsan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ubsan/rust","description":"A safe, concurrent, practical language.","fork":true,"url":"https://api.github.com/repos/ubsan/rust","forks_url":"https://api.github.com/repos/ubsan/rust/forks","keys_url":"https://api.github.com/repos/ubsan/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ubsan/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ubsan/rust/teams","hooks_url":"https://api.github.com/repos/ubsan/rust/hooks","issue_events_url":"https://api.github.com/repos/ubsan/rust/issues/events{/number}","events_url":"https://api.github.com/repos/ubsan/rust/events","assignees_url":"https://api.github.com/repos/ubsan/rust/assignees{/user}","branches_url":"https://api.github.com/repos/ubsan/rust/branches{/branch}","tags_url":"https://api.github.com/repos/ubsan/rust/tags","blobs_url":"https://api.github.com/repos/ubsan/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ubsan/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ubsan/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/ubsan/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ubsan/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/ubsan/rust/languages","stargazers_url":"https://api.github.com/repos/ubsan/rust/stargazers","contributors_url":"https://api.github.com/repos/ubsan/rust/contributors","subscribers_url":"https://api.github.com/repos/ubsan/rust/subscribers","subscription_url":"https://api.github.com/repos/ubsan/rust/subscription","commits_url":"https://api.github.com/repos/ubsan/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/ubsan/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/ubsan/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/ubsan/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/ubsan/rust/contents/{+path}","compare_url":"https://api.github.com/repos/ubsan/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ubsan/rust/merges","archive_url":"https://api.github.com/repos/ubsan/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ubsan/rust/downloads","issues_url":"https://api.github.com/repos/ubsan/rust/issues{/number}","pulls_url":"https://api.github.com/repos/ubsan/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/ubsan/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/ubsan/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ubsan/rust/labels{/name}","releases_url":"https://api.github.com/repos/ubsan/rust/releases{/id}","deployments_url":"https://api.github.com/repos/ubsan/rust/deployments","created_at":"2015-10-25T01:25:35Z","updated_at":"2016-02-19T03:25:00Z","pushed_at":"2016-07-10T04:14:08Z","git_url":"git://github.com/ubsan/rust.git","ssh_url":"git@github.com:ubsan/rust.git","clone_url":"https://github.com/ubsan/rust.git","svn_url":"https://github.com/ubsan/rust","homepage":"http://www.rust-lang.org","size":298765,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"731d37561971d80f5d7ccaba8c2affcf39965917","user":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":724712,"name":"rust","full_name":"rust-lang/rust","owner":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rust-lang/rust","description":"A safe, concurrent, practical language.","fork":false,"url":"https://api.github.com/repos/rust-lang/rust","forks_url":"https://api.github.com/repos/rust-lang/rust/forks","keys_url":"https://api.github.com/repos/rust-lang/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/rust/teams","hooks_url":"https://api.github.com/repos/rust-lang/rust/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/rust/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/rust/events","assignees_url":"https://api.github.com/repos/rust-lang/rust/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/rust/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/rust/tags","blobs_url":"https://api.github.com/repos/rust-lang/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/rust/languages","stargazers_url":"https://api.github.com/repos/rust-lang/rust/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/rust/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/rust/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/rust/subscription","commits_url":"https://api.github.com/repos/rust-lang/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/rust-lang/rust/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/rust/merges","archive_url":"https://api.github.com/repos/rust-lang/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/rust/downloads","issues_url":"https://api.github.com/repos/rust-lang/rust/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/rust/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/rust/releases{/id}","deployments_url":"https://api.github.com/repos/rust-lang/rust/deployments","created_at":"2010-06-16T20:39:03Z","updated_at":"2016-07-10T20:12:00Z","pushed_at":"2016-07-10T20:32:30Z","git_url":"git://github.com/rust-lang/rust.git","ssh_url":"git@github.com:rust-lang/rust.git","clone_url":"https://github.com/rust-lang/rust.git","svn_url":"https://github.com/rust-lang/rust","homepage":"https://www.rust-lang.org","size":516703,"stargazers_count":17417,"watchers_count":17417,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3323,"mirror_url":null,"open_issues_count":2578,"forks":3323,"open_issues":2578,"watchers":17417,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/34609"},"html":{"href":"https://github.com/rust-lang/rust/pull/34609"},"issue":{"href":"https://api.github.com/repos/rust-lang/rust/issues/34609"},"comments":{"href":"https://api.github.com/repos/rust-lang/rust/issues/34609/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/34609/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/34609/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rust/statuses/97003e56991d3e475f2d4bb18a88c768018041e9"}}}}
{"actor":{"display_login":"alexandermerritt"}}