diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 04:54:24 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-07 04:54:24 +0000 |
commit | 5230bed114f590f7edf592b7dc8ad87116b43c4b (patch) | |
tree | b1c48ea0b1b331320c50960f19e077d91f44d3c4 | |
parent | 124144050052f27693baff142ef0552cdd756ebc (diff) | |
parent | 68637a2e7bd2029f9d7a990bdd662f7c18b08b0b (diff) | |
download | async-stream-android14-mainline-media-swcodec-release.tar.gz |
Snap for 10453563 from 68637a2e7bd2029f9d7a990bdd662f7c18b08b0b to mainline-media-swcodec-releaseaml_swc_341711000aml_swc_341619000aml_swc_341513600aml_swc_341312300aml_swc_341312020aml_swc_341111000aml_swc_341011020aml_swc_340922010android14-mainline-media-swcodec-release
Change-Id: Idccdda75f431d4098127d25a0116d3af5e91a39d
-rw-r--r-- | .cargo_vcs_info.json | 7 | ||||
-rw-r--r-- | Android.bp | 61 | ||||
-rw-r--r-- | CHANGELOG.md | 9 | ||||
-rw-r--r-- | Cargo.lock | 358 | ||||
-rw-r--r-- | Cargo.toml | 24 | ||||
-rw-r--r-- | Cargo.toml.orig | 12 | ||||
-rw-r--r-- | METADATA | 14 | ||||
-rw-r--r-- | README.md | 5 | ||||
-rw-r--r-- | TEST_MAPPING | 16 | ||||
-rw-r--r-- | cargo2android.json | 11 | ||||
-rw-r--r-- | src/async_stream.rs | 52 | ||||
-rw-r--r-- | src/lib.rs | 27 | ||||
-rw-r--r-- | src/yielder.rs | 11 | ||||
-rw-r--r-- | tests/spans_preserved.rs | 15 | ||||
-rw-r--r-- | tests/stream.rs | 5 | ||||
-rw-r--r-- | tests/try_stream.rs | 9 | ||||
-rw-r--r-- | tests/ui/yield_bad_expr_in_macro.stderr | 2 | ||||
-rw-r--r-- | tests/ui/yield_in_async.stderr | 66 | ||||
-rw-r--r-- | tests/ui/yield_in_closure.stderr | 26 | ||||
-rw-r--r-- | tests/ui/yield_in_nested_fn.stderr | 7 |
20 files changed, 434 insertions, 303 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 620b2af..1354331 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,6 @@ { "git": { - "sha1": "b28da881695e3c66e1782f0c2c330d4e162eb7c2" - } -} + "sha1": "bf41b9645fe39b8865da2f25edc286eb42d49ec8" + }, + "path_in_vcs": "async-stream" +}
\ No newline at end of file @@ -18,16 +18,75 @@ license { ], } +rust_defaults { + name: "async-stream_test_defaults", + crate_name: "async_stream", + cargo_env_compat: true, + cargo_pkg_version: "0.3.4", + test_suites: ["general-tests"], + auto_gen_config: true, + edition: "2018", + rustlibs: [ + "libasync_stream", + "libfutures_core", + "libfutures_util", + "libpin_project_lite", + "libtokio", + "libtokio_test", + ], + proc_macros: [ + "libasync_stream_impl", + "librustversion", + ], +} + +rust_test { + name: "async-stream_test_tests_for_await", + defaults: ["async-stream_test_defaults"], + host_supported: true, + srcs: ["tests/for_await.rs"], + test_options: { + unit_test: true, + }, +} + +rust_test { + name: "async-stream_test_tests_spans_preserved", + defaults: ["async-stream_test_defaults"], + host_supported: true, + srcs: ["tests/spans_preserved.rs"], + test_options: { + unit_test: true, + }, +} + +rust_test { + name: "async-stream_test_tests_try_stream", + defaults: ["async-stream_test_defaults"], + host_supported: true, + srcs: ["tests/try_stream.rs"], + test_options: { + unit_test: true, + }, +} + rust_library { name: "libasync_stream", host_supported: true, crate_name: "async_stream", cargo_env_compat: true, - cargo_pkg_version: "0.3.2", + cargo_pkg_version: "0.3.4", srcs: ["src/lib.rs"], edition: "2018", rustlibs: [ "libfutures_core", + "libpin_project_lite", ], proc_macros: ["libasync_stream_impl"], + apex_available: [ + "//apex_available:platform", + "//apex_available:anyapex", + ], + product_available: true, + vendor_available: true, } diff --git a/CHANGELOG.md b/CHANGELOG.md index bd7f60f..d75deb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# 0.3.4 + +* Improve support for `#[track_caller]` (#72) +* Reduce unsafe code (#77) + +# 0.3.3 + +* Fix a bug where `yield` and `?` cannot be used on the same line (#66) + # 0.3.2 * Expand `yield` in internal macro calls (#57) @@ -14,11 +14,13 @@ dependencies = [ [[package]] name = "async-stream" -version = "0.3.2" +version = "0.3.4" dependencies = [ "async-stream-impl", "futures-core", "futures-util", + "pin-project-lite", + "rustversion", "tokio", "tokio-test", "trybuild", @@ -26,9 +28,9 @@ dependencies = [ [[package]] name = "async-stream-impl" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "648ed8c8d2ce5409ccd57453d9d1b214b342a0d69376a6feda1fd6cae3299308" +checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965" dependencies = [ "proc-macro2", "quote", @@ -37,21 +39,30 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.1" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "basic-toml" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "2e819b667739967cd44d308b8c7b71305d8bb0729ac44a248aa08f33d01950b4" +dependencies = [ + "serde", +] [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bytes" -version = "1.0.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "cfg-if" @@ -61,18 +72,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "futures-core" -version = "0.3.15" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0402f765d8a89a26043b889b26ce3c4679d268fa6bb22cd7c6aad98340e179d1" +checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" [[package]] name = "futures-macro" -version = "0.3.15" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c40298486cdf52cc00cd6d6987892ba502c7656a16a4192a9992b1ccedd121" +checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70" dependencies = [ - "autocfg", - "proc-macro-hack", "proc-macro2", "quote", "syn", @@ -80,129 +89,93 @@ dependencies = [ [[package]] name = "futures-task" -version = "0.3.15" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a16bef9fc1a4dddb5bee51c989e3fbba26569cbb0e31f5b303c184e3dd33dae" +checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" [[package]] name = "futures-util" -version = "0.3.15" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "feb5c238d27e2bf94ffdfd27b2c29e3df4a68c4193bb6427384259e2bf191967" +checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" dependencies = [ - "autocfg", "futures-core", "futures-macro", "futures-task", "pin-project-lite", "pin-utils", - "proc-macro-hack", - "proc-macro-nested", "slab", ] [[package]] name = "glob" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "hermit-abi" -version = "0.1.18" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" dependencies = [ "libc", ] [[package]] -name = "instant" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" -dependencies = [ - "cfg-if", -] - -[[package]] name = "itoa" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" - -[[package]] -name = "lazy_static" -version = "1.4.0" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" [[package]] name = "libc" -version = "0.2.94" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18794a8ad5b29321f790b55d93dfba91e125cb1a9edbd4f8e3150acc771c1a5e" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "lock_api" -version = "0.4.4" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" dependencies = [ + "autocfg", "scopeguard", ] [[package]] name = "log" -version = "0.4.14" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if", ] [[package]] name = "memchr" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "mio" -version = "0.7.11" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf80d3e903b34e0bd7282b218398aec54e082c840d9baf8339e0080a0c542956" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", - "miow", - "ntapi", - "winapi", -] - -[[package]] -name = "miow" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" -dependencies = [ - "winapi", -] - -[[package]] -name = "ntapi" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" -dependencies = [ - "winapi", + "wasi", + "windows-sys 0.45.0", ] [[package]] name = "num_cpus" -version = "1.13.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ "hermit-abi", "libc", @@ -210,40 +183,38 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.7.2" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "parking_lot" -version = "0.11.1" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ - "instant", "lock_api", "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.8.3" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if", - "instant", "libc", "redox_syscall", "smallvec", - "winapi", + "windows-sys 0.45.0", ] [[package]] name = "pin-project-lite" -version = "0.2.6" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" [[package]] name = "pin-utils" @@ -252,49 +223,43 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - -[[package]] -name = "proc-macro-nested" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" - -[[package]] name = "proc-macro2" -version = "1.0.27" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" +checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.9" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" -version = "0.2.8" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ "bitflags", ] [[package]] +name = "rustversion" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" + +[[package]] name = "ryu" -version = "1.0.5" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" [[package]] name = "scopeguard" @@ -304,18 +269,15 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.126" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" -dependencies = [ - "serde_derive", -] +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" [[package]] name = "serde_derive" -version = "1.0.126" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" dependencies = [ "proc-macro2", "quote", @@ -324,9 +286,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.64" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" dependencies = [ "itoa", "ryu", @@ -335,50 +297,63 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.3.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" dependencies = [ "libc", ] [[package]] name = "slab" -version = "0.4.3" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] [[package]] name = "smallvec" -version = "1.6.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "socket2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +dependencies = [ + "libc", + "winapi", +] [[package]] name = "syn" -version = "1.0.72" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] name = "termcolor" -version = "1.1.2" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ "winapi-util", ] [[package]] name = "tokio" -version = "1.6.0" +version = "1.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd3076b5c8cc18138b8f8814895c11eb4de37114a5d127bafdc5e55798ceef37" +checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" dependencies = [ "autocfg", "bytes", @@ -386,19 +361,19 @@ dependencies = [ "memchr", "mio", "num_cpus", - "once_cell", "parking_lot", "pin-project-lite", "signal-hook-registry", + "socket2", "tokio-macros", - "winapi", + "windows-sys 0.42.0", ] [[package]] name = "tokio-macros" -version = "1.2.0" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c49e3df43841dafb86046472506755d8501c5615673955f6aa17181125d13c37" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" dependencies = [ "proc-macro2", "quote", @@ -407,9 +382,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.6" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8864d706fdb3cc0843a49647ac892720dac98a6eeb818b77190592cf4994066" +checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" dependencies = [ "futures-core", "pin-project-lite", @@ -430,33 +405,31 @@ dependencies = [ ] [[package]] -name = "toml" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" -dependencies = [ - "serde", -] - -[[package]] name = "trybuild" -version = "1.0.42" +version = "1.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1768998d9a3b179411618e377dbb134c58a88cda284b0aa71c42c40660127d46" +checksum = "a44da5a6f2164c8e14d3bbc0657d69c5966af9f5f6930d4f600b1f5c4a673413" dependencies = [ + "basic-toml", "glob", - "lazy_static", + "once_cell", "serde", + "serde_derive", "serde_json", "termcolor", - "toml", ] [[package]] -name = "unicode-xid" -version = "0.2.2" +name = "unicode-ident" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "winapi" @@ -488,3 +461,84 @@ 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 = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" @@ -3,32 +3,38 @@ # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies -# to registry (e.g., crates.io) dependencies +# to registry (e.g., crates.io) dependencies. # -# If you believe there's an error in this file please file an -# issue against the rust-lang/cargo repository. If you're -# editing this file be aware that the upstream Cargo.toml -# will likely look very different (and much more reasonable) +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. [package] edition = "2018" +rust-version = "1.45" name = "async-stream" -version = "0.3.2" +version = "0.3.4" 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" readme = "README.md" license = "MIT" repository = "https://github.com/tokio-rs/async-stream" + [dependencies.async-stream-impl] -version = "=0.3.2" +version = "=0.3.4" [dependencies.futures-core] version = "0.3" + +[dependencies.pin-project-lite] +version = "0.2" + [dev-dependencies.futures-util] version = "0.3" +[dev-dependencies.rustversion] +version = "1" + [dev-dependencies.tokio] version = "1" features = ["full"] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 06ccf45..1407a68 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,26 +1,24 @@ [package] name = "async-stream" # When releasing to crates.io: -# - Update version number -# - README.md # - Update CHANGELOG.md # - Create git tag -version = "0.3.2" +version = "0.3.4" edition = "2018" +rust-version = "1.45" license = "MIT" authors = ["Carl Lerche <me@carllerche.com>"] description = "Asynchronous streams using async & await notation" -documentation = "https://docs.rs/async-stream" -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.2", path = "../async-stream-impl" } +async-stream-impl = { version = "=0.3.4", path = "../async-stream-impl" } futures-core = "0.3" +pin-project-lite = "0.2" [dev-dependencies] futures-util = "0.3" +rustversion = "1" tokio = { version = "1", features = ["full"] } tokio-test = "0.4" trybuild = "1" @@ -1,3 +1,7 @@ +# This project was upgraded with external_updater. +# Usage: tools/external_updater/updater.sh update rust/crates/async-stream +# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md + name: "async-stream" description: "Asynchronous streams using async & await notation" third_party { @@ -7,13 +11,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/async-stream/async-stream-0.3.2.crate" + value: "https://static.crates.io/crates/async-stream/async-stream-0.3.4.crate" } - version: "0.3.2" + version: "0.3.4" license_type: NOTICE last_upgrade_date { - year: 2021 - month: 6 - day: 21 + year: 2023 + month: 3 + day: 2 } } @@ -10,7 +10,7 @@ The `stream!` macro returns an anonymous type implementing the [`Stream`] trait. The `Item` associated type is the type of the values yielded from the stream. The `try_stream!` also returns an anonymous type implementing the [`Stream`] trait, but the `Item` associated type is `Result<T, Error>`. The -`try_stream!` macro supports using `?` notiation as part of the +`try_stream!` macro supports using `?` notation as part of the implementation. ## Usage @@ -138,7 +138,7 @@ fn bind_and_accept(addr: SocketAddr) ## Implementation The `stream!` and `try_stream!` macros are implemented using proc macros. -The macro searches the syntax tree for instances of `sender.send($expr)` and +The macro searches the syntax tree for instances of `yield $expr` and transforms them into `sender.send($expr).await`. The stream uses a lightweight sender to send values from the stream @@ -151,6 +151,7 @@ caller. [`Stream`]: https://docs.rs/futures-core/*/futures_core/stream/trait.Stream.html ## 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 index dfc3524..0d50c8f 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -7,5 +7,21 @@ { "path": "external/rust/crates/tokio-test" } + ], + "presubmit": [ + { + "name": "async-stream_test_tests_for_await" + }, + { + "name": "async-stream_test_tests_try_stream" + } + ], + "presubmit-rust": [ + { + "name": "async-stream_test_tests_for_await" + }, + { + "name": "async-stream_test_tests_try_stream" + } ] } diff --git a/cargo2android.json b/cargo2android.json index bf78496..0c66159 100644 --- a/cargo2android.json +++ b/cargo2android.json @@ -1,4 +1,11 @@ { "device": true, - "run": true -}
\ No newline at end of file + "run": true, + "tests": true, + "dependency-blocklist": [ + "trybuild" + ], + "test-blocklist": [ + "tests/stream.rs" + ] +} diff --git a/src/async_stream.rs b/src/async_stream.rs index f60c87e..ff408ab 100644 --- a/src/async_stream.rs +++ b/src/async_stream.rs @@ -1,16 +1,20 @@ use crate::yielder::Receiver; use futures_core::{FusedStream, Stream}; +use pin_project_lite::pin_project; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; -#[doc(hidden)] -#[derive(Debug)] -pub struct AsyncStream<T, U> { - rx: Receiver<T>, - done: bool, - generator: U, +pin_project! { + #[doc(hidden)] + #[derive(Debug)] + pub struct AsyncStream<T, U> { + rx: Receiver<T>, + done: bool, + #[pin] + generator: U, + } } impl<T, U> AsyncStream<T, U> { @@ -40,30 +44,28 @@ where type Item = T; fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> { - unsafe { - let me = Pin::get_unchecked_mut(self); + let me = self.project(); - if me.done { - return Poll::Ready(None); - } + if *me.done { + return Poll::Ready(None); + } - let mut dst = None; - let res = { - let _enter = me.rx.enter(&mut dst); - Pin::new_unchecked(&mut me.generator).poll(cx) - }; + let mut dst = None; + let res = { + let _enter = me.rx.enter(&mut dst); + me.generator.poll(cx) + }; - me.done = res.is_ready(); + *me.done = res.is_ready(); - if dst.is_some() { - return Poll::Ready(dst.take()); - } + if dst.is_some() { + return Poll::Ready(dst.take()); + } - if me.done { - Poll::Ready(None) - } else { - Poll::Pending - } + if *me.done { + Poll::Ready(None) + } else { + Poll::Pending } } @@ -16,7 +16,7 @@ //! trait. The `Item` associated type is the type of the values yielded from the //! stream. The `try_stream!` also returns an anonymous type implementing the //! [`Stream`] trait, but the `Item` associated type is `Result<T, Error>`. The -//! `try_stream!` macro supports using `?` notiation as part of the +//! `try_stream!` macro supports using `?` notation as part of the //! implementation. //! //! # Usage @@ -144,7 +144,7 @@ //! # Implementation //! //! The `stream!` and `try_stream!` macros are implemented using proc macros. -//! The macro searches the syntax tree for instances of `sender.send($expr)` and +//! The macro searches the syntax tree for instances of `yield $expr` and //! transforms them into `sender.send($expr).await`. //! //! The stream uses a lightweight sender to send values from the stream @@ -158,15 +158,7 @@ mod async_stream; mod next; -#[doc(hidden)] -pub mod yielder; - -// Used by the macro, but not intended to be accessed publicly. -#[doc(hidden)] -pub use crate::async_stream::AsyncStream; - -#[doc(hidden)] -pub use async_stream_impl; +mod yielder; /// Asynchronous stream /// @@ -198,7 +190,7 @@ pub use async_stream_impl; #[macro_export] macro_rules! stream { ($($tt:tt)*) => { - $crate::async_stream_impl::stream_inner!(($crate) $($tt)*) + $crate::__private::stream_inner!(($crate) $($tt)*) } } @@ -234,12 +226,17 @@ macro_rules! stream { #[macro_export] macro_rules! try_stream { ($($tt:tt)*) => { - $crate::async_stream_impl::try_stream_inner!(($crate) $($tt)*) + $crate::__private::try_stream_inner!(($crate) $($tt)*) } } +// Not public API. #[doc(hidden)] -pub mod reexport { - #[doc(hidden)] +pub mod __private { + pub use crate::async_stream::AsyncStream; pub use crate::next::next; + pub use async_stream_impl::{stream_inner, try_stream_inner}; + pub mod yielder { + pub use crate::yielder::pair; + } } diff --git a/src/yielder.rs b/src/yielder.rs index 1ee523f..597e1c9 100644 --- a/src/yielder.rs +++ b/src/yielder.rs @@ -20,7 +20,12 @@ pub(crate) struct Enter<'a, T> { prev: *mut (), } -pub fn pair<T>() -> (Sender<T>, Receiver<T>) { +// Note: It is considered unsound for anyone other than our macros to call +// this function. This is a private API intended only for calls from our +// macros, and users should never call it, but some people tend to +// misinterpret it as fine to call unless it is marked unsafe. +#[doc(hidden)] +pub unsafe fn pair<T>() -> (Sender<T>, Receiver<T>) { let tx = Sender { _p: PhantomData }; let rx = Receiver { _p: PhantomData }; (tx, rx) @@ -53,9 +58,9 @@ impl<T> Future for Send<T> { return Poll::Ready(()); } - STORE.with(|cell| unsafe { + STORE.with(|cell| { let ptr = cell.get() as *mut Option<T>; - let option_ref = ptr.as_mut().expect("invalid usage"); + let option_ref = unsafe { ptr.as_mut() }.expect("invalid usage"); if option_ref.is_none() { *option_ref = self.value.take(); diff --git a/tests/spans_preserved.rs b/tests/spans_preserved.rs new file mode 100644 index 0000000..f2663b8 --- /dev/null +++ b/tests/spans_preserved.rs @@ -0,0 +1,15 @@ +use async_stream::stream; +use futures_util::pin_mut; +use futures_util::stream::StreamExt; + +#[tokio::test] +async fn spans_preserved() { + let s = stream! { + assert_eq!(line!(), 8); + }; + pin_mut!(s); + + while s.next().await.is_some() { + unreachable!(); + } +} diff --git a/tests/stream.rs b/tests/stream.rs index 77b3813..4e26a3d 100644 --- a/tests/stream.rs +++ b/tests/stream.rs @@ -11,7 +11,7 @@ async fn noop_stream() { let s = stream! {}; pin_mut!(s); - while let Some(_) = s.next().await { + while s.next().await.is_some() { unreachable!(); } } @@ -28,7 +28,7 @@ async fn empty_stream() { }; pin_mut!(s); - while let Some(_) = s.next().await { + while s.next().await.is_some() { unreachable!(); } } @@ -229,6 +229,7 @@ fn inner_try_stream() { }; } +#[rustversion::attr(not(stable), ignore)] #[test] fn test() { let t = trybuild::TestCases::new(); diff --git a/tests/try_stream.rs b/tests/try_stream.rs index 063e37a..c404e62 100644 --- a/tests/try_stream.rs +++ b/tests/try_stream.rs @@ -66,7 +66,7 @@ async fn multi_try() { fn test() -> impl Stream<Item = Result<i32, String>> { try_stream! { let a = Ok::<_, String>(Ok::<_, String>(123))??; - for _ in (1..10) { + for _ in 1..10 { yield a; } } @@ -78,3 +78,10 @@ async fn multi_try() { values ); } + +#[allow(unused)] +fn issue_65() -> impl Stream<Item = Result<u32, ()>> { + try_stream! { + yield Err(())?; + } +} diff --git a/tests/ui/yield_bad_expr_in_macro.stderr b/tests/ui/yield_bad_expr_in_macro.stderr index 71d9075..e70e200 100644 --- a/tests/ui/yield_bad_expr_in_macro.stderr +++ b/tests/ui/yield_bad_expr_in_macro.stderr @@ -1,5 +1,5 @@ error: expected expression - --> $DIR/yield_bad_expr_in_macro.rs:8:33 + --> tests/ui/yield_bad_expr_in_macro.rs:8:33 | 8 | _ = work() => yield fn f() {}, | ^^ diff --git a/tests/ui/yield_in_async.stderr b/tests/ui/yield_in_async.stderr index 19691eb..4322758 100644 --- a/tests/ui/yield_in_async.stderr +++ b/tests/ui/yield_in_async.stderr @@ -1,5 +1,5 @@ error[E0658]: yield syntax is experimental - --> $DIR/yield_in_async.rs:6:13 + --> tests/ui/yield_in_async.rs:6:13 | 6 | yield 123; | ^^^^^^^^^ @@ -7,69 +7,13 @@ error[E0658]: yield syntax is experimental = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information error[E0727]: `async` generators are not yet supported - --> $DIR/yield_in_async.rs:6:13 + --> tests/ui/yield_in_async.rs:6:13 | 6 | yield 123; | ^^^^^^^^^ -error[E0271]: type mismatch resolving `<[static generator@$DIR/src/lib.rs:201:9: 201:67] as Generator<ResumeTy>>::Yield == ()` - --> $DIR/yield_in_async.rs:4:5 - | -4 | / stream! { -5 | | let f = async { -6 | | yield 123; -7 | | }; -8 | | -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 +error[E0308]: mismatched types + --> tests/ui/yield_in_async.rs:6:19 | 6 | yield 123; - | ^^^ cannot infer type for type `{integer}` - | -note: the type is part of the `async` block because of this `yield` - --> $DIR/yield_in_async.rs:6:13 - | -6 | yield 123; - | ^^^^^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/yield_in_async.rs:5:13 - | -5 | let f = async { - | ^ cannot infer type for type `{integer}` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/yield_in_async.rs:9:17 - | -9 | let v = f.await; - | ^^^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/yield_in_async.rs:9:17 - | -9 | let v = f.await; - | ^ cannot infer type for type `{integer}` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/yield_in_async.rs:9:17 - | -9 | let v = f.await; - | ^^^^^^^ - -error[E0698]: type inside `async` block must be known in this context - --> $DIR/yield_in_async.rs:9:17 - | -9 | let v = f.await; - | ^^^^^^^ cannot infer type for type `{integer}` - | -note: the type is part of the `async` block because of this `await` - --> $DIR/yield_in_async.rs:9:17 - | -9 | let v = f.await; - | ^^^^^^^ + | ^^^ expected `()`, found integer diff --git a/tests/ui/yield_in_closure.stderr b/tests/ui/yield_in_closure.stderr index 2506e18..9f917f3 100644 --- a/tests/ui/yield_in_closure.stderr +++ b/tests/ui/yield_in_closure.stderr @@ -1,18 +1,26 @@ error[E0658]: yield syntax is experimental - --> $DIR/yield_in_closure.rs:7:17 + --> tests/ui/yield_in_closure.rs:7:17 | 7 | yield v; | ^^^^^^^ | = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information -error[E0277]: expected a `FnOnce<(&str,)>` closure, found `[generator@$DIR/src/lib.rs:201:9: 201:67]` - --> $DIR/yield_in_closure.rs:6:14 +error[E0277]: expected a `FnOnce<(&str,)>` closure, found `[generator@$DIR/tests/ui/yield_in_closure.rs:6:23: 6:26]` + --> tests/ui/yield_in_closure.rs:6:23 | -6 | .and_then(|v| { - | ^^^^^^^^ expected an `FnOnce<(&str,)>` closure, found `[generator@$DIR/src/lib.rs:201:9: 201:67]` +6 | .and_then(|v| { + | ______________--------_^ + | | | + | | required by a bound introduced by this call +7 | | yield v; +8 | | Ok(()) +9 | | }); + | |_____________^ expected an `FnOnce<(&str,)>` closure, found `[generator@$DIR/tests/ui/yield_in_closure.rs:6:23: 6:26]` | - = help: the trait `FnOnce<(&str,)>` is not implemented for `[generator@$DIR/src/lib.rs:201:9: 201:67]` - -Some errors have detailed explanations: E0277, E0658. -For more information about an error, try `rustc --explain E0277`. + = help: the trait `FnOnce<(&str,)>` is not implemented for `[generator@$DIR/tests/ui/yield_in_closure.rs:6:23: 6:26]` +note: required by a bound in `Result::<T, E>::and_then` + --> $RUST/core/src/result.rs + | + | pub fn and_then<U, F: FnOnce(T) -> Result<U, E>>(self, op: F) -> Result<U, E> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Result::<T, E>::and_then` diff --git a/tests/ui/yield_in_nested_fn.stderr b/tests/ui/yield_in_nested_fn.stderr index a562555..54fdee9 100644 --- a/tests/ui/yield_in_nested_fn.stderr +++ b/tests/ui/yield_in_nested_fn.stderr @@ -1,5 +1,5 @@ error[E0658]: yield syntax is experimental - --> $DIR/yield_in_nested_fn.rs:6:13 + --> tests/ui/yield_in_nested_fn.rs:6:13 | 6 | yield "hello"; | ^^^^^^^^^^^^^ @@ -7,10 +7,7 @@ error[E0658]: yield syntax is experimental = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information error[E0627]: yield expression outside of generator literal - --> $DIR/yield_in_nested_fn.rs:6:13 + --> tests/ui/yield_in_nested_fn.rs:6:13 | 6 | yield "hello"; | ^^^^^^^^^^^^^ - -Some errors have detailed explanations: E0627, E0658. -For more information about an error, try `rustc --explain E0627`. |