From 631cd5845e8de329d0e227aaa707d7ea228b8f8f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:20:29 +0200 Subject: Merging upstream version 1.70.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/rustc-rayon/.cargo-checksum.json | 2 +- vendor/rustc-rayon/Cargo.lock | 289 --------------------- vendor/rustc-rayon/Cargo.toml | 27 +- vendor/rustc-rayon/README.md | 2 +- vendor/rustc-rayon/RELEASES.md | 64 +++++ vendor/rustc-rayon/build.rs | 12 - vendor/rustc-rayon/examples/README.md | 3 - vendor/rustc-rayon/examples/cpu_monitor.rs | 81 ------ vendor/rustc-rayon/src/array.rs | 9 +- vendor/rustc-rayon/src/collections/mod.rs | 4 +- .../compile_fail/cannot_collect_filtermap_data.rs | 12 +- .../src/compile_fail/cannot_zip_filtered_data.rs | 10 +- .../rustc-rayon/src/compile_fail/cell_par_iter.rs | 10 +- vendor/rustc-rayon/src/compile_fail/must_use.rs | 2 + .../src/compile_fail/no_send_par_iter.rs | 30 +-- vendor/rustc-rayon/src/compile_fail/rc_par_iter.rs | 12 +- vendor/rustc-rayon/src/iter/chunks.rs | 50 ++-- vendor/rustc-rayon/src/iter/collect/test.rs | 2 + vendor/rustc-rayon/src/iter/filter.rs | 2 +- vendor/rustc-rayon/src/iter/filter_map.rs | 2 +- vendor/rustc-rayon/src/iter/find.rs | 2 +- vendor/rustc-rayon/src/iter/fold_chunks.rs | 236 +++++++++++++++++ vendor/rustc-rayon/src/iter/fold_chunks_with.rs | 231 ++++++++++++++++ vendor/rustc-rayon/src/iter/inspect.rs | 2 +- vendor/rustc-rayon/src/iter/interleave.rs | 18 +- vendor/rustc-rayon/src/iter/map.rs | 2 +- vendor/rustc-rayon/src/iter/mod.rs | 269 +++++++++++++++++-- vendor/rustc-rayon/src/iter/par_bridge.rs | 159 ++++-------- vendor/rustc-rayon/src/iter/plumbing/README.md | 6 +- vendor/rustc-rayon/src/iter/skip_any.rs | 144 ++++++++++ vendor/rustc-rayon/src/iter/skip_any_while.rs | 166 ++++++++++++ vendor/rustc-rayon/src/iter/step_by.rs | 1 - vendor/rustc-rayon/src/iter/take_any.rs | 144 ++++++++++ vendor/rustc-rayon/src/iter/take_any_while.rs | 166 ++++++++++++ vendor/rustc-rayon/src/iter/test.rs | 24 +- vendor/rustc-rayon/src/iter/try_fold.rs | 3 +- vendor/rustc-rayon/src/iter/try_reduce.rs | 3 +- vendor/rustc-rayon/src/iter/try_reduce_with.rs | 3 +- vendor/rustc-rayon/src/iter/update.rs | 2 +- vendor/rustc-rayon/src/lib.rs | 15 +- vendor/rustc-rayon/src/math.rs | 2 +- vendor/rustc-rayon/src/slice/chunks.rs | 2 +- vendor/rustc-rayon/src/slice/mergesort.rs | 22 +- vendor/rustc-rayon/src/slice/mod.rs | 8 + vendor/rustc-rayon/src/slice/quicksort.rs | 79 +++--- vendor/rustc-rayon/src/slice/rchunks.rs | 2 +- vendor/rustc-rayon/src/slice/test.rs | 2 +- vendor/rustc-rayon/src/str.rs | 6 +- vendor/rustc-rayon/src/vec.rs | 53 ++-- vendor/rustc-rayon/tests/clones.rs | 26 +- vendor/rustc-rayon/tests/collect.rs | 2 + vendor/rustc-rayon/tests/cross-pool.rs | 1 + vendor/rustc-rayon/tests/debug.rs | 6 + vendor/rustc-rayon/tests/drain_vec.rs | 41 +++ vendor/rustc-rayon/tests/iter_panic.rs | 3 +- vendor/rustc-rayon/tests/named-threads.rs | 1 + vendor/rustc-rayon/tests/octillion.rs | 32 ++- vendor/rustc-rayon/tests/par_bridge_recursion.rs | 31 +++ vendor/rustc-rayon/tests/sort-panic-safe.rs | 10 +- 59 files changed, 1809 insertions(+), 741 deletions(-) delete mode 100644 vendor/rustc-rayon/Cargo.lock delete mode 100644 vendor/rustc-rayon/build.rs delete mode 100644 vendor/rustc-rayon/examples/README.md delete mode 100644 vendor/rustc-rayon/examples/cpu_monitor.rs create mode 100644 vendor/rustc-rayon/src/iter/fold_chunks.rs create mode 100644 vendor/rustc-rayon/src/iter/fold_chunks_with.rs create mode 100644 vendor/rustc-rayon/src/iter/skip_any.rs create mode 100644 vendor/rustc-rayon/src/iter/skip_any_while.rs create mode 100644 vendor/rustc-rayon/src/iter/take_any.rs create mode 100644 vendor/rustc-rayon/src/iter/take_any_while.rs create mode 100644 vendor/rustc-rayon/tests/drain_vec.rs create mode 100644 vendor/rustc-rayon/tests/par_bridge_recursion.rs (limited to 'vendor/rustc-rayon') diff --git a/vendor/rustc-rayon/.cargo-checksum.json b/vendor/rustc-rayon/.cargo-checksum.json index c6a6c627f..ab2bcaf06 100644 --- a/vendor/rustc-rayon/.cargo-checksum.json +++ b/vendor/rustc-rayon/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.lock":"bc7d1e87a71b0a90c4ab183cbd2ce4763686e4d875b66a19120a9f98c0edf7bd","Cargo.toml":"28f41a563973aea61fec48680449dbd0be37d808d9a7b3a865c550f793bebaf3","FAQ.md":"e963b051f6295a2944ff5abec368c7da914b913e21049978c2ef0017294abf8f","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0621878e61f0d0fda054bcbe02df75192c28bde1ecc8289cbd86aeba2dd72720","README.md":"e70e19b9564b62d7822034e06db77c33b14a05408f1310d16b1e92baa1238f32","RELEASES.md":"7ce306bade407f48d882eeef320f4e4500534d9f4eb03b1ad020236080a2799b","build.rs":"72293313a5e41d4828418c49453c2001eb76c4adee600b6442ef18bed4ed1baf","examples/README.md":"537e6fe9cf696fd4ada9c08bf31055ed6e366ed65668a523e7c5fde77f97c8d3","examples/cpu_monitor.rs":"cc21a2635059ab2d86622d86508ce360c105417522b7bd1f8e0b3ac845ed484a","src/array.rs":"ba8f5da438ddda58f71d59fcd1bfb8c2aa3ff30038ad304019c384e7f899d577","src/collections/binary_heap.rs":"58e2590ff52fa2cfe7b5797fdc37902d0c111cca844aac21a4024add2f28a8db","src/collections/btree_map.rs":"d3094ed5c54620f81a86133f52e74164bae9f0137745eb66e6d31db2e942bcab","src/collections/btree_set.rs":"7de12e388d36cb2f8672bc3b68aed5b44d047c9f5fe262a7260584634299480f","src/collections/hash_map.rs":"cdaf1aa3bedf9bde591fcb323d64bee9366feb35fee6886bedb5fec8d0018564","src/collections/hash_set.rs":"685690108fc20eca2cf346e74e48d6c751f5ceb6028996366d49f1f1ad6051e0","src/collections/linked_list.rs":"bef7f32da49b55db76cfefa0afa4789a6979e08a69427e49bab2874967163fef","src/collections/mod.rs":"183017c54dd7926115de4814f1818c85fbbecc913de4f408094f7a4bf6d8443b","src/collections/vec_deque.rs":"d14aa4edc858cd3469fff3597fc35ab83c27f3bdf66ede06d1dd25021f383109","src/compile_fail/cannot_collect_filtermap_data.rs":"6a141076c14f95e31bed3433d531bc05d806eed9e0018d1b21420d7ab2fc7eb9","src/compile_fail/cannot_zip_filtered_data.rs":"a28cfb3d00b8d277bfa77a10ca132f972e8f100080ef602fdd3c6fd36ad2a156","src/compile_fail/cell_par_iter.rs":"4f076862d9c66ed42a642a5be97116ca5982608ab76816a8f8305182bf463e9e","src/compile_fail/mod.rs":"2c346e4b52941fe0ac2667eeb753c0c21a1f998a544bb9d9167f200caba0a7bb","src/compile_fail/must_use.rs":"eb0c35acd5ba4c47ddd06950190ef2bcbeac3a201eec67b2b01781d0c1a251c3","src/compile_fail/no_send_par_iter.rs":"e78cd466a61081a0738f63b4e74249e40c37b95240e47e3faeab6ffdb6a8f14c","src/compile_fail/rc_par_iter.rs":"0faf3d26a665c3e2acc2f2f1d66ee234e561d24442efa4980a5e946e1cb2eba3","src/delegate.rs":"aad2a11998240fb7dd96bd054b588cac469df3b716b8dffb05239102b6507d05","src/iter/chain.rs":"f82a25577ca36bac93b5a13e75dcd70e8cee381b9baa5993dd645f0714fb9eb6","src/iter/chunks.rs":"8ab345783cb7412438eed33264d7db79873801784af7dab25291c349c678085f","src/iter/cloned.rs":"35e1c864f99f7bc93c258c4976d15ccfc1d04df969dc878fd03d35f6799377f7","src/iter/collect/consumer.rs":"5f9728fdf2db728a3ea37849c2fc43c417b221e580860be4dfc6cab526e57f8e","src/iter/collect/mod.rs":"ede28d59713c3291709a842cd54b17760008f6854a3982404eca973bdc3d2f23","src/iter/collect/test.rs":"975875022cf45f9a991040c60f3ed1f9df3805e27f64bbca5b446774793eddef","src/iter/copied.rs":"1a3457f3b0fb020593049b8b1f1be2f7a6684c2fcc66c02c911cb14e0a1943d7","src/iter/empty.rs":"3cb2d05721aab1a4d9e9c5813473e1646116c1ea570e26d9ac81e083688a0b7d","src/iter/enumerate.rs":"3204255723a93b3275cf0f208939de8960b13a9b13b8c2ba6b664e65da21cd87","src/iter/extend.rs":"6b93885d0bce6b1e01d9e220083e421436142b003dbe21f914dcf6b08abe7f10","src/iter/filter.rs":"c8ceea2f71afd1ffc7c713d8683e337e2c4bc3327f47d25116039ab7d950376f","src/iter/filter_map.rs":"18b2fa2d5119297ed6218e353ebb50e7cf4c853e76b9feffd2f332a885d8811d","src/iter/find.rs":"73b11b97eae7234099a05b5f59c937fe488e6a8574b9c9e4e852a7fa86341117","src/iter/find_first_last/mod.rs":"fa7d7692d81ecdbecb178606ad3b1b00c80e5e4159c57d34929b012b0bea0c82","src/iter/find_first_last/test.rs":"2052eb8b87c5a0a0d49a76c83d9d74f81be18aad52ceb1b06d7e209f4fefba94","src/iter/flat_map.rs":"4db54dcda5f1f916497d0162268e6cd554478bc7ea0190709cc7c73941a0e20f","src/iter/flat_map_iter.rs":"81886d1d71f4991963ec9b6d767d9ef391c9e84807d27f6135cd92a451dc1b32","src/iter/flatten.rs":"93407a8f44f4a265f47d7fe568508d6ef922597c4ca4558e8945cf1aacdd6b30","src/iter/flatten_iter.rs":"23cf3ddc25b6cad117932c4bac2e8b945c6b56626730fd3b1787f233495d15e6","src/iter/fold.rs":"874259b408d7f8cdc376d34276d37c1837950c035ff780de8281d1edf65ded9f","src/iter/for_each.rs":"7af0e21ed8479eec65831d1409f61a88d45a31764f2385ec759eda1a46d388b2","src/iter/from_par_iter.rs":"9439b1ae01db2c7545d6416108700dfbafcff3f584e81704cf985ab1d986b660","src/iter/inspect.rs":"d4f5c031e4a79c01b8439b5e3c78b637ecb4bcf191c8d98ec9f31a0b51977abc","src/iter/interleave.rs":"dcda8d2bd46de25227ac88243ff6ca97fcf1dbb89f935b651fd04c1ecf1abe8a","src/iter/interleave_shortest.rs":"a2b1f31ea4cb29f4761d3724feddcf5a96e1f21fd623f95c85a8659294a6745a","src/iter/intersperse.rs":"6b5d3d826ed3499ba78f0ff07468d96a0e104c7ee142a2ced6be8143b43241a5","src/iter/len.rs":"1d890dffb912134402c4778b1635af713df23df8bd2a98890209926a936d8407","src/iter/map.rs":"66e6db399de12327fec29d069462347dd16fd96d450b121ba8227e32e51552d1","src/iter/map_with.rs":"f83950016bb02addecec049fda73663861c80232477a7b89b7e8718291a4b481","src/iter/mod.rs":"6471fd96eea73c025f76abc00562c848fd216e10e736f49773e7d82cbce53ae9","src/iter/multizip.rs":"10ec107f6673c9bc6d1d611e11b716c37e8601ab2f4257a460c4bc4962771347","src/iter/noop.rs":"5be6332ddfbb8fdbae1ffdb00983950a8b37a295bcb58e9a265b33806ee504e6","src/iter/once.rs":"fcebffc374dcdd206d13311dcc2e7d7a04da5687658b2f3ec3409f03ed12774b","src/iter/panic_fuse.rs":"2a4d43fa4e717629de7f69eb180f13db90ef95004975cfa20dcfaacc80435015","src/iter/par_bridge.rs":"0066e4f2ebec979cf912f27fdccd2a670bc7f387036c9bd3c8c1402ce3692139","src/iter/plumbing/README.md":"d9ae3d57a37af5645b1c79029dd808933279d6853b30163cd0d71ead2a9a5002","src/iter/plumbing/mod.rs":"1156c55a15b651d161f463cb86b2f602f6246a3c7f8a82fb484db12aa6a60091","src/iter/positions.rs":"b7abfb59c12b6cceb5e539e85f9eca836054ae88225e16cfc0ba8e68177c7917","src/iter/product.rs":"da69f4781c2275c4a176432994c3fd80ea1f296afe47b329de61b1d733d990df","src/iter/reduce.rs":"2f5d6e07d7c0de2360505fa5d9198c31fd43ba7e58a6ec40f79edec19319e502","src/iter/repeat.rs":"ed46b17b79d8569f9d67b50585b116ee0293e1d6c17c0dc683c66644f6a58fd5","src/iter/rev.rs":"c4c796d7cb6398e74bef043a080403acccdf70f6a4e74b242e530d1718969b8f","src/iter/skip.rs":"93d54e17316ae15ff3cc30ca7144cb448569b18ea967dd2cd8913ac6f1334390","src/iter/splitter.rs":"0024db04b4430c2a1e8c921cec86af641f612f877f3675b15df0da9122de5f00","src/iter/step_by.rs":"e0e27a6b202e469237631f8a0040b40ac70429c660f6e3c0674bbce3e22537fc","src/iter/sum.rs":"cf11d996507ceba39524a102559b84289e776f8fe5772114e00ae2112b38c47c","src/iter/take.rs":"e47eeca1249553b0dfaf54cd8f99026be68db76b42f1f29e09c07a98c165c50a","src/iter/test.rs":"52ab229c2d8c4d4baf0d0cb439accbced982da088d66c3b404c97ef6bc0e136c","src/iter/try_fold.rs":"de3cee1a5e27086e259d1c189215c8984830ef65c89f75304f400a14158c85b1","src/iter/try_reduce.rs":"7697b2024709546afe9a5f0a21bc8645fdb1096b01fab1e7f7030a5c85c5f8b1","src/iter/try_reduce_with.rs":"2b62233766ba5cf9f13a1f64d3d0508c6b03093c810b1115df6777ff48aa9513","src/iter/unzip.rs":"9a16ea1f3b3019a090b7189f6c42c75beb3537bc849bd4c51093120a907cea6b","src/iter/update.rs":"08a222cf7f8f2f82389ca48d89ecef3a88e205d21ce249f2ba15a4ff85134473","src/iter/while_some.rs":"a514891d7a07031354b48e377c239ff330d0955f184abc57a69d2a193e7fcb45","src/iter/zip.rs":"4d908f75a10b5e9b68d012bbba289f3e5e9d6a9570ce0f56fc1b4f9d96860499","src/iter/zip_eq.rs":"4c18d8f7a78e197a3268c9ef74d16690f8c960407c18bb63dc6905a2fe2bde62","src/lib.rs":"2e1136e6cf10961a335932af1546d3d02765f81d3d5e89fd834e439c99e52286","src/math.rs":"4ca70519f251c479b454760c3ebadc121f4c5db358fe54cd830440cd9c98e19c","src/option.rs":"00979a9bb8f42629f2b956a6cfbd286fc8a41ffbbec85f1b5d0f0da5615dac9c","src/par_either.rs":"afa4b04ba6ea1d37aed2d68eca44d7ba0d1d09ea985c9091540dd8d3c51974f1","src/prelude.rs":"b1af578abff57f9c8a285c39e3793125cf40d9901d0f2a4f0c5f1bb9252a08de","src/private.rs":"152f6d65ce4741616a1dec796b9442f78a018d38bb040f76c4cd85008333a3bb","src/range.rs":"93bd821b851d334a365211e14b60e0fc5052a7ee09e9a26ea7dd4f018c9bf7ae","src/range_inclusive.rs":"1f18ee155ab46e7398203163d49b4dfa87135e578de3d80e2641877c5b037126","src/result.rs":"0656f0000efcea10e571df90247925dfd00a0c2194043fcbc009711fb2f7af02","src/slice/chunks.rs":"ae41c3465b0f252c8642fe39751cfabfcca6a9de4cd4bb594ee4a7f86dde880b","src/slice/mergesort.rs":"bc49ec902eab794fb474cf8444486011cffc549897ad14212fe963caffd43460","src/slice/mod.rs":"6eb3ec907365ed5d20cef0e7a1e6d99596ac217bdfd623ff26f2c773b44ac931","src/slice/quicksort.rs":"5ffd69f9e27dce6794c838b6044461a5de36214ef86cc044929062c000a1841f","src/slice/rchunks.rs":"811cdad43cd83a21c5190de9c77eee81da4a47d19a8a9160f132b961768377c5","src/slice/test.rs":"6d0a1cbe0547fb4a16c2beb99f0473d7fe42af69a67ff16ab8a9f61d0442fcb9","src/split_producer.rs":"2b143e16bc6540792f861e215a86cfea7f4ee500d4faca2476d4165619eac90d","src/str.rs":"19f2184cb1f8cbc98f953b1499e3d7ec9e1235fde5a03ad7e6a6ebf6ef5f90f3","src/string.rs":"6691dd31264bd93a0528fc584585415c12f56cfb4baebbfd31ea2f1b21550f77","src/vec.rs":"aece662a957ecaee9a313b76411fbb2418f88795c162b5e00fc41f732c20a9fa","tests/chars.rs":"5a2bef1cd8a7d1740a4e5403830da7bbdd584e97d602a07645c4986ee34c2ad3","tests/clones.rs":"8e48be01dd846c35d996c758be6a38e18763e0e42bc8f34b4f98845ea7bb0abc","tests/collect.rs":"27173f932d5c65932ad63c215c561ecf06fcbeb7253a7bb175b819e0a40107aa","tests/cross-pool.rs":"103c121c8684eef0868e3982219e406500009c26d7602167f5a514b1dfd3b4cc","tests/debug.rs":"6b2519764980232cd6247d2acef1c1346c7fb7b51470449242fa7f9f22fc0b52","tests/intersperse.rs":"bda4fb2179086e32c77c8293b9bb85d55509c282441837ba1849c2d3aa3186a7","tests/issue671-unzip.rs":"d5eb38d8a6d8f66fdf1c40293abbf58f3ac42b5acfc5dca62b02c7ace5bfc1a4","tests/issue671.rs":"52914cac517074deaedcb81bd76b867f0b99cc7b65c3e01cfe12dc9fe38c0266","tests/iter_panic.rs":"376faac33739e3479b5eb744bb2c810c27f8fdda5eeb9ad96d8b93619bf11d1c","tests/named-threads.rs":"48dd0fa0de13b4554dfc1fc0adaee093e19df8b1fc601f5b9b4f15b1fc705249","tests/octillion.rs":"65e12a22f5bc6e22316b93c57c82c2556ef8a5afd4d846a6431ce8c0499ce804","tests/producer_split_at.rs":"fbb28da59e85e4c253cc314f35f113ced8db2981ceda9977145af540f9996837","tests/sort-panic-safe.rs":"290a37a1cf7e297e622fc84caa5c7c3d50e83643a3c4f67a05cf2e1f7d6f3fc0","tests/str.rs":"49059384999be57994841652718cc048389380741be5c493423f8bd2206e4453"},"package":"1a79f0b0b2609e2eacf9758013f50e7176cb4b29fd6436a747b14a5362c8727a"} \ No newline at end of file +{"files":{"Cargo.toml":"497ce9b675a9a3b12cf34c793dd7226cfc5c1fad505ff1d91230b583a3238be8","FAQ.md":"e963b051f6295a2944ff5abec368c7da914b913e21049978c2ef0017294abf8f","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"0621878e61f0d0fda054bcbe02df75192c28bde1ecc8289cbd86aeba2dd72720","README.md":"dc1fd73bd09aa3f0aae2bc3291a7ce2bb101cb904f25f5a7102d954fcfcbc133","RELEASES.md":"0fa92841618538d1e4593351392dc1156f3be3110fdf6f69c04fd2baf183cb6d","src/array.rs":"0e1524d222baa8b64f67689b0dea3115f3befb8cc3b5aee9ace169c57b2d29d2","src/collections/binary_heap.rs":"58e2590ff52fa2cfe7b5797fdc37902d0c111cca844aac21a4024add2f28a8db","src/collections/btree_map.rs":"d3094ed5c54620f81a86133f52e74164bae9f0137745eb66e6d31db2e942bcab","src/collections/btree_set.rs":"7de12e388d36cb2f8672bc3b68aed5b44d047c9f5fe262a7260584634299480f","src/collections/hash_map.rs":"cdaf1aa3bedf9bde591fcb323d64bee9366feb35fee6886bedb5fec8d0018564","src/collections/hash_set.rs":"685690108fc20eca2cf346e74e48d6c751f5ceb6028996366d49f1f1ad6051e0","src/collections/linked_list.rs":"bef7f32da49b55db76cfefa0afa4789a6979e08a69427e49bab2874967163fef","src/collections/mod.rs":"3978222720a2df20be7fd0856d8515b6f9fa40f6556662bd3c0726b1392970ca","src/collections/vec_deque.rs":"d14aa4edc858cd3469fff3597fc35ab83c27f3bdf66ede06d1dd25021f383109","src/compile_fail/cannot_collect_filtermap_data.rs":"f76e6727ae8bd0dc8fff5f4a79df3fc598daf5d7371bdf8b2e730fba4ba82719","src/compile_fail/cannot_zip_filtered_data.rs":"3588fcf72e804ea867ea525b6dfa7a3d45fe14e28088e849fa9ddb029acc8a7a","src/compile_fail/cell_par_iter.rs":"ebf8804993c103f9d8228aba0bb2a5f0aadb957de9f1eb59cf546dbace285201","src/compile_fail/mod.rs":"2c346e4b52941fe0ac2667eeb753c0c21a1f998a544bb9d9167f200caba0a7bb","src/compile_fail/must_use.rs":"42ae57ed7cb909fad8d079ce6e3742a92ca7f72a9cc209b149d1d88df568d757","src/compile_fail/no_send_par_iter.rs":"b241446439c659f35060df12ba91590ea4267f373ddc688e4ffc203321db24b3","src/compile_fail/rc_par_iter.rs":"938776b08612e35c85b99962024d54af5a8c87d45a050a76375d16ef6fe4299f","src/delegate.rs":"aad2a11998240fb7dd96bd054b588cac469df3b716b8dffb05239102b6507d05","src/iter/chain.rs":"f82a25577ca36bac93b5a13e75dcd70e8cee381b9baa5993dd645f0714fb9eb6","src/iter/chunks.rs":"9b901441bd8684782d4e50bf24c261bdf3392f576e7ab25b2b83be2fc9361545","src/iter/cloned.rs":"35e1c864f99f7bc93c258c4976d15ccfc1d04df969dc878fd03d35f6799377f7","src/iter/collect/consumer.rs":"5f9728fdf2db728a3ea37849c2fc43c417b221e580860be4dfc6cab526e57f8e","src/iter/collect/mod.rs":"ede28d59713c3291709a842cd54b17760008f6854a3982404eca973bdc3d2f23","src/iter/collect/test.rs":"9afcf4c6cf6bbfe22aed42e5bb5a0dcbd4d7c9b060d80d3b01fad665b46e4952","src/iter/copied.rs":"1a3457f3b0fb020593049b8b1f1be2f7a6684c2fcc66c02c911cb14e0a1943d7","src/iter/empty.rs":"3cb2d05721aab1a4d9e9c5813473e1646116c1ea570e26d9ac81e083688a0b7d","src/iter/enumerate.rs":"3204255723a93b3275cf0f208939de8960b13a9b13b8c2ba6b664e65da21cd87","src/iter/extend.rs":"6b93885d0bce6b1e01d9e220083e421436142b003dbe21f914dcf6b08abe7f10","src/iter/filter.rs":"e48f317ee4d66dea6f19ac2607c6f764d20c023d847b66c6c01826e6a46f96ab","src/iter/filter_map.rs":"2530b726b27fe3a678a34722b1baf8e223a65a0770fa8ed5dca13786ea454580","src/iter/find.rs":"896ddb05b2fa7368462e0ff2a73982ced5f93266c0e0e8c27bb3fc4ec737af21","src/iter/find_first_last/mod.rs":"fa7d7692d81ecdbecb178606ad3b1b00c80e5e4159c57d34929b012b0bea0c82","src/iter/find_first_last/test.rs":"2052eb8b87c5a0a0d49a76c83d9d74f81be18aad52ceb1b06d7e209f4fefba94","src/iter/flat_map.rs":"4db54dcda5f1f916497d0162268e6cd554478bc7ea0190709cc7c73941a0e20f","src/iter/flat_map_iter.rs":"81886d1d71f4991963ec9b6d767d9ef391c9e84807d27f6135cd92a451dc1b32","src/iter/flatten.rs":"93407a8f44f4a265f47d7fe568508d6ef922597c4ca4558e8945cf1aacdd6b30","src/iter/flatten_iter.rs":"23cf3ddc25b6cad117932c4bac2e8b945c6b56626730fd3b1787f233495d15e6","src/iter/fold.rs":"874259b408d7f8cdc376d34276d37c1837950c035ff780de8281d1edf65ded9f","src/iter/fold_chunks.rs":"78c267cc341fa71206a587b548480038a7a9bbb29d341b43733515b34e4cec48","src/iter/fold_chunks_with.rs":"fc3a49dd6a2027ec8e0c78e459ed80da1185b365909694bf1395af12b22648a8","src/iter/for_each.rs":"7af0e21ed8479eec65831d1409f61a88d45a31764f2385ec759eda1a46d388b2","src/iter/from_par_iter.rs":"9439b1ae01db2c7545d6416108700dfbafcff3f584e81704cf985ab1d986b660","src/iter/inspect.rs":"d502b6e435a44f34ba49dfe46aa809a1bad3dbaefa048540a98e3026437b1016","src/iter/interleave.rs":"3c6d82fe13b52e2ce5e1b3dba93c47f479ff44d232059cd88523b422c51dea96","src/iter/interleave_shortest.rs":"a2b1f31ea4cb29f4761d3724feddcf5a96e1f21fd623f95c85a8659294a6745a","src/iter/intersperse.rs":"6b5d3d826ed3499ba78f0ff07468d96a0e104c7ee142a2ced6be8143b43241a5","src/iter/len.rs":"1d890dffb912134402c4778b1635af713df23df8bd2a98890209926a936d8407","src/iter/map.rs":"f778f1bd0a71c962375d2ce886b40ac365afed4a032e2b9dd6c385712d3d75eb","src/iter/map_with.rs":"f83950016bb02addecec049fda73663861c80232477a7b89b7e8718291a4b481","src/iter/mod.rs":"4777f488cc6fc4620ec4b6fe3ffcf1e310c7aafb59e41ebb8c268e194755d750","src/iter/multizip.rs":"10ec107f6673c9bc6d1d611e11b716c37e8601ab2f4257a460c4bc4962771347","src/iter/noop.rs":"5be6332ddfbb8fdbae1ffdb00983950a8b37a295bcb58e9a265b33806ee504e6","src/iter/once.rs":"fcebffc374dcdd206d13311dcc2e7d7a04da5687658b2f3ec3409f03ed12774b","src/iter/panic_fuse.rs":"2a4d43fa4e717629de7f69eb180f13db90ef95004975cfa20dcfaacc80435015","src/iter/par_bridge.rs":"7b78e0180a95b6a6d429d2923cd48c07f9ae3137c7e5c8706eceaec029f77b48","src/iter/plumbing/README.md":"da11d90143745b30efe99934bb5d8267d7b205c8096d0936ddb1bbba0b13ea17","src/iter/plumbing/mod.rs":"1156c55a15b651d161f463cb86b2f602f6246a3c7f8a82fb484db12aa6a60091","src/iter/positions.rs":"b7abfb59c12b6cceb5e539e85f9eca836054ae88225e16cfc0ba8e68177c7917","src/iter/product.rs":"da69f4781c2275c4a176432994c3fd80ea1f296afe47b329de61b1d733d990df","src/iter/reduce.rs":"2f5d6e07d7c0de2360505fa5d9198c31fd43ba7e58a6ec40f79edec19319e502","src/iter/repeat.rs":"ed46b17b79d8569f9d67b50585b116ee0293e1d6c17c0dc683c66644f6a58fd5","src/iter/rev.rs":"c4c796d7cb6398e74bef043a080403acccdf70f6a4e74b242e530d1718969b8f","src/iter/skip.rs":"93d54e17316ae15ff3cc30ca7144cb448569b18ea967dd2cd8913ac6f1334390","src/iter/skip_any.rs":"e827e1658aea906ab1045533d97476a91886dc6c41ab1fe9b6147f90385e45b8","src/iter/skip_any_while.rs":"88e8f5aea16cde70ae41f5eb32749e955861a476766ff678b8bbfca96ed80803","src/iter/splitter.rs":"0024db04b4430c2a1e8c921cec86af641f612f877f3675b15df0da9122de5f00","src/iter/step_by.rs":"be7abe2c2fba252a1b69c8cf18adfe510036c30f8ee2994404c18ae15dde317e","src/iter/sum.rs":"cf11d996507ceba39524a102559b84289e776f8fe5772114e00ae2112b38c47c","src/iter/take.rs":"e47eeca1249553b0dfaf54cd8f99026be68db76b42f1f29e09c07a98c165c50a","src/iter/take_any.rs":"51f5b39c3fb608fcf7d7b35592a28d95250d9cbb28dbc13a0dc01d22aa0023f9","src/iter/take_any_while.rs":"8327c019b4047d567d8fdae975049c9bc1e4422dddffd3196b62c938d1f5e1fc","src/iter/test.rs":"09b32380c3d9e64b66d14cb6d51660b1c5d008e7f31762476735c3f6742a4144","src/iter/try_fold.rs":"d4f40a00995273b8803031da4a4b139a5f462a174ef1d3c8ba54524b47ab8180","src/iter/try_reduce.rs":"12317a649f777e76e6ae610d205104d7946fbe45804fbf1caa0843118531baed","src/iter/try_reduce_with.rs":"9171563fc22110d7a359f19de7ca66a6823d8f712099d05d01560795781fdeec","src/iter/unzip.rs":"9a16ea1f3b3019a090b7189f6c42c75beb3537bc849bd4c51093120a907cea6b","src/iter/update.rs":"0362185a002cdda0e73b13237017ddc3d5e72390bba6cb2e2f021e947ed861dc","src/iter/while_some.rs":"a514891d7a07031354b48e377c239ff330d0955f184abc57a69d2a193e7fcb45","src/iter/zip.rs":"4d908f75a10b5e9b68d012bbba289f3e5e9d6a9570ce0f56fc1b4f9d96860499","src/iter/zip_eq.rs":"4c18d8f7a78e197a3268c9ef74d16690f8c960407c18bb63dc6905a2fe2bde62","src/lib.rs":"3e7bec5c34a7d2be7087fa79e8d9add939136adf9ce095907aed2851f269d55c","src/math.rs":"040e82a4ba7a6680eb65b65f4d1fc3dc477d902855d8651105b138ae2e71c8e8","src/option.rs":"00979a9bb8f42629f2b956a6cfbd286fc8a41ffbbec85f1b5d0f0da5615dac9c","src/par_either.rs":"afa4b04ba6ea1d37aed2d68eca44d7ba0d1d09ea985c9091540dd8d3c51974f1","src/prelude.rs":"b1af578abff57f9c8a285c39e3793125cf40d9901d0f2a4f0c5f1bb9252a08de","src/private.rs":"152f6d65ce4741616a1dec796b9442f78a018d38bb040f76c4cd85008333a3bb","src/range.rs":"93bd821b851d334a365211e14b60e0fc5052a7ee09e9a26ea7dd4f018c9bf7ae","src/range_inclusive.rs":"1f18ee155ab46e7398203163d49b4dfa87135e578de3d80e2641877c5b037126","src/result.rs":"0656f0000efcea10e571df90247925dfd00a0c2194043fcbc009711fb2f7af02","src/slice/chunks.rs":"2bf07a3522381e7747e40f787727747b62fbe1f1504eac6c383f0608a335ec91","src/slice/mergesort.rs":"effe59ecc40b330c364a3da868182b72b487025d9ba0256079f8a284b85a05ef","src/slice/mod.rs":"d293c9105edc3e51b11f873ac816f28232dd708120901ce3a518e03d5b748bcf","src/slice/quicksort.rs":"a7e5dd9f86e9292ccf6b2ca1668c93b8789eb85b7a9d3c9cb9fbe0ed49046e9b","src/slice/rchunks.rs":"23229976840da07e8fff6657ca626810ed380682719e4d1f0693ac08839e1b7c","src/slice/test.rs":"fca5e5e6bb5464c9332d14e7d963098ad9a072801ea508ae9eabf5d278b66bb2","src/split_producer.rs":"2b143e16bc6540792f861e215a86cfea7f4ee500d4faca2476d4165619eac90d","src/str.rs":"fe3fca9218fd17a265619551602001addf80f83187b086b3c65b4edd7857abd2","src/string.rs":"6691dd31264bd93a0528fc584585415c12f56cfb4baebbfd31ea2f1b21550f77","src/vec.rs":"c80653f3040c07e04fa293fa0359e1f8e7faad13d67899e78780e855b6f9f63a","tests/chars.rs":"5a2bef1cd8a7d1740a4e5403830da7bbdd584e97d602a07645c4986ee34c2ad3","tests/clones.rs":"1a8a4c053d2f5154c527cfb3396de2b3d1b3712e31a74f8b5e79862ea91359ea","tests/collect.rs":"3ae066cd89eacc9d171ad99ec73335e8040748370e3a3f46845d5af12ce30cc2","tests/cross-pool.rs":"d2ce3b9013f77c955aa02313b27436c5bf760ab0e6a1e7d768effae69b5bdbfe","tests/debug.rs":"187e3ef1ada63a91db117c02ca4b351d31e8eb6b891ca651bfa60a51afe4ea7c","tests/drain_vec.rs":"305ca40ba41ed3b459a334386cd742c66586d62aadfb624278aabdf10b872a12","tests/intersperse.rs":"bda4fb2179086e32c77c8293b9bb85d55509c282441837ba1849c2d3aa3186a7","tests/issue671-unzip.rs":"d5eb38d8a6d8f66fdf1c40293abbf58f3ac42b5acfc5dca62b02c7ace5bfc1a4","tests/issue671.rs":"52914cac517074deaedcb81bd76b867f0b99cc7b65c3e01cfe12dc9fe38c0266","tests/iter_panic.rs":"2ca857b37b740528b2e8395b479a409227383b46e0ed012286dcdd1330dacd70","tests/named-threads.rs":"9bd7ea27b4f6cf9e3b3486311747e15a3beb9b9d4e48f115d66ed8288ca19d38","tests/octillion.rs":"756d3789300d6eb4d5f7690937e06f87714b6b0a62ac812f72b622bb6974ccd2","tests/par_bridge_recursion.rs":"6e7030de6d97d1db1c335f676dd2a6348cde2873520df290c4a16bf949c06f00","tests/producer_split_at.rs":"fbb28da59e85e4c253cc314f35f113ced8db2981ceda9977145af540f9996837","tests/sort-panic-safe.rs":"2746cf3bca0c3ae4645ab124ae8027be9670aa749cfbb6f4205b095f6f1dbcad","tests/str.rs":"49059384999be57994841652718cc048389380741be5c493423f8bd2206e4453"},"package":"eb81aadc8837ca6ecebe0fe1353f15df83b3b3cc2cf7a8afd571bc22aa121710"} \ No newline at end of file diff --git a/vendor/rustc-rayon/Cargo.lock b/vendor/rustc-rayon/Cargo.lock deleted file mode 100644 index f827e9144..000000000 --- a/vendor/rustc-rayon/Cargo.lock +++ /dev/null @@ -1,289 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "crossbeam-channel" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" -dependencies = [ - "cfg-if", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c" -dependencies = [ - "autocfg", - "cfg-if", - "crossbeam-utils", - "lazy_static", - "memoffset", - "scopeguard", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" -dependencies = [ - "cfg-if", - "lazy_static", -] - -[[package]] -name = "docopt" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f3f119846c823f9eafcf953a8f6ffb6ed69bf6240883261a7f13b634579a51f" -dependencies = [ - "lazy_static", - "regex", - "serde", - "strsim", -] - -[[package]] -name = "either" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" - -[[package]] -name = "getrandom" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.126" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" - -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - -[[package]] -name = "num_cpus" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" - -[[package]] -name = "proc-macro2" -version = "1.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c54b25569025b7fc9651de43004ae593a75ad88543b17178aa5e1b9c4f15f56f" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_xorshift" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" -dependencies = [ - "rand_core", -] - -[[package]] -name = "regex" -version = "1.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" -dependencies = [ - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" - -[[package]] -name = "rustc-rayon" -version = "0.4.0" -dependencies = [ - "autocfg", - "crossbeam-deque", - "docopt", - "either", - "lazy_static", - "rand", - "rand_xorshift", - "rustc-rayon-core", - "serde", -] - -[[package]] -name = "rustc-rayon-core" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40093fb2061a74883f1ed2d52582a8615e2cd3bef1f14b8257e249f011303617" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils", - "num_cpus", -] - -[[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.137" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.137" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "syn" -version = "1.0.95" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbaf6116ab8924f39d52792136fb74fd60a80194cf1b1c6ffa6453eef1c3f942" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "unicode-ident" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee" - -[[package]] -name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" diff --git a/vendor/rustc-rayon/Cargo.toml b/vendor/rustc-rayon/Cargo.toml index c2dc3e952..3e4092ead 100644 --- a/vendor/rustc-rayon/Cargo.toml +++ b/vendor/rustc-rayon/Cargo.toml @@ -10,9 +10,10 @@ # See Cargo.toml.orig for the original contents. [package] -edition = "2018" +edition = "2021" +rust-version = "1.59" name = "rustc-rayon" -version = "0.4.0" +version = "0.5.0" authors = [ "Niko Matsakis ", "Josh Stone ", @@ -37,32 +38,18 @@ categories = ["concurrency"] license = "MIT OR Apache-2.0" repository = "https://github.com/rust-lang/rustc-rayon" -[dependencies.crossbeam-deque] -version = "0.8.1" +[lib] +name = "rayon" [dependencies.either] version = "1.0" default-features = false -[dependencies.rayon-core] -version = "0.4" -package = "rustc-rayon-core" - -[dev-dependencies.docopt] -version = "1" - -[dev-dependencies.lazy_static] -version = "1" +[dependencies.rustc-rayon-core] +version = "0.5" [dev-dependencies.rand] version = "0.8" [dev-dependencies.rand_xorshift] version = "0.3" - -[dev-dependencies.serde] -version = "1.0.85" -features = ["derive"] - -[build-dependencies.autocfg] -version = "1" diff --git a/vendor/rustc-rayon/README.md b/vendor/rustc-rayon/README.md index 6a0d54651..6cf1113a6 100644 --- a/vendor/rustc-rayon/README.md +++ b/vendor/rustc-rayon/README.md @@ -6,5 +6,5 @@ rustc-rayon is a fork of [the Rayon crate](https://github.com/rayon-rs/rayon/). rustc-rayon is a fork of rayon. rayon is distributed under the terms of both the MIT license and the Apache License (Version 2.0). See [LICENSE-APACHE](LICENSE-APACHE) and -[LICENSE-MIT](LICENSE-MIT) for details. Opening a pull requests is +[LICENSE-MIT](LICENSE-MIT) for details. Opening a pull request is assumed to signal agreement with these licensing terms. diff --git a/vendor/rustc-rayon/RELEASES.md b/vendor/rustc-rayon/RELEASES.md index e37540fd7..28b476d47 100644 --- a/vendor/rustc-rayon/RELEASES.md +++ b/vendor/rustc-rayon/RELEASES.md @@ -1,3 +1,67 @@ +# Release rayon 1.7.0 / rayon-core 1.11.0 (2023-03-03) + +- The minimum supported `rustc` is now 1.59. +- Added a fallback when threading is unsupported. +- The new `ParallelIterator::take_any` and `skip_any` methods work like + unordered `IndexedParallelIterator::take` and `skip`, counting items in + whatever order they are visited in parallel. +- The new `ParallelIterator::take_any_while` and `skip_any_while` methods work + like unordered `Iterator::take_while` and `skip_while`, which previously had + no parallel equivalent. The "while" condition may be satisfied from anywhere + in the parallel iterator, affecting all future items regardless of position. +- The new `yield_now` and `yield_local` functions will cooperatively yield + execution to Rayon, either trying to execute pending work from the entire + pool or from just the local deques of the current thread, respectively. + +# Release rayon-core 1.10.2 (2023-01-22) + +- Fixed miri-reported UB for SharedReadOnly tags protected by a call. + +# Release rayon 1.6.1 (2022-12-09) + +- Simplified `par_bridge` to only pull one item at a time from the iterator, + without batching. Threads that are waiting for iterator items will now block + appropriately rather than spinning CPU. (Thanks @njaard!) +- Added protection against recursion in `par_bridge`, so iterators that also + invoke rayon will not cause mutex recursion deadlocks. + +# Release rayon-core 1.10.1 (2022-11-18) + +- Fixed a race condition with threads going to sleep while a broadcast starts. + +# Release rayon 1.6.0 / rayon-core 1.10.0 (2022-11-18) + +- The minimum supported `rustc` is now 1.56. +- The new `IndexedParallelIterator::fold_chunks` and `fold_chunks_with` methods + work like `ParallelIterator::fold` and `fold_with` with fixed-size chunks of + items. This may be useful for predictable batching performance, without the + allocation overhead of `IndexedParallelIterator::chunks`. +- New "broadcast" methods run a given function on all threads in the pool. + These run at a sort of reduced priority after each thread has exhausted their + local work queue, but before they attempt work-stealing from other threads. + - The global `broadcast` function and `ThreadPool::broadcast` method will + block until completion, returning a `Vec` of all return values. + - The global `spawn_broadcast` function and methods on `ThreadPool`, `Scope`, + and `ScopeFifo` will run detached, without blocking the current thread. +- Panicking methods now use `#[track_caller]` to report the caller's location. +- Fixed a truncated length in `vec::Drain` when given an empty range. + +## Contributors + +Thanks to all of the contributors for this release! + +- @cuviper +- @idanmuze +- @JoeyBF +- @JustForFun88 +- @kianmeng +- @kornelski +- @ritchie46 +- @ryanrussell +- @steffahn +- @TheIronBorn +- @willcrozi + # Release rayon 1.5.3 (2022-05-13) - The new `ParallelSliceMut::par_sort_by_cached_key` is a stable sort that caches diff --git a/vendor/rustc-rayon/build.rs b/vendor/rustc-rayon/build.rs deleted file mode 100644 index f38f6ffb4..000000000 --- a/vendor/rustc-rayon/build.rs +++ /dev/null @@ -1,12 +0,0 @@ -fn main() { - let ac = autocfg::new(); - if ac.probe_expression("(0..10).step_by(2).rev()") { - autocfg::emit("has_step_by_rev"); - } - if ac.probe_expression("{ fn _foo() {} }") { - autocfg::emit("has_min_const_generics"); - } - if ac.probe_path("std::ops::ControlFlow") { - autocfg::emit("has_control_flow"); - } -} diff --git a/vendor/rustc-rayon/examples/README.md b/vendor/rustc-rayon/examples/README.md deleted file mode 100644 index ec08a4df8..000000000 --- a/vendor/rustc-rayon/examples/README.md +++ /dev/null @@ -1,3 +0,0 @@ -We use this directory for interactive tests that can't be run in an -automatic fashion. For examples of how to use Rayon, or benchmarks, -see `rayon-demo`. diff --git a/vendor/rustc-rayon/examples/cpu_monitor.rs b/vendor/rustc-rayon/examples/cpu_monitor.rs deleted file mode 100644 index bbe13164a..000000000 --- a/vendor/rustc-rayon/examples/cpu_monitor.rs +++ /dev/null @@ -1,81 +0,0 @@ -use docopt::Docopt; -use std::io; -use std::process; - -const USAGE: &str = " -Usage: cpu_monitor [options] - cpu_monitor --help - -A test for monitoring how much CPU usage Rayon consumes under various -scenarios. This test is intended to be executed interactively, like so: - - cargo run --example cpu_monitor -- tasks_ended - -The list of scenarios you can try are as follows: - -- tasks_ended: after all tasks have finished, go to sleep -- task_stall_root: a root task stalls for a very long time -- task_stall_scope: a task in a scope stalls for a very long time - -Options: - -h, --help Show this message. - -d N, --depth N Control how hard the dummy task works [default: 27] -"; - -#[derive(serde::Deserialize)] -pub struct Args { - arg_scenario: String, - flag_depth: usize, -} - -fn main() { - let args: &Args = &Docopt::new(USAGE) - .and_then(|d| d.deserialize()) - .unwrap_or_else(|e| e.exit()); - - match &args.arg_scenario[..] { - "tasks_ended" => tasks_ended(args), - "task_stall_root" => task_stall_root(args), - "task_stall_scope" => task_stall_scope(args), - _ => { - println!("unknown scenario: `{}`", args.arg_scenario); - println!("try --help"); - process::exit(1); - } - } -} - -fn wait_for_user() { - let mut input = String::new(); - io::stdin().read_line(&mut input).unwrap(); -} - -fn task(args: &Args) { - fn join_recursively(n: usize) { - if n == 0 { - return; - } - rayon::join(|| join_recursively(n - 1), || join_recursively(n - 1)); - } - - println!("Starting heavy work at depth {}...wait.", args.flag_depth); - join_recursively(args.flag_depth); - println!("Heavy work done; check top. You should see CPU usage drop to zero soon."); - println!("Press to quit..."); -} - -fn tasks_ended(args: &Args) { - task(args); - wait_for_user(); -} - -fn task_stall_root(args: &Args) { - rayon::join(|| task(args), wait_for_user); -} - -fn task_stall_scope(args: &Args) { - rayon::scope(|scope| { - scope.spawn(move |_| task(args)); - scope.spawn(move |_| wait_for_user()); - }); -} diff --git a/vendor/rustc-rayon/src/array.rs b/vendor/rustc-rayon/src/array.rs index c9bd8bd05..32a5fdd2f 100644 --- a/vendor/rustc-rayon/src/array.rs +++ b/vendor/rustc-rayon/src/array.rs @@ -1,11 +1,8 @@ -#![cfg(has_min_const_generics)] //! Parallel iterator types for [arrays] (`[T; N]`) //! //! You will rarely need to interact with this module directly unless you need //! to name one of the iterator types. //! -//! Everything in this module requires const generics, stabilized in Rust 1.51. -//! //! [arrays]: https://doc.rust-lang.org/std/primitive.array.html use crate::iter::plumbing::*; @@ -14,7 +11,6 @@ use crate::slice::{Iter, IterMut}; use crate::vec::DrainProducer; use std::mem::ManuallyDrop; -/// This implementation requires const generics, stabilized in Rust 1.51. impl<'data, T: Sync + 'data, const N: usize> IntoParallelIterator for &'data [T; N] { type Item = &'data T; type Iter = Iter<'data, T>; @@ -24,7 +20,6 @@ impl<'data, T: Sync + 'data, const N: usize> IntoParallelIterator for &'data [T; } } -/// This implementation requires const generics, stabilized in Rust 1.51. impl<'data, T: Send + 'data, const N: usize> IntoParallelIterator for &'data mut [T; N] { type Item = &'data mut T; type Iter = IterMut<'data, T>; @@ -34,7 +29,6 @@ impl<'data, T: Send + 'data, const N: usize> IntoParallelIterator for &'data mut } } -/// This implementation requires const generics, stabilized in Rust 1.51. impl IntoParallelIterator for [T; N] { type Item = T; type Iter = IntoIter; @@ -84,7 +78,8 @@ impl IndexedParallelIterator for IntoIter { unsafe { // Drain every item, and then the local array can just fall out of scope. let mut array = ManuallyDrop::new(self.array); - callback.callback(DrainProducer::new(&mut *array)) + let producer = DrainProducer::new(array.as_mut_slice()); + callback.callback(producer) } } } diff --git a/vendor/rustc-rayon/src/collections/mod.rs b/vendor/rustc-rayon/src/collections/mod.rs index d9b7988da..3c99f32c4 100644 --- a/vendor/rustc-rayon/src/collections/mod.rs +++ b/vendor/rustc-rayon/src/collections/mod.rs @@ -56,7 +56,7 @@ mod drain_guard { pub(super) fn new(collection: &'a mut C) -> Self { Self { // Temporarily steal the inner `Vec` so we can drain in place. - vec: Vec::from(mem::replace(collection, C::default())), + vec: Vec::from(mem::take(collection)), collection, } } @@ -65,7 +65,7 @@ mod drain_guard { impl<'a, T, C: From>> Drop for DrainGuard<'a, T, C> { fn drop(&mut self) { // Restore the collection from the `Vec` with its original capacity. - *self.collection = C::from(mem::replace(&mut self.vec, Vec::new())); + *self.collection = C::from(mem::take(&mut self.vec)); } } diff --git a/vendor/rustc-rayon/src/compile_fail/cannot_collect_filtermap_data.rs b/vendor/rustc-rayon/src/compile_fail/cannot_collect_filtermap_data.rs index 65ff87532..bb62ce02f 100644 --- a/vendor/rustc-rayon/src/compile_fail/cannot_collect_filtermap_data.rs +++ b/vendor/rustc-rayon/src/compile_fail/cannot_collect_filtermap_data.rs @@ -5,12 +5,10 @@ use rayon::prelude::*; // zip requires data of exact size, but filter yields only bounded // size, so check that we cannot apply it. -fn main() { - let a: Vec = (0..1024).collect(); - let mut v = vec![]; - a.par_iter() - .filter_map(|&x| Some(x as f32)) - .collect_into_vec(&mut v); //~ ERROR no method -} +let a: Vec = (0..1024).collect(); +let mut v = vec![]; +a.par_iter() + .filter_map(|&x| Some(x as f32)) + .collect_into_vec(&mut v); //~ ERROR no method ``` */ diff --git a/vendor/rustc-rayon/src/compile_fail/cannot_zip_filtered_data.rs b/vendor/rustc-rayon/src/compile_fail/cannot_zip_filtered_data.rs index de43fca57..54fd50de1 100644 --- a/vendor/rustc-rayon/src/compile_fail/cannot_zip_filtered_data.rs +++ b/vendor/rustc-rayon/src/compile_fail/cannot_zip_filtered_data.rs @@ -5,12 +5,10 @@ use rayon::prelude::*; // zip requires data of exact size, but filter yields only bounded // size, so check that we cannot apply it. -fn main() { - let mut a: Vec = (0..1024).rev().collect(); - let b: Vec = (0..1024).collect(); +let mut a: Vec = (0..1024).rev().collect(); +let b: Vec = (0..1024).collect(); - a.par_iter() - .zip(b.par_iter().filter(|&&x| x > 3)); //~ ERROR -} +a.par_iter() + .zip(b.par_iter().filter(|&&x| x > 3)); //~ ERROR ``` */ diff --git a/vendor/rustc-rayon/src/compile_fail/cell_par_iter.rs b/vendor/rustc-rayon/src/compile_fail/cell_par_iter.rs index 4af04b124..98a1cf96e 100644 --- a/vendor/rustc-rayon/src/compile_fail/cell_par_iter.rs +++ b/vendor/rustc-rayon/src/compile_fail/cell_par_iter.rs @@ -5,11 +5,9 @@ use rayon::prelude::*; use std::cell::Cell; -fn main() { - let c = Cell::new(42_i32); - (0_i32..1024).into_par_iter() - .map(|_| c.get()) //~ ERROR E0277 - .min(); -} +let c = Cell::new(42_i32); +(0_i32..1024).into_par_iter() + .map(|_| c.get()) //~ ERROR E0277 + .min(); ``` */ diff --git a/vendor/rustc-rayon/src/compile_fail/must_use.rs b/vendor/rustc-rayon/src/compile_fail/must_use.rs index ac50a62f3..b4b3d771c 100644 --- a/vendor/rustc-rayon/src/compile_fail/must_use.rs +++ b/vendor/rustc-rayon/src/compile_fail/must_use.rs @@ -33,6 +33,8 @@ must_use! { step_by /** v.par_iter().step_by(2); */ chain /** v.par_iter().chain(&v); */ chunks /** v.par_iter().chunks(2); */ + fold_chunks /** v.par_iter().fold_chunks(2, || 0, |x, _| x); */ + fold_chunks_with /** v.par_iter().fold_chunks_with(2, 0, |x, _| x); */ cloned /** v.par_iter().cloned(); */ copied /** v.par_iter().copied(); */ enumerate /** v.par_iter().enumerate(); */ diff --git a/vendor/rustc-rayon/src/compile_fail/no_send_par_iter.rs b/vendor/rustc-rayon/src/compile_fail/no_send_par_iter.rs index 1362c9809..7573c0346 100644 --- a/vendor/rustc-rayon/src/compile_fail/no_send_par_iter.rs +++ b/vendor/rustc-rayon/src/compile_fail/no_send_par_iter.rs @@ -10,13 +10,11 @@ struct NoSend(*const ()); unsafe impl Sync for NoSend {} -fn main() { - let x = Some(NoSend(null())); +let x = Some(NoSend(null())); - x.par_iter() - .map(|&x| x) //~ ERROR - .count(); //~ ERROR -} +x.par_iter() + .map(|&x| x) //~ ERROR + .count(); //~ ERROR ``` */ mod map {} @@ -31,13 +29,11 @@ struct NoSend(*const ()); unsafe impl Sync for NoSend {} -fn main() { - let x = Some(NoSend(null())); +let x = Some(NoSend(null())); - x.par_iter() - .filter_map(|&x| Some(x)) //~ ERROR - .count(); //~ ERROR -} +x.par_iter() + .filter_map(|&x| Some(x)) //~ ERROR + .count(); //~ ERROR ``` */ mod filter_map {} @@ -52,13 +48,11 @@ struct NoSend(*const ()); unsafe impl Sync for NoSend {} -fn main() { - let x = Some(NoSend(null())); +let x = Some(NoSend(null())); - x.par_iter() - .cloned() //~ ERROR - .count(); //~ ERROR -} +x.par_iter() + .cloned() //~ ERROR + .count(); //~ ERROR ``` */ mod cloned {} diff --git a/vendor/rustc-rayon/src/compile_fail/rc_par_iter.rs b/vendor/rustc-rayon/src/compile_fail/rc_par_iter.rs index feaedb38f..aca63e7ac 100644 --- a/vendor/rustc-rayon/src/compile_fail/rc_par_iter.rs +++ b/vendor/rustc-rayon/src/compile_fail/rc_par_iter.rs @@ -6,12 +6,10 @@ use rayon::prelude::*; use std::rc::Rc; -fn main() { - let x = vec![Rc::new(22), Rc::new(23)]; - let mut y = vec![]; - x.into_par_iter() //~ ERROR no method named `into_par_iter` - .map(|rc| *rc) - .collect_into_vec(&mut y); -} +let x = vec![Rc::new(22), Rc::new(23)]; +let mut y = vec![]; +x.into_par_iter() //~ ERROR no method named `into_par_iter` + .map(|rc| *rc) + .collect_into_vec(&mut y); ``` */ diff --git a/vendor/rustc-rayon/src/iter/chunks.rs b/vendor/rustc-rayon/src/iter/chunks.rs index be5f84cc7..ec48278d0 100644 --- a/vendor/rustc-rayon/src/iter/chunks.rs +++ b/vendor/rustc-rayon/src/iter/chunks.rs @@ -90,38 +90,46 @@ where where P: Producer, { - self.callback.callback(ChunkProducer { - chunk_size: self.size, - len: self.len, - base, - }) + let producer = ChunkProducer::new(self.size, self.len, base, Vec::from_iter); + self.callback.callback(producer) } } } } -struct ChunkProducer

-where - P: Producer, -{ +pub(super) struct ChunkProducer { chunk_size: usize, len: usize, base: P, + map: F, } -impl

Producer for ChunkProducer

+impl ChunkProducer { + pub(super) fn new(chunk_size: usize, len: usize, base: P, map: F) -> Self { + Self { + chunk_size, + len, + base, + map, + } + } +} + +impl Producer for ChunkProducer where P: Producer, + F: Fn(P::IntoIter) -> T + Send + Clone, { - type Item = Vec; - type IntoIter = ChunkSeq

; + type Item = T; + type IntoIter = std::iter::Map, F>; fn into_iter(self) -> Self::IntoIter { - ChunkSeq { + let chunks = ChunkSeq { chunk_size: self.chunk_size, len: self.len, inner: if self.len > 0 { Some(self.base) } else { None }, - } + }; + chunks.map(self.map) } fn split_at(self, index: usize) -> (Self, Self) { @@ -132,11 +140,13 @@ where chunk_size: self.chunk_size, len: elem_index, base: left, + map: self.map.clone(), }, ChunkProducer { chunk_size: self.chunk_size, len: self.len - elem_index, base: right, + map: self.map, }, ) } @@ -150,7 +160,7 @@ where } } -struct ChunkSeq

