{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/comments/178388348","pull_request_review_id":108446453,"id":178388348,"diff_hunk":"@@ -981,6 +981,107 @@ impl<T> From<T> for Option<T> {\n     }\n }\n \n+// The Option<T> type used to be defined as { None, Some(T) }, but for codegen\n+// reasons we reversed it in #49499 to reduce the amount of work that needs\n+// to be done for Result<T, ()> <-> Option<T> conversions. Keeping the derived\n+// Ord and PartialOrd implementations would make that swap a breaking change.\n+#[stable(feature = \"rust1\", since = \"1.0.0\")]\n+impl<T> Ord for Option<T>\n+where\n+    T: Ord,\n+{\n+    #[inline]\n+    fn cmp(&self, other: &Self) -> cmp::Ordering {\n+        let self_discr = unsafe { intrinsics::discriminant_value(self) } as isize;","path":"src/libcore/option.rs","position":44,"original_position":44,"commit_id":"b85f91f8da2572b9a1b97b2a0ac0563238a7057b","original_commit_id":"b85f91f8da2572b9a1b97b2a0ac0563238a7057b","user":{"login":"ollie27","id":7189418,"avatar_url":"https://avatars2.githubusercontent.com/u/7189418?v=4","gravatar_id":"","url":"https://api.github.com/users/ollie27","html_url":"https://github.com/ollie27","followers_url":"https://api.github.com/users/ollie27/followers","following_url":"https://api.github.com/users/ollie27/following{/other_user}","gists_url":"https://api.github.com/users/ollie27/gists{/gist_id}","starred_url":"https://api.github.com/users/ollie27/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ollie27/subscriptions","organizations_url":"https://api.github.com/users/ollie27/orgs","repos_url":"https://api.github.com/users/ollie27/repos","events_url":"https://api.github.com/users/ollie27/events{/privacy}","received_events_url":"https://api.github.com/users/ollie27/received_events","type":"User","site_admin":false},"body":"Couldn't this use `is_none()` or `is_some()`?","created_at":"2018-03-30T21:39:32Z","updated_at":"2018-03-30T21:39:32Z","html_url":"https://github.com/rust-lang/rust/pull/49499#discussion_r178388348","pull_request_url":"https://api.github.com/repos/rust-lang/rust/pulls/49499","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments/178388348"},"html":{"href":"https://github.com/rust-lang/rust/pull/49499#discussion_r178388348"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/49499"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/49499","id":178529285,"html_url":"https://github.com/rust-lang/rust/pull/49499","diff_url":"https://github.com/rust-lang/rust/pull/49499.diff","patch_url":"https://github.com/rust-lang/rust/pull/49499.patch","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/49499","number":49499,"state":"open","locked":false,"title":"Swap the 2 variants of Option<T>","user":{"login":"nox","id":123095,"avatar_url":"https://avatars0.githubusercontent.com/u/123095?v=4","gravatar_id":"","url":"https://api.github.com/users/nox","html_url":"https://github.com/nox","followers_url":"https://api.github.com/users/nox/followers","following_url":"https://api.github.com/users/nox/following{/other_user}","gists_url":"https://api.github.com/users/nox/gists{/gist_id}","starred_url":"https://api.github.com/users/nox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nox/subscriptions","organizations_url":"https://api.github.com/users/nox/orgs","repos_url":"https://api.github.com/users/nox/repos","events_url":"https://api.github.com/users/nox/events{/privacy}","received_events_url":"https://api.github.com/users/nox/received_events","type":"User","site_admin":false},"body":"That allows us to have a better path from Result<T, E> to Option<T>\r\nin the general case, without niche-filling optimisations.\r\n\r\n@rust-lang/wg-codegen \r\n\r\nIt should be noted that if you also have #49479 and #49420 (not sure this one matters but it was in my branch so full disclosure I guess), the methods for `Result<T, UnitStuff>` and `Option<T>` end up being shared for `T` values that don't trigger the niche-filling optimisation.\r\n\r\n```rust\r\n#![crate_type = \"lib\"]\r\n#![feature(try_trait)]\r\n\r\npub fn foo(x: Option<i32>) -> Result<i32, std::option::NoneError> {\r\n    match x {\r\n        Some(v) => Ok(v),\r\n        None => Err(std::option::NoneError),\r\n    }\r\n}\r\n\r\npub fn bar(x: Option<i32>) -> Option<i32> {\r\n    match foo(x) {\r\n        Ok(v) => Some(v),\r\n        Err(_) => None,\r\n    }\r\n}\r\n```\r\n\r\n```llvm\r\n; ModuleID = 'foo0-8787f43e282added376259c1adb08b80.rs'\r\nsource_filename = \"foo0-8787f43e282added376259c1adb08b80.rs\"\r\ntarget datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-apple-darwin\"\r\n\r\n; foo::bar\r\n; Function Attrs: norecurse nounwind readnone uwtable\r\ndefine { i32, i32 } @_ZN3foo3bar17h61d61d9e41681936E(i32 %x.0, i32 %x.1) unnamed_addr #0 {\r\nstart:\r\n  %switch.i = icmp ne i32 %x.0, 0\r\n  %. = zext i1 %switch.i to i32\r\n  %0 = insertvalue { i32, i32 } undef, i32 %., 0\r\n  %1 = insertvalue { i32, i32 } %0, i32 %x.1, 1\r\n  ret { i32, i32 } %1\r\n}\r\n\r\n; foo::foo\r\n; Function Attrs: norecurse nounwind readnone uwtable\r\ndefine { i32, i32 } @_ZN3foo3foo17h9a3b40b224e16c75E(i32, i32) unnamed_addr #0 {\r\n; call foo::bar\r\n  %3 = tail call { i32, i32 } @_ZN3foo3bar17h61d61d9e41681936E(i32 %0, i32 %1) #0\r\n  ret { i32, i32 } %3\r\n}\r\n\r\nattributes #0 = { norecurse nounwind readnone uwtable \"no-frame-pointer-elim\"=\"true\" \"probe-stack\"=\"__rust_probestack\" }\r\n```","created_at":"2018-03-30T09:45:39Z","updated_at":"2018-03-30T21:39:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0a6a95a9b991ed13bfcd7473c4470a2aa4c7e9e6","assignee":{"login":"Mark-Simulacrum","id":5047365,"avatar_url":"https://avatars0.githubusercontent.com/u/5047365?v=4","gravatar_id":"","url":"https://api.github.com/users/Mark-Simulacrum","html_url":"https://github.com/Mark-Simulacrum","followers_url":"https://api.github.com/users/Mark-Simulacrum/followers","following_url":"https://api.github.com/users/Mark-Simulacrum/following{/other_user}","gists_url":"https://api.github.com/users/Mark-Simulacrum/gists{/gist_id}","starred_url":"https://api.github.com/users/Mark-Simulacrum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mark-Simulacrum/subscriptions","organizations_url":"https://api.github.com/users/Mark-Simulacrum/orgs","repos_url":"https://api.github.com/users/Mark-Simulacrum/repos","events_url":"https://api.github.com/users/Mark-Simulacrum/events{/privacy}","received_events_url":"https://api.github.com/users/Mark-Simulacrum/received_events","type":"User","site_admin":false},"assignees":[{"login":"Mark-Simulacrum","id":5047365,"avatar_url":"https://avatars0.githubusercontent.com/u/5047365?v=4","gravatar_id":"","url":"https://api.github.com/users/Mark-Simulacrum","html_url":"https://github.com/Mark-Simulacrum","followers_url":"https://api.github.com/users/Mark-Simulacrum/followers","following_url":"https://api.github.com/users/Mark-Simulacrum/following{/other_user}","gists_url":"https://api.github.com/users/Mark-Simulacrum/gists{/gist_id}","starred_url":"https://api.github.com/users/Mark-Simulacrum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mark-Simulacrum/subscriptions","organizations_url":"https://api.github.com/users/Mark-Simulacrum/orgs","repos_url":"https://api.github.com/users/Mark-Simulacrum/repos","events_url":"https://api.github.com/users/Mark-Simulacrum/events{/privacy}","received_events_url":"https://api.github.com/users/Mark-Simulacrum/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":234956,"url":"https://api.github.com/repos/rust-lang/rust/labels/A-codegen","name":"A-codegen","color":"d7e102","default":false},{"id":583426710,"url":"https://api.github.com/repos/rust-lang/rust/labels/S-waiting-on-review","name":"S-waiting-on-review","color":"d3dddd","default":false},{"id":884691893,"url":"https://api.github.com/repos/rust-lang/rust/labels/WG-codegen","name":"WG-codegen","color":"c2e0c6","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rust/pulls/49499/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rust/pulls/49499/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/49499/comments","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/b85f91f8da2572b9a1b97b2a0ac0563238a7057b","head":{"label":"nox:option-swap","ref":"option-swap","sha":"b85f91f8da2572b9a1b97b2a0ac0563238a7057b","user":{"login":"nox","id":123095,"avatar_url":"https://avatars0.githubusercontent.com/u/123095?v=4","gravatar_id":"","url":"https://api.github.com/users/nox","html_url":"https://github.com/nox","followers_url":"https://api.github.com/users/nox/followers","following_url":"https://api.github.com/users/nox/following{/other_user}","gists_url":"https://api.github.com/users/nox/gists{/gist_id}","starred_url":"https://api.github.com/users/nox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nox/subscriptions","organizations_url":"https://api.github.com/users/nox/orgs","repos_url":"https://api.github.com/users/nox/repos","events_url":"https://api.github.com/users/nox/events{/privacy}","received_events_url":"https://api.github.com/users/nox/received_events","type":"User","site_admin":false},"repo":{"id":50607414,"name":"rust","full_name":"nox/rust","owner":{"login":"nox","id":123095,"avatar_url":"https://avatars0.githubusercontent.com/u/123095?v=4","gravatar_id":"","url":"https://api.github.com/users/nox","html_url":"https://github.com/nox","followers_url":"https://api.github.com/users/nox/followers","following_url":"https://api.github.com/users/nox/following{/other_user}","gists_url":"https://api.github.com/users/nox/gists{/gist_id}","starred_url":"https://api.github.com/users/nox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nox/subscriptions","organizations_url":"https://api.github.com/users/nox/orgs","repos_url":"https://api.github.com/users/nox/repos","events_url":"https://api.github.com/users/nox/events{/privacy}","received_events_url":"https://api.github.com/users/nox/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nox/rust","description":"A safe, concurrent, practical language.","fork":true,"url":"https://api.github.com/repos/nox/rust","forks_url":"https://api.github.com/repos/nox/rust/forks","keys_url":"https://api.github.com/repos/nox/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nox/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nox/rust/teams","hooks_url":"https://api.github.com/repos/nox/rust/hooks","issue_events_url":"https://api.github.com/repos/nox/rust/issues/events{/number}","events_url":"https://api.github.com/repos/nox/rust/events","assignees_url":"https://api.github.com/repos/nox/rust/assignees{/user}","branches_url":"https://api.github.com/repos/nox/rust/branches{/branch}","tags_url":"https://api.github.com/repos/nox/rust/tags","blobs_url":"https://api.github.com/repos/nox/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nox/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nox/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/nox/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nox/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/nox/rust/languages","stargazers_url":"https://api.github.com/repos/nox/rust/stargazers","contributors_url":"https://api.github.com/repos/nox/rust/contributors","subscribers_url":"https://api.github.com/repos/nox/rust/subscribers","subscription_url":"https://api.github.com/repos/nox/rust/subscription","commits_url":"https://api.github.com/repos/nox/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/nox/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/nox/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/nox/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/nox/rust/contents/{+path}","compare_url":"https://api.github.com/repos/nox/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nox/rust/merges","archive_url":"https://api.github.com/repos/nox/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nox/rust/downloads","issues_url":"https://api.github.com/repos/nox/rust/issues{/number}","pulls_url":"https://api.github.com/repos/nox/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/nox/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/nox/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nox/rust/labels{/name}","releases_url":"https://api.github.com/repos/nox/rust/releases{/id}","deployments_url":"https://api.github.com/repos/nox/rust/deployments","created_at":"2016-01-28T19:24:43Z","updated_at":"2016-01-28T19:24:59Z","pushed_at":"2018-03-30T13:55:31Z","git_url":"git://github.com/nox/rust.git","ssh_url":"git@github.com:nox/rust.git","clone_url":"https://github.com/nox/rust.git","svn_url":"https://github.com/nox/rust","homepage":"http://www.rust-lang.org","size":351362,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"051050dab9b39d29c8a5978bc79c7895dfa1118b","user":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars1.githubusercontent.com/u/5430905?v=4","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://avatars1.githubusercontent.com/u/5430905?v=4","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":"2018-03-30T21:20:13Z","pushed_at":"2018-03-30T21:14:52Z","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":354369,"stargazers_count":27371,"watchers_count":27371,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4810,"mirror_url":null,"archived":false,"open_issues_count":3585,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":4810,"open_issues":3585,"watchers":27371,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/49499"},"html":{"href":"https://github.com/rust-lang/rust/pull/49499"},"issue":{"href":"https://api.github.com/repos/rust-lang/rust/issues/49499"},"comments":{"href":"https://api.github.com/repos/rust-lang/rust/issues/49499/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/49499/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/49499/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rust/statuses/b85f91f8da2572b9a1b97b2a0ac0563238a7057b"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"ollie27"}}