diff options
author | Jeff Vander Stoep <jeffv@google.com> | 2023-03-03 19:38:22 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-03-03 19:38:22 +0000 |
commit | d1645c6446ecc2e17c730d5db7df1ab76d1ff203 (patch) | |
tree | 145fa12284b1e1e35d8d6ea02f129b9a88bcdfc1 | |
parent | ae065b55e76923821714846b917462b95a652b1c (diff) | |
parent | 6c2c412e889bfd50099910923fb5390e1d6977da (diff) | |
download | async-stream-d1645c6446ecc2e17c730d5db7df1ab76d1ff203.tar.gz |
Upgrade async-stream to 0.3.4 am: 4b13b9fde6 am: f675554708 am: 6c2c412e88
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/async-stream/+/2467320
Change-Id: I8f875e79b555b0af1578fa02367b78170924ed66
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 16 | ||||
-rw-r--r-- | CHANGELOG.md | 5 | ||||
-rw-r--r-- | Cargo.lock | 285 | ||||
-rw-r--r-- | Cargo.toml | 8 | ||||
-rw-r--r-- | Cargo.toml.orig | 5 | ||||
-rw-r--r-- | METADATA | 14 | ||||
-rw-r--r-- | README.md | 4 | ||||
-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/try_stream.rs | 2 | ||||
-rw-r--r-- | tests/ui/yield_in_async.stderr | 23 | ||||
-rw-r--r-- | tests/ui/yield_in_closure.stderr | 28 |
15 files changed, 281 insertions, 216 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 7d3290f..1354331 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,6 +1,6 @@ { "git": { - "sha1": "e1373e4dede24f7700452e499a46561fb45ea515" + "sha1": "bf41b9645fe39b8865da2f25edc286eb42d49ec8" }, "path_in_vcs": "async-stream" }
\ No newline at end of file @@ -22,7 +22,7 @@ rust_defaults { name: "async-stream_test_defaults", crate_name: "async_stream", cargo_env_compat: true, - cargo_pkg_version: "0.3.3", + cargo_pkg_version: "0.3.4", test_suites: ["general-tests"], auto_gen_config: true, edition: "2018", @@ -30,6 +30,7 @@ rust_defaults { "libasync_stream", "libfutures_core", "libfutures_util", + "libpin_project_lite", "libtokio", "libtokio_test", ], @@ -50,6 +51,16 @@ rust_test { } 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, @@ -64,11 +75,12 @@ rust_library { host_supported: true, crate_name: "async_stream", cargo_env_compat: true, - cargo_pkg_version: "0.3.3", + 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: [ diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e5afdc..d75deb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 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) @@ -14,11 +14,12 @@ dependencies = [ [[package]] name = "async-stream" -version = "0.3.3" +version = "0.3.4" dependencies = [ "async-stream-impl", "futures-core", "futures-util", + "pin-project-lite", "rustversion", "tokio", "tokio-test", @@ -27,9 +28,9 @@ dependencies = [ [[package]] name = "async-stream-impl" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27" +checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965" dependencies = [ "proc-macro2", "quote", @@ -37,6 +38,21 @@ dependencies = [ ] [[package]] +name = "autocfg" +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 = "2e819b667739967cd44d308b8c7b71305d8bb0729ac44a248aa08f33d01950b4" +dependencies = [ + "serde", +] + +[[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -44,9 +60,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bytes" -version = "1.1.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "cfg-if" @@ -56,15 +72,15 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "futures-core" -version = "0.3.21" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" +checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608" [[package]] name = "futures-macro" -version = "0.3.21" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" +checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70" dependencies = [ "proc-macro2", "quote", @@ -73,15 +89,15 @@ dependencies = [ [[package]] name = "futures-task" -version = "0.3.21" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" +checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366" [[package]] name = "futures-util" -version = "0.3.21" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" +checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1" dependencies = [ "futures-core", "futures-macro", @@ -93,92 +109,73 @@ dependencies = [ [[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.19" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" dependencies = [ "libc", ] [[package]] name = "itoa" -version = "1.0.1" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" [[package]] name = "libc" -version = "0.2.119" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "lock_api" -version = "0.4.6" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" +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.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "mio" -version = "0.8.1" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba42135c6a5917b9db9cd7b293e5409e1c6b041e6f9825e92e55a894c63b6f8" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" dependencies = [ "libc", "log", - "miow", - "ntapi", "wasi", - "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.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" -dependencies = [ - "winapi", + "windows-sys 0.45.0", ] [[package]] name = "num_cpus" -version = "1.13.1" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" dependencies = [ "hermit-abi", "libc", @@ -186,15 +183,15 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.10.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "parking_lot" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", "parking_lot_core", @@ -202,22 +199,22 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.1" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys", + "windows-sys 0.45.0", ] [[package]] name = "pin-project-lite" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" [[package]] name = "pin-utils" @@ -227,42 +224,42 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "proc-macro2" -version = "1.0.36" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.15" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" +checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" -version = "0.2.11" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ "bitflags", ] [[package]] name = "rustversion" -version = "1.0.6" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" +checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" [[package]] name = "ryu" -version = "1.0.9" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" [[package]] name = "scopeguard" @@ -272,18 +269,15 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.136" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" -dependencies = [ - "serde_derive", -] +checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" [[package]] name = "serde_derive" -version = "1.0.136" +version = "1.0.152" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" +checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" dependencies = [ "proc-macro2", "quote", @@ -292,9 +286,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.79" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" +checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" dependencies = [ "itoa", "ryu", @@ -303,30 +297,33 @@ dependencies = [ [[package]] name = "signal-hook-registry" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" dependencies = [ "libc", ] [[package]] name = "slab" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] [[package]] name = "smallvec" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "socket2" -version = "0.4.4" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" dependencies = [ "libc", "winapi", @@ -334,49 +331,49 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.86" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" +checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] name = "termcolor" -version = "1.1.3" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" dependencies = [ "winapi-util", ] [[package]] name = "tokio" -version = "1.17.0" +version = "1.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2af73ac49756f3f7c01172e34a23e5d0216f6c32333757c2c61feb2bbff5a5ee" +checksum = "c8e00990ebabbe4c14c08aca901caed183ecd5c09562a12c824bb53d3c3fd3af" dependencies = [ + "autocfg", "bytes", "libc", "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.7.0" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b557f72f448c511a979e2564e55d74e6c4432fc96ff4f6241bc6bded342643b7" +checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" dependencies = [ "proc-macro2", "quote", @@ -385,9 +382,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.8" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50145484efff8818b5ccd256697f36863f587da82cf8b409c53adf1e840798e3" +checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" dependencies = [ "futures-core", "pin-project-lite", @@ -408,33 +405,25 @@ 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.56" +version = "1.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d60539445867cdd9680b2bfe2d0428f1814b7d5c9652f09d8d3eae9d19308db" +checksum = "a44da5a6f2164c8e14d3bbc0657d69c5966af9f5f6930d4f600b1f5c4a673413" dependencies = [ + "basic-toml", "glob", "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 = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" +checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" [[package]] name = "wasi" @@ -475,43 +464,81 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" -version = "0.32.0" +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 = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6" +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.32.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" [[package]] name = "windows_i686_gnu" -version = "0.32.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" [[package]] name = "windows_i686_msvc" -version = "0.32.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" [[package]] name = "windows_x86_64_gnu" -version = "0.32.0" +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 = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" [[package]] name = "windows_x86_64_msvc" -version = "0.32.0" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" @@ -13,18 +13,22 @@ edition = "2018" rust-version = "1.45" name = "async-stream" -version = "0.3.3" +version = "0.3.4" authors = ["Carl Lerche <me@carllerche.com>"] description = "Asynchronous streams using async & await notation" +readme = "README.md" license = "MIT" repository = "https://github.com/tokio-rs/async-stream" [dependencies.async-stream-impl] -version = "=0.3.3" +version = "=0.3.4" [dependencies.futures-core] version = "0.3" +[dependencies.pin-project-lite] +version = "0.2" + [dev-dependencies.futures-util] version = "0.3" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 2f31b77..1407a68 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -3,7 +3,7 @@ name = "async-stream" # When releasing to crates.io: # - Update CHANGELOG.md # - Create git tag -version = "0.3.3" +version = "0.3.4" edition = "2018" rust-version = "1.45" license = "MIT" @@ -12,8 +12,9 @@ description = "Asynchronous streams using async & await notation" repository = "https://github.com/tokio-rs/async-stream" [dependencies] -async-stream-impl = { version = "=0.3.3", 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" @@ -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.3.crate" + value: "https://static.crates.io/crates/async-stream/async-stream-0.3.4.crate" } - version: "0.3.3" + version: "0.3.4" license_type: NOTICE last_upgrade_date { - year: 2022 - 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 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/try_stream.rs b/tests/try_stream.rs index 06dcc3d..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; } } diff --git a/tests/ui/yield_in_async.stderr b/tests/ui/yield_in_async.stderr index 11d2ca1..4322758 100644 --- a/tests/ui/yield_in_async.stderr +++ b/tests/ui/yield_in_async.stderr @@ -12,21 +12,8 @@ error[E0727]: `async` generators are not yet supported 6 | yield 123; | ^^^^^^^^^ -error[E0271]: type mismatch resolving `<[static generator@$DIR/src/lib.rs:201:9: 201:67] as Generator<ResumeTy>>::Yield == ()` - --> tests/ui/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: required by a bound in `from_generator` - --> $RUST/core/src/future/mod.rs - | - | T: Generator<ResumeTy, Yield = ()>, - | ^^^^^^^^^^ required by this bound in `from_generator` - = note: this error originates in the macro `stream` (in Nightly builds, run with -Z macro-backtrace for more info) +error[E0308]: mismatched types + --> tests/ui/yield_in_async.rs:6:19 + | +6 | yield 123; + | ^^^ expected `()`, found integer diff --git a/tests/ui/yield_in_closure.stderr b/tests/ui/yield_in_closure.stderr index fb52f80..9f917f3 100644 --- a/tests/ui/yield_in_closure.stderr +++ b/tests/ui/yield_in_closure.stderr @@ -6,15 +6,21 @@ 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 `FnOnce<(&str,)>` closure, found `[generator@$DIR/src/lib.rs:201:9: 201:67]` - --> tests/ui/yield_in_closure.rs:6:14 - | -6 | .and_then(|v| { - | ^^^^^^^^ expected an `FnOnce<(&str,)>` closure, found `[generator@$DIR/src/lib.rs:201:9: 201:67]` - | - = help: the trait `FnOnce<(&str,)>` is not implemented for `[generator@$DIR/src/lib.rs:201:9: 201:67]` +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| { + | ______________--------_^ + | | | + | | 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/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` + --> $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` |