{ +pub(super) struct ChunkSeq

{ chunk_size: usize, len: usize, inner: Option

, @@ -160,7 +170,7 @@ impl

Iterator for ChunkSeq

where P: Producer, { - type Item = Vec; + type Item = P::IntoIter; fn next(&mut self) -> Option { let producer = self.inner.take()?; @@ -168,11 +178,11 @@ where let (left, right) = producer.split_at(self.chunk_size); self.inner = Some(right); self.len -= self.chunk_size; - Some(left.into_iter().collect()) + Some(left.into_iter()) } else { debug_assert!(self.len > 0); self.len = 0; - Some(producer.into_iter().collect()) + Some(producer.into_iter()) } } @@ -206,11 +216,11 @@ where let (left, right) = producer.split_at(self.len - size); self.inner = Some(left); self.len -= size; - Some(right.into_iter().collect()) + Some(right.into_iter()) } else { debug_assert!(self.len > 0); self.len = 0; - Some(producer.into_iter().collect()) + Some(producer.into_iter()) } } } diff --git a/vendor/rustc-rayon/src/iter/collect/test.rs b/vendor/rustc-rayon/src/iter/collect/test.rs index b5f676f5d..97bec3f4e 100644 --- a/vendor/rustc-rayon/src/iter/collect/test.rs +++ b/vendor/rustc-rayon/src/iter/collect/test.rs @@ -76,6 +76,7 @@ fn right_produces_items_with_no_complete() { // Complete is not called by the consumer. Hence,the collection vector is not fully initialized. #[test] +#[cfg_attr(not(panic = "unwind"), ignore)] fn produces_items_with_no_complete() { let counter = DropCounter::default(); let mut v = vec![]; @@ -273,6 +274,7 @@ fn right_panics() { // The left consumer produces fewer items while the right // consumer produces correct number; check that created elements are dropped #[test] +#[cfg_attr(not(panic = "unwind"), ignore)] fn left_produces_fewer_items_drops() { let counter = DropCounter::default(); let mut v = vec![]; diff --git a/vendor/rustc-rayon/src/iter/filter.rs b/vendor/rustc-rayon/src/iter/filter.rs index 38627f7c0..e1b74ba52 100644 --- a/vendor/rustc-rayon/src/iter/filter.rs +++ b/vendor/rustc-rayon/src/iter/filter.rs @@ -97,7 +97,7 @@ where P: Fn(&T) -> bool + Sync, { fn split_off_left(&self) -> Self { - FilterConsumer::new(self.base.split_off_left(), &self.filter_op) + FilterConsumer::new(self.base.split_off_left(), self.filter_op) } fn to_reducer(&self) -> Self::Reducer { diff --git a/vendor/rustc-rayon/src/iter/filter_map.rs b/vendor/rustc-rayon/src/iter/filter_map.rs index f19c38563..db1c7e3f0 100644 --- a/vendor/rustc-rayon/src/iter/filter_map.rs +++ b/vendor/rustc-rayon/src/iter/filter_map.rs @@ -98,7 +98,7 @@ where P: Fn(T) -> Option + Sync + 'p, { fn split_off_left(&self) -> Self { - FilterMapConsumer::new(self.base.split_off_left(), &self.filter_op) + FilterMapConsumer::new(self.base.split_off_left(), self.filter_op) } fn to_reducer(&self) -> Self::Reducer { diff --git a/vendor/rustc-rayon/src/iter/find.rs b/vendor/rustc-rayon/src/iter/find.rs index 971db2b3c..b16ee8446 100644 --- a/vendor/rustc-rayon/src/iter/find.rs +++ b/vendor/rustc-rayon/src/iter/find.rs @@ -94,7 +94,7 @@ where self.item = iter .into_iter() // stop iterating if another thread has found something - .take_while(not_full(&self.found)) + .take_while(not_full(self.found)) .find(self.find_op); if self.item.is_some() { self.found.store(true, Ordering::Relaxed) diff --git a/vendor/rustc-rayon/src/iter/fold_chunks.rs b/vendor/rustc-rayon/src/iter/fold_chunks.rs new file mode 100644 index 000000000..185fb1a65 --- /dev/null +++ b/vendor/rustc-rayon/src/iter/fold_chunks.rs @@ -0,0 +1,236 @@ +use std::fmt::{self, Debug}; + +use super::chunks::ChunkProducer; +use super::plumbing::*; +use super::*; +use crate::math::div_round_up; + +/// `FoldChunks` is an iterator that groups elements of an underlying iterator and applies a +/// function over them, producing a single value for each group. +/// +/// This struct is created by the [`fold_chunks()`] method on [`IndexedParallelIterator`] +/// +/// [`fold_chunks()`]: trait.IndexedParallelIterator.html#method.fold_chunks +/// [`IndexedParallelIterator`]: trait.IndexedParallelIterator.html +#[must_use = "iterator adaptors are lazy and do nothing unless consumed"] +#[derive(Clone)] +pub struct FoldChunks +where + I: IndexedParallelIterator, +{ + base: I, + chunk_size: usize, + fold_op: F, + identity: ID, +} + +impl Debug for FoldChunks { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Fold") + .field("base", &self.base) + .field("chunk_size", &self.chunk_size) + .finish() + } +} + +impl FoldChunks +where + I: IndexedParallelIterator, + ID: Fn() -> U + Send + Sync, + F: Fn(U, I::Item) -> U + Send + Sync, + U: Send, +{ + /// Creates a new `FoldChunks` iterator + pub(super) fn new(base: I, chunk_size: usize, identity: ID, fold_op: F) -> Self { + FoldChunks { + base, + chunk_size, + identity, + fold_op, + } + } +} + +impl ParallelIterator for FoldChunks +where + I: IndexedParallelIterator, + ID: Fn() -> U + Send + Sync, + F: Fn(U, I::Item) -> U + Send + Sync, + U: Send, +{ + type Item = U; + + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: Consumer, + { + bridge(self, consumer) + } + + fn opt_len(&self) -> Option { + Some(self.len()) + } +} + +impl IndexedParallelIterator for FoldChunks +where + I: IndexedParallelIterator, + ID: Fn() -> U + Send + Sync, + F: Fn(U, I::Item) -> U + Send + Sync, + U: Send, +{ + fn len(&self) -> usize { + div_round_up(self.base.len(), self.chunk_size) + } + + fn drive(self, consumer: C) -> C::Result + where + C: Consumer, + { + bridge(self, consumer) + } + + fn with_producer(self, callback: CB) -> CB::Output + where + CB: ProducerCallback, + { + let len = self.base.len(); + return self.base.with_producer(Callback { + chunk_size: self.chunk_size, + len, + identity: self.identity, + fold_op: self.fold_op, + callback, + }); + + struct Callback { + chunk_size: usize, + len: usize, + identity: ID, + fold_op: F, + callback: CB, + } + + impl ProducerCallback for Callback + where + CB: ProducerCallback, + ID: Fn() -> U + Send + Sync, + F: Fn(U, T) -> U + Send + Sync, + { + type Output = CB::Output; + + fn callback

(self, base: P) -> CB::Output + where + P: Producer, + { + let identity = &self.identity; + let fold_op = &self.fold_op; + let fold_iter = move |iter: P::IntoIter| iter.fold(identity(), fold_op); + let producer = ChunkProducer::new(self.chunk_size, self.len, base, fold_iter); + self.callback.callback(producer) + } + } + } +} + +#[cfg(test)] +mod test { + use super::*; + use std::ops::Add; + + #[test] + fn check_fold_chunks() { + let words = "bishbashbosh!" + .chars() + .collect::>() + .into_par_iter() + .fold_chunks(4, String::new, |mut s, c| { + s.push(c); + s + }) + .collect::>(); + + assert_eq!(words, vec!["bish", "bash", "bosh", "!"]); + } + + // 'closure' values for tests below + fn id() -> i32 { + 0 + } + fn sum(x: T, y: U) -> T + where + T: Add, + { + x + y + } + + #[test] + #[should_panic(expected = "chunk_size must not be zero")] + fn check_fold_chunks_zero_size() { + let _: Vec = vec![1, 2, 3] + .into_par_iter() + .fold_chunks(0, id, sum) + .collect(); + } + + #[test] + fn check_fold_chunks_even_size() { + assert_eq!( + vec![1 + 2 + 3, 4 + 5 + 6, 7 + 8 + 9], + (1..10) + .into_par_iter() + .fold_chunks(3, id, sum) + .collect::>() + ); + } + + #[test] + fn check_fold_chunks_empty() { + let v: Vec = vec![]; + let expected: Vec = vec![]; + assert_eq!( + expected, + v.into_par_iter() + .fold_chunks(2, id, sum) + .collect::>() + ); + } + + #[test] + fn check_fold_chunks_len() { + assert_eq!(4, (0..8).into_par_iter().fold_chunks(2, id, sum).len()); + assert_eq!(3, (0..9).into_par_iter().fold_chunks(3, id, sum).len()); + assert_eq!(3, (0..8).into_par_iter().fold_chunks(3, id, sum).len()); + assert_eq!(1, (&[1]).par_iter().fold_chunks(3, id, sum).len()); + assert_eq!(0, (0..0).into_par_iter().fold_chunks(3, id, sum).len()); + } + + #[test] + fn check_fold_chunks_uneven() { + let cases: Vec<(Vec, usize, Vec)> = vec![ + ((0..5).collect(), 3, vec![0 + 1 + 2, 3 + 4]), + (vec![1], 5, vec![1]), + ((0..4).collect(), 3, vec![0 + 1 + 2, 3]), + ]; + + for (i, (v, n, expected)) in cases.into_iter().enumerate() { + let mut res: Vec = vec![]; + v.par_iter() + .fold_chunks(n, || 0, sum) + .collect_into_vec(&mut res); + assert_eq!(expected, res, "Case {} failed", i); + + res.truncate(0); + v.into_par_iter() + .fold_chunks(n, || 0, sum) + .rev() + .collect_into_vec(&mut res); + assert_eq!( + expected.into_iter().rev().collect::>(), + res, + "Case {} reversed failed", + i + ); + } + } +} diff --git a/vendor/rustc-rayon/src/iter/fold_chunks_with.rs b/vendor/rustc-rayon/src/iter/fold_chunks_with.rs new file mode 100644 index 000000000..af120aec4 --- /dev/null +++ b/vendor/rustc-rayon/src/iter/fold_chunks_with.rs @@ -0,0 +1,231 @@ +use std::fmt::{self, Debug}; + +use super::chunks::ChunkProducer; +use super::plumbing::*; +use super::*; +use crate::math::div_round_up; + +/// `FoldChunksWith` is an iterator that groups elements of an underlying iterator and applies a +/// function over them, producing a single value for each group. +/// +/// This struct is created by the [`fold_chunks_with()`] method on [`IndexedParallelIterator`] +/// +/// [`fold_chunks_with()`]: trait.IndexedParallelIterator.html#method.fold_chunks +/// [`IndexedParallelIterator`]: trait.IndexedParallelIterator.html +#[must_use = "iterator adaptors are lazy and do nothing unless consumed"] +#[derive(Clone)] +pub struct FoldChunksWith +where + I: IndexedParallelIterator, +{ + base: I, + chunk_size: usize, + item: U, + fold_op: F, +} + +impl Debug for FoldChunksWith { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Fold") + .field("base", &self.base) + .field("chunk_size", &self.chunk_size) + .field("item", &self.item) + .finish() + } +} + +impl FoldChunksWith +where + I: IndexedParallelIterator, + U: Send + Clone, + F: Fn(U, I::Item) -> U + Send + Sync, +{ + /// Creates a new `FoldChunksWith` iterator + pub(super) fn new(base: I, chunk_size: usize, item: U, fold_op: F) -> Self { + FoldChunksWith { + base, + chunk_size, + item, + fold_op, + } + } +} + +impl ParallelIterator for FoldChunksWith +where + I: IndexedParallelIterator, + U: Send + Clone, + F: Fn(U, I::Item) -> U + Send + Sync, +{ + type Item = U; + + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: Consumer, + { + bridge(self, consumer) + } + + fn opt_len(&self) -> Option { + Some(self.len()) + } +} + +impl IndexedParallelIterator for FoldChunksWith +where + I: IndexedParallelIterator, + U: Send + Clone, + F: Fn(U, I::Item) -> U + Send + Sync, +{ + fn len(&self) -> usize { + div_round_up(self.base.len(), self.chunk_size) + } + + fn drive(self, consumer: C) -> C::Result + where + C: Consumer, + { + bridge(self, consumer) + } + + fn with_producer(self, callback: CB) -> CB::Output + where + CB: ProducerCallback, + { + let len = self.base.len(); + return self.base.with_producer(Callback { + chunk_size: self.chunk_size, + len, + item: self.item, + fold_op: self.fold_op, + callback, + }); + + struct Callback { + chunk_size: usize, + len: usize, + item: T, + fold_op: F, + callback: CB, + } + + impl ProducerCallback for Callback + where + CB: ProducerCallback, + U: Send + Clone, + F: Fn(U, T) -> U + Send + Sync, + { + type Output = CB::Output; + + fn callback

