{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/comments/197355758","pull_request_review_id":131084343,"id":197355758,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NzM1NTc1OA==","diff_hunk":"@@ -0,0 +1,110 @@\n+// Copyright 2013 The Rust Project Developers. See the COPYRIGHT\n+// file at the top-level directory of this distribution and at\n+// http://rust-lang.org/COPYRIGHT.\n+//\n+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or\n+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license\n+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your\n+// option. This file may not be copied, modified, or distributed\n+// except according to those terms.\n+\n+#![allow(missing_docs)]\n+#![unstable(feature = \"raw\", issue = \"27751\")]\n+\n+//! Contains struct definitions for the layout of compiler built-in types.\n+//!\n+//! They can be used as targets of transmutes in unsafe code for manipulating\n+//! the raw representations directly.\n+//!\n+//! Their definition should always match the ABI defined in `rustc::back::abi`.\n+\n+use core::cell::Cell;\n+use core::future::Future;\n+use core::marker::Unpin;\n+use core::mem::PinMut;\n+use core::option::Option;\n+use core::ptr::NonNull;\n+use core::task::{self, Poll};\n+use core::ops::{Drop, Generator, GeneratorState};\n+\n+#[stable(feature = \"rust1\", since = \"1.0.0\")]\n+pub use core::raw::*;\n+\n+/// Wrap a future in a generator.\n+///\n+/// This function returns a `GenFuture` underneath, but hides it in `impl Trait` to give\n+/// better error messages (`impl Future` rather than `GenFuture<[closure.....]>`).\n+#[unstable(feature = \"gen_future\", issue = \"50547\")]\n+pub fn future_from_generator<T: Generator<Yield = ()>>(x: T) -> impl Future<Output = T::Return> {\n+    GenFuture(x)\n+}\n+\n+/// A wrapper around generators used to implement `Future` for `async`/`await` code.\n+#[unstable(feature = \"gen_future\", issue = \"50547\")]\n+#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]\n+struct GenFuture<T: Generator<Yield = ()>>(T);\n+\n+// We rely on the fact that async/await futures are immovable in order to create\n+// self-referential borrows in the underlying generator.\n+impl<T: Generator<Yield = ()>> !Unpin for GenFuture<T> {}\n+\n+#[unstable(feature = \"gen_future\", issue = \"50547\")]\n+impl<T: Generator<Yield = ()>> Future for GenFuture<T> {\n+    type Output = T::Return;\n+    fn poll(self: PinMut<Self>, cx: &mut task::Context) -> Poll<Self::Output> {\n+        with_set_cx(cx, || match unsafe { PinMut::get_mut(self).0.resume() } {\n+            GeneratorState::Yielded(()) => Poll::Pending,\n+            GeneratorState::Complete(x) => Poll::Ready(x),\n+        })\n+    }\n+}\n+\n+thread_local! {\n+    static TLS_CX: Cell<Option<NonNull<task::Context<'static>>>> = Cell::new(None);\n+}\n+\n+struct SetOnDrop(Option<NonNull<task::Context<'static>>>);\n+\n+impl Drop for SetOnDrop {\n+    fn drop(&mut self) {\n+        TLS_CX.with(|tls_cx| {\n+            tls_cx.set(self.0.take());\n+        });\n+    }\n+}\n+\n+#[unstable(feature = \"gen_future\", issue = \"50547\")]\n+pub fn with_set_cx<F, R>(cx: &mut task::Context, f: F) -> R","path":"src/libstd/raw.rs","position":77,"original_position":77,"commit_id":"85e4866320e992126e73d1c640f16a4c755a66b3","original_commit_id":"85e4866320e992126e73d1c640f16a4c755a66b3","user":{"login":"eddyb","id":77424,"node_id":"MDQ6VXNlcjc3NDI0","avatar_url":"https://avatars2.githubusercontent.com/u/77424?v=4","gravatar_id":"","url":"https://api.github.com/users/eddyb","html_url":"https://github.com/eddyb","followers_url":"https://api.github.com/users/eddyb/followers","following_url":"https://api.github.com/users/eddyb/following{/other_user}","gists_url":"https://api.github.com/users/eddyb/gists{/gist_id}","starred_url":"https://api.github.com/users/eddyb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eddyb/subscriptions","organizations_url":"https://api.github.com/users/eddyb/orgs","repos_url":"https://api.github.com/users/eddyb/repos","events_url":"https://api.github.com/users/eddyb/events{/privacy}","received_events_url":"https://api.github.com/users/eddyb/received_events","type":"User","site_admin":false},"body":"I'd call this `set_task_cx` and the other one `get_task_cx`.","created_at":"2018-06-22T06:59:03Z","updated_at":"2018-06-22T06:59:03Z","html_url":"https://github.com/rust-lang/rust/pull/51580#discussion_r197355758","pull_request_url":"https://api.github.com/repos/rust-lang/rust/pulls/51580","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments/197355758"},"html":{"href":"https://github.com/rust-lang/rust/pull/51580#discussion_r197355758"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/51580"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/51580","id":195287632,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk1Mjg3NjMy","html_url":"https://github.com/rust-lang/rust/pull/51580","diff_url":"https://github.com/rust-lang/rust/pull/51580.diff","patch_url":"https://github.com/rust-lang/rust/pull/51580.patch","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/51580","number":51580,"state":"open","locked":false,"title":"async/await","user":{"login":"cramertj","id":5963049,"node_id":"MDQ6VXNlcjU5NjMwNDk=","avatar_url":"https://avatars1.githubusercontent.com/u/5963049?v=4","gravatar_id":"","url":"https://api.github.com/users/cramertj","html_url":"https://github.com/cramertj","followers_url":"https://api.github.com/users/cramertj/followers","following_url":"https://api.github.com/users/cramertj/following{/other_user}","gists_url":"https://api.github.com/users/cramertj/gists{/gist_id}","starred_url":"https://api.github.com/users/cramertj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cramertj/subscriptions","organizations_url":"https://api.github.com/users/cramertj/orgs","repos_url":"https://api.github.com/users/cramertj/repos","events_url":"https://api.github.com/users/cramertj/events{/privacy}","received_events_url":"https://api.github.com/users/cramertj/received_events","type":"User","site_admin":false},"body":"This PR implements `async`/`await` syntax for `async fn` in Rust 2015 and `async` closures and `async` blocks in Rust 2018 (tracking issue: https://github.com/rust-lang/rust/issues/50547). Limitations: non-`move` async closures with arguments are currently not supported, nor are `async fn` with multiple different input lifetimes. These limitations are not fundamental and will be removed in the future, however I'd like to go ahead and get this PR merged so we can start experimenting with this in combination with futures 0.3.\r\n\r\nBased on https://github.com/rust-lang/rust/pull/51414.\r\ncc @petrochenkov for parsing changes.\r\nr? @eddyb ","created_at":"2018-06-15T21:32:34Z","updated_at":"2018-06-22T06:59:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"af7b1a6b21a545081beafc31f056560b0ceba26d","assignee":{"login":"eddyb","id":77424,"node_id":"MDQ6VXNlcjc3NDI0","avatar_url":"https://avatars2.githubusercontent.com/u/77424?v=4","gravatar_id":"","url":"https://api.github.com/users/eddyb","html_url":"https://github.com/eddyb","followers_url":"https://api.github.com/users/eddyb/followers","following_url":"https://api.github.com/users/eddyb/following{/other_user}","gists_url":"https://api.github.com/users/eddyb/gists{/gist_id}","starred_url":"https://api.github.com/users/eddyb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eddyb/subscriptions","organizations_url":"https://api.github.com/users/eddyb/orgs","repos_url":"https://api.github.com/users/eddyb/repos","events_url":"https://api.github.com/users/eddyb/events{/privacy}","received_events_url":"https://api.github.com/users/eddyb/received_events","type":"User","site_admin":false},"assignees":[{"login":"eddyb","id":77424,"node_id":"MDQ6VXNlcjc3NDI0","avatar_url":"https://avatars2.githubusercontent.com/u/77424?v=4","gravatar_id":"","url":"https://api.github.com/users/eddyb","html_url":"https://github.com/eddyb","followers_url":"https://api.github.com/users/eddyb/followers","following_url":"https://api.github.com/users/eddyb/following{/other_user}","gists_url":"https://api.github.com/users/eddyb/gists{/gist_id}","starred_url":"https://api.github.com/users/eddyb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eddyb/subscriptions","organizations_url":"https://api.github.com/users/eddyb/orgs","repos_url":"https://api.github.com/users/eddyb/repos","events_url":"https://api.github.com/users/eddyb/events{/privacy}","received_events_url":"https://api.github.com/users/eddyb/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":583426710,"node_id":"MDU6TGFiZWw1ODM0MjY3MTA=","url":"https://api.github.com/repos/rust-lang/rust/labels/S-waiting-on-review","name":"S-waiting-on-review","color":"d3dddd","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rust/pulls/51580/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rust/pulls/51580/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/51580/comments","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/85e4866320e992126e73d1c640f16a4c755a66b3","head":{"label":"cramertj:async-await","ref":"async-await","sha":"85e4866320e992126e73d1c640f16a4c755a66b3","user":{"login":"cramertj","id":5963049,"node_id":"MDQ6VXNlcjU5NjMwNDk=","avatar_url":"https://avatars1.githubusercontent.com/u/5963049?v=4","gravatar_id":"","url":"https://api.github.com/users/cramertj","html_url":"https://github.com/cramertj","followers_url":"https://api.github.com/users/cramertj/followers","following_url":"https://api.github.com/users/cramertj/following{/other_user}","gists_url":"https://api.github.com/users/cramertj/gists{/gist_id}","starred_url":"https://api.github.com/users/cramertj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cramertj/subscriptions","organizations_url":"https://api.github.com/users/cramertj/orgs","repos_url":"https://api.github.com/users/cramertj/repos","events_url":"https://api.github.com/users/cramertj/events{/privacy}","received_events_url":"https://api.github.com/users/cramertj/received_events","type":"User","site_admin":false},"repo":{"id":57869658,"node_id":"MDEwOlJlcG9zaXRvcnk1Nzg2OTY1OA==","name":"rust","full_name":"cramertj/rust","owner":{"login":"cramertj","id":5963049,"node_id":"MDQ6VXNlcjU5NjMwNDk=","avatar_url":"https://avatars1.githubusercontent.com/u/5963049?v=4","gravatar_id":"","url":"https://api.github.com/users/cramertj","html_url":"https://github.com/cramertj","followers_url":"https://api.github.com/users/cramertj/followers","following_url":"https://api.github.com/users/cramertj/following{/other_user}","gists_url":"https://api.github.com/users/cramertj/gists{/gist_id}","starred_url":"https://api.github.com/users/cramertj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cramertj/subscriptions","organizations_url":"https://api.github.com/users/cramertj/orgs","repos_url":"https://api.github.com/users/cramertj/repos","events_url":"https://api.github.com/users/cramertj/events{/privacy}","received_events_url":"https://api.github.com/users/cramertj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cramertj/rust","description":"A safe, concurrent, practical language.","fork":true,"url":"https://api.github.com/repos/cramertj/rust","forks_url":"https://api.github.com/repos/cramertj/rust/forks","keys_url":"https://api.github.com/repos/cramertj/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cramertj/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cramertj/rust/teams","hooks_url":"https://api.github.com/repos/cramertj/rust/hooks","issue_events_url":"https://api.github.com/repos/cramertj/rust/issues/events{/number}","events_url":"https://api.github.com/repos/cramertj/rust/events","assignees_url":"https://api.github.com/repos/cramertj/rust/assignees{/user}","branches_url":"https://api.github.com/repos/cramertj/rust/branches{/branch}","tags_url":"https://api.github.com/repos/cramertj/rust/tags","blobs_url":"https://api.github.com/repos/cramertj/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cramertj/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cramertj/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/cramertj/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cramertj/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/cramertj/rust/languages","stargazers_url":"https://api.github.com/repos/cramertj/rust/stargazers","contributors_url":"https://api.github.com/repos/cramertj/rust/contributors","subscribers_url":"https://api.github.com/repos/cramertj/rust/subscribers","subscription_url":"https://api.github.com/repos/cramertj/rust/subscription","commits_url":"https://api.github.com/repos/cramertj/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/cramertj/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/cramertj/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/cramertj/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/cramertj/rust/contents/{+path}","compare_url":"https://api.github.com/repos/cramertj/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cramertj/rust/merges","archive_url":"https://api.github.com/repos/cramertj/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cramertj/rust/downloads","issues_url":"https://api.github.com/repos/cramertj/rust/issues{/number}","pulls_url":"https://api.github.com/repos/cramertj/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/cramertj/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/cramertj/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cramertj/rust/labels{/name}","releases_url":"https://api.github.com/repos/cramertj/rust/releases{/id}","deployments_url":"https://api.github.com/repos/cramertj/rust/deployments","created_at":"2016-05-02T06:18:13Z","updated_at":"2016-05-02T06:18:31Z","pushed_at":"2018-06-22T06:26:29Z","git_url":"git://github.com/cramertj/rust.git","ssh_url":"git@github.com:cramertj/rust.git","clone_url":"https://github.com/cramertj/rust.git","svn_url":"https://github.com/cramertj/rust","homepage":"http://www.rust-lang.org","size":372802,"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,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"4b17d31f1147f840231c43b1ac1478a497af20df","user":{"login":"rust-lang","id":5430905,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU0MzA5MDU=","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,"node_id":"MDEwOlJlcG9zaXRvcnk3MjQ3MTI=","name":"rust","full_name":"rust-lang/rust","owner":{"login":"rust-lang","id":5430905,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU0MzA5MDU=","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-06-22T06:37:55Z","pushed_at":"2018-06-22T06:36:17Z","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":375674,"stargazers_count":28902,"watchers_count":28902,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4999,"mirror_url":null,"archived":false,"open_issues_count":3906,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":4999,"open_issues":3906,"watchers":28902,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/51580"},"html":{"href":"https://github.com/rust-lang/rust/pull/51580"},"issue":{"href":"https://api.github.com/repos/rust-lang/rust/issues/51580"},"comments":{"href":"https://api.github.com/repos/rust-lang/rust/issues/51580/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/51580/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/51580/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rust/statuses/85e4866320e992126e73d1c640f16a4c755a66b3"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"eddyb"}}