diff options
author | Joel Galenson <jgalenson@google.com> | 2021-06-09 23:51:18 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-06-09 23:51:18 +0000 |
commit | f1c1d24c4a86dcd75d8a236adaee2c08dc58d367 (patch) | |
tree | e0ff36289998cdfba16df4c8dc238b22026243cf | |
parent | 4e5a273a51866f0ca336c5ba3100489645b6cc43 (diff) | |
parent | 3acc453a2eccbc01e62976ba9c9452e7d083cad6 (diff) | |
download | async-stream-f1c1d24c4a86dcd75d8a236adaee2c08dc58d367.tar.gz |
Upgrade rust/crates/async-stream to 0.3.1 am: b7cdcf8095 am: 88a5c327ac am: f658afd40c am: 3acc453a2e
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/async-stream/+/1712789
Change-Id: I3d63b95de691651f249598452809514d7e7530dc
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 13 | ||||
-rw-r--r-- | Cargo.lock | 360 | ||||
-rw-r--r-- | Cargo.toml | 10 | ||||
-rw-r--r-- | Cargo.toml.orig | 10 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | README.md | 27 | ||||
-rw-r--r-- | TEST_MAPPING | 113 | ||||
-rw-r--r-- | examples/tcp_accept.rs | 2 | ||||
-rw-r--r-- | src/async_stream.rs | 8 | ||||
-rw-r--r-- | src/lib.rs | 89 | ||||
-rw-r--r-- | src/yielder.rs | 6 | ||||
-rw-r--r-- | tests/stream.rs | 16 | ||||
-rw-r--r-- | tests/ui/yield_in_async.stderr | 7 | ||||
-rw-r--r-- | tests/ui/yield_in_closure.stderr | 6 |
15 files changed, 405 insertions, 272 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 29bac5d..4a76e44 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "d346ad2d77b11855969b82c9d16bd78ec84e4863" + "sha1": "8c22349b9367b981ad08db573d8d906069e66d8c" } } @@ -1,4 +1,5 @@ // This file is generated by cargo2android.py --run --dependencies --device. +// Do not modify this file as changes will be overridden on upgrade. package { default_applicable_licenses: ["external_rust_crates_async-stream_license"], @@ -30,9 +31,9 @@ rust_library { } // dependent_library ["feature_list"] -// async-stream-impl-0.3.0 -// futures-core-0.3.12 "alloc,default,std" -// proc-macro2-1.0.24 "default,proc-macro" -// quote-1.0.8 "default,proc-macro" -// syn-1.0.60 "clone-impls,default,derive,extra-traits,full,parsing,printing,proc-macro,quote,visit-mut" -// unicode-xid-0.2.1 "default" +// async-stream-impl-0.3.1 +// futures-core-0.3.15 "alloc,default,std" +// proc-macro2-1.0.26 "default,proc-macro" +// quote-1.0.9 "default,proc-macro" +// syn-1.0.72 "clone-impls,default,derive,extra-traits,full,parsing,printing,proc-macro,quote,visit-mut" +// unicode-xid-0.2.2 "default" @@ -1,14 +1,20 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] -name = "arc-swap" -version = "0.4.7" +name = "async-stream" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034" +checksum = "3670df70cbc01729f901f94c887814b3c68db038aad1329a418bae178bc5295c" +dependencies = [ + "async-stream-impl", + "futures-core", +] [[package]] name = "async-stream" -version = "0.3.0" +version = "0.3.1" dependencies = [ "async-stream-impl", "futures-core", @@ -20,9 +26,9 @@ dependencies = [ [[package]] name = "async-stream-impl" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3548b8efc9f8e8a5a0a2808c5bd8451a9031b9e5b879a79590304ae928b0a70" +checksum = "db134ba52475c060f3329a8ef0f8786d6b872ed01515d4b79c162e5798da1340" dependencies = [ "proc-macro2", "quote", @@ -30,6 +36,12 @@ dependencies = [ ] [[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] name = "bitflags" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -37,49 +49,27 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "bytes" -version = "0.5.6" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" +checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" [[package]] name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags", - "fuchsia-zircon-sys", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "futures-core" -version = "0.3.5" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399" +checksum = "098cd1c6dda6ca01650f1a37a794245eb73181d0d4d4e955e2f3c37db7af1815" [[package]] name = "futures-macro" -version = "0.3.5" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39" +checksum = "668c6733a182cd7deb4f1de7ba3bf2120823835b3bcfbeacf7d2c4a773c1bb8b" dependencies = [ "proc-macro-hack", "proc-macro2", @@ -89,23 +79,20 @@ dependencies = [ [[package]] name = "futures-task" -version = "0.3.5" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626" -dependencies = [ - "once_cell", -] +checksum = "ba7aa51095076f3ba6d9a1f702f74bd05ec65f555d70d2033d55ba8d69f581bc" [[package]] name = "futures-util" -version = "0.3.5" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6" +checksum = "3c144ad54d60f23927f0a6b6d816e4271278b64f005ad65e4e35291d2de9c025" dependencies = [ "futures-core", "futures-macro", "futures-task", - "pin-project", + "pin-project-lite", "pin-utils", "proc-macro-hack", "proc-macro-nested", @@ -120,37 +107,27 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "hermit-abi" -version = "0.1.15" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3deed196b6e7f9e44a2ae8d94225d80302d81208b1bb673fd21fe634645c85a9" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" dependencies = [ "libc", ] [[package]] -name = "iovec" -version = "0.1.4" +name = "instant" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" dependencies = [ - "libc", + "cfg-if", ] [[package]] name = "itoa" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" - -[[package]] -name = "kernel32-sys" -version = "0.2.2" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "lazy_static" @@ -160,98 +137,63 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.74" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2f02823cf78b754822df5f7f268fb59822e7296276d3e069d8e8cb26a14bd10" +checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41" [[package]] -name = "log" -version = "0.4.11" +name = "lock_api" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +checksum = "5a3c91c24eae6777794bb1997ad98bbb87daf92890acab859f7eaa4320333176" dependencies = [ - "cfg-if", + "scopeguard", ] [[package]] -name = "memchr" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" - -[[package]] -name = "mio" -version = "0.6.22" +name = "log" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ "cfg-if", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", - "libc", - "log", - "miow 0.2.1", - "net2", - "slab", - "winapi 0.2.8", ] [[package]] -name = "mio-named-pipes" -version = "0.1.7" +name = "memchr" +version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656" -dependencies = [ - "log", - "mio", - "miow 0.3.5", - "winapi 0.3.9", -] +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" [[package]] -name = "mio-uds" -version = "0.6.8" +name = "mio" +version = "0.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" +checksum = "cf80d3e903b34e0bd7282b218398aec54e082c840d9baf8339e0080a0c542956" dependencies = [ - "iovec", "libc", - "mio", -] - -[[package]] -name = "miow" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", + "log", + "miow", + "ntapi", + "winapi", ] [[package]] name = "miow" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b88fb9795d4d36d62a012dfbf49a8f5cf12751f36d31a9dbe66d528e58979e" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" dependencies = [ - "socket2", - "winapi 0.3.9", + "winapi", ] [[package]] -name = "net2" -version = "0.2.34" +name = "ntapi" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7" +checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" dependencies = [ - "cfg-if", - "libc", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -266,35 +208,40 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.4.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" [[package]] -name = "pin-project" -version = "0.4.23" +name = "parking_lot" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca4433fff2ae79342e497d9f8ee990d174071408f28f726d6d83af93e58e48aa" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" dependencies = [ - "pin-project-internal", + "instant", + "lock_api", + "parking_lot_core", ] [[package]] -name = "pin-project-internal" -version = "0.4.23" +name = "parking_lot_core" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c0e815c3ee9a031fdf5af21c10aa17c573c9c6a566328d99e3936c34e36461f" +checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" dependencies = [ - "proc-macro2", - "quote", - "syn", + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", ] [[package]] name = "pin-project-lite" -version = "0.1.7" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282adbf10f2698a7a77f8e983a74b2d18176c19a7fd32a45446139ae7b02b715" +checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" [[package]] name = "pin-utils" @@ -304,39 +251,42 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "proc-macro-hack" -version = "0.5.18" +version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99c605b9a0adc77b7211c6b1f722dcb613d68d66859a44f3d485a6da332b0598" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro-nested" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" [[package]] name = "proc-macro2" -version = "1.0.19" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12" +checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" dependencies = [ "unicode-xid", ] [[package]] name = "quote" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" -version = "0.1.57" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +checksum = "8270314b5ccceb518e7e578952f0b72b88222d02e8f77f5ecf7abbb673539041" +dependencies = [ + "bitflags", +] [[package]] name = "ryu" @@ -345,19 +295,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] name = "serde" -version = "1.0.114" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3" +checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.114" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0be94b04690fbaed37cddffc5c134bf537c8e3329d53e982fe04c374978f8e" +checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" dependencies = [ "proc-macro2", "quote", @@ -366,9 +322,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.57" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "164eacbdb13512ec2745fb09d51fd5b22b0d65ed294a1dcf7285a360c80a675c" +checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" dependencies = [ "itoa", "ryu", @@ -377,37 +333,30 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e12110bc539e657a646068aaf5eb5b63af9d0c1f7b29c97113fad80e15f035" +checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" dependencies = [ - "arc-swap", "libc", ] [[package]] name = "slab" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" [[package]] -name = "socket2" -version = "0.3.12" +name = "smallvec" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "winapi 0.3.9", -] +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "syn" -version = "1.0.38" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e69abc24912995b3038597a7a593be5053eb0fb44f3cc5beec0deb421790c1f4" +checksum = "48fe99c6bd8b1cc636890bcc071842de909d902c81ac7dab53ba33c421ab8ffb" dependencies = [ "proc-macro2", "quote", @@ -416,42 +365,38 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.0" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" dependencies = [ "winapi-util", ] [[package]] name = "tokio" -version = "0.2.22" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd" +checksum = "83f0c8e7c0addab50b663055baf787d0af7f413a46e6e7fb9559a4e4db7137a5" dependencies = [ + "autocfg", "bytes", - "fnv", - "futures-core", - "iovec", - "lazy_static", "libc", "memchr", "mio", - "mio-named-pipes", - "mio-uds", "num_cpus", + "once_cell", + "parking_lot", "pin-project-lite", "signal-hook-registry", - "slab", "tokio-macros", - "winapi 0.3.9", + "winapi", ] [[package]] name = "tokio-macros" -version = "0.2.5" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389" +checksum = "caf7b11a536f46a809a8a9f0bb4237020f70ecbf115b842360afb127ea2fda57" dependencies = [ "proc-macro2", "quote", @@ -459,30 +404,43 @@ dependencies = [ ] [[package]] +name = "tokio-stream" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e177a5d8c3bf36de9ebe6d58537d8879e964332f93fb3339e43f618c81361af0" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] name = "tokio-test" -version = "0.2.1" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed0049c119b6d505c4447f5c64873636c7af6c75ab0d45fd9f618d82acb8016d" +checksum = "f58403903e94d4bc56805e46597fced893410b2e753e229d3f7f22423ea03f67" dependencies = [ + "async-stream 0.3.0", "bytes", "futures-core", "tokio", + "tokio-stream", ] [[package]] name = "toml" -version = "0.5.6" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" dependencies = [ "serde", ] [[package]] name = "trybuild" -version = "1.0.31" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a4d94e6adf00b96b1ab94fcfcd8c3cf916733b39adf90c8f72693629887b9b8" +checksum = "1768998d9a3b179411618e377dbb134c58a88cda284b0aa71c42c40660127d46" dependencies = [ "glob", "lazy_static", @@ -500,12 +458,6 @@ checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" [[package]] name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - -[[package]] -name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" @@ -515,12 +467,6 @@ dependencies = [ ] [[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - -[[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -532,7 +478,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] @@ -540,13 +486,3 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] @@ -13,16 +13,16 @@ [package] edition = "2018" name = "async-stream" -version = "0.3.0" +version = "0.3.1" authors = ["Carl Lerche <me@carllerche.com>"] description = "Asynchronous streams using async & await notation" homepage = "https://github.com/tokio-rs/async-stream" -documentation = "https://docs.rs/async-stream/0.3.0/async-stream" +documentation = "https://docs.rs/async-stream/0.3" readme = "README.md" license = "MIT" repository = "https://github.com/tokio-rs/async-stream" [dependencies.async-stream-impl] -version = "0.3.0" +version = "=0.3.1" [dependencies.futures-core] version = "0.3" @@ -30,11 +30,11 @@ version = "0.3" version = "0.3" [dev-dependencies.tokio] -version = "0.2" +version = "1" features = ["full"] [dev-dependencies.tokio-test] -version = "0.2" +version = "0.4" [dev-dependencies.trybuild] version = "1" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index aca3396..c30cb3d 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -9,22 +9,22 @@ name = "async-stream" # - Cargo.toml # - README.md # - Create git tag -version = "0.3.0" +version = "0.3.1" edition = "2018" license = "MIT" authors = ["Carl Lerche <me@carllerche.com>"] description = "Asynchronous streams using async & await notation" -documentation = "https://docs.rs/async-stream/0.3.0/async-stream" +documentation = "https://docs.rs/async-stream/0.3" homepage = "https://github.com/tokio-rs/async-stream" repository = "https://github.com/tokio-rs/async-stream" readme = "README.md" [dependencies] -async-stream-impl = { version = "0.3.0", path = "../async-stream-impl" } +async-stream-impl = { version = "=0.3.1", path = "../async-stream-impl" } futures-core = "0.3" [dev-dependencies] futures-util = "0.3" -tokio = { version = "0.2", features = ["full"] } -tokio-test = "0.2" +tokio = { version = "1", features = ["full"] } +tokio-test = "0.4" trybuild = "1" @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/async-stream/async-stream-0.3.0.crate" + value: "https://static.crates.io/crates/async-stream/async-stream-0.3.1.crate" } - version: "0.3.0" + version: "0.3.1" license_type: NOTICE last_upgrade_date { year: 2021 - month: 2 - day: 8 + month: 5 + day: 19 } } @@ -4,7 +4,7 @@ Asynchronous stream of elements. Provides two macros, `stream!` and `try_stream!`, allowing the caller to define asynchronous streams of elements. These are implemented using `async` -& `await` notation. The `stream!` macro works without unstable features. +& `await` notation. This crate works without unstable features. The `stream!` macro returns an anonymous type implementing the [`Stream`] trait. The `Item` associated type is the type of the values yielded from the @@ -68,7 +68,8 @@ async fn main() { } ``` -Streams may be implemented in terms of other streams: +Streams may be implemented in terms of other streams - `async-stream` provides `for await` +syntax to assist with this: ```rust use async_stream::stream; @@ -89,8 +90,7 @@ fn double<S: Stream<Item = u32>>(input: S) -> impl Stream<Item = u32> { stream! { - pin_mut!(input); - while let Some(value) = input.next().await { + for await value in input { yield value * 2; } } @@ -124,7 +124,7 @@ fn bind_and_accept(addr: SocketAddr) -> impl Stream<Item = io::Result<TcpStream>> { try_stream! { - let mut listener = TcpListener::bind(&addr)?; + let mut listener = TcpListener::bind(addr).await?; loop { let (stream, addr) = listener.accept().await?; @@ -138,9 +138,7 @@ fn bind_and_accept(addr: SocketAddr) ## Implementation The `stream!` and `try_stream!` macros are implemented using proc macros. -Given that proc macros in expression position are not supported on stable -rust, a hack similar to the one provided by the [`proc-macro-hack`] crate is -used. The macro searches the syntax tree for instances of `sender.send($expr)` and +The macro searches the syntax tree for instances of `sender.send($expr)` and transforms them into `sender.send($expr).await`. The stream uses a lightweight sender to send values from the stream @@ -150,17 +148,10 @@ stored on the stack. A pointer to the cell is stored in a thread local and `sender.send(value)` stores the value that cell and yields back to the caller. -## Limitations - -`async-stream` suffers from the same limitations as the [`proc-macro-hack`] -crate. Primarily, nesting support must be implemented using a `TT-muncher`. -If large `stream!` blocks are used, the caller will be required to add -`#![recursion_limit = "..."]` to their crate. - -A `stream!` macro may only contain up to 64 macro invocations. - [`Stream`]: https://docs.rs/futures-core/*/futures_core/stream/trait.Stream.html -[`proc-macro-hack`]: https://github.com/dtolnay/proc-macro-hack/ + +## Supported Rust Versions +`async-stream` is built against the latest stable release. The minimum supported version is 1.45 due to [function-like procedural macros in expression, pattern, and statement positions](https://blog.rust-lang.org/2020/07/16/Rust-1.45.0.html#stabilizing-function-like-procedural-macros-in-expressions-patterns-and-statements). ## License diff --git a/TEST_MAPPING b/TEST_MAPPING new file mode 100644 index 0000000..73ad094 --- /dev/null +++ b/TEST_MAPPING @@ -0,0 +1,113 @@ +// Generated by update_crate_tests.py for tests that depend on this crate. +{ + "presubmit": [ + { + "name": "tokio-test_device_test_src_lib" + }, + { + "name": "tokio-test_device_test_tests_block_on" + }, + { + "name": "tokio-test_device_test_tests_io" + }, + { + "name": "tokio-test_device_test_tests_macros" + }, + { + "name": "tokio_device_test_tests_buffered" + }, + { + "name": "tokio_device_test_tests_io_async_read" + }, + { + "name": "tokio_device_test_tests_io_copy_bidirectional" + }, + { + "name": "tokio_device_test_tests_io_lines" + }, + { + "name": "tokio_device_test_tests_io_mem_stream" + }, + { + "name": "tokio_device_test_tests_io_read" + }, + { + "name": "tokio_device_test_tests_io_read_buf" + }, + { + "name": "tokio_device_test_tests_io_read_to_end" + }, + { + "name": "tokio_device_test_tests_io_take" + }, + { + "name": "tokio_device_test_tests_io_write" + }, + { + "name": "tokio_device_test_tests_io_write_all" + }, + { + "name": "tokio_device_test_tests_io_write_buf" + }, + { + "name": "tokio_device_test_tests_io_write_int" + }, + { + "name": "tokio_device_test_tests_macros_join" + }, + { + "name": "tokio_device_test_tests_no_rt" + }, + { + "name": "tokio_device_test_tests_rt_basic" + }, + { + "name": "tokio_device_test_tests_rt_threaded" + }, + { + "name": "tokio_device_test_tests_sync_barrier" + }, + { + "name": "tokio_device_test_tests_sync_broadcast" + }, + { + "name": "tokio_device_test_tests_sync_errors" + }, + { + "name": "tokio_device_test_tests_sync_mpsc" + }, + { + "name": "tokio_device_test_tests_sync_mutex_owned" + }, + { + "name": "tokio_device_test_tests_sync_rwlock" + }, + { + "name": "tokio_device_test_tests_sync_watch" + }, + { + "name": "tokio_device_test_tests_task_local" + }, + { + "name": "tokio_device_test_tests_task_local_set" + }, + { + "name": "tokio_device_test_tests_tcp_accept" + }, + { + "name": "tokio_device_test_tests_tcp_echo" + }, + { + "name": "tokio_device_test_tests_tcp_into_std" + }, + { + "name": "tokio_device_test_tests_tcp_shutdown" + }, + { + "name": "tokio_device_test_tests_time_rt" + }, + { + "name": "tokio_device_test_tests_uds_split" + } + ] +} diff --git a/examples/tcp_accept.rs b/examples/tcp_accept.rs index 023e1a1..1b69bda 100644 --- a/examples/tcp_accept.rs +++ b/examples/tcp_accept.rs @@ -5,7 +5,7 @@ use tokio::net::TcpListener; #[tokio::main] async fn main() { - let mut listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); + let listener = TcpListener::bind("127.0.0.1:0").await.unwrap(); let incoming = stream! { loop { diff --git a/src/async_stream.rs b/src/async_stream.rs index 30115df..f60c87e 100644 --- a/src/async_stream.rs +++ b/src/async_stream.rs @@ -66,4 +66,12 @@ where } } } + + fn size_hint(&self) -> (usize, Option<usize>) { + if self.done { + (0, Some(0)) + } else { + (0, None) + } + } } @@ -1,4 +1,4 @@ -#![doc(html_root_url = "https://docs.rs/async-stream/0.3.0")] +#![doc(html_root_url = "https://docs.rs/async-stream/0.3.1")] #![warn( missing_debug_implementations, missing_docs, @@ -11,7 +11,7 @@ //! //! Provides two macros, `stream!` and `try_stream!`, allowing the caller to //! define asynchronous streams of elements. These are implemented using `async` -//! & `await` notation. The `stream!` macro works without unstable features. +//! & `await` notation. This crate works without unstable features. //! //! The `stream!` macro returns an anonymous type implementing the [`Stream`] //! trait. The `Item` associated type is the type of the values yielded from the @@ -75,7 +75,8 @@ //! } //! ``` //! -//! Streams may be implemented in terms of other streams: +//! Streams may be implemented in terms of other streams - `async-stream` provides `for await` +//! syntax to assist with this: //! //! ```rust //! use async_stream::stream; @@ -96,8 +97,7 @@ //! -> impl Stream<Item = u32> //! { //! stream! { -//! pin_mut!(input); -//! while let Some(value) = input.next().await { +//! for await value in input { //! yield value * 2; //! } //! } @@ -145,9 +145,7 @@ //! # Implementation //! //! The `stream!` and `try_stream!` macros are implemented using proc macros. -//! Given that proc macros in expression position are not supported on stable -//! rust, a hack similar to the one provided by the [`proc-macro-hack`] crate is -//! used. The macro searches the syntax tree for instances of `sender.send($expr)` and +//! The macro searches the syntax tree for instances of `sender.send($expr)` and //! transforms them into `sender.send($expr).await`. //! //! The stream uses a lightweight sender to send values from the stream @@ -164,11 +162,82 @@ mod next; #[doc(hidden)] pub mod yielder; -// Used by the macro, but not intended to be accessed publically. +// Used by the macro, but not intended to be accessed publicly. #[doc(hidden)] pub use crate::async_stream::AsyncStream; -pub use async_stream_impl::{stream, try_stream}; +#[doc(hidden)] +pub use async_stream_impl; + +/// Asynchronous stream +/// +/// See [crate](index.html) documentation for more details. +/// +/// # Examples +/// +/// ``` +/// use async_stream::stream; +/// +/// use futures_util::pin_mut; +/// use futures_util::stream::StreamExt; +/// +/// #[tokio::main] +/// async fn main() { +/// let s = stream! { +/// for i in 0..3 { +/// yield i; +/// } +/// }; +/// +/// pin_mut!(s); // needed for iteration +/// +/// while let Some(value) = s.next().await { +/// println!("got {}", value); +/// } +/// } +/// ``` +#[macro_export] +macro_rules! stream { + ($($tt:tt)*) => { + $crate::async_stream_impl::stream_inner!(($crate) $($tt)*) + } +} + +/// Asynchronous fallible stream +/// +/// See [crate](index.html) documentation for more details. +/// +/// # Examples +/// +/// ``` +/// use tokio::net::{TcpListener, TcpStream}; +/// +/// use async_stream::try_stream; +/// use futures_core::stream::Stream; +/// +/// use std::io; +/// use std::net::SocketAddr; +/// +/// fn bind_and_accept(addr: SocketAddr) +/// -> impl Stream<Item = io::Result<TcpStream>> +/// { +/// try_stream! { +/// let mut listener = TcpListener::bind(addr).await?; +/// +/// loop { +/// let (stream, addr) = listener.accept().await?; +/// println!("received on {:?}", addr); +/// yield stream; +/// } +/// } +/// } +/// ``` +#[macro_export] +macro_rules! try_stream { + ($($tt:tt)*) => { + $crate::async_stream_impl::try_stream_inner!(($crate) $($tt)*) + } +} #[doc(hidden)] pub mod reexport { diff --git a/src/yielder.rs b/src/yielder.rs index 49c4133..1ee523f 100644 --- a/src/yielder.rs +++ b/src/yielder.rs @@ -33,7 +33,7 @@ thread_local!(static STORE: Cell<*mut ()> = Cell::new(ptr::null_mut())); // ===== impl Sender ===== -impl<T: Unpin> Sender<T> { +impl<T> Sender<T> { pub fn send(&mut self, value: T) -> impl Future<Output = ()> { Send { value: Some(value) } } @@ -43,7 +43,9 @@ struct Send<T> { value: Option<T>, } -impl<T: Unpin> Future for Send<T> { +impl<T> Unpin for Send<T> {} + +impl<T> Future for Send<T> { type Output = (); fn poll(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<()> { diff --git a/tests/stream.rs b/tests/stream.rs index e46fc5a..bc9c742 100644 --- a/tests/stream.rs +++ b/tests/stream.rs @@ -101,7 +101,7 @@ async fn return_stream() { #[tokio::test] async fn consume_channel() { - let (mut tx, mut rx) = mpsc::channel(10); + let (tx, mut rx) = mpsc::channel(10); let s = stream! { while let Some(v) = rx.recv().await { @@ -158,6 +158,20 @@ async fn stream_in_stream() { assert_eq!(3, values.len()); } +#[tokio::test] +async fn yield_non_unpin_value() { + let s: Vec<_> = stream! { + for i in 0..3 { + yield async move { i }; + } + } + .buffered(1) + .collect() + .await; + + assert_eq!(s, vec![0, 1, 2]); +} + #[test] fn test() { let t = trybuild::TestCases::new(); diff --git a/tests/ui/yield_in_async.stderr b/tests/ui/yield_in_async.stderr index 1e9d8ff..98c3568 100644 --- a/tests/ui/yield_in_async.stderr +++ b/tests/ui/yield_in_async.stderr @@ -12,7 +12,7 @@ error[E0727]: `async` generators are not yet supported 6 | yield 123; | ^^^^^^^^^ -error[E0271]: type mismatch resolving `<[static generator@$DIR/tests/ui/yield_in_async.rs:4:5: 10:7 _] as std::ops::Generator<std::future::ResumeTy>>::Yield == ()` +error[E0271]: type mismatch resolving `<[static generator@$DIR/src/lib.rs:202:9: 202:67] as Generator<ResumeTy>>::Yield == ()` --> $DIR/yield_in_async.rs:4:5 | 4 | / stream! { @@ -23,6 +23,8 @@ error[E0271]: type mismatch resolving `<[static generator@$DIR/tests/ui/yield_in 9 | | let v = f.await; 10 | | }; | |______^ expected `()`, found integer + | + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0698]: type inside `async` block must be known in this context --> $DIR/yield_in_async.rs:6:19 @@ -71,6 +73,3 @@ note: the type is part of the `async` block because of this `await` | 9 | let v = f.await; | ^^^^^^^ - -Some errors have detailed explanations: E0271, E0658, E0698, E0727. -For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/yield_in_closure.stderr b/tests/ui/yield_in_closure.stderr index 77092e0..6eb733d 100644 --- a/tests/ui/yield_in_closure.stderr +++ b/tests/ui/yield_in_closure.stderr @@ -6,13 +6,13 @@ error[E0658]: yield syntax is experimental | = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information -error[E0277]: expected a `std::ops::FnOnce<(&str,)>` closure, found `[generator@$DIR/tests/ui/yield_in_closure.rs:4:5: 10:7 _]` +error[E0277]: expected a `FnOnce<(&str,)>` closure, found `[generator@$DIR/src/lib.rs:202:9: 202:67]` --> $DIR/yield_in_closure.rs:6:14 | 6 | .and_then(|v| { - | ^^^^^^^^ expected an `FnOnce<(&str,)>` closure, found `[generator@$DIR/tests/ui/yield_in_closure.rs:4:5: 10:7 _]` + | ^^^^^^^^ expected an `FnOnce<(&str,)>` closure, found `[generator@$DIR/src/lib.rs:202:9: 202:67]` | - = help: the trait `std::ops::FnOnce<(&str,)>` is not implemented for `[generator@$DIR/tests/ui/yield_in_closure.rs:4:5: 10:7 _]` + = help: the trait `FnOnce<(&str,)>` is not implemented for `[generator@$DIR/src/lib.rs:202:9: 202:67]` Some errors have detailed explanations: E0277, E0658. For more information about an error, try `rustc --explain E0277`. |