(self, base: P) -> CB::Output + where + P: Producer, + { + let item = self.item; + let fold_op = &self.fold_op; + let fold_iter = move |iter: P::IntoIter| iter.fold(item.clone(), fold_op); + let producer = ChunkProducer::new(self.chunk_size, self.len, base, fold_iter); + self.callback.callback(producer) + } + } + } +} + +#[cfg(test)] +mod test { + use super::*; + use std::ops::Add; + + #[test] + fn check_fold_chunks_with() { + let words = "bishbashbosh!" + .chars() + .collect::>() + .into_par_iter() + .fold_chunks_with(4, String::new(), |mut s, c| { + s.push(c); + s + }) + .collect::>(); + + assert_eq!(words, vec!["bish", "bash", "bosh", "!"]); + } + + // 'closure' value for tests below + fn sum(x: T, y: U) -> T + where + T: Add, + { + x + y + } + + #[test] + #[should_panic(expected = "chunk_size must not be zero")] + fn check_fold_chunks_zero_size() { + let _: Vec = vec![1, 2, 3] + .into_par_iter() + .fold_chunks_with(0, 0, sum) + .collect(); + } + + #[test] + fn check_fold_chunks_even_size() { + assert_eq!( + vec![1 + 2 + 3, 4 + 5 + 6, 7 + 8 + 9], + (1..10) + .into_par_iter() + .fold_chunks_with(3, 0, sum) + .collect::>() + ); + } + + #[test] + fn check_fold_chunks_with_empty() { + let v: Vec = vec![]; + let expected: Vec = vec![]; + assert_eq!( + expected, + v.into_par_iter() + .fold_chunks_with(2, 0, sum) + .collect::>() + ); + } + + #[test] + fn check_fold_chunks_len() { + assert_eq!(4, (0..8).into_par_iter().fold_chunks_with(2, 0, sum).len()); + assert_eq!(3, (0..9).into_par_iter().fold_chunks_with(3, 0, sum).len()); + assert_eq!(3, (0..8).into_par_iter().fold_chunks_with(3, 0, sum).len()); + assert_eq!(1, (&[1]).par_iter().fold_chunks_with(3, 0, sum).len()); + assert_eq!(0, (0..0).into_par_iter().fold_chunks_with(3, 0, sum).len()); + } + + #[test] + fn check_fold_chunks_uneven() { + let cases: Vec<(Vec, usize, Vec)> = vec![ + ((0..5).collect(), 3, vec![0 + 1 + 2, 3 + 4]), + (vec![1], 5, vec![1]), + ((0..4).collect(), 3, vec![0 + 1 + 2, 3]), + ]; + + for (i, (v, n, expected)) in cases.into_iter().enumerate() { + let mut res: Vec = vec![]; + v.par_iter() + .fold_chunks_with(n, 0, sum) + .collect_into_vec(&mut res); + assert_eq!(expected, res, "Case {} failed", i); + + res.truncate(0); + v.into_par_iter() + .fold_chunks_with(n, 0, sum) + .rev() + .collect_into_vec(&mut res); + assert_eq!( + expected.into_iter().rev().collect::>(), + res, + "Case {} reversed failed", + i + ); + } + } +} diff --git a/vendor/rustc-rayon/src/iter/inspect.rs b/vendor/rustc-rayon/src/iter/inspect.rs index 9b1cd094d..c50ca022d 100644 --- a/vendor/rustc-rayon/src/iter/inspect.rs +++ b/vendor/rustc-rayon/src/iter/inspect.rs @@ -209,7 +209,7 @@ where F: Fn(&T) + Sync, { fn split_off_left(&self) -> Self { - InspectConsumer::new(self.base.split_off_left(), &self.inspect_op) + InspectConsumer::new(self.base.split_off_left(), self.inspect_op) } fn to_reducer(&self) -> Self::Reducer { diff --git a/vendor/rustc-rayon/src/iter/interleave.rs b/vendor/rustc-rayon/src/iter/interleave.rs index b5d43d53d..3cacc49f9 100644 --- a/vendor/rustc-rayon/src/iter/interleave.rs +++ b/vendor/rustc-rayon/src/iter/interleave.rs @@ -310,16 +310,16 @@ where { #[inline] fn next_back(&mut self) -> Option { - if self.i.len() == self.j.len() { - if self.i_next { - self.i.next_back() - } else { - self.j.next_back() + match self.i.len().cmp(&self.j.len()) { + Ordering::Less => self.j.next_back(), + Ordering::Equal => { + if self.i_next { + self.i.next_back() + } else { + self.j.next_back() + } } - } else if self.i.len() < self.j.len() { - self.j.next_back() - } else { - self.i.next_back() + Ordering::Greater => self.i.next_back(), } } } diff --git a/vendor/rustc-rayon/src/iter/map.rs b/vendor/rustc-rayon/src/iter/map.rs index f2a35ff8c..da14d4082 100644 --- a/vendor/rustc-rayon/src/iter/map.rs +++ b/vendor/rustc-rayon/src/iter/map.rs @@ -213,7 +213,7 @@ where R: Send, { fn split_off_left(&self) -> Self { - MapConsumer::new(self.base.split_off_left(), &self.map_op) + MapConsumer::new(self.base.split_off_left(), self.map_op) } fn to_reducer(&self) -> Self::Reducer { diff --git a/vendor/rustc-rayon/src/iter/mod.rs b/vendor/rustc-rayon/src/iter/mod.rs index 89e96fcef..e60ea1633 100644 --- a/vendor/rustc-rayon/src/iter/mod.rs +++ b/vendor/rustc-rayon/src/iter/mod.rs @@ -119,6 +119,8 @@ mod flat_map_iter; mod flatten; mod flatten_iter; mod fold; +mod fold_chunks; +mod fold_chunks_with; mod for_each; mod from_par_iter; mod inspect; @@ -139,9 +141,14 @@ mod reduce; mod repeat; mod rev; mod skip; +mod skip_any; +mod skip_any_while; mod splitter; +mod step_by; mod sum; mod take; +mod take_any; +mod take_any_while; mod try_fold; mod try_reduce; mod try_reduce_with; @@ -165,6 +172,8 @@ pub use self::{ flatten::Flatten, flatten_iter::FlattenIter, fold::{Fold, FoldWith}, + fold_chunks::FoldChunks, + fold_chunks_with::FoldChunksWith, inspect::Inspect, interleave::Interleave, interleave_shortest::InterleaveShortest, @@ -180,8 +189,13 @@ pub use self::{ repeat::{repeat, repeatn, Repeat, RepeatN}, rev::Rev, skip::Skip, + skip_any::SkipAny, + skip_any_while::SkipAnyWhile, splitter::{split, Split}, + step_by::StepBy, take::Take, + take_any::TakeAny, + take_any_while::TakeAnyWhile, try_fold::{TryFold, TryFoldWith}, update::Update, while_some::WhileSome, @@ -189,10 +203,6 @@ pub use self::{ zip_eq::ZipEq, }; -mod step_by; -#[cfg(has_step_by_rev)] -pub use self::step_by::StepBy; - /// `IntoParallelIterator` implements the conversion to a [`ParallelIterator`]. /// /// By implementing `IntoParallelIterator` for a type, you define how it will @@ -1124,7 +1134,7 @@ pub trait ParallelIterator: Sized + Send { /// multiple sums. The number of results is nondeterministic, as /// is the point where the breaks occur. /// - /// So if did the same parallel fold (`fold(0, |a,b| a+b)`) on + /// So if we did the same parallel fold (`fold(0, |a,b| a+b)`) on /// our example list, we might wind up with a sequence of two numbers, /// like so: /// @@ -2192,6 +2202,143 @@ pub trait ParallelIterator: Sized + Send { Intersperse::new(self, element) } + /// Creates an iterator that yields `n` elements from *anywhere* in the original iterator. + /// + /// This is similar to [`IndexedParallelIterator::take`] without being + /// constrained to the "first" `n` of the original iterator order. The + /// taken items will still maintain their relative order where that is + /// visible in `collect`, `reduce`, and similar outputs. + /// + /// # Examples + /// + /// ``` + /// use rayon::prelude::*; + /// + /// let result: Vec<_> = (0..100) + /// .into_par_iter() + /// .filter(|&x| x % 2 == 0) + /// .take_any(5) + /// .collect(); + /// + /// assert_eq!(result.len(), 5); + /// assert!(result.windows(2).all(|w| w[0] < w[1])); + /// ``` + fn take_any(self, n: usize) -> TakeAny { + TakeAny::new(self, n) + } + + /// Creates an iterator that skips `n` elements from *anywhere* in the original iterator. + /// + /// This is similar to [`IndexedParallelIterator::skip`] without being + /// constrained to the "first" `n` of the original iterator order. The + /// remaining items will still maintain their relative order where that is + /// visible in `collect`, `reduce`, and similar outputs. + /// + /// # Examples + /// + /// ``` + /// use rayon::prelude::*; + /// + /// let result: Vec<_> = (0..100) + /// .into_par_iter() + /// .filter(|&x| x % 2 == 0) + /// .skip_any(5) + /// .collect(); + /// + /// assert_eq!(result.len(), 45); + /// assert!(result.windows(2).all(|w| w[0] < w[1])); + /// ``` + fn skip_any(self, n: usize) -> SkipAny { + SkipAny::new(self, n) + } + + /// Creates an iterator that takes elements from *anywhere* in the original iterator + /// until the given `predicate` returns `false`. + /// + /// The `predicate` may be anything -- e.g. it could be checking a fact about the item, a + /// global condition unrelated to the item itself, or some combination thereof. + /// + /// If parallel calls to the `predicate` race and give different results, then the + /// `true` results will still take those particular items, while respecting the `false` + /// result from elsewhere to skip any further items. + /// + /// This is similar to [`Iterator::take_while`] without being constrained to the original + /// iterator order. The taken items will still maintain their relative order where that is + /// visible in `collect`, `reduce`, and similar outputs. + /// + /// # Examples + /// + /// ``` + /// use rayon::prelude::*; + /// + /// let result: Vec<_> = (0..100) + /// .into_par_iter() + /// .take_any_while(|x| *x < 50) + /// .collect(); + /// + /// assert!(result.len() <= 50); + /// assert!(result.windows(2).all(|w| w[0] < w[1])); + /// ``` + /// + /// ``` + /// use rayon::prelude::*; + /// use std::sync::atomic::AtomicUsize; + /// use std::sync::atomic::Ordering::Relaxed; + /// + /// // Collect any group of items that sum <= 1000 + /// let quota = AtomicUsize::new(1000); + /// let result: Vec<_> = (0_usize..100) + /// .into_par_iter() + /// .take_any_while(|&x| { + /// quota.fetch_update(Relaxed, Relaxed, |q| q.checked_sub(x)) + /// .is_ok() + /// }) + /// .collect(); + /// + /// let sum = result.iter().sum::(); + /// assert!(matches!(sum, 902..=1000)); + /// ``` + fn take_any_while

