Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add core::future::{pending,ready} #70834

Merged
merged 1 commit into from
May 9, 2020
Merged

Add core::future::{pending,ready} #70834

merged 1 commit into from
May 9, 2020

Conversation

yoshuawuyts
Copy link
Member

Adds two future constructors to core: future::ready and future::pending. These functions enable constructing futures of any type that either immediately resolve, or never resolve which is an incredible useful tool when writing documentation.

These functions have prior art in both the futures and async-std crates. This implementation has been adapted from the futures crate.

Examples

In #70817 we propose adding the ready! macro. In the example we use an async fn which does not return a future that implements Unpin, which leads to the use of unsafe. Instead had we had future::ready available, we could've written the same example without using unsafe:

use core::task::{Context, Poll};
use core::future::{self, Future};
use core::pin::Pin;

pub fn do_poll(cx: &mut Context<'_>) -> Poll<()> {
    let mut fut = future::ready(42_u8);
    let num = ready!(Pin::new(fut).poll(cx));
    // ... use num

    Poll::Ready(())
}

Why future::ready?

Arguably future::ready and async {} can be considered equivalent. The main differences are that future::ready returns a future that implements Unpin, and the returned future is a concrete type. This is useful for traits that require a future as an associated type that can sometimes be a no-op (example).

The final, minor argument is that future::ready and future::pending form a counterpart to the enum members of Poll: Ready and Pending. These functions form a conceptual bridge between Poll and Future, and can be used as a useful teaching device.