(self, predicate: P) -> TakeAnyWhile + where + P: Fn(&Self::Item) -> bool + Sync + Send, + { + TakeAnyWhile::new(self, predicate) + } + + /// Creates an iterator that skips elements from *anywhere* in the original iterator + /// until the given `predicate` returns `false`. + /// + /// The `predicate` may be anything -- e.g. it could be checking a fact about the item, a + /// global condition unrelated to the item itself, or some combination thereof. + /// + /// If parallel calls to the `predicate` race and give different results, then the + /// `true` results will still skip those particular items, while respecting the `false` + /// result from elsewhere to skip any further items. + /// + /// This is similar to [`Iterator::skip_while`] without being constrained to the original + /// iterator order. The remaining items will still maintain their relative order where that is + /// visible in `collect`, `reduce`, and similar outputs. + /// + /// # Examples + /// + /// ``` + /// use rayon::prelude::*; + /// + /// let result: Vec<_> = (0..100) + /// .into_par_iter() + /// .skip_any_while(|x| *x < 50) + /// .collect(); + /// + /// assert!(result.len() >= 50); + /// assert!(result.windows(2).all(|w| w[0] < w[1])); + /// ``` + fn skip_any_while

(self, predicate: P) -> SkipAnyWhile + where + P: Fn(&Self::Item) -> bool + Sync + Send, + { + SkipAnyWhile::new(self, predicate) + } + /// Internal method used to define the behavior of this parallel /// iterator. You should not need to call this directly. /// @@ -2241,6 +2388,8 @@ impl IntoParallelIterator for T { /// those points. /// /// **Note:** Not implemented for `u64`, `i64`, `u128`, or `i128` ranges +// Waiting for `ExactSizeIterator::is_empty` to be stabilized. See rust-lang/rust#35428 +#[allow(clippy::len_without_is_empty)] pub trait IndexedParallelIterator: ParallelIterator { /// Collects the results of the iterator into the specified /// vector. The vector is always truncated before execution @@ -2339,13 +2488,18 @@ pub trait IndexedParallelIterator: ParallelIterator { /// // we should never get here /// assert_eq!(1, zipped.len()); /// ``` + #[track_caller] fn zip_eq(self, zip_op: Z) -> ZipEq where Z: IntoParallelIterator, Z::Iter: IndexedParallelIterator, { let zip_op_iter = zip_op.into_par_iter(); - assert_eq!(self.len(), zip_op_iter.len()); + assert_eq!( + self.len(), + zip_op_iter.len(), + "iterators must have the same length" + ); ZipEq::new(self, zip_op_iter) } @@ -2410,11 +2564,95 @@ pub trait IndexedParallelIterator: ParallelIterator { /// let r: Vec> = a.into_par_iter().chunks(3).collect(); /// assert_eq!(r, vec![vec![1,2,3], vec![4,5,6], vec![7,8,9], vec![10]]); /// ``` + #[track_caller] fn chunks(self, chunk_size: usize) -> Chunks { assert!(chunk_size != 0, "chunk_size must not be zero"); Chunks::new(self, chunk_size) } + /// Splits an iterator into fixed-size chunks, performing a sequential [`fold()`] on + /// each chunk. + /// + /// Returns an iterator that produces a folded result for each chunk of items + /// produced by this iterator. + /// + /// This works essentially like: + /// + /// ```text + /// iter.chunks(chunk_size) + /// .map(|chunk| + /// chunk.into_iter() + /// .fold(identity, fold_op) + /// ) + /// ``` + /// + /// except there is no per-chunk allocation overhead. + /// + /// [`fold()`]: std::iter::Iterator#method.fold + /// + /// **Panics** if `chunk_size` is 0. + /// + /// # Examples + /// + /// ``` + /// use rayon::prelude::*; + /// let nums = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + /// let chunk_sums = nums.into_par_iter().fold_chunks(2, || 0, |a, n| a + n).collect::>(); + /// assert_eq!(chunk_sums, vec![3, 7, 11, 15, 19]); + /// ``` + #[track_caller] + fn fold_chunks( + self, + chunk_size: usize, + identity: ID, + fold_op: F, + ) -> FoldChunks + where + ID: Fn() -> T + Send + Sync, + F: Fn(T, Self::Item) -> T + Send + Sync, + T: Send, + { + assert!(chunk_size != 0, "chunk_size must not be zero"); + FoldChunks::new(self, chunk_size, identity, fold_op) + } + + /// Splits an iterator into fixed-size chunks, performing a sequential [`fold()`] on + /// each chunk. + /// + /// Returns an iterator that produces a folded result for each chunk of items + /// produced by this iterator. + /// + /// This works essentially like `fold_chunks(chunk_size, || init.clone(), fold_op)`, + /// except it doesn't require the `init` type to be `Sync`, nor any other form of + /// added synchronization. + /// + /// [`fold()`]: std::iter::Iterator#method.fold + /// + /// **Panics** if `chunk_size` is 0. + /// + /// # Examples + /// + /// ``` + /// use rayon::prelude::*; + /// let nums = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + /// let chunk_sums = nums.into_par_iter().fold_chunks_with(2, 0, |a, n| a + n).collect::>(); + /// assert_eq!(chunk_sums, vec![3, 7, 11, 15, 19]); + /// ``` + #[track_caller] + fn fold_chunks_with( + self, + chunk_size: usize, + init: T, + fold_op: F, + ) -> FoldChunksWith + where + T: Send + Clone, + F: Fn(T, Self::Item) -> T + Send + Sync, + { + assert!(chunk_size != 0, "chunk_size must not be zero"); + FoldChunksWith::new(self, chunk_size, init, fold_op) + } + /// Lexicographically compares the elements of this `ParallelIterator` with those of /// another. /// @@ -2601,11 +2839,6 @@ pub trait IndexedParallelIterator: ParallelIterator { /// /// assert_eq!(result, [3, 6, 9]) /// ``` - /// - /// # Compatibility - /// - /// This method is only available on Rust 1.38 or greater. - #[cfg(has_step_by_rev)] fn step_by(self, step: usize) -> StepBy { StepBy::new(self, step) } @@ -3146,20 +3379,9 @@ pub trait ParallelDrainRange { /// stable clone of the standard library's `Try` trait, as yet unstable. mod private { use std::convert::Infallible; + use std::ops::ControlFlow::{self, Break, Continue}; use std::task::Poll; - #[cfg(has_control_flow)] - pub(crate) use std::ops::ControlFlow; - - #[cfg(not(has_control_flow))] - #[allow(missing_debug_implementations)] - pub enum ControlFlow { - Continue(C), - Break(B), - } - - use self::ControlFlow::{Break, Continue}; - /// Clone of `std::ops::Try`. /// /// Implementing this trait is not permitted outside of `rayon`. @@ -3176,7 +3398,6 @@ mod private { fn branch(self) -> ControlFlow; } - #[cfg(has_control_flow)] impl Try for ControlFlow { private_impl! {} diff --git a/vendor/rustc-rayon/src/iter/par_bridge.rs b/vendor/rustc-rayon/src/iter/par_bridge.rs index 339ac1a32..8398274b3 100644 --- a/vendor/rustc-rayon/src/iter/par_bridge.rs +++ b/vendor/rustc-rayon/src/iter/par_bridge.rs @@ -1,12 +1,9 @@ -use crossbeam_deque::{Steal, Stealer, Worker}; - use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; -use std::sync::{Mutex, TryLockError}; -use std::thread::yield_now; +use std::sync::Mutex; -use crate::current_num_threads; use crate::iter::plumbing::{bridge_unindexed, Folder, UnindexedConsumer, UnindexedProducer}; use crate::iter::ParallelIterator; +use crate::{current_num_threads, current_thread_index}; /// Conversion trait to convert an `Iterator` to a `ParallelIterator`. /// @@ -78,71 +75,46 @@ where where C: UnindexedConsumer, { - let split_count = AtomicUsize::new(current_num_threads()); - let worker = Worker::new_fifo(); - let stealer = worker.stealer(); - let done = AtomicBool::new(false); - let iter = Mutex::new((self.iter, worker)); + let num_threads = current_num_threads(); + let threads_started: Vec<_> = (0..num_threads).map(|_| AtomicBool::new(false)).collect(); bridge_unindexed( - IterParallelProducer { - split_count: &split_count, - done: &done, - iter: &iter, - items: stealer, + &IterParallelProducer { + split_count: AtomicUsize::new(num_threads), + iter: Mutex::new(self.iter.fuse()), + threads_started: &threads_started, }, consumer, ) } } -struct IterParallelProducer<'a, Iter: Iterator> { - split_count: &'a AtomicUsize, - done: &'a AtomicBool, - iter: &'a Mutex<(Iter, Worker)>, - items: Stealer, -} - -// manual clone because T doesn't need to be Clone, but the derive assumes it should be -impl<'a, Iter: Iterator + 'a> Clone for IterParallelProducer<'a, Iter> { - fn clone(&self) -> Self { - IterParallelProducer { - split_count: self.split_count, - done: self.done, - iter: self.iter, - items: self.items.clone(), - } - } +struct IterParallelProducer<'a, Iter> { + split_count: AtomicUsize, + iter: Mutex>, + threads_started: &'a [AtomicBool], } -impl<'a, Iter: Iterator + Send + 'a> UnindexedProducer for IterParallelProducer<'a, Iter> -where - Iter::Item: Send, -{ +impl UnindexedProducer for &IterParallelProducer<'_, Iter> { type Item = Iter::Item; fn split(self) -> (Self, Option) { let mut count = self.split_count.load(Ordering::SeqCst); loop { - // Check if the iterator is exhausted *and* we've consumed every item from it. - let done = self.done.load(Ordering::SeqCst) && self.items.is_empty(); - - match count.checked_sub(1) { - Some(new_count) if !done => { - match self.split_count.compare_exchange_weak( - count, - new_count, - Ordering::SeqCst, - Ordering::SeqCst, - ) { - Ok(_) => return (self.clone(), Some(self)), - Err(last_count) => count = last_count, - } - } - _ => { - return (self, None); + // Check if the iterator is exhausted + if let Some(new_count) = count.checked_sub(1) { + match self.split_count.compare_exchange_weak( + count, + new_count, + Ordering::SeqCst, + Ordering::SeqCst, + ) { + Ok(_) => return (self, Some(self)), + Err(last_count) => count = last_count, } + } else { + return (self, None); } } } @@ -151,66 +123,39 @@ where where F: Folder, { + // Guard against work-stealing-induced recursion, in case `Iter::next()` + // calls rayon internally, so we don't deadlock our mutex. We might also + // be recursing via `folder` methods, which doesn't present a mutex hazard, + // but it's lower overhead for us to just check this once, rather than + // updating additional shared state on every mutex lock/unlock. + // (If this isn't a rayon thread, then there's no work-stealing anyway...) + if let Some(i) = current_thread_index() { + // Note: If the number of threads in the pool ever grows dynamically, then + // we'll end up sharing flags and may falsely detect recursion -- that's + // still fine for overall correctness, just not optimal for parallelism. + let thread_started = &self.threads_started[i % self.threads_started.len()]; + if thread_started.swap(true, Ordering::Relaxed) { + // We can't make progress with a nested mutex, so just return and let + // the outermost loop continue with the rest of the iterator items. + return folder; + } + } + loop { - match self.items.steal() { - Steal::Success(it) => { + if let Ok(mut iter) = self.iter.lock() { + if let Some(it) = iter.next() { + drop(iter); folder = folder.consume(it); if folder.full() { return folder; } + } else { + return folder; } - Steal::Empty => { - // Don't storm the mutex if we're already done. - if self.done.load(Ordering::SeqCst) { - // Someone might have pushed more between our `steal()` and `done.load()` - if self.items.is_empty() { - // The iterator is out of items, no use in continuing - return folder; - } - } else { - // our cache is out of items, time to load more from the iterator - match self.iter.try_lock() { - Ok(mut guard) => { - // Check `done` again in case we raced with the previous lock - // holder on its way out. - if self.done.load(Ordering::SeqCst) { - if self.items.is_empty() { - return folder; - } - continue; - } - - let count = current_num_threads(); - let count = (count * count) * 2; - - let (ref mut iter, ref worker) = *guard; - - // while worker.len() < count { - // FIXME the new deque doesn't let us count items. We can just - // push a number of items, but that doesn't consider active - // stealers elsewhere. - for _ in 0..count { - if let Some(it) = iter.next() { - worker.push(it); - } else { - self.done.store(true, Ordering::SeqCst); - break; - } - } - } - Err(TryLockError::WouldBlock) => { - // someone else has the mutex, just sit tight until it's ready - yield_now(); //TODO: use a thread-pool-aware yield? (#548) - } - Err(TryLockError::Poisoned(_)) => { - // any panics from other threads will have been caught by the pool, - // and will be re-thrown when joined - just exit - return folder; - } - } - } - } - Steal::Retry => (), + } else { + // any panics from other threads will have been caught by the pool, + // and will be re-thrown when joined - just exit + return folder; } } } diff --git a/vendor/rustc-rayon/src/iter/plumbing/README.md b/vendor/rustc-rayon/src/iter/plumbing/README.md index cd94eae30..42d22effe 100644 --- a/vendor/rustc-rayon/src/iter/plumbing/README.md +++ b/vendor/rustc-rayon/src/iter/plumbing/README.md @@ -35,8 +35,8 @@ modes (which is why there are two): more like a `for_each` call: each time a new item is produced, the `consume` method is called with that item. (The traits themselves are a bit more complex, as they support state that can be threaded - through and ultimately reduced.) Unlike producers, there are two - variants of consumers. The difference is how the split is performed: + through and ultimately reduced.) Like producers, there are two + variants of consumers which differ in how the split is performed: - in the `Consumer` trait, splitting is done with `split_at`, which accepts an index where the split should be performed. All iterators can work in this mode. The resulting halves thus have an @@ -124,7 +124,7 @@ implement `IndexedParallelIterator`. The `bridge` function will then connect the consumer, which is handling the `flat_map` and `for_each`, with the producer, which is -handling the `zip` and its preecessors. It will split down until the +handling the `zip` and its predecessors. It will split down until the chunks seem reasonably small, then pull items from the producer and feed them to the consumer. diff --git a/vendor/rustc-rayon/src/iter/skip_any.rs b/vendor/rustc-rayon/src/iter/skip_any.rs new file mode 100644 index 000000000..0660a564a --- /dev/null +++ b/vendor/rustc-rayon/src/iter/skip_any.rs @@ -0,0 +1,144 @@ +use super::plumbing::*; +use super::*; +use std::sync::atomic::{AtomicUsize, Ordering}; + +/// `SkipAny` is an iterator that skips over `n` elements from anywhere in `I`. +/// This struct is created by the [`skip_any()`] method on [`ParallelIterator`] +/// +/// [`skip_any()`]: trait.ParallelIterator.html#method.skip_any +/// [`ParallelIterator`]: trait.ParallelIterator.html +#[must_use = "iterator adaptors are lazy and do nothing unless consumed"] +#[derive(Clone, Debug)] +pub struct SkipAny { + base: I, + count: usize, +} + +impl SkipAny +where + I: ParallelIterator, +{ + /// Creates a new `SkipAny` iterator. + pub(super) fn new(base: I, count: usize) -> Self { + SkipAny { base, count } + } +} + +impl ParallelIterator for SkipAny +where + I: ParallelIterator, +{ + type Item = I::Item; + + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + let consumer1 = SkipAnyConsumer { + base: consumer, + count: &AtomicUsize::new(self.count), + }; + self.base.drive_unindexed(consumer1) + } +} + +/// //////////////////////////////////////////////////////////////////////// +/// Consumer implementation + +struct SkipAnyConsumer<'f, C> { + base: C, + count: &'f AtomicUsize, +} + +impl<'f, T, C> Consumer for SkipAnyConsumer<'f, C> +where + C: Consumer, + T: Send, +{ + type Folder = SkipAnyFolder<'f, C::Folder>; + type Reducer = C::Reducer; + type Result = C::Result; + + fn split_at(self, index: usize) -> (Self, Self, Self::Reducer) { + let (left, right, reducer) = self.base.split_at(index); + ( + SkipAnyConsumer { base: left, ..self }, + SkipAnyConsumer { + base: right, + ..self + }, + reducer, + ) + } + + fn into_folder(self) -> Self::Folder { + SkipAnyFolder { + base: self.base.into_folder(), + count: self.count, + } + } + + fn full(&self) -> bool { + self.base.full() + } +} + +impl<'f, T, C> UnindexedConsumer for SkipAnyConsumer<'f, C> +where + C: UnindexedConsumer, + T: Send, +{ + fn split_off_left(&self) -> Self { + SkipAnyConsumer { + base: self.base.split_off_left(), + ..*self + } + } + + fn to_reducer(&self) -> Self::Reducer { + self.base.to_reducer() + } +} + +struct SkipAnyFolder<'f, C> { + base: C, + count: &'f AtomicUsize, +} + +fn checked_decrement(u: &AtomicUsize) -> bool { + u.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |u| u.checked_sub(1)) + .is_ok() +} + +impl<'f, T, C> Folder for SkipAnyFolder<'f, C> +where + C: Folder, +{ + type Result = C::Result; + + fn consume(mut self, item: T) -> Self { + if !checked_decrement(self.count) { + self.base = self.base.consume(item); + } + self + } + + fn consume_iter(mut self, iter: I) -> Self + where + I: IntoIterator, + { + self.base = self.base.consume_iter( + iter.into_iter() + .skip_while(move |_| checked_decrement(self.count)), + ); + self + } + + fn complete(self) -> C::Result { + self.base.complete() + } + + fn full(&self) -> bool { + self.base.full() + } +} diff --git a/vendor/rustc-rayon/src/iter/skip_any_while.rs b/vendor/rustc-rayon/src/iter/skip_any_while.rs new file mode 100644 index 000000000..28b9e5973 --- /dev/null +++ b/vendor/rustc-rayon/src/iter/skip_any_while.rs @@ -0,0 +1,166 @@ +use super::plumbing::*; +use super::*; +use std::fmt; +use std::sync::atomic::{AtomicBool, Ordering}; + +/// `SkipAnyWhile` is an iterator that skips over elements from anywhere in `I` +/// until the callback returns `false`. +/// This struct is created by the [`skip_any_while()`] method on [`ParallelIterator`] +/// +/// [`skip_any_while()`]: trait.ParallelIterator.html#method.skip_any_while +/// [`ParallelIterator`]: trait.ParallelIterator.html +#[must_use = "iterator adaptors are lazy and do nothing unless consumed"] +#[derive(Clone)] +pub struct SkipAnyWhile { + base: I, + predicate: P, +} + +impl fmt::Debug for SkipAnyWhile { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("SkipAnyWhile") + .field("base", &self.base) + .finish() + } +} + +impl SkipAnyWhile +where + I: ParallelIterator, +{ + /// Creates a new `SkipAnyWhile` iterator. + pub(super) fn new(base: I, predicate: P) -> Self { + SkipAnyWhile { base, predicate } + } +} + +impl ParallelIterator for SkipAnyWhile +where + I: ParallelIterator, + P: Fn(&I::Item) -> bool + Sync + Send, +{ + type Item = I::Item; + + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + let consumer1 = SkipAnyWhileConsumer { + base: consumer, + predicate: &self.predicate, + skipping: &AtomicBool::new(true), + }; + self.base.drive_unindexed(consumer1) + } +} + +/// //////////////////////////////////////////////////////////////////////// +/// Consumer implementation + +struct SkipAnyWhileConsumer<'p, C, P> { + base: C, + predicate: &'p P, + skipping: &'p AtomicBool, +} + +impl<'p, T, C, P> Consumer for SkipAnyWhileConsumer<'p, C, P> +where + C: Consumer, + P: Fn(&T) -> bool + Sync, +{ + type Folder = SkipAnyWhileFolder<'p, C::Folder, P>; + type Reducer = C::Reducer; + type Result = C::Result; + + fn split_at(self, index: usize) -> (Self, Self, Self::Reducer) { + let (left, right, reducer) = self.base.split_at(index); + ( + SkipAnyWhileConsumer { base: left, ..self }, + SkipAnyWhileConsumer { + base: right, + ..self + }, + reducer, + ) + } + + fn into_folder(self) -> Self::Folder { + SkipAnyWhileFolder { + base: self.base.into_folder(), + predicate: self.predicate, + skipping: self.skipping, + } + } + + fn full(&self) -> bool { + self.base.full() + } +} + +impl<'p, T, C, P> UnindexedConsumer for SkipAnyWhileConsumer<'p, C, P> +where + C: UnindexedConsumer, + P: Fn(&T) -> bool + Sync, +{ + fn split_off_left(&self) -> Self { + SkipAnyWhileConsumer { + base: self.base.split_off_left(), + ..*self + } + } + + fn to_reducer(&self) -> Self::Reducer { + self.base.to_reducer() + } +} + +struct SkipAnyWhileFolder<'p, C, P> { + base: C, + predicate: &'p P, + skipping: &'p AtomicBool, +} + +fn skip(item: &T, skipping: &AtomicBool, predicate: &impl Fn(&T) -> bool) -> bool { + if !skipping.load(Ordering::Relaxed) { + return false; + } + if predicate(item) { + return true; + } + skipping.store(false, Ordering::Relaxed); + false +} + +impl<'p, T, C, P> Folder for SkipAnyWhileFolder<'p, C, P> +where + C: Folder, + P: Fn(&T) -> bool + 'p, +{ + type Result = C::Result; + + fn consume(mut self, item: T) -> Self { + if !skip(&item, self.skipping, self.predicate) { + self.base = self.base.consume(item); + } + self + } + + fn consume_iter(mut self, iter: I) -> Self + where + I: IntoIterator, + { + self.base = self.base.consume_iter( + iter.into_iter() + .skip_while(move |x| skip(x, self.skipping, self.predicate)), + ); + self + } + + fn complete(self) -> C::Result { + self.base.complete() + } + + fn full(&self) -> bool { + self.base.full() + } +} diff --git a/vendor/rustc-rayon/src/iter/step_by.rs b/vendor/rustc-rayon/src/iter/step_by.rs index 863de3cf0..94b8334e8 100644 --- a/vendor/rustc-rayon/src/iter/step_by.rs +++ b/vendor/rustc-rayon/src/iter/step_by.rs @@ -1,4 +1,3 @@ -#![cfg(has_step_by_rev)] use std::cmp::min; use super::plumbing::*; diff --git a/vendor/rustc-rayon/src/iter/take_any.rs b/vendor/rustc-rayon/src/iter/take_any.rs new file mode 100644 index 000000000..e3992b383 --- /dev/null +++ b/vendor/rustc-rayon/src/iter/take_any.rs @@ -0,0 +1,144 @@ +use super::plumbing::*; +use super::*; +use std::sync::atomic::{AtomicUsize, Ordering}; + +/// `TakeAny` is an iterator that iterates over `n` elements from anywhere in `I`. +/// This struct is created by the [`take_any()`] method on [`ParallelIterator`] +/// +/// [`take_any()`]: trait.ParallelIterator.html#method.take_any +/// [`ParallelIterator`]: trait.ParallelIterator.html +#[must_use = "iterator adaptors are lazy and do nothing unless consumed"] +#[derive(Clone, Debug)] +pub struct TakeAny { + base: I, + count: usize, +} + +impl TakeAny +where + I: ParallelIterator, +{ + /// Creates a new `TakeAny` iterator. + pub(super) fn new(base: I, count: usize) -> Self { + TakeAny { base, count } + } +} + +impl ParallelIterator for TakeAny +where + I: ParallelIterator, +{ + type Item = I::Item; + + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + let consumer1 = TakeAnyConsumer { + base: consumer, + count: &AtomicUsize::new(self.count), + }; + self.base.drive_unindexed(consumer1) + } +} + +/// //////////////////////////////////////////////////////////////////////// +/// Consumer implementation + +struct TakeAnyConsumer<'f, C> { + base: C, + count: &'f AtomicUsize, +} + +impl<'f, T, C> Consumer for TakeAnyConsumer<'f, C> +where + C: Consumer, + T: Send, +{ + type Folder = TakeAnyFolder<'f, C::Folder>; + type Reducer = C::Reducer; + type Result = C::Result; + + fn split_at(self, index: usize) -> (Self, Self, Self::Reducer) { + let (left, right, reducer) = self.base.split_at(index); + ( + TakeAnyConsumer { base: left, ..self }, + TakeAnyConsumer { + base: right, + ..self + }, + reducer, + ) + } + + fn into_folder(self) -> Self::Folder { + TakeAnyFolder { + base: self.base.into_folder(), + count: self.count, + } + } + + fn full(&self) -> bool { + self.count.load(Ordering::Relaxed) == 0 || self.base.full() + } +} + +impl<'f, T, C> UnindexedConsumer for TakeAnyConsumer<'f, C> +where + C: UnindexedConsumer, + T: Send, +{ + fn split_off_left(&self) -> Self { + TakeAnyConsumer { + base: self.base.split_off_left(), + ..*self + } + } + + fn to_reducer(&self) -> Self::Reducer { + self.base.to_reducer() + } +} + +struct TakeAnyFolder<'f, C> { + base: C, + count: &'f AtomicUsize, +} + +fn checked_decrement(u: &AtomicUsize) -> bool { + u.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |u| u.checked_sub(1)) + .is_ok() +} + +impl<'f, T, C> Folder for TakeAnyFolder<'f, C> +where + C: Folder, +{ + type Result = C::Result; + + fn consume(mut self, item: T) -> Self { + if checked_decrement(self.count) { + self.base = self.base.consume(item); + } + self + } + + fn consume_iter(mut self, iter: I) -> Self + where + I: IntoIterator, + { + self.base = self.base.consume_iter( + iter.into_iter() + .take_while(move |_| checked_decrement(self.count)), + ); + self + } + + fn complete(self) -> C::Result { + self.base.complete() + } + + fn full(&self) -> bool { + self.count.load(Ordering::Relaxed) == 0 || self.base.full() + } +} diff --git a/vendor/rustc-rayon/src/iter/take_any_while.rs b/vendor/rustc-rayon/src/iter/take_any_while.rs new file mode 100644 index 000000000..e6a91afab --- /dev/null +++ b/vendor/rustc-rayon/src/iter/take_any_while.rs @@ -0,0 +1,166 @@ +use super::plumbing::*; +use super::*; +use std::fmt; +use std::sync::atomic::{AtomicBool, Ordering}; + +/// `TakeAnyWhile` is an iterator that iterates over elements from anywhere in `I` +/// until the callback returns `false`. +/// This struct is created by the [`take_any_while()`] method on [`ParallelIterator`] +/// +/// [`take_any_while()`]: trait.ParallelIterator.html#method.take_any_while +/// [`ParallelIterator`]: trait.ParallelIterator.html +#[must_use = "iterator adaptors are lazy and do nothing unless consumed"] +#[derive(Clone)] +pub struct TakeAnyWhile { + base: I, + predicate: P, +} + +impl fmt::Debug for TakeAnyWhile { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("TakeAnyWhile") + .field("base", &self.base) + .finish() + } +} + +impl TakeAnyWhile +where + I: ParallelIterator, +{ + /// Creates a new `TakeAnyWhile` iterator. + pub(super) fn new(base: I, predicate: P) -> Self { + TakeAnyWhile { base, predicate } + } +} + +impl ParallelIterator for TakeAnyWhile +where + I: ParallelIterator, + P: Fn(&I::Item) -> bool + Sync + Send, +{ + type Item = I::Item; + + fn drive_unindexed(self, consumer: C) -> C::Result + where + C: UnindexedConsumer, + { + let consumer1 = TakeAnyWhileConsumer { + base: consumer, + predicate: &self.predicate, + taking: &AtomicBool::new(true), + }; + self.base.drive_unindexed(consumer1) + } +} + +/// //////////////////////////////////////////////////////////////////////// +/// Consumer implementation + +struct TakeAnyWhileConsumer<'p, C, P> { + base: C, + predicate: &'p P, + taking: &'p AtomicBool, +} + +impl<'p, T, C, P> Consumer for TakeAnyWhileConsumer<'p, C, P> +where + C: Consumer, + P: Fn(&T) -> bool + Sync, +{ + type Folder = TakeAnyWhileFolder<'p, C::Folder, P>; + type Reducer = C::Reducer; + type Result = C::Result; + + fn split_at(self, index: usize) -> (Self, Self, Self::Reducer) { + let (left, right, reducer) = self.base.split_at(index); + ( + TakeAnyWhileConsumer { base: left, ..self }, + TakeAnyWhileConsumer { + base: right, + ..self + }, + reducer, + ) + } + + fn into_folder(self) -> Self::Folder { + TakeAnyWhileFolder { + base: self.base.into_folder(), + predicate: self.predicate, + taking: self.taking, + } + } + + fn full(&self) -> bool { + !self.taking.load(Ordering::Relaxed) || self.base.full() + } +} + +impl<'p, T, C, P> UnindexedConsumer for TakeAnyWhileConsumer<'p, C, P> +where + C: UnindexedConsumer, + P: Fn(&T) -> bool + Sync, +{ + fn split_off_left(&self) -> Self { + TakeAnyWhileConsumer { + base: self.base.split_off_left(), + ..*self + } + } + + fn to_reducer(&self) -> Self::Reducer { + self.base.to_reducer() + } +} + +struct TakeAnyWhileFolder<'p, C, P> { + base: C, + predicate: &'p P, + taking: &'p AtomicBool, +} + +fn take(item: &T, taking: &AtomicBool, predicate: &impl Fn(&T) -> bool) -> bool { + if !taking.load(Ordering::Relaxed) { + return false; + } + if predicate(item) { + return true; + } + taking.store(false, Ordering::Relaxed); + false +} + +impl<'p, T, C, P> Folder for TakeAnyWhileFolder<'p, C, P> +where + C: Folder, + P: Fn(&T) -> bool + 'p, +{ + type Result = C::Result; + + fn consume(mut self, item: T) -> Self { + if take(&item, self.taking, self.predicate) { + self.base = self.base.consume(item); + } + self + } + + fn consume_iter(mut self, iter: I) -> Self + where + I: IntoIterator, + { + self.base = self.base.consume_iter( + iter.into_iter() + .take_while(move |x| take(x, self.taking, self.predicate)), + ); + self + } + + fn complete(self) -> C::Result { + self.base.complete() + } + + fn full(&self) -> bool { + !self.taking.load(Ordering::Relaxed) || self.base.full() + } +} diff --git a/vendor/rustc-rayon/src/iter/test.rs b/vendor/rustc-rayon/src/iter/test.rs index bc5106bec..c72068df7 100644 --- a/vendor/rustc-rayon/src/iter/test.rs +++ b/vendor/rustc-rayon/src/iter/test.rs @@ -117,13 +117,10 @@ fn fold_map_reduce() { let r1 = (0_i32..32) .into_par_iter() .with_max_len(1) - .fold( - || vec![], - |mut v, e| { - v.push(e); - v - }, - ) + .fold(Vec::new, |mut v, e| { + v.push(e); + v + }) .map(|v| vec![v]) .reduce_with(|mut v_a, v_b| { v_a.extend(v_b); @@ -394,7 +391,7 @@ fn check_slice_mut_indexed() { #[test] fn check_vec_indexed() { let a = vec![1, 2, 3]; - is_indexed(a.clone().into_par_iter()); + is_indexed(a.into_par_iter()); } #[test] @@ -471,6 +468,7 @@ fn check_cmp_gt_to_seq() { } #[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] fn check_cmp_short_circuit() { // We only use a single thread in order to make the short-circuit behavior deterministic. let pool = ThreadPoolBuilder::new().num_threads(1).build().unwrap(); @@ -500,6 +498,7 @@ fn check_cmp_short_circuit() { } #[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] fn check_partial_cmp_short_circuit() { // We only use a single thread to make the short-circuit behavior deterministic. let pool = ThreadPoolBuilder::new().num_threads(1).build().unwrap(); @@ -529,6 +528,7 @@ fn check_partial_cmp_short_circuit() { } #[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] fn check_partial_cmp_nan_short_circuit() { // We only use a single thread to make the short-circuit behavior deterministic. let pool = ThreadPoolBuilder::new().num_threads(1).build().unwrap(); @@ -1371,10 +1371,10 @@ fn check_find_is_present() { let counter = AtomicUsize::new(0); let value: Option = (0_i32..2048).into_par_iter().find_any(|&p| { counter.fetch_add(1, Ordering::SeqCst); - p >= 1024 && p < 1096 + (1024..1096).contains(&p) }); let q = value.unwrap(); - assert!(q >= 1024 && q < 1096); + assert!((1024..1096).contains(&q)); assert!(counter.load(Ordering::SeqCst) < 2048); // should not have visited every single one } @@ -1892,7 +1892,7 @@ fn check_either() { // try an indexed iterator let left: E = Either::Left(v.clone().into_par_iter()); - assert!(left.enumerate().eq(v.clone().into_par_iter().enumerate())); + assert!(left.enumerate().eq(v.into_par_iter().enumerate())); } #[test] @@ -2063,7 +2063,7 @@ fn check_chunks_len() { assert_eq!(4, (0..8).into_par_iter().chunks(2).len()); assert_eq!(3, (0..9).into_par_iter().chunks(3).len()); assert_eq!(3, (0..8).into_par_iter().chunks(3).len()); - assert_eq!(1, (&[1]).par_iter().chunks(3).len()); + assert_eq!(1, [1].par_iter().chunks(3).len()); assert_eq!(0, (0..0).into_par_iter().chunks(3).len()); } diff --git a/vendor/rustc-rayon/src/iter/try_fold.rs b/vendor/rustc-rayon/src/iter/try_fold.rs index c1881d10f..6d1048d75 100644 --- a/vendor/rustc-rayon/src/iter/try_fold.rs +++ b/vendor/rustc-rayon/src/iter/try_fold.rs @@ -2,10 +2,9 @@ use super::plumbing::*; use super::ParallelIterator; use super::Try; -use super::private::ControlFlow::{self, Break, Continue}; - use std::fmt::{self, Debug}; use std::marker::PhantomData; +use std::ops::ControlFlow::{self, Break, Continue}; impl TryFold where diff --git a/vendor/rustc-rayon/src/iter/try_reduce.rs b/vendor/rustc-rayon/src/iter/try_reduce.rs index 7bf6cc4a5..35a724c94 100644 --- a/vendor/rustc-rayon/src/iter/try_reduce.rs +++ b/vendor/rustc-rayon/src/iter/try_reduce.rs @@ -2,8 +2,7 @@ use super::plumbing::*; use super::ParallelIterator; use super::Try; -use super::private::ControlFlow::{self, Break, Continue}; - +use std::ops::ControlFlow::{self, Break, Continue}; use std::sync::atomic::{AtomicBool, Ordering}; pub(super) fn try_reduce(pi: PI, identity: ID, reduce_op: R) -> T diff --git a/vendor/rustc-rayon/src/iter/try_reduce_with.rs b/vendor/rustc-rayon/src/iter/try_reduce_with.rs index 9fe34d61d..cd7c83e27 100644 --- a/vendor/rustc-rayon/src/iter/try_reduce_with.rs +++ b/vendor/rustc-rayon/src/iter/try_reduce_with.rs @@ -2,8 +2,7 @@ use super::plumbing::*; use super::ParallelIterator; use super::Try; -use super::private::ControlFlow::{self, Break, Continue}; - +use std::ops::ControlFlow::{self, Break, Continue}; use std::sync::atomic::{AtomicBool, Ordering}; pub(super) fn try_reduce_with(pi: PI, reduce_op: R) -> Option diff --git a/vendor/rustc-rayon/src/iter/update.rs b/vendor/rustc-rayon/src/iter/update.rs index 373a4d772..c693ac8d6 100644 --- a/vendor/rustc-rayon/src/iter/update.rs +++ b/vendor/rustc-rayon/src/iter/update.rs @@ -210,7 +210,7 @@ where F: Fn(&mut T) + Send + Sync, { fn split_off_left(&self) -> Self { - UpdateConsumer::new(self.base.split_off_left(), &self.update_op) + UpdateConsumer::new(self.base.split_off_left(), self.update_op) } fn to_reducer(&self) -> Self::Reducer { diff --git a/vendor/rustc-rayon/src/lib.rs b/vendor/rustc-rayon/src/lib.rs index b59f3fa2b..86f997b36 100644 --- a/vendor/rustc-rayon/src/lib.rs +++ b/vendor/rustc-rayon/src/lib.rs @@ -1,4 +1,3 @@ -#![doc(html_root_url = "https://docs.rs/rayon/1.5")] #![deny(missing_debug_implementations)] #![deny(missing_docs)] #![deny(unreachable_pub)] @@ -77,6 +76,11 @@ //! [the `collections` from `std`]: https://doc.rust-lang.org/std/collections/index.html //! [`std`]: https://doc.rust-lang.org/std/ //! +//! # Targets without threading +//! +//! Rayon has limited support for targets without `std` threading implementations. +//! See the [`rayon_core`] documentation for more information about its global fallback. +//! //! # Other questions? //! //! See [the Rayon FAQ][faq]. @@ -114,11 +118,13 @@ pub use rayon_core::ThreadBuilder; pub use rayon_core::ThreadPool; pub use rayon_core::ThreadPoolBuildError; pub use rayon_core::ThreadPoolBuilder; +pub use rayon_core::{broadcast, spawn_broadcast, BroadcastContext}; pub use rayon_core::{current_num_threads, current_thread_index, max_num_threads}; pub use rayon_core::{in_place_scope, scope, Scope}; pub use rayon_core::{in_place_scope_fifo, scope_fifo, ScopeFifo}; pub use rayon_core::{join, join_context}; pub use rayon_core::{spawn, spawn_fifo}; +pub use rayon_core::{yield_local, yield_now, Yield}; /// We need to transmit raw pointers across threads. It is possible to do this /// without any unsafe code by converting pointers to usize or to AtomicPtr @@ -136,6 +142,13 @@ unsafe impl Send for SendPtr {} // SAFETY: !Sync for raw pointers is not for safety, just as a lint unsafe impl Sync for SendPtr {} +impl SendPtr { + // Helper to avoid disjoint captures of `send_ptr.0` + fn get(self) -> *mut T { + self.0 + } +} + // Implement Clone without the T: Clone bound from the derive impl Clone for SendPtr { fn clone(&self) -> Self { diff --git a/vendor/rustc-rayon/src/math.rs b/vendor/rustc-rayon/src/math.rs index 9de588965..3a630be14 100644 --- a/vendor/rustc-rayon/src/math.rs +++ b/vendor/rustc-rayon/src/math.rs @@ -1,7 +1,7 @@ use std::ops::{Bound, Range, RangeBounds}; /// Divide `n` by `divisor`, and round up to the nearest integer -/// if not evenly divisable. +/// if not evenly divisible. #[inline] pub(super) fn div_round_up(n: usize, divisor: usize) -> usize { debug_assert!(divisor != 0, "Division by zero!"); diff --git a/vendor/rustc-rayon/src/slice/chunks.rs b/vendor/rustc-rayon/src/slice/chunks.rs index 5b145bdd8..a3cc70953 100644 --- a/vendor/rustc-rayon/src/slice/chunks.rs +++ b/vendor/rustc-rayon/src/slice/chunks.rs @@ -317,7 +317,7 @@ impl<'data, T: Send> ChunksExactMut<'data, T> { /// returned by the iterator. The returned slice has at most `chunk_size-1` /// elements. Subsequent calls will return an empty slice. pub fn take_remainder(&mut self) -> &'data mut [T] { - std::mem::replace(&mut self.rem, &mut []) + std::mem::take(&mut self.rem) } } diff --git a/vendor/rustc-rayon/src/slice/mergesort.rs b/vendor/rustc-rayon/src/slice/mergesort.rs index a24ba65b7..fec309d27 100644 --- a/vendor/rustc-rayon/src/slice/mergesort.rs +++ b/vendor/rustc-rayon/src/slice/mergesort.rs @@ -205,9 +205,8 @@ where impl Drop for MergeHole { fn drop(&mut self) { // `T` is not a zero-sized type, so it's okay to divide by its size. - let len = (self.end as usize - self.start as usize) / size_of::(); unsafe { - // TODO 1.47: let len = self.end.offset_from(self.start) as usize; + let len = self.end.offset_from(self.start) as usize; ptr::copy_nonoverlapping(self.start, self.dest, len); } } @@ -491,8 +490,8 @@ where let dest_l = SendPtr(dest); let dest_r = SendPtr(dest.add(left_l.len() + right_l.len())); rayon_core::join( - || par_merge(left_l, right_l, dest_l.0, is_less), - || par_merge(left_r, right_r, dest_r.0, is_less), + move || par_merge(left_l, right_l, dest_l.get(), is_less), + move || par_merge(left_r, right_r, dest_r.get(), is_less), ); } // Finally, `s` gets dropped if we used sequential merge, thus copying the remaining elements @@ -570,7 +569,7 @@ unsafe fn recurse( // After recursive calls finish we'll have to merge chunks `(start, mid)` and `(mid, end)` from // `src` into `dest`. If the current invocation has to store the result into `buf`, we'll - // merge chunks from `v` into `buf`, and viceversa. + // merge chunks from `v` into `buf`, and vice versa. // // Recursive calls flip `into_buf` at each level of recursion. More concretely, `par_merge` // merges chunks from `buf` into `v` at the first level, from `v` into `buf` at the second @@ -593,8 +592,8 @@ unsafe fn recurse( let v = SendPtr(v); let buf = SendPtr(buf); rayon_core::join( - || recurse(v.0, buf.0, left, !into_buf, is_less), - || recurse(v.0, buf.0, right, !into_buf, is_less), + move || recurse(v.get(), buf.get(), left, !into_buf, is_less), + move || recurse(v.get(), buf.get(), right, !into_buf, is_less), ); // Everything went all right - recursive calls didn't panic. @@ -661,16 +660,17 @@ where // Wrap pointer in SendPtr so that it can be sent to another thread // See the documentation of SendPtr for a full explanation let buf = SendPtr(buf); + let is_less = &is_less; v.par_chunks_mut(CHUNK_LENGTH) .with_max_len(1) .enumerate() - .map(|(i, chunk)| { + .map(move |(i, chunk)| { let l = CHUNK_LENGTH * i; let r = l + chunk.len(); unsafe { - let buf = buf.0.add(l); - (l, r, mergesort(chunk, buf, &is_less)) + let buf = buf.get().add(l); + (l, r, mergesort(chunk, buf, is_less)) } }) .collect::>() @@ -731,7 +731,7 @@ mod tests { check(&[1, 2, 2, 2, 2, 3], &[]); check(&[], &[1, 2, 2, 2, 2, 3]); - let ref mut rng = thread_rng(); + let rng = &mut thread_rng(); for _ in 0..100 { let limit: u32 = rng.gen_range(1..21); diff --git a/vendor/rustc-rayon/src/slice/mod.rs b/vendor/rustc-rayon/src/slice/mod.rs index a4e777374..dab56deb3 100644 --- a/vendor/rustc-rayon/src/slice/mod.rs +++ b/vendor/rustc-rayon/src/slice/mod.rs @@ -85,6 +85,7 @@ pub trait ParallelSlice { /// let chunks: Vec<_> = [1, 2, 3, 4, 5].par_chunks(2).collect(); /// assert_eq!(chunks, vec![&[1, 2][..], &[3, 4], &[5]]); /// ``` + #[track_caller] fn par_chunks(&self, chunk_size: usize) -> Chunks<'_, T> { assert!(chunk_size != 0, "chunk_size must not be zero"); Chunks::new(chunk_size, self.as_parallel_slice()) @@ -104,6 +105,7 @@ pub trait ParallelSlice { /// let chunks: Vec<_> = [1, 2, 3, 4, 5].par_chunks_exact(2).collect(); /// assert_eq!(chunks, vec![&[1, 2][..], &[3, 4]]); /// ``` + #[track_caller] fn par_chunks_exact(&self, chunk_size: usize) -> ChunksExact<'_, T> { assert!(chunk_size != 0, "chunk_size must not be zero"); ChunksExact::new(chunk_size, self.as_parallel_slice()) @@ -123,6 +125,7 @@ pub trait ParallelSlice { /// let chunks: Vec<_> = [1, 2, 3, 4, 5].par_rchunks(2).collect(); /// assert_eq!(chunks, vec![&[4, 5][..], &[2, 3], &[1]]); /// ``` + #[track_caller] fn par_rchunks(&self, chunk_size: usize) -> RChunks<'_, T> { assert!(chunk_size != 0, "chunk_size must not be zero"); RChunks::new(chunk_size, self.as_parallel_slice()) @@ -142,6 +145,7 @@ pub trait ParallelSlice { /// let chunks: Vec<_> = [1, 2, 3, 4, 5].par_rchunks_exact(2).collect(); /// assert_eq!(chunks, vec![&[4, 5][..], &[2, 3]]); /// ``` + #[track_caller] fn par_rchunks_exact(&self, chunk_size: usize) -> RChunksExact<'_, T> { assert!(chunk_size != 0, "chunk_size must not be zero"); RChunksExact::new(chunk_size, self.as_parallel_slice()) @@ -199,6 +203,7 @@ pub trait ParallelSliceMut { /// .for_each(|slice| slice.reverse()); /// assert_eq!(array, [2, 1, 4, 3, 5]); /// ``` + #[track_caller] fn par_chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<'_, T> { assert!(chunk_size != 0, "chunk_size must not be zero"); ChunksMut::new(chunk_size, self.as_parallel_slice_mut()) @@ -220,6 +225,7 @@ pub trait ParallelSliceMut { /// .for_each(|slice| slice.reverse()); /// assert_eq!(array, [3, 2, 1, 4, 5]); /// ``` + #[track_caller] fn par_chunks_exact_mut(&mut self, chunk_size: usize) -> ChunksExactMut<'_, T> { assert!(chunk_size != 0, "chunk_size must not be zero"); ChunksExactMut::new(chunk_size, self.as_parallel_slice_mut()) @@ -241,6 +247,7 @@ pub trait ParallelSliceMut { /// .for_each(|slice| slice.reverse()); /// assert_eq!(array, [1, 3, 2, 5, 4]); /// ``` + #[track_caller] fn par_rchunks_mut(&mut self, chunk_size: usize) -> RChunksMut<'_, T> { assert!(chunk_size != 0, "chunk_size must not be zero"); RChunksMut::new(chunk_size, self.as_parallel_slice_mut()) @@ -262,6 +269,7 @@ pub trait ParallelSliceMut { /// .for_each(|slice| slice.reverse()); /// assert_eq!(array, [1, 2, 5, 4, 3]); /// ``` + #[track_caller] fn par_rchunks_exact_mut(&mut self, chunk_size: usize) -> RChunksExactMut<'_, T> { assert!(chunk_size != 0, "chunk_size must not be zero"); RChunksExactMut::new(chunk_size, self.as_parallel_slice_mut()) diff --git a/vendor/rustc-rayon/src/slice/quicksort.rs b/vendor/rustc-rayon/src/slice/quicksort.rs index 87fb724c3..2bfc35032 100644 --- a/vendor/rustc-rayon/src/slice/quicksort.rs +++ b/vendor/rustc-rayon/src/slice/quicksort.rs @@ -5,16 +5,34 @@ //! `rayon_core::join`. use std::cmp; +use std::marker::PhantomData; use std::mem::{self, MaybeUninit}; use std::ptr; /// When dropped, copies from `src` into `dest`. -struct CopyOnDrop { +#[must_use] +struct CopyOnDrop<'a, T> { src: *const T, dest: *mut T, + /// `src` is often a local pointer here, make sure we have appropriate + /// PhantomData so that dropck can protect us. + marker: PhantomData<&'a mut T>, } -impl Drop for CopyOnDrop { +impl<'a, T> CopyOnDrop<'a, T> { + /// Construct from a source pointer and a destination + /// Assumes dest lives longer than src, since there is no easy way to + /// copy down lifetime information from another pointer + unsafe fn new(src: &'a T, dest: *mut T) -> Self { + CopyOnDrop { + src, + dest, + marker: PhantomData, + } + } +} + +impl Drop for CopyOnDrop<'_, T> { fn drop(&mut self) { // SAFETY: This is a helper class. // Please refer to its usage for correctness. @@ -54,10 +72,7 @@ where // into the slice. let tmp = mem::ManuallyDrop::new(ptr::read(v.get_unchecked(0))); let v = v.as_mut_ptr(); - let mut hole = CopyOnDrop { - src: &*tmp, - dest: v.add(1), - }; + let mut hole = CopyOnDrop::new(&*tmp, v.add(1)); ptr::copy_nonoverlapping(v.add(1), v.add(0), 1); for i in 2..len { @@ -103,10 +118,7 @@ where // into the slice. let tmp = mem::ManuallyDrop::new(ptr::read(v.get_unchecked(len - 1))); let v = v.as_mut_ptr(); - let mut hole = CopyOnDrop { - src: &*tmp, - dest: v.add(len - 2), - }; + let mut hole = CopyOnDrop::new(&*tmp, v.add(len - 2)); ptr::copy_nonoverlapping(v.add(len - 2), v.add(len - 1), 1); for i in (0..len - 2).rev() { @@ -191,25 +203,25 @@ where // This binary heap respects the invariant `parent >= child`. let sift_down = |v: &mut [T], mut node| { loop { - // Children of `node`: - let left = 2 * node + 1; - let right = 2 * node + 2; + // Children of `node`. + let mut child = 2 * node + 1; + if child >= v.len() { + break; + } // Choose the greater child. - let greater = if right < v.len() && is_less(&v[left], &v[right]) { - right - } else { - left - }; + if child + 1 < v.len() && is_less(&v[child], &v[child + 1]) { + child += 1; + } // Stop if the invariant holds at `node`. - if greater >= v.len() || !is_less(&v[node], &v[greater]) { + if !is_less(&v[node], &v[child]) { break; } // Swap `node` with the greater child, move one step down, and continue sifting. - v.swap(node, greater); - node = greater; + v.swap(node, child); + node = child; } }; @@ -426,7 +438,7 @@ where // safe. Otherwise, the debug assertions in the `is_done` case guarantee that // `width(l, r) == block_l + block_r`, namely, that the block sizes have been adjusted to account // for the smaller number of remaining elements. - l = unsafe { l.offset(block_l as isize) }; + l = unsafe { l.add(block_l) }; } if start_r == end_r { @@ -510,10 +522,7 @@ where // SAFETY: `pivot` is a reference to the first element of `v`, so `ptr::read` is safe. let tmp = mem::ManuallyDrop::new(unsafe { ptr::read(pivot) }); - let _pivot_guard = CopyOnDrop { - src: &*tmp, - dest: pivot, - }; + let _pivot_guard = unsafe { CopyOnDrop::new(&*tmp, pivot) }; let pivot = &*tmp; // Find the first pair of out-of-order elements. @@ -569,10 +578,7 @@ where // operation panics, the pivot will be automatically written back into the slice. // SAFETY: The pointer here is valid because it is obtained from a reference to a slice. let tmp = mem::ManuallyDrop::new(unsafe { ptr::read(pivot) }); - let _pivot_guard = CopyOnDrop { - src: &*tmp, - dest: pivot, - }; + let _pivot_guard = unsafe { CopyOnDrop::new(&*tmp, pivot) }; let pivot = &*tmp; // Now partition the slice. @@ -629,8 +635,7 @@ fn break_patterns(v: &mut [T]) { random }; let mut gen_usize = || { - // TODO 1.53: if usize::BITS <= 32 { - if mem::size_of::() <= 4 { + if usize::BITS <= 32 { gen_u32() as usize } else { (((gen_u32() as u64) << 32) | (gen_u32() as u64)) as usize @@ -676,6 +681,7 @@ where let len = v.len(); // Three indices near which we are going to choose a pivot. + #[allow(clippy::identity_op)] let mut a = len / 4 * 1; let mut b = len / 4 * 2; let mut c = len / 4 * 3; @@ -850,8 +856,7 @@ where } // Limit the number of imbalanced partitions to `floor(log2(len)) + 1`. - // TODO 1.53: let limit = usize::BITS - v.len().leading_zeros(); - let limit = mem::size_of::() as u32 * 8 - v.len().leading_zeros(); + let limit = usize::BITS - v.len().leading_zeros(); recurse(v, &is_less, None, limit); } @@ -864,7 +869,7 @@ mod tests { #[test] fn test_heapsort() { - let ref mut rng = thread_rng(); + let rng = &mut thread_rng(); for len in (0..25).chain(500..501) { for &modulus in &[5, 10, 100] { @@ -891,8 +896,8 @@ mod tests { heapsort(&mut v, &|_, _| thread_rng().gen()); heapsort(&mut v, &|a, b| a < b); - for i in 0..v.len() { - assert_eq!(v[i], i); + for (i, &entry) in v.iter().enumerate() { + assert_eq!(entry, i); } } } diff --git a/vendor/rustc-rayon/src/slice/rchunks.rs b/vendor/rustc-rayon/src/slice/rchunks.rs index 4ff712548..63e765d77 100644 --- a/vendor/rustc-rayon/src/slice/rchunks.rs +++ b/vendor/rustc-rayon/src/slice/rchunks.rs @@ -314,7 +314,7 @@ impl<'data, T: Send> RChunksExactMut<'data, T> { /// returned by the iterator. The returned slice has at most `chunk_size-1` /// elements. Subsequent calls will return an empty slice. pub fn take_remainder(&mut self) -> &'data mut [T] { - std::mem::replace(&mut self.rem, &mut []) + std::mem::take(&mut self.rem) } } diff --git a/vendor/rustc-rayon/src/slice/test.rs b/vendor/rustc-rayon/src/slice/test.rs index 4325aa88d..f74ca0f74 100644 --- a/vendor/rustc-rayon/src/slice/test.rs +++ b/vendor/rustc-rayon/src/slice/test.rs @@ -10,7 +10,7 @@ macro_rules! sort { ($f:ident, $name:ident) => { #[test] fn $name() { - let ref mut rng = thread_rng(); + let rng = &mut thread_rng(); for len in (0..25).chain(500..501) { for &modulus in &[5, 10, 100] { diff --git a/vendor/rustc-rayon/src/str.rs b/vendor/rustc-rayon/src/str.rs index 7afda3063..c85754e3d 100644 --- a/vendor/rustc-rayon/src/str.rs +++ b/vendor/rustc-rayon/src/str.rs @@ -689,11 +689,7 @@ pub struct Lines<'ch>(&'ch str); #[inline] fn no_carriage_return(line: &str) -> &str { - if line.ends_with('\r') { - &line[..line.len() - 1] - } else { - line - } + line.strip_suffix('\r').unwrap_or(line) } impl<'ch> ParallelIterator for Lines<'ch> { diff --git a/vendor/rustc-rayon/src/vec.rs b/vendor/rustc-rayon/src/vec.rs index e07963922..7892f53fa 100644 --- a/vendor/rustc-rayon/src/vec.rs +++ b/vendor/rustc-rayon/src/vec.rs @@ -132,7 +132,7 @@ impl<'data, T: Send> IndexedParallelIterator for Drain<'data, T> { self.range.len() } - fn with_producer(mut self, callback: CB) -> CB::Output + fn with_producer(self, callback: CB) -> CB::Output where CB: ProducerCallback, { @@ -141,7 +141,7 @@ impl<'data, T: Send> IndexedParallelIterator for Drain<'data, T> { self.vec.set_len(self.range.start); // Create the producer as the exclusive "owner" of the slice. - let producer = DrainProducer::from_vec(&mut self.vec, self.range.len()); + let producer = DrainProducer::from_vec(self.vec, self.range.len()); // The producer will move or drop each item from the drained range. callback.callback(producer) @@ -151,22 +151,24 @@ impl<'data, T: Send> IndexedParallelIterator for Drain<'data, T> { impl<'data, T: Send> Drop for Drain<'data, T> { fn drop(&mut self) { - if self.range.len() > 0 { - let Range { start, end } = self.range; - if self.vec.len() != start { - // We must not have produced, so just call a normal drain to remove the items. - assert_eq!(self.vec.len(), self.orig_len); - self.vec.drain(start..end); - } else if end < self.orig_len { - // The producer was responsible for consuming the drained items. - // Move the tail items to their new place, then set the length to include them. - unsafe { - let ptr = self.vec.as_mut_ptr().add(start); - let tail_ptr = self.vec.as_ptr().add(end); - let tail_len = self.orig_len - end; - ptr::copy(tail_ptr, ptr, tail_len); - self.vec.set_len(start + tail_len); - } + let Range { start, end } = self.range; + if self.vec.len() == self.orig_len { + // We must not have produced, so just call a normal drain to remove the items. + self.vec.drain(start..end); + } else if start == end { + // Empty range, so just restore the length to its original state + unsafe { + self.vec.set_len(self.orig_len); + } + } else if end < self.orig_len { + // The producer was responsible for consuming the drained items. + // Move the tail items to their new place, then set the length to include them. + unsafe { + let ptr = self.vec.as_mut_ptr().add(start); + let tail_ptr = self.vec.as_ptr().add(end); + let tail_len = self.orig_len - end; + ptr::copy(tail_ptr, ptr, tail_len); + self.vec.set_len(start + tail_len); } } } @@ -181,7 +183,7 @@ pub(crate) struct DrainProducer<'data, T: Send> { impl DrainProducer<'_, T> { /// Creates a draining producer, which *moves* items from the slice. /// - /// Unsafe bacause `!Copy` data must not be read after the borrow is released. + /// Unsafe because `!Copy` data must not be read after the borrow is released. pub(crate) unsafe fn new(slice: &mut [T]) -> DrainProducer<'_, T> { DrainProducer { slice } } @@ -207,7 +209,7 @@ impl<'data, T: 'data + Send> Producer for DrainProducer<'data, T> { fn into_iter(mut self) -> Self::IntoIter { // replace the slice so we don't drop it twice - let slice = mem::replace(&mut self.slice, &mut []); + let slice = mem::take(&mut self.slice); SliceDrain { iter: slice.iter_mut(), } @@ -215,7 +217,7 @@ impl<'data, T: 'data + Send> Producer for DrainProducer<'data, T> { fn split_at(mut self, index: usize) -> (Self, Self) { // replace the slice so we don't drop it twice - let slice = mem::replace(&mut self.slice, &mut []); + let slice = mem::take(&mut self.slice); let (left, right) = slice.split_at_mut(index); unsafe { (DrainProducer::new(left), DrainProducer::new(right)) } } @@ -223,8 +225,9 @@ impl<'data, T: 'data + Send> Producer for DrainProducer<'data, T> { impl<'data, T: 'data + Send> Drop for DrainProducer<'data, T> { fn drop(&mut self) { - // use `Drop for [T]` - unsafe { ptr::drop_in_place(self.slice) }; + // extract the slice so we can use `Drop for [T]` + let slice_ptr: *mut [T] = mem::take::<&'data mut [T]>(&mut self.slice); + unsafe { ptr::drop_in_place::<[T]>(slice_ptr) }; } } @@ -274,7 +277,7 @@ impl<'data, T: 'data> iter::FusedIterator for SliceDrain<'data, T> {} impl<'data, T: 'data> Drop for SliceDrain<'data, T> { fn drop(&mut self) { // extract the iterator so we can use `Drop for [T]` - let iter = mem::replace(&mut self.iter, [].iter_mut()); - unsafe { ptr::drop_in_place(iter.into_slice()) }; + let slice_ptr: *mut [T] = mem::replace(&mut self.iter, [].iter_mut()).into_slice(); + unsafe { ptr::drop_in_place::<[T]>(slice_ptr) }; } } diff --git a/vendor/rustc-rayon/tests/clones.rs b/vendor/rustc-rayon/tests/clones.rs index 2f512ca05..0d6c86487 100644 --- a/vendor/rustc-rayon/tests/clones.rs +++ b/vendor/rustc-rayon/tests/clones.rs @@ -10,6 +10,13 @@ where assert_eq!(a, b); } +fn check_count(iter: I) +where + I: ParallelIterator + Clone, +{ + assert_eq!(iter.clone().count(), iter.count()); +} + #[test] fn clone_binary_heap() { use std::collections::BinaryHeap; @@ -130,6 +137,12 @@ fn clone_adaptors() { check(v.par_iter().flatten_iter()); check(v.par_iter().with_max_len(1).fold(|| 0, |x, _| x)); check(v.par_iter().with_max_len(1).fold_with(0, |x, _| x)); + check(v.par_iter().with_max_len(1).fold_chunks(1, || 0, |x, _| x)); + check( + v.par_iter() + .with_max_len(1) + .fold_chunks_with(1, 0, |x, _| x), + ); check(v.par_iter().with_max_len(1).try_fold(|| 0, |_, &x| x)); check(v.par_iter().with_max_len(1).try_fold_with(0, |_, &x| x)); check(v.par_iter().inspect(|_| ())); @@ -144,8 +157,10 @@ fn clone_adaptors() { check(v.par_iter().panic_fuse()); check(v.par_iter().positions(|_| true)); check(v.par_iter().rev()); - check(v.par_iter().skip(1)); - check(v.par_iter().take(1)); + check(v.par_iter().skip(42)); + check(v.par_iter().skip_any_while(|_| false)); + check(v.par_iter().take(42)); + check(v.par_iter().take_any_while(|_| true)); check(v.par_iter().cloned().while_some()); check(v.par_iter().with_max_len(1)); check(v.par_iter().with_min_len(1)); @@ -154,6 +169,13 @@ fn clone_adaptors() { check(v.par_iter().step_by(2)); } +#[test] +fn clone_counted_adaptors() { + let v: Vec<_> = (0..1000).collect(); + check_count(v.par_iter().skip_any(42)); + check_count(v.par_iter().take_any(42)); +} + #[test] fn clone_empty() { check(rayon::iter::empty::()); diff --git a/vendor/rustc-rayon/tests/collect.rs b/vendor/rustc-rayon/tests/collect.rs index 48b80f699..bfb080ceb 100644 --- a/vendor/rustc-rayon/tests/collect.rs +++ b/vendor/rustc-rayon/tests/collect.rs @@ -6,6 +6,7 @@ use std::sync::atomic::Ordering; use std::sync::Mutex; #[test] +#[cfg_attr(not(panic = "unwind"), ignore)] fn collect_drop_on_unwind() { struct Recorddrop<'a>(i64, &'a Mutex>); @@ -61,6 +62,7 @@ fn collect_drop_on_unwind() { } #[test] +#[cfg_attr(not(panic = "unwind"), ignore)] fn collect_drop_on_unwind_zst() { static INSERTS: AtomicUsize = AtomicUsize::new(0); static DROPS: AtomicUsize = AtomicUsize::new(0); diff --git a/vendor/rustc-rayon/tests/cross-pool.rs b/vendor/rustc-rayon/tests/cross-pool.rs index f0a2128a7..835e2e27f 100644 --- a/vendor/rustc-rayon/tests/cross-pool.rs +++ b/vendor/rustc-rayon/tests/cross-pool.rs @@ -2,6 +2,7 @@ use rayon::prelude::*; use rayon::ThreadPoolBuilder; #[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] fn cross_pool_busy() { let pool1 = ThreadPoolBuilder::new().num_threads(1).build().unwrap(); let pool2 = ThreadPoolBuilder::new().num_threads(1).build().unwrap(); diff --git a/vendor/rustc-rayon/tests/debug.rs b/vendor/rustc-rayon/tests/debug.rs index d107b1377..14f37917b 100644 --- a/vendor/rustc-rayon/tests/debug.rs +++ b/vendor/rustc-rayon/tests/debug.rs @@ -155,6 +155,8 @@ fn debug_adaptors() { check(v.par_iter().map(Some).flatten_iter()); check(v.par_iter().fold(|| 0, |x, _| x)); check(v.par_iter().fold_with(0, |x, _| x)); + check(v.par_iter().fold_chunks(3, || 0, |x, _| x)); + check(v.par_iter().fold_chunks_with(3, 0, |x, _| x)); check(v.par_iter().try_fold(|| 0, |x, _| Some(x))); check(v.par_iter().try_fold_with(0, |x, _| Some(x))); check(v.par_iter().inspect(|_| ())); @@ -170,7 +172,11 @@ fn debug_adaptors() { check(v.par_iter().positions(|_| true)); check(v.par_iter().rev()); check(v.par_iter().skip(1)); + check(v.par_iter().skip_any(1)); + check(v.par_iter().skip_any_while(|_| false)); check(v.par_iter().take(1)); + check(v.par_iter().take_any(1)); + check(v.par_iter().take_any_while(|_| true)); check(v.par_iter().map(Some).while_some()); check(v.par_iter().with_max_len(1)); check(v.par_iter().with_min_len(1)); diff --git a/vendor/rustc-rayon/tests/drain_vec.rs b/vendor/rustc-rayon/tests/drain_vec.rs new file mode 100644 index 000000000..08f1120b7 --- /dev/null +++ b/vendor/rustc-rayon/tests/drain_vec.rs @@ -0,0 +1,41 @@ +use rayon::prelude::*; + +#[test] +fn drain_vec_yielded() { + let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + let yielded = vec_org.par_drain(0..5).collect::>(); + + assert_eq!(&yielded, &[0, 1, 2, 3, 4]); + assert_eq!(&vec_org, &[5, 6, 7, 8, 9]); +} + +#[test] +fn drain_vec_dropped() { + let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + let yielded = vec_org.par_drain(0..5); + + drop(yielded); + assert_eq!(&vec_org, &[5, 6, 7, 8, 9]); +} + +#[test] +fn drain_vec_empty_range_yielded() { + let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + let yielded = vec_org.par_drain(5..5).collect::>(); + + assert_eq!(&yielded, &[]); + assert_eq!(&vec_org, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); +} + +#[test] +fn drain_vec_empty_range_dropped() { + let mut vec_org = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + let yielded = vec_org.par_drain(5..5); + + drop(yielded); + assert_eq!(&vec_org, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); +} diff --git a/vendor/rustc-rayon/tests/iter_panic.rs b/vendor/rustc-rayon/tests/iter_panic.rs index 4885a28be..c62a8dbda 100644 --- a/vendor/rustc-rayon/tests/iter_panic.rs +++ b/vendor/rustc-rayon/tests/iter_panic.rs @@ -20,6 +20,7 @@ fn iter_panic() { } #[test] +#[cfg_attr(not(panic = "unwind"), ignore)] fn iter_panic_fuse() { // We only use a single thread in order to make the behavior // of 'panic_fuse' deterministic @@ -47,6 +48,6 @@ fn iter_panic_fuse() { assert!(count(iter.clone().panic_fuse().inspect(check)) < expected); // Try in reverse to be sure we hit the producer case. - assert!(count(iter.clone().panic_fuse().inspect(check).rev()) < expected); + assert!(count(iter.panic_fuse().inspect(check).rev()) < expected); }); } diff --git a/vendor/rustc-rayon/tests/named-threads.rs b/vendor/rustc-rayon/tests/named-threads.rs index fd1b0be2d..dadb37ba6 100644 --- a/vendor/rustc-rayon/tests/named-threads.rs +++ b/vendor/rustc-rayon/tests/named-threads.rs @@ -4,6 +4,7 @@ use rayon::prelude::*; use rayon::*; #[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] fn named_threads() { ThreadPoolBuilder::new() .thread_name(|i| format!("hello-name-test-{}", i)) diff --git a/vendor/rustc-rayon/tests/octillion.rs b/vendor/rustc-rayon/tests/octillion.rs index cff2b1192..1af9ad8ba 100644 --- a/vendor/rustc-rayon/tests/octillion.rs +++ b/vendor/rustc-rayon/tests/octillion.rs @@ -68,7 +68,14 @@ fn two_threads R, R: Send>(f: F) -> R { } #[test] -#[cfg_attr(not(target_pointer_width = "64"), ignore)] +#[cfg_attr( + any( + not(target_pointer_width = "64"), + target_os = "emscripten", + target_family = "wasm" + ), + ignore +)] fn find_last_octillion() { // It would be nice if `find_last` could prioritize the later splits, // basically flipping the `join` args, without needing indexed `rev`. @@ -78,32 +85,49 @@ fn find_last_octillion() { } #[test] -#[cfg_attr(not(target_pointer_width = "64"), ignore)] +#[cfg_attr( + any( + not(target_pointer_width = "64"), + target_os = "emscripten", + target_family = "wasm" + ), + ignore +)] fn find_last_octillion_inclusive() { let x = two_threads(|| octillion_inclusive().find_last(|_| true)); assert_eq!(x, Some(OCTILLION)); } #[test] -#[cfg_attr(not(target_pointer_width = "64"), ignore)] +#[cfg_attr( + any( + not(target_pointer_width = "64"), + target_os = "emscripten", + target_family = "wasm" + ), + ignore +)] fn find_last_octillion_flat() { let x = two_threads(|| octillion_flat().find_last(|_| true)); assert_eq!(x, Some(OCTILLION - 1)); } #[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] fn find_any_octillion() { let x = two_threads(|| octillion().find_any(|x| *x > OCTILLION / 2)); assert!(x.is_some()); } #[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] fn find_any_octillion_flat() { let x = two_threads(|| octillion_flat().find_any(|x| *x > OCTILLION / 2)); assert!(x.is_some()); } #[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] fn filter_find_any_octillion() { let x = two_threads(|| { octillion() @@ -114,6 +138,7 @@ fn filter_find_any_octillion() { } #[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] fn filter_find_any_octillion_flat() { let x = two_threads(|| { octillion_flat() @@ -124,6 +149,7 @@ fn filter_find_any_octillion_flat() { } #[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] fn fold_find_any_octillion_flat() { let x = two_threads(|| octillion_flat().fold(|| (), |_, _| ()).find_any(|_| true)); assert!(x.is_some()); diff --git a/vendor/rustc-rayon/tests/par_bridge_recursion.rs b/vendor/rustc-rayon/tests/par_bridge_recursion.rs new file mode 100644 index 000000000..3a48ef143 --- /dev/null +++ b/vendor/rustc-rayon/tests/par_bridge_recursion.rs @@ -0,0 +1,31 @@ +use rayon::prelude::*; +use std::iter::once_with; + +const N: usize = 100_000; + +#[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] +fn par_bridge_recursion() { + let pool = rayon::ThreadPoolBuilder::new() + .num_threads(10) + .build() + .unwrap(); + + let seq: Vec<_> = (0..N).map(|i| (i, i.to_string())).collect(); + + pool.broadcast(|_| { + let mut par: Vec<_> = (0..N) + .into_par_iter() + .flat_map(|i| { + once_with(move || { + // Using rayon within the serial iterator creates an opportunity for + // work-stealing to make par_bridge's mutex accidentally recursive. + rayon::join(move || i, move || i.to_string()) + }) + .par_bridge() + }) + .collect(); + par.par_sort_unstable(); + assert_eq!(seq, par); + }); +} diff --git a/vendor/rustc-rayon/tests/sort-panic-safe.rs b/vendor/rustc-rayon/tests/sort-panic-safe.rs index 00a973106..95ef88d39 100644 --- a/vendor/rustc-rayon/tests/sort-panic-safe.rs +++ b/vendor/rustc-rayon/tests/sort-panic-safe.rs @@ -8,11 +8,12 @@ use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering::Relaxed; use std::thread; -static VERSIONS: AtomicUsize = AtomicUsize::new(0); +const ZERO: AtomicUsize = AtomicUsize::new(0); +const LEN: usize = 20_000; -lazy_static::lazy_static! { - static ref DROP_COUNTS: Vec = (0..20_000).map(|_| AtomicUsize::new(0)).collect(); -} +static VERSIONS: AtomicUsize = ZERO; + +static DROP_COUNTS: [AtomicUsize; LEN] = [ZERO; LEN]; #[derive(Clone, Eq)] struct DropCounter { @@ -117,6 +118,7 @@ macro_rules! test { thread_local!(static SILENCE_PANIC: Cell = Cell::new(false)); #[test] +#[cfg_attr(any(target_os = "emscripten", target_family = "wasm"), ignore)] fn sort_panic_safe() { let prev = panic::take_hook(); panic::set_hook(Box::new(move |info| { -- cgit v1.2.3