References

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-04-06T08:28:27.9878509Z ========================== Starting Command Output ===========================
2020-04-06T08:28:27.9895722Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/de194ed8-bc7b-40a8-bd1d-cc2b85c47700.sh
2020-04-06T08:28:28.0089801Z 
2020-04-06T08:28:28.0146537Z ##[section]Finishing: Disable git automatic line ending conversion
2020-04-06T08:28:28.0165305Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70834/merge to s
2020-04-06T08:28:28.0168713Z Task         : Get sources
2020-04-06T08:28:28.0169023Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-06T08:28:28.0169318Z Version      : 1.0.0
2020-04-06T08:28:28.0169517Z Author       : Microsoft
---
2020-04-06T08:28:28.7355304Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-04-06T08:28:28.7364177Z ##[command]git config gc.auto 0
2020-04-06T08:28:28.7479223Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-04-06T08:28:28.7502120Z ##[command]git config --get-all http.proxy
2020-04-06T08:28:28.7508287Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/70834/merge:refs/remotes/pull/70834/merge
---
2020-04-06T08:31:54.0977214Z Looks like docker image is the same as before, not uploading
2020-04-06T08:32:02.4041396Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-06T08:32:02.4326033Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-06T08:32:02.4383936Z == clock drift check ==
2020-04-06T08:32:02.4384251Z   local time: Mon Apr  6 08:32:02 UTC 2020
2020-04-06T08:32:02.7059021Z   network time: Mon, 06 Apr 2020 08:32:02 GMT
2020-04-06T08:32:02.7081415Z Starting sccache server...
2020-04-06T08:32:02.7915996Z configure: processing command line
2020-04-06T08:32:02.7916279Z configure: 
2020-04-06T08:32:02.7918463Z configure: rust.dist-src        := False
---
2020-04-06T08:37:02.0102797Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-06T08:37:03.4132832Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-06T08:37:05.0020566Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-06T08:37:05.1025555Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-06T08:37:14.6804122Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-06T08:37:16.2850353Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-06T08:37:20.5475757Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-06T08:37:24.5542944Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-06T08:37:34.3949117Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-06T08:59:29.5636116Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-06T08:59:31.3488433Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-06T08:59:33.3637466Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-06T08:59:34.3733378Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-06T08:59:45.9147246Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-06T08:59:47.9616559Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-06T08:59:53.1736788Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-06T08:59:58.7027357Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-06T09:00:10.5735349Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-06T09:25:41.1138393Z .................................................................................................... 1700/9878
2020-04-06T09:25:45.1564754Z .................................................................................................... 1800/9878
2020-04-06T09:25:53.9568918Z .................................................................................................i.. 1900/9878
2020-04-06T09:26:01.7767120Z .................................................................................................... 2000/9878
2020-04-06T09:26:08.3117123Z .......................................................................................iiiii........ 2100/9878
2020-04-06T09:26:29.2761394Z .................................................................................................... 2300/9878
2020-04-06T09:26:31.3990287Z .................................................................................................... 2400/9878
2020-04-06T09:26:33.6277792Z .................................................................................................... 2500/9878
2020-04-06T09:26:39.7122812Z .................................................................................................... 2600/9878
---
2020-04-06T09:29:31.9953631Z .............................................................i...............i...................... 5000/9878
2020-04-06T09:29:39.4109966Z .................................................................................................... 5100/9878
2020-04-06T09:29:47.2460535Z .................................................................................................... 5200/9878
2020-04-06T09:29:52.5011541Z ......i............................................................................................. 5300/9878
2020-04-06T09:30:02.7607069Z ...............................................................................................ii.ii 5400/9878
2020-04-06T09:30:07.9746827Z ........i...i....................................................................................... 5500/9878
2020-04-06T09:30:17.2882255Z ........................................i........................................................... 5700/9878
2020-04-06T09:30:17.2882255Z ........................................i........................................................... 5700/9878
2020-04-06T09:30:27.2633459Z ............................................................ii.....................................i 5800/9878
2020-04-06T09:30:40.3167484Z .................................................................................................... 6000/9878
2020-04-06T09:30:40.3167484Z .................................................................................................... 6000/9878
2020-04-06T09:30:50.3711090Z .............................................................................................ii...i. 6100/9878
2020-04-06T09:31:02.3970965Z .ii...........i..................................................................................... 6200/9878
2020-04-06T09:31:18.2740025Z .................................................................................................... 6400/9878
2020-04-06T09:31:21.0226298Z .................................................................................................... 6500/9878
2020-04-06T09:31:21.0226298Z .................................................................................................... 6500/9878
2020-04-06T09:31:33.6197372Z .......................i..ii........................................................................ 6600/9878
2020-04-06T09:31:54.5609778Z .................................................................................................... 6800/9878
2020-04-06T09:31:56.7000128Z .......................i............................................................................ 6900/9878
2020-04-06T09:31:58.7931371Z .................................................................................................... 7000/9878
2020-04-06T09:32:01.0603766Z ..............................................................i..................................... 7100/9878
---
2020-04-06T09:33:39.3330153Z .................................................................................................... 7800/9878
2020-04-06T09:33:43.6175121Z .................................................................................................... 7900/9878
2020-04-06T09:33:49.6291622Z .................................................................................................... 8000/9878
2020-04-06T09:33:57.2580349Z ...........................i........................................................................ 8100/9878
2020-04-06T09:34:05.4089236Z ............................................................................iiiiiiiiii.i............ 8200/9878
2020-04-06T09:34:21.0538232Z ....................i......i........................................................................ 8400/9878
2020-04-06T09:34:25.7266789Z .................................................................................................... 8500/9878
2020-04-06T09:34:36.4282459Z .................................................................................................... 8600/9878
2020-04-06T09:34:48.5348622Z .................................................................................................... 8700/9878
---
2020-04-06T09:37:14.4666732Z Suite("src/test/codegen") not skipped for "bootstrap::test::Codegen" -- not in ["src/tools/tidy"]
2020-04-06T09:37:14.4922037Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-06T09:37:14.7095218Z 
2020-04-06T09:37:14.7095612Z running 185 tests
2020-04-06T09:37:17.6126030Z iiii......i............ii.i..iiii....i....i...........i............i..i..................i....i..... 100/185
2020-04-06T09:37:20.3117072Z .......i.i.i...iii..iiiiiiiiiiiiiiii.......................iii...............ii......
2020-04-06T09:37:20.3120144Z 
2020-04-06T09:37:20.3127405Z  finished in 5.820
2020-04-06T09:37:20.3134348Z Suite("src/test/codegen-units") not skipped for "bootstrap::test::CodegenUnits" -- not in ["src/tools/tidy"]
2020-04-06T09:37:20.3328529Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-06T09:37:22.5632149Z Suite("src/test/assembly") not skipped for "bootstrap::test::Assembly" -- not in ["src/tools/tidy"]
2020-04-06T09:37:22.5834745Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-06T09:37:22.7420690Z 
2020-04-06T09:37:22.7421387Z running 9 tests
2020-04-06T09:37:22.7422894Z iiiiiiiii
2020-04-06T09:37:22.7424289Z 
2020-04-06T09:37:22.7428443Z  finished in 0.159
2020-04-06T09:37:22.7434774Z Suite("src/test/incremental") not skipped for "bootstrap::test::Incremental" -- not in ["src/tools/tidy"]
2020-04-06T09:37:22.7631073Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-06T09:37:44.0431766Z Suite("src/test/debuginfo") not skipped for "bootstrap::test::Debuginfo" -- not in ["src/tools/tidy"]
2020-04-06T09:37:44.0693986Z Check compiletest suite=debuginfo mode=debuginfo (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-06T09:37:44.2739321Z 
2020-04-06T09:37:44.2739794Z running 115 tests
2020-04-06T09:37:59.4910632Z iiiii..i.....i..i...i..i.i.i..i..i..ii....i.i....ii..........iiii.........i.....i..i.......ii.i.ii.. 100/115
2020-04-06T09:38:01.1690468Z ...iiii.....ii.
2020-04-06T09:38:01.1691806Z 
2020-04-06T09:38:01.1698857Z  finished in 17.100
2020-04-06T09:38:01.1709081Z Suite("src/test/ui-fulldeps") not skipped for "bootstrap::test::UiFullDeps" -- not in ["src/tools/tidy"]
2020-04-06T09:38:01.1713717Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-06T09:50:15.9878895Z 
2020-04-06T09:50:15.9883005Z    Doc-tests core
2020-04-06T09:50:20.4902738Z 
2020-04-06T09:50:20.4903719Z running 2492 tests
2020-04-06T09:50:29.5258721Z ......iiiii......................................................................................... 100/2492
2020-04-06T09:50:38.0964522Z .....................................................................................ii............. 200/2492
2020-04-06T09:50:58.1634178Z ......................i............................................................................. 400/2492
2020-04-06T09:51:08.0596292Z ............................................................................i..i..................ii 500/2492
2020-04-06T09:51:15.5386822Z ii.................................................................................................. 600/2492
2020-04-06T09:51:23.8983237Z .................................................................................................... 700/2492
---
2020-04-06T09:55:01.8322977Z ...............................................thread '<unnamed>' panicked at 'explicit panic', src/libstd/io/stdio.rs:888:13
2020-04-06T09:55:01.8331003Z .. 300/760
2020-04-06T09:55:01.9258254Z .................................................................................................... 400/760
2020-04-06T09:55:04.0132029Z .................................................................................................... 500/760
2020-04-06T09:55:04.0567672Z ..................thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:2741:22
2020-04-06T09:55:04.0584831Z ....thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"', src/libstd/sync/mpsc/mod.rs:2766:17
2020-04-06T09:55:04.0596743Z thread '.<unnamed>.' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:2778:21
2020-04-06T09:55:04.0612134Z .....thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:2645:13
2020-04-06T09:55:04.4210985Z ..........................................thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:1997:22
2020-04-06T09:55:04.4254706Z ....thread '.<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', .src/libstd/sync/mpsc/mod.rs.:.2034:...21thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/libstd/sync/mpsc/mod.rs:1916:13
2020-04-06T09:55:04.4674630Z ................. 600/760
2020-04-06T09:55:06.4936631Z ....................thread '<unnamed>' panicked at 'explicit panic', src/libstd/sync/mutex.rs:633:13
2020-04-06T09:55:06.4950734Z ..thread '<unnamed>' panicked at 'test panic in inner thread to poison mutex', src/libstd/sync/mutex.rs:587:13
2020-04-06T09:55:06.4962613Z ...thread '<unnamed>' panicked at 'test panic in inner thread to poison mutex', src/libstd/sync/mutex.rs:563:13
---
2020-04-06T09:55:15.5060095Z 
2020-04-06T09:55:15.5060592Z running 1018 tests
2020-04-06T09:55:32.3307198Z i................................................................................................... 100/1018
2020-04-06T09:55:42.0987477Z .................................................................................................... 200/1018
2020-04-06T09:55:49.3047919Z ..................iii......i......i...i......i...................................................... 300/1018
2020-04-06T09:56:00.2320391Z ..................................................i....i......................................ii.... 500/1018
2020-04-06T09:56:07.5900824Z .................................................................................................... 600/1018
2020-04-06T09:56:12.3895481Z .................................................................................................... 700/1018
2020-04-06T09:56:12.3895481Z .................................................................................................... 700/1018
2020-04-06T09:56:19.8173001Z ............................................iiii.................................................... 800/1018
2020-04-06T09:56:32.4956446Z .................................................................................................... 900/1018
2020-04-06T09:56:38.4969558Z ..................................................................iiii.............................. 1000/1018
2020-04-06T09:56:39.5064516Z test result: ok. 998 passed; 0 failed; 20 ignored; 0 measured; 0 filtered out
2020-04-06T09:56:39.5065021Z 
2020-04-06T09:56:39.5175076Z  finished in 158.207
2020-04-06T09:56:39.5180925Z Set({"src/libterm"}) not skipped for "bootstrap::test::Crate" -- not in ["src/tools/tidy"]
---
2020-04-06T09:59:45.2754952Z 
2020-04-06T09:59:45.2755417Z test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
2020-04-06T09:59:45.2755823Z 
2020-04-06T09:59:45.2846950Z  finished in 0.984
2020-04-06T09:59:45.2857173Z Set({"/checkout/src/librustc_query_system"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
2020-04-06T09:59:45.2881096Z Testing rustc_query_system stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-06T09:59:45.4724160Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-06T09:59:46.4745194Z      Running build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_query_system-6282e4abc4e5c2cd
2020-04-06T09:59:46.4778716Z 
2020-04-06T09:59:46.4779206Z running 0 tests
2020-04-06T09:59:46.4779903Z 
---
2020-04-06T10:13:59.1489936Z Set({"/checkout/src/librustc_parse"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
2020-04-06T10:13:59.1490729Z Set({"/checkout/src/librustc_passes"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
2020-04-06T10:13:59.1491532Z Set({"/checkout/src/librustc_plugin_impl"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
2020-04-06T10:13:59.1492331Z Set({"/checkout/src/librustc_privacy"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
2020-04-06T10:13:59.1493153Z Set({"/checkout/src/librustc_query_system"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
2020-04-06T10:13:59.1495123Z Set({"/checkout/src/librustc_save_analysis"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
2020-04-06T10:13:59.1495957Z Set({"/checkout/src/librustc_session"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
2020-04-06T10:13:59.1496738Z Set({"/checkout/src/librustc_span"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
2020-04-06T10:13:59.1497694Z Set({"/checkout/src/librustc_symbol_mangling"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
---
2020-04-06T10:14:11.5741940Z Rustbook (x86_64-unknown-linux-gnu) - edition-guide
2020-04-06T10:14:11.9803124Z Building stage0 tool linkchecker (x86_64-unknown-linux-gnu)
2020-04-06T10:14:12.1501479Z    Compiling linkchecker v0.1.0 (/checkout/src/tools/linkchecker)
2020-04-06T10:14:13.5753860Z     Finished release [optimized] target(s) in 1.59s
2020-04-06T10:14:13.8639374Z core/future/fn.pending.html:3: broken link - core/future/struct.Poll.html
2020-04-06T10:14:16.0839568Z std/future/fn.pending.html:3: broken link - std/future/struct.Poll.html
2020-04-06T10:14:21.0155129Z thread 'main' panicked at 'found some broken links', src/tools/linkchecker/main.rs:43:9
2020-04-06T10:14:21.0187779Z 
2020-04-06T10:14:21.0188150Z 
2020-04-06T10:14:21.0189338Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/linkchecker" "/checkout/obj/build/x86_64-unknown-linux-gnu/doc"
2020-04-06T10:14:21.0189876Z expected success, got: exit code: 101
2020-04-06T10:14:21.0189876Z expected success, got: exit code: 101
2020-04-06T10:14:21.0190070Z 
2020-04-06T10:14:21.0190187Z 
2020-04-06T10:14:21.0197983Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --exclude src/tools/tidy
2020-04-06T10:14:21.0198394Z Build completed unsuccessfully in 1:40:49
2020-04-06T10:14:21.0256790Z == clock drift check ==
2020-04-06T10:14:21.0274539Z   local time: Mon Apr  6 10:14:21 UTC 2020
2020-04-06T10:14:21.0579190Z   network time: Mon, 06 Apr 2020 10:14:21 GMT
2020-04-06T10:14:22.5886521Z 
2020-04-06T10:14:22.5886521Z 
2020-04-06T10:14:22.5957746Z ##[error]Bash exited with code '1'.
2020-04-06T10:14:22.5970866Z ##[section]Finishing: Run build
2020-04-06T10:14:22.6023038Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70834/merge to s
2020-04-06T10:14:22.6028697Z Task         : Get sources
2020-04-06T10:14:22.6029064Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-06T10:14:22.6029412Z Version      : 1.0.0
2020-04-06T10:14:22.6029649Z Author       : Microsoft
2020-04-06T10:14:22.6029649Z Author       : Microsoft
2020-04-06T10:14:22.6030031Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-04-06T10:14:22.6030474Z ==============================================================================
2020-04-06T10:14:22.9413538Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-04-06T10:14:22.9454835Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/70834/merge to s
2020-04-06T10:14:22.9536724Z Cleaning up task key
2020-04-06T10:14:22.9538224Z Start cleaning up orphan processes.
2020-04-06T10:14:22.9712766Z Terminate orphan process: pid (3853) (python)
2020-04-06T10:14:22.9978009Z ##[section]Finishing: Finalize Job

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-7 of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2020-04-06T12:42:52.2001666Z ========================== Starting Command Output ===========================
2020-04-06T12:42:52.2005583Z [command]/bin/bash --noprofile --norc /home/vsts/work/_temp/7e8569c7-4cac-4720-bd0a-ded8199c70b8.sh
2020-04-06T12:42:52.2005913Z 
2020-04-06T12:42:52.2011081Z ##[section]Finishing: Disable git automatic line ending conversion
2020-04-06T12:42:52.2030642Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70834/merge to s
2020-04-06T12:42:52.2033071Z Task         : Get sources
2020-04-06T12:42:52.2033294Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-06T12:42:52.2033505Z Version      : 1.0.0
2020-04-06T12:42:52.2033664Z Author       : Microsoft
---
2020-04-06T12:42:53.1994026Z ##[command]git remote add origin https://github.com/rust-lang/rust
2020-04-06T12:42:53.2000143Z ##[command]git config gc.auto 0
2020-04-06T12:42:53.2004314Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2020-04-06T12:42:53.2008231Z ##[command]git config --get-all http.proxy
2020-04-06T12:42:53.2015688Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/70834/merge:refs/remotes/pull/70834/merge
---
2020-04-06T12:45:14.0884511Z Looks like docker image is the same as before, not uploading
2020-04-06T12:45:21.6983812Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-06T12:45:21.7195524Z [CI_JOB_NAME=x86_64-gnu-llvm-7]
2020-04-06T12:45:21.7215792Z == clock drift check ==
2020-04-06T12:45:21.7234023Z   local time: Mon Apr  6 12:45:21 UTC 2020
2020-04-06T12:45:21.8823001Z   network time: Mon, 06 Apr 2020 12:45:21 GMT
2020-04-06T12:45:21.8841874Z Starting sccache server...
2020-04-06T12:45:21.9509675Z configure: processing command line
2020-04-06T12:45:21.9510394Z configure: 
2020-04-06T12:45:21.9511518Z configure: rust.dist-src        := False
---
2020-04-06T12:49:23.6460911Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-06T12:49:24.7883532Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-06T12:49:26.0019572Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-06T12:49:26.1476308Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-06T12:49:33.6983494Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-06T12:49:34.9944587Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-06T12:49:38.4265747Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-06T12:49:41.5323781Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-06T12:49:49.2570751Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-06T13:07:19.5152829Z    Compiling rustc_feature v0.0.0 (/checkout/src/librustc_feature)
2020-04-06T13:07:20.9875936Z    Compiling fmt_macros v0.0.0 (/checkout/src/libfmt_macros)
2020-04-06T13:07:22.5551393Z    Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
2020-04-06T13:07:23.4632376Z    Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
2020-04-06T13:07:32.2190236Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-06T13:07:33.9652598Z    Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
2020-04-06T13:07:38.2614130Z    Compiling rustc_attr v0.0.0 (/checkout/src/librustc_attr)
2020-04-06T13:07:42.4639152Z    Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
2020-04-06T13:07:51.4043319Z    Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
2020-04-06T13:27:49.1905932Z .................................................................................................... 1700/9878
2020-04-06T13:27:52.4418840Z .................................................................................................... 1800/9878
2020-04-06T13:27:59.3948509Z .................................................................................................i.. 1900/9878
2020-04-06T13:28:05.5721892Z .................................................................................................... 2000/9878
2020-04-06T13:28:10.5887266Z .......................................................................................iiiii........ 2100/9878
2020-04-06T13:28:27.1463710Z .................................................................................................... 2300/9878
2020-04-06T13:28:28.8335916Z .................................................................................................... 2400/9878
2020-04-06T13:28:30.6244349Z .................................................................................................... 2500/9878
2020-04-06T13:28:35.4051377Z .................................................................................................... 2600/9878
---
2020-04-06T13:30:55.2195490Z .............................................................i...............i...................... 5000/9878
2020-04-06T13:31:01.2032777Z .................................................................................................... 5100/9878
2020-04-06T13:31:07.3071572Z .................................................................................................... 5200/9878
2020-04-06T13:31:11.6339806Z ......i............................................................................................. 5300/9878
2020-04-06T13:31:19.6382532Z ...............................................................................................ii.ii 5400/9878
2020-04-06T13:31:23.5985442Z ........i...i....................................................................................... 5500/9878
2020-04-06T13:31:30.6961040Z ........................................i........................................................... 5700/9878
2020-04-06T13:31:30.6961040Z ........................................i........................................................... 5700/9878
2020-04-06T13:31:38.3886529Z ............................................................ii.....................................i 5800/9878
2020-04-06T13:31:48.2775943Z .................................................................................................... 6000/9878
2020-04-06T13:31:48.2775943Z .................................................................................................... 6000/9878
2020-04-06T13:31:56.0601297Z .............................................................................................ii...i. 6100/9878
2020-04-06T13:32:06.0569681Z .ii...........i..................................................................................... 6200/9878
2020-04-06T13:32:18.4376237Z .................................................................................................... 6400/9878
2020-04-06T13:32:20.6226101Z .................................................................................................... 6500/9878
2020-04-06T13:32:20.6226101Z .................................................................................................... 6500/9878
2020-04-06T13:32:30.6242457Z .......................i..ii........................................................................ 6600/9878
2020-04-06T13:32:47.0840645Z .................................................................................................... 6800/9878
2020-04-06T13:32:48.7114201Z .......................i............................................................................ 6900/9878
2020-04-06T13:32:50.3300549Z .................................................................................................... 7000/9878
2020-04-06T13:32:52.0945353Z ..............................................................i..................................... 7100/9878
---
2020-04-06T13:34:08.9419512Z .................................................................................................... 7800/9878
2020-04-06T13:34:12.6291548Z .................................................................................................... 7900/9878
2020-04-06T13:34:17.3587296Z .................................................................................................... 8000/9878
2020-04-06T13:34:23.3489807Z ...........................i........................................................................ 8100/9878
2020-04-06T13:34:29.7978929Z ............................................................................iiiiiiiiii.i............ 8200/9878
2020-04-06T13:34:41.9315300Z ....................i......i........................................................................ 8400/9878
2020-04-06T13:34:45.7304444Z .................................................................................................... 8500/9878
2020-04-06T13:34:54.2600136Z .................................................................................................... 8600/9878
2020-04-06T13:35:03.8521018Z .................................................................................................... 8700/9878
---
2020-04-06T13:36:56.0514853Z Suite("src/test/codegen") not skipped for "bootstrap::test::Codegen" -- not in ["src/tools/tidy"]
2020-04-06T13:36:56.0686668Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-06T13:36:56.2401715Z 
2020-04-06T13:36:56.2401990Z running 185 tests
2020-04-06T13:36:58.7201028Z iiii......i............ii.i..iiii....i....i...........i............i..i..................i....i..... 100/185
2020-04-06T13:37:00.8099149Z .......i.i.i...iii..iiiiiiiiiiiiiiii.......................iii...............ii......
2020-04-06T13:37:00.8101088Z 
2020-04-06T13:37:00.8101203Z  finished in 4.741
2020-04-06T13:37:00.8107301Z Suite("src/test/codegen-units") not skipped for "bootstrap::test::CodegenUnits" -- not in ["src/tools/tidy"]
2020-04-06T13:37:00.8256893Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-06T13:37:02.7017884Z Suite("src/test/assembly") not skipped for "bootstrap::test::Assembly" -- not in ["src/tools/tidy"]
2020-04-06T13:37:02.7170392Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-06T13:37:02.8347907Z 
2020-04-06T13:37:02.8348241Z running 9 tests
2020-04-06T13:37:02.8354814Z iiiiiiiii
2020-04-06T13:37:02.8356025Z 
2020-04-06T13:37:02.8356211Z  finished in 0.117
2020-04-06T13:37:02.8361238Z Suite("src/test/incremental") not skipped for "bootstrap::test::Incremental" -- not in ["src/tools/tidy"]
2020-04-06T13:37:02.8512082Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-06T13:37:19.5050591Z Suite("src/test/debuginfo") not skipped for "bootstrap::test::Debuginfo" -- not in ["src/tools/tidy"]
2020-04-06T13:37:19.5227926Z Check compiletest suite=debuginfo mode=debuginfo (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-06T13:37:19.6730484Z 
2020-04-06T13:37:19.6730864Z running 115 tests
2020-04-06T13:37:30.7915077Z iiiii..i.....i..i...i..i.i.i..i..i..ii....i.i....ii..........iiii.........i.....i..i.......ii.i.ii.. 100/115
2020-04-06T13:37:32.1595154Z ...iiii.....ii.
2020-04-06T13:37:32.1600045Z 
2020-04-06T13:37:32.1600821Z Suite("src/test/ui-fulldeps") not skipped for "bootstrap::test::UiFullDeps" -- not in ["src/tools/tidy"]
2020-04-06T13:37:32.1601327Z  finished in 12.636
2020-04-06T13:37:32.1601996Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
2020-04-06T13:47:10.5515695Z 
2020-04-06T13:47:10.5516527Z    Doc-tests core
2020-04-06T13:47:14.1586961Z 
2020-04-06T13:47:14.1587691Z running 2492 tests
2020-04-06T13:47:21.2299182Z ......iiiii......................................................................................... 100/2492
2020-04-06T13:47:27.9957081Z .....................................................................................ii............. 200/2492
2020-04-06T13:47:43.7631428Z ......................i............................................................................. 400/2492
2020-04-06T13:47:51.3401326Z ............................................................................i..i..................ii 500/2492
2020-04-06T13:47:57.2285726Z ii.................................................................................................. 600/2492
2020-04-06T13:48:03.6790689Z .................................................................................................... 700/2492
---
2020-04-06T13:51:07.6688128Z 
2020-04-06T13:51:07.6688497Z running 1018 tests
2020-04-06T13:51:20.9270058Z i................................................................................................... 100/1018
2020-04-06T13:51:28.6419781Z .................................................................................................... 200/1018
2020-04-06T13:51:34.4039841Z ..................iii......i......i...i......i...................................................... 300/1018
2020-04-06T13:51:43.0155468Z ..................................................i....i......................................ii.... 500/1018
2020-04-06T13:51:48.7884898Z .................................................................................................... 600/1018
2020-04-06T13:51:52.5795529Z .................................................................................................... 700/1018
2020-04-06T13:51:52.5795529Z .................................................................................................... 700/1018
2020-04-06T13:51:57.9595432Z ............................................iiii.................................................... 800/1018
2020-04-06T13:52:08.7140334Z .................................................................................................... 900/1018
2020-04-06T13:52:13.5853064Z ..................................................................iiii.............................. 1000/1018
2020-04-06T13:52:14.3405834Z test result: ok. 998 passed; 0 failed; 20 ignored; 0 measured; 0 filtered out
2020-04-06T13:52:14.3406038Z 
2020-04-06T13:52:14.3508257Z  finished in 126.554
2020-04-06T13:52:14.3510206Z Set({"src/libterm"}) not skipped for "bootstrap::test::Crate" -- not in ["src/tools/tidy"]
---
2020-04-06T13:54:35.2865318Z 
2020-04-06T13:54:35.2865626Z test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
2020-04-06T13:54:35.2865908Z 
2020-04-06T13:54:35.2866117Z  finished in 0.761
2020-04-06T13:54:35.2866889Z Set({"/checkout/src/librustc_query_system"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
2020-04-06T13:54:35.2867972Z Testing rustc_query_system stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2020-04-06T13:54:35.2868808Z    Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
2020-04-06T13:54:35.6839020Z      Running build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_query_system-2ec9520e787c69a9
2020-04-06T13:54:35.6860088Z 
2020-04-06T13:54:35.6860268Z running 0 tests
2020-04-06T13:54:35.6860393Z 
---
2020-04-06T14:05:58.9458293Z Set({"/checkout/src/librustc_parse"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
2020-04-06T14:05:58.9459056Z Set({"/checkout/src/librustc_passes"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
2020-04-06T14:05:58.9459861Z Set({"/checkout/src/librustc_plugin_impl"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
2020-04-06T14:05:58.9460746Z Set({"/checkout/src/librustc_privacy"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
2020-04-06T14:05:58.9461552Z Set({"/checkout/src/librustc_query_system"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
2020-04-06T14:05:58.9463195Z Set({"/checkout/src/librustc_save_analysis"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
2020-04-06T14:05:58.9464014Z Set({"/checkout/src/librustc_session"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
2020-04-06T14:05:58.9464782Z Set({"/checkout/src/librustc_span"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
2020-04-06T14:05:58.9465574Z Set({"/checkout/src/librustc_symbol_mangling"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
---
2020-04-06T14:06:08.8850312Z Rustbook (x86_64-unknown-linux-gnu) - edition-guide
2020-04-06T14:06:09.1939460Z Building stage0 tool linkchecker (x86_64-unknown-linux-gnu)
2020-04-06T14:06:09.4660878Z    Compiling linkchecker v0.1.0 (/checkout/src/tools/linkchecker)
2020-04-06T14:06:10.5217013Z     Finished release [optimized] target(s) in 1.32s
2020-04-06T14:06:10.7406889Z core/future/fn.pending.html:3: broken link - core/task/struct.Poll.html
2020-04-06T14:06:12.3941221Z std/future/fn.pending.html:3: broken link - core/task/struct.Poll.html
2020-04-06T14:06:15.8194099Z thread 'main' panicked at 'found some broken links', src/tools/linkchecker/main.rs:43:9
2020-04-06T14:06:15.8218333Z 
2020-04-06T14:06:15.8218768Z 
2020-04-06T14:06:15.8219986Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/linkchecker" "/checkout/obj/build/x86_64-unknown-linux-gnu/doc"
2020-04-06T14:06:15.8220942Z expected success, got: exit code: 101
2020-04-06T14:06:15.8220942Z expected success, got: exit code: 101
2020-04-06T14:06:15.8221254Z 
2020-04-06T14:06:15.8221469Z 
2020-04-06T14:06:15.8226423Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --exclude src/tools/tidy
2020-04-06T14:06:15.8227007Z Build completed unsuccessfully in 1:19:37
2020-04-06T14:06:15.8275937Z == clock drift check ==
2020-04-06T14:06:15.8292444Z   local time: Mon Apr  6 14:06:15 UTC 2020
2020-04-06T14:06:15.8953758Z   network time: Mon, 06 Apr 2020 14:06:15 GMT
2020-04-06T14:06:18.5828818Z 
2020-04-06T14:06:18.5828818Z 
2020-04-06T14:06:18.5875426Z ##[error]Bash exited with code '1'.
2020-04-06T14:06:18.5897224Z ##[section]Finishing: Run build
2020-04-06T14:06:18.5940977Z ##[section]Starting: Checkout rust-lang/rust@refs/pull/70834/merge to s
2020-04-06T14:06:18.5946055Z Task         : Get sources
2020-04-06T14:06:18.5946411Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
2020-04-06T14:06:18.5946748Z Version      : 1.0.0
2020-04-06T14:06:18.5946981Z Author       : Microsoft
2020-04-06T14:06:18.5946981Z Author       : Microsoft
2020-04-06T14:06:18.5947340Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
2020-04-06T14:06:18.5947790Z ==============================================================================
2020-04-06T14:06:18.8556500Z Cleaning any cached credential from repository: rust-lang/rust (GitHub)
2020-04-06T14:06:18.8594972Z ##[section]Finishing: Checkout rust-lang/rust@refs/pull/70834/merge to s
2020-04-06T14:06:18.8676274Z Cleaning up task key
2020-04-06T14:06:18.8681510Z Start cleaning up orphan processes.
2020-04-06T14:06:18.8831463Z Terminate orphan process: pid (3554) (python)
2020-04-06T14:06:18.9065221Z ##[section]Finishing: Finalize Job

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

@Dylan-DPC-zz
Copy link

r? @withoutboats

@ogoffart
Copy link
Contributor

ogoffart commented Apr 9, 2020

Do the Pending and Ready struct really need to be public? Would it not be better if the function returned impl Future<Output = T>
That way, the documentation is not cluttered with "useless" types which do not really have raison on their own.

(I personally find it a bit confusing when looking for things to stumble into many of these types related to iterator for example. These were implemented before the time impl Trait was implemented, but now, i'd say it is better to use that impl feature.)

Note: I'm not a reviewer. Just a user.

@yoshuawuyts
Copy link
Member Author

yoshuawuyts commented Apr 9, 2020

Do the Pending and Ready struct really need to be public?

Yes, else we cannot guarantee that they're Unpin which limits their functionality. Additionally because async fn futures are "voldemort types" (types that cannot be named) it limits their functionality for inclusion as no-op types (example). We ran into both of these issues when implementing the functions for async-std using async fn.

@JohnTitor JohnTitor added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 12, 2020
pub struct Pending<T> {
// We only ever produce T. By marking we don't store it we can bypass
// dropck and be covariant.
_data: marker::PhantomData<dyn Fn() -> T>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't dyn Fn() -> T invariant over T because it's an associated type constraint?

We don't do this anywhere else AFAICT, there's a PhantomData<fn() -> T> in core::mem::Discriminant but no PhantomData<Fn or PhantomData<dyn Fn in the codebase.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw variance is pretty easy to test for if you keep it simple:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

futures::future::Pending<T> uses PhantomData<T> so it's covariant (but also interacts with dropck).

async-std uses pub async fn pending<T>() -> T which means it's necessarily invariant (although the private struct Pending<T>, that it relies on, looks identical to the futures one).

Given that a value of T never exists at any point and the parameter only exists for trait dispatch (I don't know what "We only ever produce T." means in the comment), I'd argue that T could be bivariant here, but that's not an option nowadays (cc @nikomatsakis this may be an interesting edge case).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment was added based on @matklad's review in #70834 (comment). I don't think I have enough understanding of variance to participate in this discussion. Is there a change we should make here to enable this PR to move forward?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think fn() -> T is probably what we want here, based on the comment anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yoshuawuyts Ah, @matklad's comment is entirely correct, but note that it said fn() -> T, not dyn Fn() -> T. If I had to guess, maybe fn was typo'd as Fn and then the compiler asked for dyn to be added for the new, more explicit, trait object syntax.

Like @nikomatsakis said, dyn Fn needs to be replaced with fn.


PhantomData<fn() -> T> and PhantomData<T> have the same ("normal" aka "co-") variance, it's just that the former is more relaxed in terms of reasoning about drops (whereas the latter would be needed if you had, say, an owning raw pointer to a heap-allocated T value, like Box<T> or even Rc<T>).


PhantomData<dyn Fn() -> T>, OTOH, being a trait object, is necessarily (because we know nothing of the concrete type, which may have arbitrary restrictions) invariant over T .
That makes it similar to PhantomData<Cell<T>> and PhantomData<&'a mut T>.

If Pending<T> was invariant over T, then Pending<&'static ()> would not be able to become Pending<&'a ()> for some 'a smaller than 'static.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That said, we just saw in the context of Discriminant<T> that we may wish we had been invariant here in the future. Perhaps we should leave it as is. (For that matter, I suspect that PhantomData<T> would suffice, even if it's more conservative with respect to dropck.) Seems like best practices here are not entirely obvious.

Copy link
Member Author

@yoshuawuyts yoshuawuyts May 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that PhantomData<T> would suffice (...) best practices here are not entirely obvious.

Alright; moved the PR to use PhantomData<T> since that also happens to be the simplest impl. All of this is internal anyway and doesn't risk having accidental soundness implications; it can always be changed later. I think at the very least this should be good enough to release on nightly. Thanks all!

@nikomatsakis nikomatsakis added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Apr 13, 2020
@nikomatsakis
Copy link
Contributor

I'm tagging this for @rust-lang/libs, since that seems like the most appropriate team to make decisions here, but I think we should also have some discussion about the best way to manage "async-related conveniences" (not on this PR, I'll fire up a discussion on Zulip under #wg-async-foundations perhaps).

In any case, this seems like a pretty logical set of primitives to include to me!

@yoshuawuyts
Copy link
Member Author

Updated the patch with @taiki-e's suggestion.

@yoshuawuyts
Copy link
Member Author

Resolved the final discussion thread on this PR. Re-tagging @rust-lang/libs for review.

@sfackler
Copy link
Member

sfackler commented May 8, 2020

👍 on adding these!

@sfackler
Copy link
Member

sfackler commented May 8, 2020

@bors r+

@bors
Copy link
Contributor

bors commented May 8, 2020

📌 Commit 029515d has been approved by sfackler

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 8, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request May 9, 2020
Rollup of 8 pull requests

Successful merges:

 - rust-lang#70834 (Add core::future::{pending,ready})
 - rust-lang#71839 (Make BTreeMap::new and BTreeSet::new const)
 - rust-lang#71890 (Simplify the error Registry methods a little)
 - rust-lang#71942 (Shrink `LocalDecl`)
 - rust-lang#71947 (Dead-code pass highlights too much of impl functions)
 - rust-lang#71981 (Fix `strip-priv-imports` pass name in the rustdoc documentation)
 - rust-lang#72018 (Fix canonicalization links)
 - rust-lang#72031 (Better documentation for io::Read::read() return value)

Failed merges:

r? @ghost
@bors bors merged commit 62374ee into rust-lang:master May 9, 2020
@yoshuawuyts yoshuawuyts deleted the future-pending-ready branch May 9, 2020 09:20
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 10, 2020
Add core::future::{poll_fn, PollFn}

This is a sibling PR to rust-lang#70834, adding `future::poll_fn`. This is a small helper function that helps bridge the gap between "poll state machines" and "async/await". It was first introduced in [futures@0.1.7](https://docs.rs/futures/0.1.7/futures/future/fn.poll_fn.html) in December of 2016, and has been tried and tested as part of the ecosystem for the past 3.5 years.

## Implementation

Much of the same reasoning from rust-lang#70834 applies: by returning a concrete struct rather than an `async fn` we get to mark the future as `Unpin`. It also becomes named which allows storing it in structs without boxing. This implementation has been modified from the implementation in `futures-rs`.

## References
- [`futures::future::poll_fn`](https://docs.rs/futures/0.3.5/futures/future/fn.poll_fn.html)
- [`async_std::future::poll_fn`](https://docs.rs/async-std/1.5.0/async_std/future/fn.poll_fn.html)
Manishearth added a commit to Manishearth/rust that referenced this pull request Jul 11, 2020
Add core::future::{poll_fn, PollFn}

This is a sibling PR to rust-lang#70834, adding `future::poll_fn`. This is a small helper function that helps bridge the gap between "poll state machines" and "async/await". It was first introduced in [futures@0.1.7](https://docs.rs/futures/0.1.7/futures/future/fn.poll_fn.html) in December of 2016, and has been tried and tested as part of the ecosystem for the past 3.5 years.

## Implementation

Much of the same reasoning from rust-lang#70834 applies: by returning a concrete struct rather than an `async fn` we get to mark the future as `Unpin`. It also becomes named which allows storing it in structs without boxing. This implementation has been modified from the implementation in `futures-rs`.

## References
- [`futures::future::poll_fn`](https://docs.rs/futures/0.3.5/futures/future/fn.poll_fn.html)
- [`async_std::future::poll_fn`](https://docs.rs/async-std/1.5.0/async_std/future/fn.poll_fn.html)
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Sep 12, 2020
…ess-fns, r=sfackler

Stabilize core::future::{pending,ready}

This PR stabilizes `core::future::{pending,ready}`, tracking issue rust-lang#70921.

## Motivation

These functions have been on nightly for three months now, and have lived as part of the futures ecosystem for several years. In that time these functions have undergone several iterations, with [the `async-std` impls](https://docs.rs/async-std/1.6.2/async_std/future/index.html) probably diverging the most (using `async fn`, which in hindsight was a mistake).

It seems the space around these functions has been _thoroughly_ explored over the last couple of years, and the ecosystem has settled on the current shape of the functions. It seems highly unlikely we'd want to make any further changes to these functions, so I propose we stabilize.

## Implementation notes

This stabilization PR was fairly straightforward; this feature has already thoroughly been reviewed by the libs team already in rust-lang#70834. So all this PR does is remove the feature gate.
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 12, 2020
…s-fns, r=sfackler

Stabilize core::future::{pending,ready}

This PR stabilizes `core::future::{pending,ready}`, tracking issue rust-lang#70921.

## Motivation

These functions have been on nightly for three months now, and have lived as part of the futures ecosystem for several years. In that time these functions have undergone several iterations, with [the `async-std` impls](https://docs.rs/async-std/1.6.2/async_std/future/index.html) probably diverging the most (using `async fn`, which in hindsight was a mistake).

It seems the space around these functions has been _thoroughly_ explored over the last couple of years, and the ecosystem has settled on the current shape of the functions. It seems highly unlikely we'd want to make any further changes to these functions, so I propose we stabilize.

## Implementation notes

This stabilization PR was fairly straightforward; this feature has already thoroughly been reviewed by the libs team already in rust-lang#70834. So all this PR does is remove the feature gate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.