Bug 1750646 - Bulk update of rust crates (a, b and c). r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D136189
This commit is contained in:
Mike Hommey 2022-01-18 09:10:41 +00:00
Родитель 1e3b441a4e
Коммит 61b0c02a5b
96 изменённых файлов: 1394 добавлений и 892 удалений

58
Cargo.lock сгенерированный
Просмотреть файл

@ -65,9 +65,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.51"
version = "1.0.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203"
checksum = "84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3"
[[package]]
name = "app_services_logger"
@ -149,9 +149,9 @@ checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0"
[[package]]
name = "async-trait"
version = "0.1.51"
version = "0.1.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e"
checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3"
dependencies = [
"proc-macro2",
"quote",
@ -443,9 +443,9 @@ dependencies = [
[[package]]
name = "bitreader"
version = "0.3.4"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9178181a7d44239c6c8eaafa8688558a2ab5fa04b8855381f2681e9591fb941b"
checksum = "bd5bf8a17cdc06d475689f9e9226f4b5bf5610e93cf5c3010a518fe6fb0d97f5"
dependencies = [
"cfg-if 1.0.0",
]
@ -482,7 +482,7 @@ version = "0.1.0"
dependencies = [
"bits_client",
"comedy",
"crossbeam-utils 0.8.5",
"crossbeam-utils 0.8.6",
"libc",
"log",
"moz_task",
@ -493,9 +493,9 @@ dependencies = [
[[package]]
name = "blake2b_simd"
version = "0.5.9"
version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b83b7baab1e671718d78204225800d6b170e648188ac7dc992e9d6bddf87d0c0"
checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587"
dependencies = [
"arrayref",
"arrayvec 0.5.2",
@ -553,16 +553,16 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8e3ff9db740167616e528c509b3618046fc05d337f8f3182d300f4aa977d2bb"
dependencies = [
"crossbeam-utils 0.8.5",
"crossbeam-utils 0.8.6",
"jobserver",
"num_cpus",
]
[[package]]
name = "bumpalo"
version = "3.8.0"
version = "3.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c"
checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899"
[[package]]
name = "byte-tools"
@ -600,9 +600,9 @@ checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8"
[[package]]
name = "cache-padded"
version = "1.1.1"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba"
checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c"
[[package]]
name = "cascade_bloom_filter"
@ -628,7 +628,7 @@ version = "0.0.1"
dependencies = [
"base64 0.10.1",
"byteorder",
"crossbeam-utils 0.8.5",
"crossbeam-utils 0.8.6",
"cstr",
"log",
"malloc_size_of_derive",
@ -975,12 +975,12 @@ dependencies = [
[[package]]
name = "crossbeam-channel"
version = "0.5.1"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4"
checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils 0.8.5",
"crossbeam-utils 0.8.6",
]
[[package]]
@ -1001,8 +1001,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-epoch 0.9.5",
"crossbeam-utils 0.8.5",
"crossbeam-epoch 0.9.6",
"crossbeam-utils 0.8.6",
]
[[package]]
@ -1022,12 +1022,12 @@ dependencies = [
[[package]]
name = "crossbeam-epoch"
version = "0.9.5"
version = "0.9.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd"
checksum = "97242a70df9b89a65d0b6df3c4bf5b9ce03c5b7309019777fbde37e7537f8762"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils 0.8.5",
"crossbeam-utils 0.8.6",
"lazy_static",
"memoffset 0.6.5",
"scopeguard",
@ -1065,9 +1065,9 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
version = "0.8.5"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db"
checksum = "cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120"
dependencies = [
"cfg-if 1.0.0",
"lazy_static",
@ -2699,7 +2699,7 @@ name = "kvstore"
version = "0.1.0"
dependencies = [
"atomic_refcell",
"crossbeam-utils 0.8.5",
"crossbeam-utils 0.8.6",
"cstr",
"lazy_static",
"libc",
@ -4164,7 +4164,7 @@ checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e"
dependencies = [
"crossbeam-channel",
"crossbeam-deque 0.8.1",
"crossbeam-utils 0.8.5",
"crossbeam-utils 0.8.6",
"lazy_static",
"num_cpus",
]
@ -4348,7 +4348,7 @@ dependencies = [
"base64 0.13.0",
"blake2b_simd",
"constant_time_eq",
"crossbeam-utils 0.8.5",
"crossbeam-utils 0.8.6",
]
[[package]]
@ -5960,7 +5960,7 @@ dependencies = [
name = "xulstore"
version = "0.1.0"
dependencies = [
"crossbeam-utils 0.8.5",
"crossbeam-utils 0.8.6",
"cstr",
"libc",
"log",

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"5e3414ce23940106f95102f85e643cb5bed5e8ed9027557963c728d5f46d5586","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"f6bffe3676b128afe14aaf91c972d69c37f2e5afe4e02b99a974f7b7393f4cda","build.rs":"b6ee548cb30aba0a4a7ff92379478fcf94ef246b892da8e2134ee2d9575bf08c","rust-toolchain.toml":"6bbb61302978c736b2da03e4fb40e3beab908f85d533ab46fd541e637b5f3e0f","src/backtrace.rs":"a1a52f9874f0aa1382fb404f029c6fa88e53afe38fb2417877d5711f1f2b90c9","src/chain.rs":"6edefc5f3c7d69683095862e54e3bb56faba5b3387bf2eeaed429da090007a0a","src/context.rs":"559478ae785ce913523aa21358cc1561ef4b0b95c5c87675a77890364c0162fe","src/ensure.rs":"98b2f4a7923e06cf6558b0a15f39a7c7ff3d36711e217475c6a93690cd58b7a1","src/error.rs":"33a0f6c49d2c5d08b8d027aa930be75ece822331d6e6b28db74520ea69587cbc","src/fmt.rs":"c2d4aad6ce20625a70a7c091e3087b6a2c19a4a87c7a12edb4c98978307245ea","src/kind.rs":"b21b15dbee77d50abe88684a9571b39659076465dd4b1956f366af8fdd26e95a","src/lib.rs":"f39d4684ce6ce473b585d2f9bc8b7a355cf28e5b5c936431d8072ac5c4fe94fd","src/macros.rs":"5a735a3fa919de58729be54976678c0a386e8e9af947987f17fd988c531974c7","src/ptr.rs":"f4e28bc9feba1e84160ca9d185008a51b5d72e168e6546f3e942f4258c361e19","src/wrapper.rs":"1229beca67dbd95ca77c9ecce282272acc55276c267c58cb73a75388b4693dda","tests/common/mod.rs":"f9088c2d7afafa64ff730b629272045b776bfafc2f5957508242da630635f2e1","tests/compiletest.rs":"022a8e400ef813d7ea1875b944549cee5125f6a995dc33e93b48cba3e1b57bd1","tests/drop/mod.rs":"382956f4bd3dcd1f6036efb8f11193595a7c60e0a5dbf5f2da149f1f25183abf","tests/test_autotrait.rs":"981e792db353be2f14c7a1cabe43b5f1329c168cb7679077cc2be786a0920d48","tests/test_backtrace.rs":"0e50edbb33b6bd07ba89ff3db72fb7c688ba2a4371fccdbbb20309ab02948b6a","tests/test_boxed.rs":"6b26db0e2eb72afe9af7352ea820837aab90f8d486294616dd5dc34c1b94038c","tests/test_chain.rs":"d5e90e3eba58abc60d241d3aade39e0b8d4006d9a14f3cf015d3d925160b5812","tests/test_context.rs":"8409c53b328562c11e822bd6c3cd17e0d4d50b9bbb8fc3617333fd77303a6a33","tests/test_convert.rs":"7e7a8b4772a427a911014ac4d1083f9519000e786177f898808980dd9bdfde61","tests/test_downcast.rs":"ce8438cb58a1b7f3599740c261f6ef05855127ccde20c83c82db15eaf51c57ad","tests/test_ensure.rs":"45331ef18c4c69acf4b80f5f55d2cefb55cc82f00e854b81d54c3df36a639003","tests/test_ffi.rs":"d0cb4c1d6d9154090982dee72ae3ebe05a5981f976058c3250f1c9da5a45edef","tests/test_fmt.rs":"17572596f257aac9aa2ec4620e292ca6a954128b94772bb948399fab53832e70","tests/test_macros.rs":"3f808b3050fc2b18c5b9058fe71b6b464d70e3658ff9b1daa379cd58c6874296","tests/test_repr.rs":"dbb9b04ddbe1ab31eb5331ea69f05bb3a147299da2275a3d4dcc92947b5591b9","tests/test_source.rs":"b80723cf635a4f8c4df21891b34bfab9ed2b2aa407e7a2f826d24e334cd5f88e","tests/ui/chained-comparison.rs":"6504b03d95b5acc232a7f4defc9f343b2be6733bf475fa0992e8e6545b912bd4","tests/ui/chained-comparison.stderr":"7f1d0a8c251b0ede2d30b3087ec157fc660945c97a642c4a5acf5a14ec58de34","tests/ui/empty-ensure.rs":"ab5bf37c846a0d689f26ce9257a27228411ed64154f9c950f1602d88a355d94b","tests/ui/empty-ensure.stderr":"0fa39de3edadb86382d8cd147c2640771e080338be2f4b067650258e3150f181","tests/ui/no-impl.rs":"fab6cbf2f6ea510b86f567dfb3b7c31250a9fd71ae5d110dbb9188be569ec593","tests/ui/no-impl.stderr":"9d2d9cdf441f1c4a0ccbc4a7433013166425b98cd8dd8738381e8fd070c1aed9","tests/ui/temporary-value.rs":"4dcc96271b2403e6372cf4cfc813445e5ce4365fc6e156b6bc38274098499a70","tests/ui/temporary-value.stderr":"64e448b6759cf51d41b1360307a638452bbe53ffa706f93e4a503b712d7b89a8","tests/ui/wrong-interpolation.rs":"9c44d4674c2dccd27b9dedd03341346ec02d993b41793ee89b5755202e7e367e","tests/ui/wrong-interpolation.stderr":"301e60e2eb9401782c7dc0b3580613a4cb2aafd4cc8065734a630a62e1161aa5"},"package":"8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203"}
{"files":{"Cargo.toml":"ce2fb7f23073f4f0bd58bae44baab86fa6c3d3595f32d28b410ec52394b3f64c","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"f6bffe3676b128afe14aaf91c972d69c37f2e5afe4e02b99a974f7b7393f4cda","build.rs":"b6ee548cb30aba0a4a7ff92379478fcf94ef246b892da8e2134ee2d9575bf08c","rust-toolchain.toml":"6bbb61302978c736b2da03e4fb40e3beab908f85d533ab46fd541e637b5f3e0f","src/backtrace.rs":"5a60bd1fe1717c044c7ab34c062ce6651c0cb08596a5878e391c2755ecac07f9","src/chain.rs":"6edefc5f3c7d69683095862e54e3bb56faba5b3387bf2eeaed429da090007a0a","src/context.rs":"559478ae785ce913523aa21358cc1561ef4b0b95c5c87675a77890364c0162fe","src/ensure.rs":"98b2f4a7923e06cf6558b0a15f39a7c7ff3d36711e217475c6a93690cd58b7a1","src/error.rs":"33a0f6c49d2c5d08b8d027aa930be75ece822331d6e6b28db74520ea69587cbc","src/fmt.rs":"c2d4aad6ce20625a70a7c091e3087b6a2c19a4a87c7a12edb4c98978307245ea","src/kind.rs":"b21b15dbee77d50abe88684a9571b39659076465dd4b1956f366af8fdd26e95a","src/lib.rs":"330286a28b4d4da255db38bc267da17fb03f2333ea26684f82124973ffcaea43","src/macros.rs":"5a735a3fa919de58729be54976678c0a386e8e9af947987f17fd988c531974c7","src/ptr.rs":"f4e28bc9feba1e84160ca9d185008a51b5d72e168e6546f3e942f4258c361e19","src/wrapper.rs":"1229beca67dbd95ca77c9ecce282272acc55276c267c58cb73a75388b4693dda","tests/common/mod.rs":"f9088c2d7afafa64ff730b629272045b776bfafc2f5957508242da630635f2e1","tests/compiletest.rs":"022a8e400ef813d7ea1875b944549cee5125f6a995dc33e93b48cba3e1b57bd1","tests/drop/mod.rs":"08c3e553c1cc0d2dbd936fc45f4b5b1105057186affd6865e8d261e05f0f0646","tests/test_autotrait.rs":"981e792db353be2f14c7a1cabe43b5f1329c168cb7679077cc2be786a0920d48","tests/test_backtrace.rs":"0e50edbb33b6bd07ba89ff3db72fb7c688ba2a4371fccdbbb20309ab02948b6a","tests/test_boxed.rs":"6b26db0e2eb72afe9af7352ea820837aab90f8d486294616dd5dc34c1b94038c","tests/test_chain.rs":"d5e90e3eba58abc60d241d3aade39e0b8d4006d9a14f3cf015d3d925160b5812","tests/test_context.rs":"8409c53b328562c11e822bd6c3cd17e0d4d50b9bbb8fc3617333fd77303a6a33","tests/test_convert.rs":"7e7a8b4772a427a911014ac4d1083f9519000e786177f898808980dd9bdfde61","tests/test_downcast.rs":"ce8438cb58a1b7f3599740c261f6ef05855127ccde20c83c82db15eaf51c57ad","tests/test_ensure.rs":"f8bc5174219da947e6292891864f35307d5c400fd5690f51d574edaa5e39b8a4","tests/test_ffi.rs":"d0cb4c1d6d9154090982dee72ae3ebe05a5981f976058c3250f1c9da5a45edef","tests/test_fmt.rs":"17572596f257aac9aa2ec4620e292ca6a954128b94772bb948399fab53832e70","tests/test_macros.rs":"3f808b3050fc2b18c5b9058fe71b6b464d70e3658ff9b1daa379cd58c6874296","tests/test_repr.rs":"dbb9b04ddbe1ab31eb5331ea69f05bb3a147299da2275a3d4dcc92947b5591b9","tests/test_source.rs":"b80723cf635a4f8c4df21891b34bfab9ed2b2aa407e7a2f826d24e334cd5f88e","tests/ui/chained-comparison.rs":"6504b03d95b5acc232a7f4defc9f343b2be6733bf475fa0992e8e6545b912bd4","tests/ui/chained-comparison.stderr":"7f1d0a8c251b0ede2d30b3087ec157fc660945c97a642c4a5acf5a14ec58de34","tests/ui/empty-ensure.rs":"ab5bf37c846a0d689f26ce9257a27228411ed64154f9c950f1602d88a355d94b","tests/ui/empty-ensure.stderr":"0fa39de3edadb86382d8cd147c2640771e080338be2f4b067650258e3150f181","tests/ui/no-impl.rs":"fab6cbf2f6ea510b86f567dfb3b7c31250a9fd71ae5d110dbb9188be569ec593","tests/ui/no-impl.stderr":"9d2d9cdf441f1c4a0ccbc4a7433013166425b98cd8dd8738381e8fd070c1aed9","tests/ui/temporary-value.rs":"4dcc96271b2403e6372cf4cfc813445e5ce4365fc6e156b6bc38274098499a70","tests/ui/temporary-value.stderr":"64e448b6759cf51d41b1360307a638452bbe53ffa706f93e4a503b712d7b89a8","tests/ui/wrong-interpolation.rs":"9c44d4674c2dccd27b9dedd03341346ec02d993b41793ee89b5755202e7e367e","tests/ui/wrong-interpolation.stderr":"301e60e2eb9401782c7dc0b3580613a4cb2aafd4cc8065734a630a62e1161aa5"},"package":"84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3"}

4
third_party/rust/anyhow/Cargo.toml поставляемый
Просмотреть файл

@ -13,7 +13,7 @@
edition = "2018"
rust-version = "1.38"
name = "anyhow"
version = "1.0.51"
version = "1.0.52"
authors = ["David Tolnay <dtolnay@gmail.com>"]
description = "Flexible concrete Error type built on std::error::Error"
documentation = "https://docs.rs/anyhow"
@ -32,7 +32,7 @@ version = "0.3"
default-features = false
[dev-dependencies.rustversion]
version = "1.0"
version = "1.0.6"
[dev-dependencies.syn]
version = "1.0"

4
third_party/rust/anyhow/src/backtrace.rs поставляемый
Просмотреть файл

@ -182,7 +182,7 @@ mod capture {
impl Backtrace {
fn enabled() -> bool {
static ENABLED: AtomicUsize = AtomicUsize::new(0);
match ENABLED.load(Ordering::SeqCst) {
match ENABLED.load(Ordering::Relaxed) {
0 => {}
1 => return false,
_ => return true,
@ -194,7 +194,7 @@ mod capture {
None => false,
},
};
ENABLED.store(enabled as usize + 1, Ordering::SeqCst);
ENABLED.store(enabled as usize + 1, Ordering::Relaxed);
enabled
}

3
third_party/rust/anyhow/src/lib.rs поставляемый
Просмотреть файл

@ -210,7 +210,7 @@
//! will require an explicit `.map_err(Error::msg)` when working with a
//! non-Anyhow error type inside a function that returns Anyhow's error type.
#![doc(html_root_url = "https://docs.rs/anyhow/1.0.51")]
#![doc(html_root_url = "https://docs.rs/anyhow/1.0.52")]
#![cfg_attr(backtrace, feature(backtrace))]
#![cfg_attr(doc_cfg, feature(doc_cfg))]
#![cfg_attr(not(feature = "std"), no_std)]
@ -225,6 +225,7 @@
clippy::needless_doctest_main,
clippy::new_ret_no_self,
clippy::redundant_else,
clippy::return_self_not_must_use,
clippy::unused_self,
clippy::used_underscore_binding,
clippy::wildcard_imports,

7
third_party/rust/anyhow/tests/drop/mod.rs поставляемый
Просмотреть файл

@ -2,8 +2,7 @@
use std::error::Error as StdError;
use std::fmt::{self, Display};
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering::SeqCst;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
#[derive(Debug)]
@ -19,7 +18,7 @@ impl Flag {
}
pub fn get(&self) -> bool {
self.atomic.load(SeqCst)
self.atomic.load(Ordering::Relaxed)
}
}
@ -48,7 +47,7 @@ impl Display for DetectDrop {
impl Drop for DetectDrop {
fn drop(&mut self) {
let already_dropped = self.has_dropped.atomic.swap(true, SeqCst);
let already_dropped = self.has_dropped.atomic.swap(true, Ordering::Relaxed);
assert!(!already_dropped);
}
}

63
third_party/rust/anyhow/tests/test_ensure.rs поставляемый
Просмотреть файл

@ -5,6 +5,7 @@
clippy::items_after_statements,
clippy::let_and_return,
clippy::let_underscore_drop,
clippy::logic_bug,
clippy::match_bool,
clippy::never_loop,
clippy::redundant_closure_call,
@ -45,13 +46,15 @@ impl<T> Trait for T {}
fn assert_err<T: Debug>(result: impl FnOnce() -> Result<T>, expected: &'static str) {
let actual = result().unwrap_err().to_string();
let mut accepted_alternatives = expected.split('\n');
let expected = accepted_alternatives.next_back().unwrap();
if accepted_alternatives.any(|alternative| actual == alternative) {
return;
// In general different rustc versions will format the interpolated lhs and
// rhs $:expr fragment with insignificant differences in whitespace or
// punctuation, so we check the message in full against nightly and do just
// a cursory test on older toolchains.
if rustversion::cfg!(nightly) && !cfg!(miri) {
assert_eq!(actual, expected);
} else {
assert_eq!(actual.contains(" vs "), expected.contains(" vs "));
}
assert_eq!(actual, expected);
}
#[test]
@ -98,7 +101,7 @@ fn test_low_precedence_binary_operator() {
let test = || Ok(ensure!(while false == true && false {} < ()));
assert_err(
test,
"Condition failed: `while false == true && false { } < ()` (() vs ())",
"Condition failed: `while false == true && false {} < ()` (() vs ())",
);
}
@ -145,41 +148,41 @@ fn test_unary() {
fn test_if() {
#[rustfmt::skip]
let test = || Ok(ensure!(if false {}.t(1) == 2));
assert_err(test, "Condition failed: `if false { }.t(1) == 2` (1 vs 2)");
assert_err(test, "Condition failed: `if false {}.t(1) == 2` (1 vs 2)");
#[rustfmt::skip]
let test = || Ok(ensure!(if false {} else {}.t(1) == 2));
assert_err(
test,
"Condition failed: `if false { } else { }.t(1) == 2` (1 vs 2)",
"Condition failed: `if false {} else {}.t(1) == 2` (1 vs 2)",
);
#[rustfmt::skip]
let test = || Ok(ensure!(if false {} else if false {}.t(1) == 2));
assert_err(
test,
"Condition failed: `if false { } else if false { }.t(1) == 2` (1 vs 2)",
"Condition failed: `if false {} else if false {}.t(1) == 2` (1 vs 2)",
);
#[rustfmt::skip]
let test = || Ok(ensure!(if let 1 = 2 {}.t(1) == 2));
assert_err(
test,
"Condition failed: `if let 1 = 2 { }.t(1) == 2` (1 vs 2)",
"Condition failed: `if let 1 = 2 {}.t(1) == 2` (1 vs 2)",
);
#[rustfmt::skip]
let test = || Ok(ensure!(if let 1 | 2 = 2 {}.t(1) == 2));
assert_err(
test,
"Condition failed: `if let 1 | 2 = 2 { }.t(1) == 2` (1 vs 2)",
"Condition failed: `if let 1 | 2 = 2 {}.t(1) == 2` (1 vs 2)",
);
#[rustfmt::skip]
let test = || Ok(ensure!(if let | 1 | 2 = 2 {}.t(1) == 2));
assert_err(
test,
"Condition failed: `if let 1 | 2 = 2 { }.t(1) == 2` (1 vs 2)",
"Condition failed: `if let 1 | 2 = 2 {}.t(1) == 2` (1 vs 2)",
);
}
@ -189,53 +192,49 @@ fn test_loop() {
let test = || Ok(ensure!(1 + loop { break 1 } == 1));
assert_err(
test,
// 1.54 puts a double space after loop
"Condition failed: `1 + loop { break 1 } == 1` (2 vs 1)\n\
Condition failed: `1 + loop { break 1 } == 1` (2 vs 1)",
"Condition failed: `1 + loop { break 1 } == 1` (2 vs 1)",
);
#[rustfmt::skip]
let test = || Ok(ensure!(1 + 'a: loop { break 'a 1 } == 1));
assert_err(
test,
// 1.54 puts a double space after loop
"Condition failed: `1 + 'a: loop { break 'a 1 } == 1` (2 vs 1)\n\
Condition failed: `1 + 'a: loop { break 'a 1 } == 1` (2 vs 1)",
"Condition failed: `1 + 'a: loop { break 'a 1 } == 1` (2 vs 1)",
);
#[rustfmt::skip]
let test = || Ok(ensure!(while false {}.t(1) == 2));
assert_err(
test,
"Condition failed: `while false { }.t(1) == 2` (1 vs 2)",
"Condition failed: `while false {}.t(1) == 2` (1 vs 2)",
);
#[rustfmt::skip]
let test = || Ok(ensure!(while let None = Some(1) {}.t(1) == 2));
assert_err(
test,
"Condition failed: `while let None = Some(1) { }.t(1) == 2` (1 vs 2)",
"Condition failed: `while let None = Some(1) {}.t(1) == 2` (1 vs 2)",
);
#[rustfmt::skip]
let test = || Ok(ensure!(for _x in iter::once(0) {}.t(1) == 2));
assert_err(
test,
"Condition failed: `for _x in iter::once(0) { }.t(1) == 2` (1 vs 2)",
"Condition failed: `for _x in iter::once(0) {}.t(1) == 2` (1 vs 2)",
);
#[rustfmt::skip]
let test = || Ok(ensure!(for | _x in iter::once(0) {}.t(1) == 2));
assert_err(
test,
"Condition failed: `for _x in iter::once(0) { }.t(1) == 2` (1 vs 2)",
"Condition failed: `for _x in iter::once(0) {}.t(1) == 2` (1 vs 2)",
);
#[rustfmt::skip]
let test = || Ok(ensure!(for true | false in iter::empty() {}.t(1) == 2));
assert_err(
test,
"Condition failed: `for true | false in iter::empty() { }.t(1) == 2` (1 vs 2)",
"Condition failed: `for true | false in iter::empty() {}.t(1) == 2` (1 vs 2)",
);
}
@ -264,13 +263,13 @@ fn test_atom() {
let test = || Ok(ensure!(S + async { 1 } == true));
assert_err(
test,
"Condition failed: `S + async { 1 } == true` (false vs true)",
"Condition failed: `S + async { 1 } == true` (false vs true)",
);
let test = || Ok(ensure!(S + async move { 1 } == true));
assert_err(
test,
"Condition failed: `S + async move { 1 } == true` (false vs true)",
"Condition failed: `S + async move { 1 } == true` (false vs true)",
);
let x = &1;
@ -381,7 +380,7 @@ fn test_macro() {
let test = || Ok(ensure!(stringify! {} != ""));
assert_err(
test,
"Condition failed: `stringify! { } != \"\"` (\"\" vs \"\")",
"Condition failed: `stringify! {} != \"\"` (\"\" vs \"\")",
);
}
@ -529,7 +528,7 @@ fn test_as() {
let test = || Ok(ensure!(f as for<'a> fn() as usize * 0 != 0));
assert_err(
test,
"Condition failed: `f as for<'a>fn() as usize * 0 != 0` (0 vs 0)",
"Condition failed: `f as for<'a>fn() as usize * 0 != 0` (0 vs 0)", // FIXME
);
let test = || Ok(ensure!(f as unsafe fn() as usize * 0 != 0));
@ -614,7 +613,7 @@ fn test_pat() {
let test = || Ok(ensure!(if let -1..=1 = 0 { 0 } else { 1 } == 1));
assert_err(
test,
"Condition failed: `if let -1 ..=1 = 0 { 0 } else { 1 } == 1` (0 vs 1)",
"Condition failed: `if let -1 ..=1 = 0 { 0 } else { 1 } == 1` (0 vs 1)", // FIXME
);
let test = || Ok(ensure!(if let &0 = &0 { 0 } else { 1 } == 1));
@ -657,13 +656,13 @@ fn test_pat() {
let test = || Ok(ensure!(if let P::<u8> {} = p { 0 } else { 1 } == 1));
assert_err(
test,
"Condition failed: `if let P::<u8> { } = p { 0 } else { 1 } == 1` (0 vs 1)",
"Condition failed: `if let P::<u8> { } = p { 0 } else { 1 } == 1` (0 vs 1)", // FIXME
);
let test = || Ok(ensure!(if let ::std::marker::PhantomData = p {} != ()));
assert_err(
test,
"Condition failed: `if let ::std::marker::PhantomData = p { } != ()` (() vs ())",
"Condition failed: `if let ::std::marker::PhantomData = p {} != ()` (() vs ())",
);
let test = || Ok(ensure!(if let <S as Trait>::V = 0 { 0 } else { 1 } == 1));
@ -675,7 +674,7 @@ fn test_pat() {
let test = || Ok(ensure!(for _ in iter::once(()) {} != ()));
assert_err(
test,
"Condition failed: `for _ in iter::once(()) { } != ()` (() vs ())",
"Condition failed: `for _ in iter::once(()) {} != ()` (() vs ())",
);
let test = || Ok(ensure!(if let stringify!(x) = "x" { 0 } else { 1 } == 1));

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"fda2e0dc95a93f95edaa7dfdf9b7323593214c1b9e165789cd8b8e6057349ecb","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"b733a7cddbdc409fcd5fb8eff5fe1d5692b6d1e0364568366a69bb1dd68e232c","build.rs":"e2ca6b6c6f18d5d47cb662083856d1399946bc41a272b30231c31ae8317a3ed0","src/args.rs":"6eed5497db91752b3aae597943c39e769f60406b37055304e69e4699f1f87b15","src/expand.rs":"231d1e732f295949939583df7169f49f950317679e7415ee6b5d38b8414f8b7b","src/lib.rs":"51cd49b85c0a7662ef32f30631f1f6a2ce448f18e951725b9d13227b5a596d3e","src/lifetime.rs":"4b94740e2847ef8df128a25d264f0a1bc1d1723ea107fc53849322b98f1e6927","src/parse.rs":"cd9032fe2c6dcf41050b3a59b9fb98eb9700a29bbe2fa011ee2854014c1666b7","src/receiver.rs":"31f5ff929bb6ac061ca3f44d4efac1ca0c60273d54ef8f8f92234a69829dc88d","tests/compiletest.rs":"0a52a44786aea1c299c695bf948b2ed2081e4cc344e5c2cadceab4eb03d0010d","tests/executor/mod.rs":"3cf48614288715f625514a73ae642f649c2635a402a3ad90278bbee116a7234c","tests/test.rs":"8a60ea2181287bfd42bcc73df1d157398f202f60991ec91eb906029e3a1ae88b","tests/ui/bare-trait-object.rs":"4546e8bd6682de11920fa4c768295fed61954484ef0550dfadbc5677b77f29a5","tests/ui/bare-trait-object.stderr":"fd6f80e2cae790f6370c537eaabedb17e9ff06c2b1f056d3d7071ed7f021f831","tests/ui/delimiter-span.rs":"97edf38c804d5e0d4cef6f040dee113d78ff76b08bf8c49586b803caa3ce7f40","tests/ui/delimiter-span.stderr":"f3c32ae57ead984ac985641bd07f50a894b572d6b8b8269556cf606f34d05101","tests/ui/lifetime-span.rs":"263de0b98abd0772fe9dc73ced1a71a3b85efb90d2b208226fe35ab9378c5e5a","tests/ui/lifetime-span.stderr":"1e1cbcbbfded1da0a252666f2077d806d11e16fccea825c7d58805c1d88a9d58","tests/ui/missing-body.rs":"d06c0da8c6044e7c790b924136f167e2edc0d0d3fa01f23521f3f08ca605929b","tests/ui/missing-body.stderr":"636a03cc42933b59d73032ce6cea862e33c16efb9c7fe7f27749247998bc9f23","tests/ui/must-use.rs":"75090c7df984df0996464337f60371d198bd0caf3f9f44b10d1e131f15fd4fca","tests/ui/must-use.stderr":"e6cb190e02f0226df6444065aaca3051f7db8ae599bba18a685155c52bb799b6","tests/ui/self-span.rs":"67ddde05907d7014bfb3f2c63d427b1d72d6c4369a9108a4335dac6bee5832b2","tests/ui/self-span.stderr":"590ba1db336f57133b66b83a576afa6f96f2201147b9c90eea4bdc84b966b19c","tests/ui/send-not-implemented.rs":"affbbe8bc9c3501d3db3a024e06daa9d076f1d142dba290c7aa1ea119daebd19","tests/ui/send-not-implemented.stderr":"63ed733b35b71f29ff0e863d287049e831dd0923978d16f5679ebd4d9d1c6d69","tests/ui/unreachable.rs":"7905c3fd0115753d18d64e12c39f42f3abec7a41b02572ea009c7d93f6d7751d","tests/ui/unreachable.stderr":"1fe3a63e44a99c62c489e1994176f03c2218bf382439bc20f1f12d368fe1558a","tests/ui/unsupported-self.rs":"f7855bc39dab1fd2f533fb2e873a27c3757dcb9fb57001e4b19f58d3dda36d01","tests/ui/unsupported-self.stderr":"be1893e21e626f0f76d16799bf27ad12df304384245462515e1fa63f06a83d80"},"package":"44318e776df68115a881de9a8fd1b9e53368d7a4a5ce4cc48517da3393233a5e"}
{"files":{"Cargo.toml":"9168c83306a2940b86790578d9d72c23d70bad572bf67ad3def2c8265bd0c270","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"b733a7cddbdc409fcd5fb8eff5fe1d5692b6d1e0364568366a69bb1dd68e232c","build.rs":"e2ca6b6c6f18d5d47cb662083856d1399946bc41a272b30231c31ae8317a3ed0","src/args.rs":"6eed5497db91752b3aae597943c39e769f60406b37055304e69e4699f1f87b15","src/expand.rs":"f1002235c33fc292e6784937c2c64d6e7ba105147b9a82126c830d09b86c1059","src/lib.rs":"51cd49b85c0a7662ef32f30631f1f6a2ce448f18e951725b9d13227b5a596d3e","src/lifetime.rs":"4b94740e2847ef8df128a25d264f0a1bc1d1723ea107fc53849322b98f1e6927","src/parse.rs":"cd9032fe2c6dcf41050b3a59b9fb98eb9700a29bbe2fa011ee2854014c1666b7","src/receiver.rs":"31f5ff929bb6ac061ca3f44d4efac1ca0c60273d54ef8f8f92234a69829dc88d","tests/compiletest.rs":"0a52a44786aea1c299c695bf948b2ed2081e4cc344e5c2cadceab4eb03d0010d","tests/executor/mod.rs":"3cf48614288715f625514a73ae642f649c2635a402a3ad90278bbee116a7234c","tests/test.rs":"df12d6551ce0a8e3416f83fe92686ab2a22fb0a5dadb45499f531c8822c63c3e","tests/ui/bare-trait-object.rs":"4546e8bd6682de11920fa4c768295fed61954484ef0550dfadbc5677b77f29a5","tests/ui/bare-trait-object.stderr":"1df5569f4615620172affeaa86da629623f32a0bb15f790a10c0837bd9da27e6","tests/ui/delimiter-span.rs":"97edf38c804d5e0d4cef6f040dee113d78ff76b08bf8c49586b803caa3ce7f40","tests/ui/delimiter-span.stderr":"0f70f0bda0e86a43e6d6f6980f1ef8a1989c3e32db593bd60f920025a25728d5","tests/ui/lifetime-span.rs":"263de0b98abd0772fe9dc73ced1a71a3b85efb90d2b208226fe35ab9378c5e5a","tests/ui/lifetime-span.stderr":"21ce55872b2a6d57077ada797a5c3ae78a3d218570605a7509951b45afa212b3","tests/ui/missing-async-in-impl.rs":"5a5538d08d11c145211a92af0d8973eee8b21f33b90adda85430805bd3dbbc83","tests/ui/missing-async-in-impl.stderr":"2916bc8a51e25f4dd18eaf433b916d533943eac2c1afbee64e9a89e7b928040d","tests/ui/missing-async-in-trait.rs":"dc67241593f270233ba885df92e59164126416e68d49d8d62edc251666b5db6e","tests/ui/missing-async-in-trait.stderr":"67e66e7b19358830deff3ba01f5d701a9ae05c4e6fa9c081c49c1c75efbb7ade","tests/ui/missing-body.rs":"d06c0da8c6044e7c790b924136f167e2edc0d0d3fa01f23521f3f08ca605929b","tests/ui/missing-body.stderr":"e5ee994398bf8294324d61df02467a4229f68f4113bf5acc004851c03d66ec6a","tests/ui/must-use.rs":"75090c7df984df0996464337f60371d198bd0caf3f9f44b10d1e131f15fd4fca","tests/ui/must-use.stderr":"cd7bf2fe9023021837b2b3e8cc164ffc18900b01cf704c68cde91edd07d65dc8","tests/ui/self-span.rs":"67ddde05907d7014bfb3f2c63d427b1d72d6c4369a9108a4335dac6bee5832b2","tests/ui/self-span.stderr":"7865153d1e41ecdfa64b197901e3bda57bcda0c486bbcf11dc6e9837ceb40b29","tests/ui/send-not-implemented.rs":"affbbe8bc9c3501d3db3a024e06daa9d076f1d142dba290c7aa1ea119daebd19","tests/ui/send-not-implemented.stderr":"01e6800bcabca87306c72269e38d1eac53ef1e8ad9951a9be052b97aff16364d","tests/ui/unreachable.rs":"be0aa7cc129fe42a1fbd85e36b3f08c6a2bd16c90ed2e33fc4c50e40ce085bcd","tests/ui/unreachable.stderr":"73beb71cb74076f2cb45485271de31658cf59f4143e62daa34b9f2a8980ddfcd","tests/ui/unsupported-self.rs":"f7855bc39dab1fd2f533fb2e873a27c3757dcb9fb57001e4b19f58d3dda36d01","tests/ui/unsupported-self.stderr":"64fc5d45cb51330f0a1e85e69a28b69ddda12a109aa6a8ba3eaee1ac58d93b5f"},"package":"061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3"}

5
third_party/rust/async-trait/Cargo.toml поставляемый
Просмотреть файл

@ -11,8 +11,9 @@
[package]
edition = "2018"
rust-version = "1.39"
name = "async-trait"
version = "0.1.51"
version = "0.1.52"
authors = ["David Tolnay <dtolnay@gmail.com>"]
description = "Type erasure for async trait methods"
documentation = "https://docs.rs/async-trait"
@ -47,5 +48,5 @@ version = "0.1.14"
version = "0.1.14"
[dev-dependencies.trybuild]
version = "1.0.19"
version = "1.0.49"
features = ["diff"]

2
third_party/rust/async-trait/src/expand.rs поставляемый
Просмотреть файл

@ -125,6 +125,8 @@ fn lint_suppress_with_body() -> Attribute {
parse_quote! {
#[allow(
clippy::let_unit_value,
clippy::no_effect_underscore_binding,
clippy::shadow_same,
clippy::type_complexity,
clippy::type_repetition_in_bounds,
clippy::used_underscore_binding

13
third_party/rust/async-trait/tests/test.rs поставляемый
Просмотреть файл

@ -6,6 +6,7 @@
clippy::let_underscore_drop,
clippy::let_unit_value,
clippy::missing_panics_doc,
clippy::missing_safety_doc,
clippy::needless_return,
clippy::trivially_copy_pass_by_ref,
clippy::unused_async
@ -1376,3 +1377,15 @@ pub mod issue169 {
pub fn test(_t: &dyn Trait) {}
}
// https://github.com/dtolnay/async-trait/issues/183
pub mod issue183 {
#![deny(clippy::shadow_same)]
use async_trait::async_trait;
#[async_trait]
trait Foo {
async fn foo(_n: i32) {}
}
}

Просмотреть файл

@ -1,13 +1,13 @@
error: trait objects without an explicit `dyn` are deprecated
--> $DIR/bare-trait-object.rs:11:16
--> tests/ui/bare-trait-object.rs:11:16
|
11 | impl Trait for Send + Sync {
| ^^^^^^^^^^^ help: use `dyn`: `dyn Send + Sync`
|
note: the lint level is defined here
--> $DIR/bare-trait-object.rs:1:9
--> tests/ui/bare-trait-object.rs:1:9
|
1 | #![deny(bare_trait_objects)]
| ^^^^^^^^^^^^^^^^^^
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
= note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>

Просмотреть файл

@ -1,5 +1,5 @@
error: no rules expected the token `{`
--> $DIR/delimiter-span.rs:17:16
--> tests/ui/delimiter-span.rs:17:16
|
3 | macro_rules! picky {
| ------------------ when calling this macro
@ -8,7 +8,7 @@ error: no rules expected the token `{`
| ^ no rules expected this token in macro call
error: no rules expected the token `{`
--> $DIR/delimiter-span.rs:18:16
--> tests/ui/delimiter-span.rs:18:16
|
3 | macro_rules! picky {
| ------------------ when calling this macro

Просмотреть файл

@ -1,5 +1,5 @@
error[E0726]: implicit elided lifetime not allowed here
--> $DIR/lifetime-span.rs:12:6
--> tests/ui/lifetime-span.rs:12:6
|
12 | impl Trait for A {
| ^^^^^- help: indicate the anonymous lifetime: `<'_>`
@ -7,7 +7,7 @@ error[E0726]: implicit elided lifetime not allowed here
= note: assuming a `'static` lifetime...
error[E0107]: this trait takes 0 lifetime arguments but 1 lifetime argument was supplied
--> $DIR/lifetime-span.rs:32:10
--> tests/ui/lifetime-span.rs:32:10
|
32 | impl<'r> Trait2<'r> for B {
| ^^^^^^---- help: remove these generics
@ -15,13 +15,13 @@ error[E0107]: this trait takes 0 lifetime arguments but 1 lifetime argument was
| expected 0 lifetime arguments
|
note: trait defined here, with 0 lifetime parameters
--> $DIR/lifetime-span.rs:22:11
--> tests/ui/lifetime-span.rs:22:11
|
22 | pub trait Trait2 {
| ^^^^^^
error[E0195]: lifetime parameters or bounds on method `method` do not match the trait declaration
--> $DIR/lifetime-span.rs:13:14
--> tests/ui/lifetime-span.rs:13:14
|
8 | async fn method(&'r self);
| ---------------- lifetimes in impl do not match this method in trait
@ -30,7 +30,7 @@ error[E0195]: lifetime parameters or bounds on method `method` do not match the
| ^^^^^^^^^^^^^ lifetimes do not match method in trait
error[E0195]: lifetime parameters or bounds on method `method` do not match the trait declaration
--> $DIR/lifetime-span.rs:18:14
--> tests/ui/lifetime-span.rs:18:14
|
8 | async fn method(&'r self);
| ---------------- lifetimes in impl do not match this method in trait
@ -39,7 +39,7 @@ error[E0195]: lifetime parameters or bounds on method `method` do not match the
| ^^^^^^^^^^^^^ lifetimes do not match method in trait
error[E0195]: lifetime parameters or bounds on method `method` do not match the trait declaration
--> $DIR/lifetime-span.rs:33:14
--> tests/ui/lifetime-span.rs:33:14
|
23 | async fn method<'r>(&'r self);
| ---- lifetimes in impl do not match this method in trait

15
third_party/rust/async-trait/tests/ui/missing-async-in-impl.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,15 @@
use async_trait::async_trait;
#[async_trait]
pub trait Trait {
async fn method();
}
pub struct Struct;
#[async_trait]
impl Trait for Struct {
fn method() {}
}
fn main() {}

Просмотреть файл

@ -0,0 +1,8 @@
error[E0195]: lifetime parameters or bounds on method `method` do not match the trait declaration
--> tests/ui/missing-async-in-impl.rs:12:14
|
5 | async fn method();
| -------- lifetimes in impl do not match this method in trait
...
12 | fn method() {}
| ^ lifetimes do not match method in trait

15
third_party/rust/async-trait/tests/ui/missing-async-in-trait.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,15 @@
use async_trait::async_trait;
#[async_trait]
pub trait Trait {
fn method();
}
pub struct Struct;
#[async_trait]
impl Trait for Struct {
async fn method() {}
}
fn main() {}

Просмотреть файл

@ -0,0 +1,8 @@
error[E0195]: lifetime parameters or bounds on method `method` do not match the trait declaration
--> tests/ui/missing-async-in-trait.rs:12:14
|
5 | fn method();
| - lifetimes in impl do not match this method in trait
...
12 | async fn method() {}
| ^^^^^^^^ lifetimes do not match method in trait

Просмотреть файл

@ -1,5 +1,5 @@
error: associated function in `impl` without body
--> $DIR/missing-body.rs:12:5
--> tests/ui/missing-body.rs:12:5
|
12 | async fn f(&self);
| ^^^^^^^^^^^^^^^^^-

Просмотреть файл

@ -1,11 +1,11 @@
error: unused return value of `Interface::f` that must be used
--> $DIR/must-use.rs:18:5
--> tests/ui/must-use.rs:18:5
|
18 | Thing.f();
| ^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/must-use.rs:1:9
--> tests/ui/must-use.rs:1:9
|
1 | #![deny(unused_must_use)]
| ^^^^^^^^^^^^^^^

Просмотреть файл

@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/self-span.rs:17:21
--> tests/ui/self-span.rs:17:21
|
17 | let _: () = self;
| -- ^^^^ expected `()`, found struct `S`
@ -7,13 +7,13 @@ error[E0308]: mismatched types
| expected due to this
error: the `Self` constructor can only be used with tuple or unit structs
--> $DIR/self-span.rs:18:23
--> tests/ui/self-span.rs:18:23
|
18 | let _: Self = Self;
| ^^^^ help: use curly brackets: `Self { /* fields */ }`
error[E0308]: mismatched types
--> $DIR/self-span.rs:25:21
--> tests/ui/self-span.rs:25:21
|
25 | let _: () = self;
| -- ^^^^ expected `()`, found enum `E`
@ -21,7 +21,7 @@ error[E0308]: mismatched types
| expected due to this
error[E0533]: expected unit struct, unit variant or constant, found struct variant `Self::V`
--> $DIR/self-span.rs:26:23
--> tests/ui/self-span.rs:26:23
|
26 | let _: Self = Self::V;
| ^^^^^^^

Просмотреть файл

@ -1,5 +1,5 @@
error: future cannot be sent between threads safely
--> $DIR/send-not-implemented.rs:8:26
--> tests/ui/send-not-implemented.rs:8:26
|
8 | async fn test(&self) {
| __________________________^
@ -9,9 +9,9 @@ error: future cannot be sent between threads safely
12 | | }
| |_____^ future created by async block is not `Send`
|
= help: within `impl Future`, the trait `Send` is not implemented for `MutexGuard<'_, ()>`
= help: within `impl Future<Output = [async output]>`, the trait `Send` is not implemented for `MutexGuard<'_, ()>`
note: future is not `Send` as this value is used across an await
--> $DIR/send-not-implemented.rs:11:9
--> tests/ui/send-not-implemented.rs:11:9
|
10 | let _guard = mutex.lock().unwrap();
| ------ has type `MutexGuard<'_, ()>` which is not `Send`
@ -22,7 +22,7 @@ note: future is not `Send` as this value is used across an await
= note: required for the cast to the object type `dyn Future<Output = ()> + Send`
error: future cannot be sent between threads safely
--> $DIR/send-not-implemented.rs:14:38
--> tests/ui/send-not-implemented.rs:14:38
|
14 | async fn test_ret(&self) -> bool {
| ______________________________________^
@ -33,9 +33,9 @@ error: future cannot be sent between threads safely
19 | | }
| |_____^ future created by async block is not `Send`
|
= help: within `impl Future`, the trait `Send` is not implemented for `MutexGuard<'_, ()>`
= help: within `impl Future<Output = [async output]>`, the trait `Send` is not implemented for `MutexGuard<'_, ()>`
note: future is not `Send` as this value is used across an await
--> $DIR/send-not-implemented.rs:17:9
--> tests/ui/send-not-implemented.rs:17:9
|
16 | let _guard = mutex.lock().unwrap();
| ------ has type `MutexGuard<'_, ()>` which is not `Send`

Просмотреть файл

@ -12,8 +12,8 @@ pub trait Trait {
#[async_trait]
pub trait TraitFoo {
async fn f() {
let y = unimplemented!();
let z = y;
let _y = unimplemented!();
let _z = _y;
}
}

Просмотреть файл

@ -1,13 +1,13 @@
error: unreachable statement
--> $DIR/unreachable.rs:16:9
--> tests/ui/unreachable.rs:16:9
|
15 | let y = unimplemented!();
| ---------------- any code following this expression is unreachable
16 | let z = y;
| ^^^^^^^^^^ unreachable statement
15 | let _y = unimplemented!();
| ---------------- any code following this expression is unreachable
16 | let _z = _y;
| ^^^^^^^^^^^^ unreachable statement
|
note: the lint level is defined here
--> $DIR/unreachable.rs:1:9
--> tests/ui/unreachable.rs:1:9
|
1 | #![deny(warnings)]
| ^^^^^^^^

Просмотреть файл

@ -1,5 +1,5 @@
error: the `Self` constructor can only be used with tuple or unit structs
--> $DIR/unsupported-self.rs:11:17
--> tests/ui/unsupported-self.rs:11:17
|
11 | let _ = Self;
| ^^^^

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"1da2771067c7bb47f182c75624cec456ef99daf6882314633a2a68aefc2616ad","LICENSE-APACHE":"cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30","LICENSE-MIT":"8583712ee2b062ff3d4d6d3e16f19ff0f92bc3a0a4beeec11a81ef00146fbd4f","README.md":"28986de2e8d457e76ae3303d80094697e6ef4ad8da06a4a3178bb1b52bff63d5","src/lib.rs":"6dcb62a9279ecad8cdcfe37f383282089753e28adc0f2785ca73d50040bc89e7","src/tests.rs":"f67d17aa8faed5e3838322de9b98bb0cdc58d35fe5870e3f5c65ef1ef788966e"},"package":"9178181a7d44239c6c8eaafa8688558a2ab5fa04b8855381f2681e9591fb941b"}
{"files":{"Cargo.toml":"28a1d4b7f04f3989f856789ec569d890a91b9dfdc8775ff8cbd4e0c1b2f8f9f2","LICENSE-APACHE":"cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30","LICENSE-MIT":"8583712ee2b062ff3d4d6d3e16f19ff0f92bc3a0a4beeec11a81ef00146fbd4f","README.md":"28986de2e8d457e76ae3303d80094697e6ef4ad8da06a4a3178bb1b52bff63d5","src/lib.rs":"250d841ee01b90209c6c4ad304969de145287c6c6588850b95e6f843ec4dd579","src/tests.rs":"5e62c77cfa155fd8affa8ff3c7ea688d80bce6f4956f9956582775ae3adca1a6"},"package":"bd5bf8a17cdc06d475689f9e9226f4b5bf5610e93cf5c3010a518fe6fb0d97f5"}

11
third_party/rust/bitreader/Cargo.toml поставляемый
Просмотреть файл

@ -3,16 +3,15 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
name = "bitreader"
version = "0.3.4"
version = "0.3.5"
authors = ["Ilkka Rauta <ilkka.rauta@gmail.com>"]
description = "BitReader helps reading individual bits from a slice of bytes.\n\nYou can read \"unusual\" numbers of bits from the byte slice, for example 13 bits\nat once. The reader internally keeps track of position within the buffer.\n"
homepage = "https://github.com/irauta/bitreader"

71
third_party/rust/bitreader/src/lib.rs поставляемый
Просмотреть файл

@ -50,6 +50,7 @@
cfg_if::cfg_if!{
if #[cfg(feature = "std")] {
extern crate std;
use std::cmp::min;
use std::prelude::v1::*;
use std::fmt;
use std::error::Error;
@ -57,6 +58,7 @@ cfg_if::cfg_if!{
} else {
use core::result;
use core::fmt;
use core::cmp::min;
}
}
@ -69,6 +71,9 @@ pub struct BitReader<'a> {
/// Position from the start of the slice, counted as bits instead of bytes
position: u64,
relative_offset: u64,
/// Length this reader is allowed to read from the slice, counted as bits instead of bytes.
length: u64,
}
impl<'a> BitReader<'a> {
@ -79,6 +84,7 @@ impl<'a> BitReader<'a> {
bytes: bytes,
position: 0,
relative_offset: 0,
length: bytes.len() as u64 * 8,
}
}
@ -109,6 +115,45 @@ impl<'a> BitReader<'a> {
bytes: self.bytes,
position: self.position,
relative_offset: self.position,
length: self.length - self.position,
}
}
/// Returns a copy of current BitReader, with the difference that its position() returns
/// positions relative to the position of the original BitReader at the construction time, and
/// will not allow reading more than len bits. After construction, both readers are otherwise
// completely independent, except of course for sharing the same source data.
///
/// ```
/// use bitreader::BitReader;
/// use bitreader::BitReaderError;
///
/// let bytes = &[0b11110000, 0b00001111];
/// let mut original = BitReader::new(bytes);
/// assert_eq!(original.read_u8(4).unwrap(), 0b1111);
/// assert_eq!(original.position(), 4);
///
/// let mut relative = original.relative_reader_atmost(8);
/// assert_eq!(relative.position(), 0);
///
/// assert_eq!(original.read_u8(8).unwrap(), 0);
/// assert_eq!(relative.read_u8(8).unwrap(), 0);
///
/// assert_eq!(original.position(), 12);
/// assert_eq!(relative.position(), 8);
///
/// assert_eq!(relative.read_u8(8).unwrap_err(), BitReaderError::NotEnoughData{
/// position: 8,
/// length: 8,
/// requested: 8
/// });
/// ```
pub fn relative_reader_atmost(&self, len: u64) -> BitReader<'a> {
BitReader {
bytes: self.bytes,
position: self.position,
relative_offset: self.position,
length: min(self.length - self.position, len),
}
}
@ -130,9 +175,9 @@ impl<'a> BitReader<'a> {
let requested = output_bytes.len() as u64 * 8;
if requested > self.remaining() {
Err(BitReaderError::NotEnoughData {
position: self.position,
length: (self.bytes.len() * 8) as u64,
requested: requested,
position: self.position(),
length: self.length,
requested,
})
} else {
for byte in output_bytes.iter_mut() {
@ -221,10 +266,10 @@ impl<'a> BitReader<'a> {
/// Skip arbitrary number of bits. However, you can skip at most to the end of the byte slice.
pub fn skip(&mut self, bit_count: u64) -> Result<()> {
let end_position = self.position + bit_count;
if end_position > self.bytes.len() as u64 * 8 {
if end_position > (self.relative_offset + self.length) {
return Err(BitReaderError::NotEnoughData {
position: self.position,
length: (self.bytes.len() * 8) as u64,
position: self.position(),
length: self.length,
requested: bit_count,
});
}
@ -239,8 +284,7 @@ impl<'a> BitReader<'a> {
/// Returns the number of bits not yet read from the underlying slice.
pub fn remaining(&self) -> u64 {
let total_bits = self.bytes.len() as u64 * 8;
total_bits - self.position
self.length - self.position
}
/// Helper to make sure the "bit cursor" is exactly at the beginning of a byte, or at specific
@ -291,10 +335,10 @@ impl<'a> BitReader<'a> {
}
let start_position = self.position;
let end_position = self.position + bit_count as u64;
if end_position > self.bytes.len() as u64 * 8 {
if end_position > (self.relative_offset + self.length) {
return Err(BitReaderError::NotEnoughData {
position: self.position,
length: (self.bytes.len() * 8) as u64,
position: self.position(),
length: self.length,
requested: bit_count as u64,
});
}
@ -322,8 +366,13 @@ pub type Result<T> = result::Result<T, BitReaderError>;
pub enum BitReaderError {
/// Requested more bits than there are left in the byte slice at the current position.
NotEnoughData {
/// Current posititon in bits relative to the beginning of the reader.
position: u64,
/// Total readable length in bits of the underlaying slice.
length: u64,
/// Bits requested to be read.
requested: u64,
},
/// Requested more bits than the returned variable can hold, for example more than 8 bits when

31
third_party/rust/bitreader/src/tests.rs поставляемый
Просмотреть файл

@ -282,3 +282,34 @@ fn read_slice_too_much() {
});
assert_eq!(&output, &[0u8; 4]);
}
#[test]
fn relative_reader() {
let bytes = &[
0b0001_0010, 0b0011_0100,
];
let mut reader = BitReader::new(bytes);
assert_eq!(reader.read_u8(4).unwrap(), 0b0001);
let mut relative_reader = reader.relative_reader();
assert_eq!(reader.read_u8(4).unwrap(), 0b0010);
assert_eq!(reader.read_u8(4).unwrap(), 0b0011);
assert_eq!(reader.read_u8(4).unwrap(), 0b0100);
assert_eq!(reader.read_u8(1).unwrap_err(), BitReaderError::NotEnoughData {
position: 16,
length: 16,
requested: 1
});
assert_eq!(relative_reader.read_u8(4).unwrap(), 0b0010);
assert_eq!(relative_reader.read_u8(4).unwrap(), 0b0011);
assert_eq!(relative_reader.read_u8(4).unwrap(), 0b0100);
assert_eq!(relative_reader.read_u8(1).unwrap_err(), BitReaderError::NotEnoughData {
position: 12,
length: 12,
requested: 1
});
}

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"648c10063fa1a16a961df45f194f50982bdf3d41d04586a48d2cc6d69e0252c1","README.md":"2253eba78d5af06642073c5dfd41253fb8be73d3a0e823bc3d7642c9d0ad0c6c","src/avx2.rs":"a97ec761e4e7f70ff6311f4c1e67cb5136ac66cfc51bc49525b81f9e23814d81","src/blake2bp.rs":"83577d4a22db3b92030d9bd4563aa9ad440f23c64a6ad5f10a9d709f22d50589","src/guts.rs":"1189cab87b18eaaf2abd5bcb3d7d799c75401a312cee6f1f65fdaad30203eb6f","src/lib.rs":"67723a3abc30dc7f3d488f434ced884b5ce962a807991c8f1cc9940df869c342","src/many.rs":"60d07e4d7ad63949fb5432ad05f7c6a525a3eee39d325f7d4e65e901b466be95","src/portable.rs":"c47baa15b311bc95d49f3d189111fe45756fb7d623a1f48f0050ae591817aedf","src/sse41.rs":"7a644b1056b804ada9ddc7586552a4a5c769e576d610ffe7ec74065f7eaff491","src/test.rs":"1685eec6fedc30fca1332cbb78c85e6c9b56eca962b6c6343c91ba69eefac754"},"package":"b83b7baab1e671718d78204225800d6b170e648188ac7dc992e9d6bddf87d0c0"}
{"files":{"Cargo.toml":"b79e2347297dee32b9483747ee3cf145bd60e8c9d14cc02929287dabde4685ff","README.md":"b90c7a163a0fbff29e2c049953968c8cbfe8aa616d7e36775f0a565761dcc671","src/avx2.rs":"b79f36e3a7442d241e3fdf2ec159866aea31b78883660a63cdc9b1a262f18d10","src/blake2bp.rs":"83577d4a22db3b92030d9bd4563aa9ad440f23c64a6ad5f10a9d709f22d50589","src/guts.rs":"1189cab87b18eaaf2abd5bcb3d7d799c75401a312cee6f1f65fdaad30203eb6f","src/lib.rs":"b0404c81988e4de8d8864437c512937d9e888c681ef4739ef2d5db1650bd8766","src/many.rs":"60d07e4d7ad63949fb5432ad05f7c6a525a3eee39d325f7d4e65e901b466be95","src/portable.rs":"a274acd298a394c014096a8214a0dc1db7439d1e920bd2ad75707fadcc501e10","src/sse41.rs":"58e9e2ec97d266e9fb4cfa874f8cfcf5ee046911837824ceea4b99cd4007560b","src/test.rs":"1685eec6fedc30fca1332cbb78c85e6c9b56eca962b6c6343c91ba69eefac754"},"package":"afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587"}

4
third_party/rust/blake2b_simd/Cargo.toml поставляемый
Просмотреть файл

@ -13,11 +13,12 @@
[package]
edition = "2018"
name = "blake2b_simd"
version = "0.5.9"
version = "0.5.11"
authors = ["Jack O'Connor"]
description = "a pure Rust BLAKE2b implementation with dynamic SIMD"
documentation = "https://docs.rs/blake2b_simd"
readme = "README.md"
keywords = ["blake2b", "blake2bp", "blake2"]
license = "MIT"
repository = "https://github.com/oconnor663/blake2_simd"
[dependencies.arrayref]
@ -33,3 +34,4 @@ version = "0.1.3"
[features]
default = ["std"]
std = []
uninline_portable = []

2
third_party/rust/blake2b_simd/README.md поставляемый
Просмотреть файл

@ -1,4 +1,4 @@
# blake2b_simd [![GitHub](https://img.shields.io/github/tag/oconnor663/blake2_simd.svg?label=GitHub)](https://github.com/oconnor663/blake2_simd) [![crates.io](https://img.shields.io/crates/v/blake2b_simd.svg)](https://crates.io/crates/blake2b_simd) [![Build Status](https://travis-ci.org/oconnor663/blake2_simd.svg?branch=master)](https://travis-ci.org/oconnor663/blake2_simd)
# blake2b_simd [![GitHub](https://img.shields.io/github/tag/oconnor663/blake2_simd.svg?label=GitHub)](https://github.com/oconnor663/blake2_simd) [![crates.io](https://img.shields.io/crates/v/blake2b_simd.svg)](https://crates.io/crates/blake2b_simd) [![Actions Status](https://github.com/oconnor663/blake2_simd/workflows/tests/badge.svg)](https://github.com/oconnor663/blake2_simd/actions)
An implementation of the BLAKE2b and BLAKE2bp hash functions. See also
[`blake2s_simd`](../blake2s).

25
third_party/rust/blake2b_simd/src/avx2.rs поставляемый
Просмотреть файл

@ -74,32 +74,33 @@ macro_rules! _MM_SHUFFLE {
};
}
// These rotations are the "simple version". For the "complicated version", see
// https://github.com/sneves/blake2-avx2/blob/b3723921f668df09ece52dcd225a36d4a4eea1d9/blake2b-common.h#L43-L46.
// For a discussion of the tradeoffs, see
// https://github.com/sneves/blake2-avx2/pull/5. In short:
// - Due to an LLVM bug (https://bugs.llvm.org/show_bug.cgi?id=44379), this
// version performs better on recent x86 chips.
// - LLVM is able to optimize this version to AVX-512 rotation instructions
// when those are enabled.
#[inline(always)]
unsafe fn rot32(x: __m256i) -> __m256i {
_mm256_shuffle_epi32(x, _MM_SHUFFLE!(2, 3, 0, 1))
_mm256_or_si256(_mm256_srli_epi64(x, 32), _mm256_slli_epi64(x, 64 - 32))
}
#[inline(always)]
unsafe fn rot24(x: __m256i) -> __m256i {
let rotate24 = _mm256_setr_epi8(
3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10, 3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13,
14, 15, 8, 9, 10,
);
_mm256_shuffle_epi8(x, rotate24)
_mm256_or_si256(_mm256_srli_epi64(x, 24), _mm256_slli_epi64(x, 64 - 24))
}
#[inline(always)]
unsafe fn rot16(x: __m256i) -> __m256i {
let rotate16 = _mm256_setr_epi8(
2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9, 2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12,
13, 14, 15, 8, 9,
);
_mm256_shuffle_epi8(x, rotate16)
_mm256_or_si256(_mm256_srli_epi64(x, 16), _mm256_slli_epi64(x, 64 - 16))
}
#[inline(always)]
unsafe fn rot63(x: __m256i) -> __m256i {
_mm256_or_si256(_mm256_srli_epi64(x, 63), add(x, x))
_mm256_or_si256(_mm256_srli_epi64(x, 63), _mm256_slli_epi64(x, 64 - 63))
}
#[inline(always)]

2
third_party/rust/blake2b_simd/src/lib.rs поставляемый
Просмотреть файл

@ -1,4 +1,4 @@
//! [![GitHub](https://img.shields.io/github/tag/oconnor663/blake2_simd.svg?label=GitHub)](https://github.com/oconnor663/blake2_simd) [![crates.io](https://img.shields.io/crates/v/blake2b_simd.svg)](https://crates.io/crates/blake2b_simd) [![Build Status](https://travis-ci.org/oconnor663/blake2_simd.svg?branch=master)](https://travis-ci.org/oconnor663/blake2_simd)
//! [![GitHub](https://img.shields.io/github/tag/oconnor663/blake2_simd.svg?label=GitHub)](https://github.com/oconnor663/blake2_simd) [![crates.io](https://img.shields.io/crates/v/blake2b_simd.svg)](https://crates.io/crates/blake2b_simd) [![Actions Status](https://github.com/oconnor663/blake2_simd/workflows/tests/badge.svg)](https://github.com/oconnor663/blake2_simd/actions)
//!
//! An implementation of the BLAKE2b and BLAKE2bp hash functions. See also
//! [`blake2s_simd`](https://docs.rs/blake2s_simd).

Просмотреть файл

@ -23,7 +23,9 @@ fn g(v: &mut [Word; 16], a: usize, b: usize, c: usize, d: usize, x: Word, y: Wor
v[b] = (v[b] ^ v[c]).rotate_right(63);
}
#[inline(always)]
// This is too much inlining for some small chips like ARM Cortex-M0, so the
// uninline_portable feature is provided to disable it.
#[cfg_attr(not(feature = "uninline_portable"), inline(always))]
fn round(r: usize, m: &[Word; 16], v: &mut [Word; 16]) {
// Select the message schedule based on the round.
let s = SIGMA[r];

19
third_party/rust/blake2b_simd/src/sse41.rs поставляемый
Просмотреть файл

@ -70,26 +70,33 @@ macro_rules! _MM_SHUFFLE {
};
}
// These rotations are the "simple version". For the "complicated version", see
// https://github.com/sneves/blake2-avx2/blob/b3723921f668df09ece52dcd225a36d4a4eea1d9/blake2b-common.h#L43-L46.
// For a discussion of the tradeoffs, see
// https://github.com/sneves/blake2-avx2/pull/5. In short:
// - Due to an LLVM bug (https://bugs.llvm.org/show_bug.cgi?id=44379), this
// version performs better on recent x86 chips.
// - LLVM is able to optimize this version to AVX-512 rotation instructions
// when those are enabled.
#[inline(always)]
unsafe fn rot32(x: __m128i) -> __m128i {
_mm_shuffle_epi32(x, _MM_SHUFFLE!(2, 3, 0, 1))
_mm_or_si128(_mm_srli_epi64(x, 32), _mm_slli_epi64(x, 64 - 32))
}
#[inline(always)]
unsafe fn rot24(x: __m128i) -> __m128i {
let rotate24 = _mm_setr_epi8(3, 4, 5, 6, 7, 0, 1, 2, 11, 12, 13, 14, 15, 8, 9, 10);
_mm_shuffle_epi8(x, rotate24)
_mm_or_si128(_mm_srli_epi64(x, 24), _mm_slli_epi64(x, 64 - 24))
}
#[inline(always)]
unsafe fn rot16(x: __m128i) -> __m128i {
let rotate16 = _mm_setr_epi8(2, 3, 4, 5, 6, 7, 0, 1, 10, 11, 12, 13, 14, 15, 8, 9);
_mm_shuffle_epi8(x, rotate16)
_mm_or_si128(_mm_srli_epi64(x, 16), _mm_slli_epi64(x, 64 - 16))
}
#[inline(always)]
unsafe fn rot63(x: __m128i) -> __m128i {
_mm_or_si128(_mm_srli_epi64(x, 63), add(x, x))
_mm_or_si128(_mm_srli_epi64(x, 63), _mm_slli_epi64(x, 64 - 63))
}
#[inline(always)]

Просмотреть файл

@ -1 +1 @@
{"files":{"CHANGELOG.md":"fb807cac318c99faa6fe40bcb6ddefd867c2048b9f2badd813281ddc808191b8","Cargo.toml":"74ed9ce9af6ed0be99c388989ab7e919ca1272fdd7e8a0d223506c790a74f1d5","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"65f94e99ddaf4f5d1782a6dae23f35d4293a9a01444a13135a6887017d353cee","README.md":"84d13918b74c4175683118042305b0a4ff90333da9abf214bcf46d9b546ae319","README.tpl":"ec385000e14590a306855e7893daed0168102f33166bdc1e5cf5fa5599dac03f","src/alloc.rs":"ab0f23fa11c26efdd8f0596ebdf0e3faa75d097881fb59639b0fb23340c106bc","src/boxed.rs":"d18d363677a97a73225cb5c5b90e6187f7b5aae93979a41e40417fdd5a3f9975","src/collections/collect_in.rs":"243799901b950687d6e78220958cfb3484faefefafd5892e03d1564617842812","src/collections/mod.rs":"0fa36a7a5f2b5916b8e3bf4e2804e87c5f7716c87c719a9ab465d377e6272170","src/collections/raw_vec.rs":"11395868cfd0802fab3fe43417751a5755abb516136923e6d8fdbc2f0ff49d19","src/collections/str/lossy.rs":"c5d62b16e01071e2a574ae41ef6693ad12f1e6c786c5d38f7a13ebd6cb23c088","src/collections/str/mod.rs":"d82a8bd417fbf52a589d89a16ea2a0ac4f6ac920c3976ab1f5b6ac0c8493c4f2","src/collections/string.rs":"d4e6c74d7431fa2548ac10290afef6bcdefbf110c6343f0c0244306c11370b8c","src/collections/vec.rs":"8f445224c914c7a4f532636798f2b6ac254e650aa58aa57bd61aee1003d7f6af","src/lib.rs":"05bee63bd4bbfcf09a31b6511b5ec3f56ea1e973d079b398ff15d77be9a13d4a"},"package":"8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c"}
{"files":{"CHANGELOG.md":"31820be449d15a59a3fd124c89c5c5108bd8934fbd1c11d8d31cca3f9b082aee","Cargo.toml":"9a34d33f35a8271f6fed49f54b096ed9dcf80dd899f60205cf58962529abb4b9","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"65f94e99ddaf4f5d1782a6dae23f35d4293a9a01444a13135a6887017d353cee","README.md":"9a3b4407bab9fdf0f4a2acf5c2d3876f4c78fd25f1b8159462f07343a234fc8e","src/alloc.rs":"ab0f23fa11c26efdd8f0596ebdf0e3faa75d097881fb59639b0fb23340c106bc","src/boxed.rs":"a0dcc1b5691e4a445f35fe84be46a938515dfdca1651396b880682547ae91292","src/collections/collect_in.rs":"243799901b950687d6e78220958cfb3484faefefafd5892e03d1564617842812","src/collections/mod.rs":"0fa36a7a5f2b5916b8e3bf4e2804e87c5f7716c87c719a9ab465d377e6272170","src/collections/raw_vec.rs":"11395868cfd0802fab3fe43417751a5755abb516136923e6d8fdbc2f0ff49d19","src/collections/str/lossy.rs":"c5d62b16e01071e2a574ae41ef6693ad12f1e6c786c5d38f7a13ebd6cb23c088","src/collections/str/mod.rs":"d82a8bd417fbf52a589d89a16ea2a0ac4f6ac920c3976ab1f5b6ac0c8493c4f2","src/collections/string.rs":"d4e6c74d7431fa2548ac10290afef6bcdefbf110c6343f0c0244306c11370b8c","src/collections/vec.rs":"d8d997589a7449f14cdd21fb85583f6c94eb0d3ea2c832d3c4c570e92a0a5cdd","src/lib.rs":"835cbcfa2ac45d9d8d40a13258922419027f60c9481e2cbc1b22690edea2f481"},"package":"a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899"}

24
third_party/rust/bumpalo/CHANGELOG.md поставляемый
Просмотреть файл

@ -28,6 +28,30 @@ Released YYYY-MM-DD.
--------------------------------------------------------------------------------
## 3.9.1
Released 2022-01-06.
### Fixed
* Fixed link to logo in docs and README.md
--------------------------------------------------------------------------------
## 3.9.0
Released 2022-01-05.
### Changed
* The minimum supported Rust version (MSRV) has been raised to Rust 1.54.0.
* `bumpalo::collections::Vec<T>` implements relevant traits for all arrays of
any size `N` via const generics. Previously, it was just arrays up to length
32. Similar for `bumpalo::boxed::Box<[T; N]>`.
--------------------------------------------------------------------------------
## 3.8.0
Released 2021-10-19.

2
third_party/rust/bumpalo/Cargo.toml поставляемый
Просмотреть файл

@ -12,7 +12,7 @@
[package]
edition = "2018"
name = "bumpalo"
version = "3.8.0"
version = "3.9.1"
authors = ["Nick Fitzgerald <fitzgen@gmail.com>"]
exclude = ["/.github/*", "/benches", "/tests", "valgrind.supp", "bumpalo.png"]
description = "A fast bump allocation arena for Rust."

85
third_party/rust/bumpalo/README.md поставляемый
Просмотреть файл

@ -1,6 +1,5 @@
# `bumpalo`
**A fast bump allocation arena for Rust.**
[![](https://docs.rs/bumpalo/badge.svg)](https://docs.rs/bumpalo/)
@ -8,7 +7,7 @@
[![](https://img.shields.io/crates/d/bumpalo.svg)](https://crates.io/crates/bumpalo)
[![Build Status](https://github.com/fitzgen/bumpalo/workflows/Rust/badge.svg)](https://github.com/fitzgen/bumpalo/actions?query=workflow%3ARust)
![](https://github.com/fitzgen/bumpalo/raw/master/bumpalo.png)
![](https://github.com/fitzgen/bumpalo/raw/main/bumpalo.png)
### Bump Allocation
@ -33,11 +32,12 @@ pointer back to the start of the arena's memory chunk. This makes mass
deallocation *extremely* fast, but allocated objects' `Drop` implementations are
not invoked.
> **However:** [`bumpalo::boxed::Box<T>`][crate::boxed::Box] can be used to wrap
> **However:** [`bumpalo::boxed::Box<T>`][box] can be used to wrap
> `T` values allocated in the `Bump` arena, and calls `T`'s `Drop`
> implementation when the `Box<T>` wrapper goes out of scope. This is similar to
> how [`std::boxed::Box`] works, except without deallocating its backing memory.
[box]: https://docs.rs/bumpalo/latest/bumpalo/boxed/struct.Box.html
[`std::boxed::Box`]: https://doc.rust-lang.org/std/boxed/struct.Box.html
### What happens when the memory chunk is full?
@ -80,19 +80,22 @@ collection types are modified to allocate their space inside `bumpalo::Bump`
arenas.
```rust
use bumpalo::{Bump, collections::Vec};
#[cfg(feature = "collections")]
{
use bumpalo::{Bump, collections::Vec};
// Create a new bump arena.
let bump = Bump::new();
// Create a new bump arena.
let bump = Bump::new();
// Create a vector of integers whose storage is backed by the bump arena. The
// vector cannot outlive its backing arena, and this property is enforced with
// Rust's lifetime rules.
let mut v = Vec::new_in(&bump);
// Create a vector of integers whose storage is backed by the bump arena. The
// vector cannot outlive its backing arena, and this property is enforced with
// Rust's lifetime rules.
let mut v = Vec::new_in(&bump);
// Push a bunch of integers onto `v`!
for i in 0..100 {
v.push(i);
// Push a bunch of integers onto `v`!
for i in 0..100 {
v.push(i);
}
}
```
@ -114,33 +117,36 @@ can use this to work around the fact that `Bump` does not drop values allocated
in its space itself.
```rust
use bumpalo::{Bump, boxed::Box};
use std::sync::atomic::{AtomicUsize, Ordering};
#[cfg(feature = "boxed")]
{
use bumpalo::{Bump, boxed::Box};
use std::sync::atomic::{AtomicUsize, Ordering};
static NUM_DROPPED: AtomicUsize = AtomicUsize::new(0);
static NUM_DROPPED: AtomicUsize = AtomicUsize::new(0);
struct CountDrops;
struct CountDrops;
impl Drop for CountDrops {
fn drop(&mut self) {
NUM_DROPPED.fetch_add(1, Ordering::SeqCst);
impl Drop for CountDrops {
fn drop(&mut self) {
NUM_DROPPED.fetch_add(1, Ordering::SeqCst);
}
}
// Create a new bump arena.
let bump = Bump::new();
// Create a `CountDrops` inside the bump arena.
let mut c = Box::new_in(CountDrops, &bump);
// No `CountDrops` have been dropped yet.
assert_eq!(NUM_DROPPED.load(Ordering::SeqCst), 0);
// Drop our `Box<CountDrops>`.
drop(c);
// Its `Drop` implementation was run, and so `NUM_DROPS` has been incremented.
assert_eq!(NUM_DROPPED.load(Ordering::SeqCst), 1);
}
// Create a new bump arena.
let bump = Bump::new();
// Create a `CountDrops` inside the bump arena.
let mut c = Box::new_in(CountDrops, &bump);
// No `CountDrops` have been dropped yet.
assert_eq!(NUM_DROPPED.load(Ordering::SeqCst), 0);
// Drop our `Box<CountDrops>`.
drop(c);
// Its `Drop` implementation was run, and so `NUM_DROPS` has been incremented.
assert_eq!(NUM_DROPPED.load(Ordering::SeqCst), 1);
```
### `#![no_std]` Support
@ -174,14 +180,14 @@ bumpalo = { version = "3.4.0", features = ["allocator_api"] }
Next, enable the `allocator_api` nightly Rust feature in your `src/lib.rs` or `src/main.rs`:
```rust
```rust,ignore
#![feature(allocator_api)]
```
Finally, use `std` collections with `Bump`, so that their internal heap
allocations are made within the given bump arena:
```rust
```rust,ignore
#![feature(allocator_api)]
use bumpalo::Bump;
@ -197,9 +203,8 @@ v.push(2);
#### Minimum Supported Rust Version (MSRV)
This crate is guaranteed to compile on stable Rust 1.44 and up. It might compile
with older versions but that may change in any new patch release.
This crate is guaranteed to compile on stable Rust **1.54** and up. It might
compile with older versions but that may change in any new patch release.
We reserve the right to increment the MSRV on minor releases, however we will strive
to only do it deliberately and for good reasons.

3
third_party/rust/bumpalo/README.tpl поставляемый
Просмотреть файл

@ -1,3 +0,0 @@
# `{{crate}}`
{{readme}}

50
third_party/rust/bumpalo/src/boxed.rs поставляемый
Просмотреть файл

@ -647,39 +647,25 @@ impl<'a, F: ?Sized + Future + Unpin> Future for Box<'a, F> {
}
}
macro_rules! array_impls {
($($N: expr)+) => {
$(
/// This impl replaces unsize coercion.
impl<'a, T> From<Box<'a, [T; $N]>> for Box<'a, [T]> {
fn from(mut arr: Box<'a, [T; $N]>) -> Box<'a, [T]> {
let ptr = core::ptr::slice_from_raw_parts_mut(arr.as_mut_ptr(), $N);
mem::forget(arr);
unsafe { Box::from_raw(ptr) }
}
}
/// This impl replaces unsize coercion.
impl<'a, T> TryFrom<Box<'a, [T]>> for Box<'a, [T; $N]> {
type Error = Box<'a, [T]>;
fn try_from(mut slice: Box<'a, [T]>) -> Result<Box<'a, [T; $N]>, Box<'a, [T]>> {
if slice.len() == $N {
let ptr = slice.as_mut_ptr() as *mut [T; $N];
mem::forget(slice);
Ok(unsafe { Box::from_raw(ptr) })
} else {
Err(slice)
}
}
}
)+
/// This impl replaces unsize coercion.
impl<'a, T, const N: usize> From<Box<'a, [T; N]>> for Box<'a, [T]> {
fn from(mut arr: Box<'a, [T; N]>) -> Box<'a, [T]> {
let ptr = core::ptr::slice_from_raw_parts_mut(arr.as_mut_ptr(), N);
mem::forget(arr);
unsafe { Box::from_raw(ptr) }
}
}
array_impls! {
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29
30 31 32
/// This impl replaces unsize coercion.
impl<'a, T, const N: usize> TryFrom<Box<'a, [T]>> for Box<'a, [T; N]> {
type Error = Box<'a, [T]>;
fn try_from(mut slice: Box<'a, [T]>) -> Result<Box<'a, [T; N]>, Box<'a, [T]>> {
if slice.len() == N {
let ptr = slice.as_mut_ptr() as *mut [T; N];
mem::forget(slice);
Ok(unsafe { Box::from_raw(ptr) })
} else {
Err(slice)
}
}
}

Просмотреть файл

@ -1983,26 +1983,23 @@ __impl_slice_eq1! { Vec<'a, A>, &'b [B] }
__impl_slice_eq1! { Vec<'a, A>, &'b mut [B] }
// __impl_slice_eq1! { Cow<'a, [A]>, Vec<'b, B>, Clone }
macro_rules! array_impls {
($($N: expr)+) => {
$(
// NOTE: some less important impls are omitted to reduce code bloat
__impl_slice_eq1! { Vec<'a, A>, [B; $N] }
__impl_slice_eq1! { Vec<'a, A>, &'b [B; $N] }
// __impl_slice_eq1! { Vec<A>, &'b mut [B; $N] }
// __impl_slice_eq1! { Cow<'a, [A]>, [B; $N], Clone }
// __impl_slice_eq1! { Cow<'a, [A]>, &'b [B; $N], Clone }
// __impl_slice_eq1! { Cow<'a, [A]>, &'b mut [B; $N], Clone }
)+
}
macro_rules! __impl_slice_eq1_array {
($Lhs: ty, $Rhs: ty) => {
impl<'a, 'b, A, B, const N: usize> PartialEq<$Rhs> for $Lhs
where
A: PartialEq<B>,
{
#[inline]
fn eq(&self, other: &$Rhs) -> bool {
self[..] == other[..]
}
}
};
}
array_impls! {
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29
30 31 32
}
__impl_slice_eq1_array! { Vec<'a, A>, [B; N] }
__impl_slice_eq1_array! { Vec<'a, A>, &'b [B; N] }
__impl_slice_eq1_array! { Vec<'a, A>, &'b mut [B; N] }
/// Implements comparison of vectors, lexicographically.
impl<'bump, T: 'bump + PartialOrd> PartialOrd for Vec<'bump, T> {
@ -2073,6 +2070,18 @@ impl<'bump, T: 'bump> BorrowMut<[T]> for Vec<'bump, T> {
}
}
impl<'bump, T> Drop for Vec<'bump, T> {
fn drop(&mut self) {
unsafe {
// use drop for [T]
// use a raw slice to refer to the elements of the vector as weakest necessary type;
// could avoid questions of validity in certain cases
ptr::drop_in_place(ptr::slice_from_raw_parts_mut(self.as_mut_ptr(), self.len))
}
// RawVec handles deallocation
}
}
////////////////////////////////////////////////////////////////////////////////
// Clone-on-write
////////////////////////////////////////////////////////////////////////////////

222
third_party/rust/bumpalo/src/lib.rs поставляемый
Просмотреть файл

@ -1,222 +1,4 @@
/*!
**A fast bump allocation arena for Rust.**
[![](https://docs.rs/bumpalo/badge.svg)](https://docs.rs/bumpalo/)
[![](https://img.shields.io/crates/v/bumpalo.svg)](https://crates.io/crates/bumpalo)
[![](https://img.shields.io/crates/d/bumpalo.svg)](https://crates.io/crates/bumpalo)
[![Build Status](https://github.com/fitzgen/bumpalo/workflows/Rust/badge.svg)](https://github.com/fitzgen/bumpalo/actions?query=workflow%3ARust)
![](https://github.com/fitzgen/bumpalo/raw/master/bumpalo.png)
## Bump Allocation
Bump allocation is a fast, but limited approach to allocation. We have a chunk
of memory, and we maintain a pointer within that memory. Whenever we allocate an
object, we do a quick test that we have enough capacity left in our chunk to
allocate the object and then update the pointer by the object's size. *That's
it!*
The disadvantage of bump allocation is that there is no general way to
deallocate individual objects or reclaim the memory region for a
no-longer-in-use object.
These trade offs make bump allocation well-suited for *phase-oriented*
allocations. That is, a group of objects that will all be allocated during the
same program phase, used, and then can all be deallocated together as a group.
## Deallocation en Masse, but No `Drop`
To deallocate all the objects in the arena at once, we can simply reset the bump
pointer back to the start of the arena's memory chunk. This makes mass
deallocation *extremely* fast, but allocated objects' `Drop` implementations are
not invoked.
> **However:** [`bumpalo::boxed::Box<T>`][crate::boxed::Box] can be used to wrap
> `T` values allocated in the `Bump` arena, and calls `T`'s `Drop`
> implementation when the `Box<T>` wrapper goes out of scope. This is similar to
> how [`std::boxed::Box`] works, except without deallocating its backing memory.
[`std::boxed::Box`]: https://doc.rust-lang.org/std/boxed/struct.Box.html
## What happens when the memory chunk is full?
This implementation will allocate a new memory chunk from the global allocator
and then start bump allocating into this new memory chunk.
## Example
```
use bumpalo::Bump;
use std::u64;
struct Doggo {
cuteness: u64,
age: u8,
scritches_required: bool,
}
// Create a new arena to bump allocate into.
let bump = Bump::new();
// Allocate values into the arena.
let scooter = bump.alloc(Doggo {
cuteness: u64::max_value(),
age: 8,
scritches_required: true,
});
// Exclusive, mutable references to the just-allocated value are returned.
assert!(scooter.scritches_required);
scooter.age += 1;
```
## Collections
When the `"collections"` cargo feature is enabled, a fork of some of the `std`
library's collections are available in the `collections` module. These
collection types are modified to allocate their space inside `bumpalo::Bump`
arenas.
```rust
# #[cfg(feature = "collections")]
# {
use bumpalo::{Bump, collections::Vec};
// Create a new bump arena.
let bump = Bump::new();
// Create a vector of integers whose storage is backed by the bump arena. The
// vector cannot outlive its backing arena, and this property is enforced with
// Rust's lifetime rules.
let mut v = Vec::new_in(&bump);
// Push a bunch of integers onto `v`!
for i in 0..100 {
v.push(i);
}
# }
```
Eventually [all `std` collection types will be parameterized by an
allocator](https://github.com/rust-lang/rust/issues/42774) and we can remove
this `collections` module and use the `std` versions.
For unstable, nightly-only support for custom allocators in `std`, see the
`allocator_api` section below.
## `bumpalo::boxed::Box`
When the `"boxed"` cargo feature is enabled, a fork of `std::boxed::Box` library
is available in the `boxed` module. This `Box` type is modified to allocate its
space inside `bumpalo::Bump` arenas.
**A `Box<T>` runs `T`'s drop implementation when the `Box<T>` is dropped.** You
can use this to work around the fact that `Bump` does not drop values allocated
in its space itself.
```rust
# #[cfg(feature = "boxed")]
# {
use bumpalo::{Bump, boxed::Box};
use std::sync::atomic::{AtomicUsize, Ordering};
static NUM_DROPPED: AtomicUsize = AtomicUsize::new(0);
struct CountDrops;
impl Drop for CountDrops {
fn drop(&mut self) {
NUM_DROPPED.fetch_add(1, Ordering::SeqCst);
}
}
// Create a new bump arena.
let bump = Bump::new();
// Create a `CountDrops` inside the bump arena.
let mut c = Box::new_in(CountDrops, &bump);
// No `CountDrops` have been dropped yet.
assert_eq!(NUM_DROPPED.load(Ordering::SeqCst), 0);
// Drop our `Box<CountDrops>`.
drop(c);
// Its `Drop` implementation was run, and so `NUM_DROPS` has been incremented.
assert_eq!(NUM_DROPPED.load(Ordering::SeqCst), 1);
# }
```
## `#![no_std]` Support
Bumpalo is a `no_std` crate. It depends only on the `alloc` and `core` crates.
## Thread support
The `Bump` is `!Sync`, which makes it hard to use in certain situations around threads for
example in `rayon`.
The [`bumpalo-herd`](https://crates.io/crates/bumpalo-herd) crate provides a pool of `Bump`
allocators for use in such situations.
## Nightly Rust `feature(allocator_api)` Support
The unstable, nightly-only Rust `allocator_api` feature defines an `Allocator`
trait and exposes custom allocators for `std` types. Bumpalo has a matching
`allocator_api` cargo feature to enable implementing `Allocator` and using
`Bump` with `std` collections. Note that, as `feature(allocator_api)` is
unstable and only in nightly Rust, Bumpalo's matching `allocator_api` cargo
feature should be considered unstable, and will not follow the semver
conventions that the rest of the crate does.
First, enable the `allocator_api` feature in your `Cargo.toml`:
```toml
[dependencies]
bumpalo = { version = "3.4.0", features = ["allocator_api"] }
```
Next, enable the `allocator_api` nightly Rust feature in your `src/lib.rs` or `src/main.rs`:
```rust
# #[cfg(feature = "allocator_api")]
# {
#![feature(allocator_api)]
# }
```
Finally, use `std` collections with `Bump`, so that their internal heap
allocations are made within the given bump arena:
```
# #![cfg_attr(feature = "allocator_api", feature(allocator_api))]
# #[cfg(feature = "allocator_api")]
# {
#![feature(allocator_api)]
use bumpalo::Bump;
// Create a new bump arena.
let bump = Bump::new();
// Create a `Vec` whose elements are allocated within the bump arena.
let mut v = Vec::new_in(&bump);
v.push(0);
v.push(1);
v.push(2);
# }
```
### Minimum Supported Rust Version (MSRV)
This crate is guaranteed to compile on stable Rust 1.44 and up. It might compile
with older versions but that may change in any new patch release.
We reserve the right to increment the MSRV on minor releases, however we will strive
to only do it deliberately and for good reasons.
*/
#![doc = include_str!("../README.md")]
#![deny(missing_debug_implementations)]
#![deny(missing_docs)]
#![no_std]
@ -420,7 +202,7 @@ impl<E: Display> Display for AllocOrInitError<E> {
///
/// Even when optimizations are on, these functions do not **guarantee** that
/// the value is constructed on the heap. To the best of our knowledge no such
/// guarantee can be made in stable Rust as of 1.44.
/// guarantee can be made in stable Rust as of 1.51.
///
/// ### Fallible Initialization: The `_try_with` Method Suffix
///

Просмотреть файл

@ -1 +1 @@
{"files":{"CHANGELOG.md":"50d6fbb00aa801cffefd2ecbbb43bba8686925658b3bf5e304b5af735f90bf08","Cargo.toml":"7ff90cd0fd3bc7449b8f55dea7de4d7d51f7c11948119512a274369733a94321","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"106c91d873d7c2681ca6264195737d7f2ea73f91cc74dd4c200f3fe9c5ea4907","src/lib.rs":"d2b1a7280c5cb8c1e946a5839862a1496749c445851f7ed196debf8386a4e646","tests/padding.rs":"120cc65d1fcebbdb0ed8b0c287680ede2483e3ab040746e1a3616ffb39d8f414"},"package":"631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba"}
{"files":{"CHANGELOG.md":"01efe9c9a75e5a305dac0e12676ed451f746049a825aa86acef0d8ee90742f71","Cargo.toml":"ea55c73cacac2dcc3bdcb2c657e057d9b73214e76f8654799236b13c853e97bd","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"61d450a57f8699dfc1c39e3bb69236f7d10f31f4503b03aa8b2b37b2448b8b69","src/lib.rs":"4bcb45fe37cdca78ba0e403d9e531102c521ad42e9ffd2ecbb154b4509864978","tests/padding.rs":"120cc65d1fcebbdb0ed8b0c287680ede2483e3ab040746e1a3616ffb39d8f414"},"package":"c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c"}

4
third_party/rust/cache-padded/CHANGELOG.md поставляемый
Просмотреть файл

@ -1,3 +1,7 @@
# Version 1.2.0
- Improve implementation of `CachePadded`.
# Version 1.1.1
- Forbid unsafe code.

17
third_party/rust/cache-padded/Cargo.toml поставляемый
Просмотреть файл

@ -3,23 +3,20 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
name = "cache-padded"
version = "1.1.1"
version = "1.2.0"
authors = ["Stjepan Glavina <stjepang@gmail.com>"]
description = "Prevent false sharing by padding and aligning to the length of a cache line"
homepage = "https://github.com/stjepang/cache-padded"
documentation = "https://docs.rs/cache-padded"
readme = "README.md"
homepage = "https://github.com/smol-rs/cache-padded"
keywords = ["cache", "padding", "lock-free", "atomic"]
categories = ["concurrency", "no-std"]
license = "Apache-2.0 OR MIT"
repository = "https://github.com/stjepang/cache-padded"
repository = "https://github.com/smol-rs/cache-padded"

8
third_party/rust/cache-padded/README.md поставляемый
Просмотреть файл

@ -1,9 +1,9 @@
# cache-padded
[![Build](https://github.com/stjepang/cache-padded/workflows/Build%20and%20test/badge.svg)](
https://github.com/stjepang/cache-padded/actions)
[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)](
https://github.com/stjepang/cache-padded)
[![Build](https://github.com/smol-rs/cache-padded/workflows/Build%20and%20test/badge.svg)](
https://github.com/smol-rs/cache-padded/actions)
[![License](https://img.shields.io/badge/license-Apache--2.0_OR_MIT-blue.svg)](
https://github.com/smol-rs/cache-padded)
[![Cargo](https://img.shields.io/crates/v/cache-padded.svg)](
https://crates.io/crates/cache-padded)
[![Documentation](https://docs.rs/cache-padded/badge.svg)](

62
third_party/rust/cache-padded/src/lib.rs поставляемый
Просмотреть файл

@ -1,7 +1,7 @@
//! Prevent false sharing by padding and aligning to the length of a cache line.
//!
//! In concurrent programming, sometimes it is desirable to make sure commonly accessed shared data
//! is not all placed into the same cache line. Updating an atomic value invalides the whole cache
//! is not all placed into the same cache line. Updating an atomic value invalidates the whole cache
//! line it belongs to, which makes the next access to the same cache line slower for other CPU
//! cores. Use [`CachePadded`] to ensure updating one piece of data doesn't invalidate other cached
//! data.
@ -10,8 +10,9 @@
//!
//! Cache lines are assumed to be N bytes long, depending on the architecture:
//!
//! * On x86-64 and aarch64, N = 128.
//! * On all others, N = 64.
//! * On x86-64, aarch64, and powerpc64, N = 128.
//! * On arm, mips, mips64, and riscv64, N = 32.
//! * On s390x, N = 256.
//!
//! Note that N is just a reasonable guess and is not guaranteed to match the actual cache line
//! length of the machine the program is running on.
@ -67,14 +68,63 @@ use core::ops::{Deref, DerefMut};
// - https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf
// - https://github.com/facebook/folly/blob/1b5288e6eea6df074758f877c849b6e73bbb9fbb/folly/lang/Align.h#L107
//
// ARM's big.LITTLE architecture has asymmetric cores and "big" cores have 128-byte cache lines.
// ARM's big.LITTLE architecture has asymmetric cores and "big" cores have 128-byte cache line size.
//
// Sources:
// - https://www.mono-project.com/news/2016/09/12/arm64-icache/
//
#[cfg_attr(any(target_arch = "x86_64", target_arch = "aarch64"), repr(align(128)))]
// powerpc64 has 128-byte cache line size.
//
// Sources:
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_ppc64x.go#L9
#[cfg_attr(
not(any(target_arch = "x86_64", target_arch = "aarch64")),
any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "powerpc64",
),
repr(align(128))
)]
// arm, mips, mips64, and riscv64 have 32-byte cache line size.
//
// Sources:
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_arm.go#L7
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_mips.go#L7
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_mipsle.go#L7
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_mips64x.go#L9
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_riscv64.go#L7
#[cfg_attr(
any(
target_arch = "arm",
target_arch = "mips",
target_arch = "mips64",
target_arch = "riscv64",
),
repr(align(32))
)]
// s390x has 256-byte cache line size.
//
// Sources:
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_s390x.go#L7
#[cfg_attr(target_arch = "s390x", repr(align(256)))]
// x86 and wasm have 64-byte cache line size.
//
// Sources:
// - https://github.com/golang/go/blob/dda2991c2ea0c5914714469c4defc2562a907230/src/internal/cpu/cpu_x86.go#L9
// - https://github.com/golang/go/blob/3dd58676054223962cd915bb0934d1f9f489d4d2/src/internal/cpu/cpu_wasm.go#L7
//
// All others are assumed to have 64-byte cache line size.
#[cfg_attr(
not(any(
target_arch = "x86_64",
target_arch = "aarch64",
target_arch = "powerpc64",
target_arch = "arm",
target_arch = "mips",
target_arch = "mips64",
target_arch = "riscv64",
target_arch = "s390x",
)),
repr(align(64))
)]
#[derive(Clone, Copy, Default, Hash, PartialEq, Eq)]

Просмотреть файл

@ -1 +1 @@
{"files":{"CHANGELOG.md":"74ac49b84461217698d4430f81b1cdcba0595bc4e57216ffc52b8296ac44cd41","Cargo.lock":"7956079bcac40cc40c894f0260266365ecdb1c01c48636ae4c4080977603e7b8","Cargo.toml":"6a7acaffaa30dab2b5ea1f5ab86b20bc97370314ed03472288745b3b969786dc","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"5734ed989dfca1f625b40281ee9f4530f91b2411ec01cb748223e7eb87e201ab","LICENSE-THIRD-PARTY":"b16db96b93b1d7cf7bea533f572091ec6bca3234fbe0a83038be772ff391a44c","README.md":"415a71d4978cfd338a6ae1f1b41284652eccd277a815542c304647dc437a8274","benches/crossbeam.rs":"f5720508d3458f2451271b9887f7557823304bd38288c928b0d6aa1f459865e5","examples/fibonacci.rs":"6a26ecd74c7493d2c93f4280c0804afc19adc612b77b3d9fea433119ff472a44","examples/matching.rs":"63c250e164607a7a9f643d46f107bb5da846d49e89cf9069909562d20e530f71","examples/stopwatch.rs":"f9a00477b41823199e4af06bddeb0c6cfd22e272340eec1b98b333fc59ee6a1f","src/channel.rs":"a9baaad2f414c38cd324a60ac9375ca58462ce6662217683648e9b66cec43a8c","src/context.rs":"ad24cabfc50dd5e6ae84aa46a0246da12da1f1a6fa19043244ad25136075c6ca","src/counter.rs":"c49a9f44587888850edeb62f7c8ecd1acecb39c836834254ff3ac934c478440a","src/err.rs":"fdbde7279a1e74973e5c7d3e835a97836229a357fe465c0ba1a37f2a012d1bef","src/flavors/array.rs":"c125146771265058ac320226456b1e21667e93649531a3d20157f71cd715881d","src/flavors/at.rs":"65bf870b3ddb14738256706b0276f2656ad1fe9cd8eb91737489868edd088e92","src/flavors/list.rs":"50dbe59616c39b5aa184470023ce0cfb1cb0dbd92e1577375d299446981527c0","src/flavors/mod.rs":"3d9d43bc38b0adb18c96c995c2bd3421d8e33ab6c30b20c3c467d21d48e485dc","src/flavors/never.rs":"0e7921922d00c711552fb063c63c78192fa6ddc0762fb81c1713b847495ec39a","src/flavors/tick.rs":"38a479b9f4a72a5ccb9c407a1e7b44d36b6ad0f4e214e39266b12b9564c803dc","src/flavors/zero.rs":"1bda0c5483b04d53f36f9f4a6fe6f87b69f698068771e637e224c09400c6ce83","src/lib.rs":"3a65706d4124844ffc4c8cb1f8cc779631ec94f449f85cbb68364ad3619404f1","src/select.rs":"4eb4b1988c5dffff3e3d2138d14a1b86613bf62b78c45a5c70f65aaee92c11bb","src/select_macro.rs":"96bc9acb9a22588a4e733b0ab0761ad2be9a6b3e03744e8fc9c6de9ae433b696","src/utils.rs":"746fe315d6cfc832e3dda35e5055c0fd5c99907f1303b2ea7eacc4e37c8527e1","src/waker.rs":"9058cc441d467539c439ef88f0be1a187bf122d26fc116ce3e3a0265a693761f","tests/after.rs":"324c7d773f72bef62d150171f74ba7b7ac1b06f6030b3d4d2b1a35d211956b21","tests/array.rs":"574bff53aff0b0a8c365bf3f9ad77bb64675df9e6e0714be9c16eeeeac22e4d5","tests/golang.rs":"ec03806945fecd381cfce0634e2d776741423589c92e1bd4d8a431ac20f5d2d0","tests/iter.rs":"7563dc7fdf4c63e31dd74ee3fedecdd3aed490f7ef599b98f6f75f929cf79edb","tests/list.rs":"cc2971e69fd7f6a94b5463c9d4e9079df7955b37552e16dd66f4c6e65db60d96","tests/mpsc.rs":"0c4c6b056f5cec77ca19eca45f99b083632700a4b67133e88071a1d22a61d6fe","tests/never.rs":"665441a9fb004f7cd44047619637ebe6766cf2faf58e68e6481397bbfc682e11","tests/ready.rs":"eae3d7f16e817e63f3a6ceda062fece3de5e11c7a9631b32b02f23396a9d59c1","tests/same_channel.rs":"2bab761443671e841e1b2476bd8082d75533a2f6be7946f5dbcee67cdc82dccb","tests/select.rs":"3603f450b23f5e0d1e4014a167a9b23ab149b5f418c8b89636f1c02c90501569","tests/select_macro.rs":"00dd7963f79b96abf30851fdab29e86c8424b502a8a7d34abf4bc1714f493ecf","tests/thread_locals.rs":"3611db5502e6af0a8d15187d09fd195381819795544208b946e9f99b04579a81","tests/tick.rs":"dc4a7d3c8dd888ce135fe8a8c67f5dc8b5ab0c3fa57a48459f96d51fa0f1e6d5","tests/zero.rs":"0ff0587cc74569bfe389e0c619217799a960a0dfc5e6354603c88e6eea1b79a1"},"package":"06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4"}
{"files":{"CHANGELOG.md":"e70d1a5fa6697a8b24e193e3934975317df12279c167b90fcb9616291792197c","Cargo.lock":"0f4e59f28bdd52c4781d102fc7d1f16d1ea417aaec0a4846432444a4019b2537","Cargo.toml":"c8334f658b699a1a0e25d997d752a9493a627f9ddcb7aab739c7319ea583882f","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"5734ed989dfca1f625b40281ee9f4530f91b2411ec01cb748223e7eb87e201ab","LICENSE-THIRD-PARTY":"b16db96b93b1d7cf7bea533f572091ec6bca3234fbe0a83038be772ff391a44c","README.md":"415a71d4978cfd338a6ae1f1b41284652eccd277a815542c304647dc437a8274","benches/crossbeam.rs":"96cb1abd23cac3ef8a7174a802e94609926b555bb02c9658c78723d433f1dd92","examples/fibonacci.rs":"4e88fa40048cdc31e9c7bb60347d46f92543d7ddf39cab3b52bfe44affdb6a02","examples/matching.rs":"63c250e164607a7a9f643d46f107bb5da846d49e89cf9069909562d20e530f71","examples/stopwatch.rs":"d02121258f08d56f1eb7997e19bcb9bacb6836cfa0abbba90a9e59d8a50ae5cf","src/channel.rs":"a9baaad2f414c38cd324a60ac9375ca58462ce6662217683648e9b66cec43a8c","src/context.rs":"ff4d39639ddf16aaab582d4a5f3d10ef2c71afe1abbf4e60f3d9d2ddbd72c230","src/counter.rs":"c49a9f44587888850edeb62f7c8ecd1acecb39c836834254ff3ac934c478440a","src/err.rs":"fdbde7279a1e74973e5c7d3e835a97836229a357fe465c0ba1a37f2a012d1bef","src/flavors/array.rs":"853c2ad068f912cfb49877bcd41e241f34b25026b709bf0629523f19952e3adc","src/flavors/at.rs":"65bf870b3ddb14738256706b0276f2656ad1fe9cd8eb91737489868edd088e92","src/flavors/list.rs":"50dbe59616c39b5aa184470023ce0cfb1cb0dbd92e1577375d299446981527c0","src/flavors/mod.rs":"3d9d43bc38b0adb18c96c995c2bd3421d8e33ab6c30b20c3c467d21d48e485dc","src/flavors/never.rs":"0e7921922d00c711552fb063c63c78192fa6ddc0762fb81c1713b847495ec39a","src/flavors/tick.rs":"38a479b9f4a72a5ccb9c407a1e7b44d36b6ad0f4e214e39266b12b9564c803dc","src/flavors/zero.rs":"012a53f56b86df22ce49866da95e5f457fb99a18a098f0f64779c6d1cdd7092f","src/lib.rs":"3a65706d4124844ffc4c8cb1f8cc779631ec94f449f85cbb68364ad3619404f1","src/select.rs":"66eb10a6cbdf8dd0869f2a7cac9992fdaee36c9e2a01d708d39d7c794572935b","src/select_macro.rs":"96bc9acb9a22588a4e733b0ab0761ad2be9a6b3e03744e8fc9c6de9ae433b696","src/utils.rs":"746fe315d6cfc832e3dda35e5055c0fd5c99907f1303b2ea7eacc4e37c8527e1","src/waker.rs":"591ee70bf62ccad5aa2fac7b92d444183b02790a79c024f016c78de2396d08a3","tests/after.rs":"0154a8e152880db17a20514ecdd49dabc361d3629858d119b9746b5e932c780c","tests/array.rs":"e5f25e8991863a9a86d61a66be646d04feae527f35b1697fd215b97af4383736","tests/golang.rs":"dc85669c9c4e902b1bb263d00f5cb6f9ecb6d42b19fe53425b55ce97c887da49","tests/iter.rs":"25dc02135bbae9d47a30f9047661648e66bdc134e40ba78bc2fbacbb8b3819bc","tests/list.rs":"de865ef097f3bcb35c1c814554e6108fed43b3dbb1533c8bbcf8688cceb6b6ab","tests/mpsc.rs":"401aa3c6923815058881ddce98070df68ebab283913c89c007436bb8af7ca0ea","tests/never.rs":"ee40c4fc4dd5af4983fae8de6927f52b81174d222c162f745b26c4a6c7108e4f","tests/ready.rs":"d349702f123925a0781b48d677e6dcf64fc5d1fc788a7bf1e151a3d57e81871c","tests/same_channel.rs":"2bab761443671e841e1b2476bd8082d75533a2f6be7946f5dbcee67cdc82dccb","tests/select.rs":"d20259a45f387cbce80c2c876ae81ea3883f36ea01c5151c159d58c362f6ba07","tests/select_macro.rs":"d3af2dc98e0dd03dc4ffab464b8ccb2f8b7504e8bb830948a04c015b92f0b296","tests/thread_locals.rs":"a1ce59e2aff69161621c0cb215eb6ea238088c06a31a8507a74cf179fd5a4299","tests/tick.rs":"5f697bd14c48505d932e82065b5302ef668e1cc19cac18e8ac22e0c83c221c1d","tests/zero.rs":"afbd838001d4196daddf17133e60ccea31529cc48ee01e245ac0d6366d1e30b9"},"package":"e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa"}

Просмотреть файл

@ -1,3 +1,7 @@
# Version 0.5.2
- Fix stacked borrows violations. (#763, #764)
# Version 0.5.1
- Fix memory leak in unbounded channel. (#669)

57
third_party/rust/crossbeam-channel/Cargo.lock сгенерированный поставляемый
Просмотреть файл

@ -2,12 +2,6 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "autocfg"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "cfg-if"
version = "1.0.0"
@ -16,7 +10,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "crossbeam-channel"
version = "0.5.1"
version = "0.5.2"
dependencies = [
"cfg-if",
"crossbeam-utils",
@ -27,20 +21,19 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
version = "0.8.3"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49"
checksum = "cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120"
dependencies = [
"autocfg",
"cfg-if",
"lazy_static",
]
[[package]]
name = "getrandom"
version = "0.2.2"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
dependencies = [
"cfg-if",
"libc",
@ -49,9 +42,9 @@ dependencies = [
[[package]]
name = "hermit-abi"
version = "0.1.18"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
@ -64,15 +57,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.93"
version = "0.2.112"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41"
checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
[[package]]
name = "num_cpus"
version = "1.13.0"
version = "1.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1"
dependencies = [
"hermit-abi",
"libc",
@ -80,15 +73,15 @@ dependencies = [
[[package]]
name = "ppv-lite86"
version = "0.2.10"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
[[package]]
name = "rand"
version = "0.8.3"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
dependencies = [
"libc",
"rand_chacha",
@ -98,9 +91,9 @@ dependencies = [
[[package]]
name = "rand_chacha"
version = "0.3.0"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core",
@ -108,27 +101,27 @@ dependencies = [
[[package]]
name = "rand_core"
version = "0.6.2"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7"
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
dependencies = [
"getrandom",
]
[[package]]
name = "rand_hc"
version = "0.3.0"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"
dependencies = [
"rand_core",
]
[[package]]
name = "signal-hook"
version = "0.3.8"
version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef33d6d0cd06e0840fba9985aab098c147e67e05cee14d412d3345ed14ff30ac"
checksum = "647c97df271007dcea485bb74ffdb57f2e683f1306c854f468a0c244badabf2d"
dependencies = [
"libc",
"signal-hook-registry",
@ -136,9 +129,9 @@ dependencies = [
[[package]]
name = "signal-hook-registry"
version = "1.3.0"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16f1d0fef1604ba8f7a073c7e701f213e056707210e9020af4528e0101ce11a6"
checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0"
dependencies = [
"libc",
]

14
third_party/rust/crossbeam-channel/Cargo.toml поставляемый
Просмотреть файл

@ -3,21 +3,19 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
rust-version = "1.36"
name = "crossbeam-channel"
version = "0.5.1"
authors = ["The Crossbeam Project Developers"]
version = "0.5.2"
description = "Multi-producer multi-consumer channels for message passing"
homepage = "https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-channel"
documentation = "https://docs.rs/crossbeam-channel"
keywords = ["channel", "mpmc", "select", "golang", "message"]
categories = ["algorithms", "concurrency", "data-structures"]
license = "MIT OR Apache-2.0"

Просмотреть файл

@ -13,7 +13,7 @@ mod unbounded {
#[bench]
fn create(b: &mut Bencher) {
b.iter(|| unbounded::<i32>());
b.iter(unbounded::<i32>);
}
#[bench]

Просмотреть файл

@ -10,7 +10,7 @@ fn fibonacci(sender: Sender<u64>) {
while sender.send(x).is_ok() {
let tmp = x;
x = y;
y = tmp + y;
y += tmp;
}
}

Просмотреть файл

@ -33,11 +33,7 @@ fn main() {
// Prints the elapsed time.
fn show(dur: Duration) {
println!(
"Elapsed: {}.{:03} sec",
dur.as_secs(),
dur.subsec_nanos() / 1_000_000
);
println!("Elapsed: {}.{:03} sec", dur.as_secs(), dur.subsec_millis());
}
let start = Instant::now();

Просмотреть файл

@ -1,7 +1,8 @@
//! Thread-local context used in select.
use std::cell::Cell;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::ptr;
use std::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
use std::sync::Arc;
use std::thread::{self, Thread, ThreadId};
use std::time::Instant;
@ -11,6 +12,7 @@ use crossbeam_utils::Backoff;
use crate::select::Selected;
/// Thread-local context used in select.
// This is a private API that is used by the select macro.
#[derive(Debug, Clone)]
pub struct Context {
inner: Arc<Inner>,
@ -23,7 +25,7 @@ struct Inner {
select: AtomicUsize,
/// A slot into which another thread may store a pointer to its `Packet`.
packet: AtomicUsize,
packet: AtomicPtr<()>,
/// Thread handle.
thread: Thread,
@ -45,7 +47,7 @@ impl Context {
}
let mut f = Some(f);
let mut f = move |cx: &Context| -> R {
let mut f = |cx: &Context| -> R {
let f = f.take().unwrap();
f(cx)
};
@ -69,7 +71,7 @@ impl Context {
Context {
inner: Arc::new(Inner {
select: AtomicUsize::new(Selected::Waiting.into()),
packet: AtomicUsize::new(0),
packet: AtomicPtr::new(ptr::null_mut()),
thread: thread::current(),
thread_id: thread::current().id(),
}),
@ -82,7 +84,7 @@ impl Context {
self.inner
.select
.store(Selected::Waiting.into(), Ordering::Release);
self.inner.packet.store(0, Ordering::Release);
self.inner.packet.store(ptr::null_mut(), Ordering::Release);
}
/// Attempts to select an operation.
@ -112,19 +114,19 @@ impl Context {
///
/// This method must be called after `try_select` succeeds and there is a packet to provide.
#[inline]
pub fn store_packet(&self, packet: usize) {
if packet != 0 {
pub fn store_packet(&self, packet: *mut ()) {
if !packet.is_null() {
self.inner.packet.store(packet, Ordering::Release);
}
}
/// Waits until a packet is provided and returns it.
#[inline]
pub fn wait_packet(&self) -> usize {
pub fn wait_packet(&self) -> *mut () {
let backoff = Backoff::new();
loop {
let packet = self.inner.packet.load(Ordering::Acquire);
if packet != 0 {
if !packet.is_null() {
return packet;
}
backoff.snooze();

Просмотреть файл

@ -10,7 +10,7 @@
use std::cell::UnsafeCell;
use std::marker::PhantomData;
use std::mem::{self, MaybeUninit};
use std::mem::MaybeUninit;
use std::ptr;
use std::sync::atomic::{self, AtomicUsize, Ordering};
use std::time::Instant;
@ -110,7 +110,7 @@ impl<T> Channel<T> {
// Allocate a buffer of `cap` slots initialized
// with stamps.
let buffer = {
let mut boxed: Box<[Slot<T>]> = (0..cap)
let boxed: Box<[Slot<T>]> = (0..cap)
.map(|i| {
// Set the stamp to `{ lap: 0, mark: 0, index: i }`.
Slot {
@ -119,9 +119,7 @@ impl<T> Channel<T> {
}
})
.collect();
let ptr = boxed.as_mut_ptr();
mem::forget(boxed);
ptr
Box::into_raw(boxed) as *mut Slot<T>
};
Channel {

Просмотреть файл

@ -6,6 +6,7 @@ use std::cell::UnsafeCell;
use std::marker::PhantomData;
use std::sync::atomic::{AtomicBool, Ordering};
use std::time::Instant;
use std::{fmt, ptr};
use crossbeam_utils::Backoff;
@ -16,7 +17,19 @@ use crate::utils::Spinlock;
use crate::waker::Waker;
/// A pointer to a packet.
pub(crate) type ZeroToken = usize;
pub struct ZeroToken(*mut ());
impl Default for ZeroToken {
fn default() -> Self {
Self(ptr::null_mut())
}
}
impl fmt::Debug for ZeroToken {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&(self.0 as usize), f)
}
}
/// A slot for passing one message from a sender to a receiver.
struct Packet<T> {
@ -117,10 +130,10 @@ impl<T> Channel<T> {
// If there's a waiting receiver, pair up with it.
if let Some(operation) = inner.receivers.try_select() {
token.zero = operation.packet;
token.zero.0 = operation.packet;
true
} else if inner.is_disconnected {
token.zero = 0;
token.zero.0 = ptr::null_mut();
true
} else {
false
@ -130,11 +143,11 @@ impl<T> Channel<T> {
/// Writes a message into the packet.
pub(crate) unsafe fn write(&self, token: &mut Token, msg: T) -> Result<(), T> {
// If there is no packet, the channel is disconnected.
if token.zero == 0 {
if token.zero.0.is_null() {
return Err(msg);
}
let packet = &*(token.zero as *const Packet<T>);
let packet = &*(token.zero.0 as *const Packet<T>);
packet.msg.get().write(Some(msg));
packet.ready.store(true, Ordering::Release);
Ok(())
@ -146,10 +159,10 @@ impl<T> Channel<T> {
// If there's a waiting sender, pair up with it.
if let Some(operation) = inner.senders.try_select() {
token.zero = operation.packet;
token.zero.0 = operation.packet;
true
} else if inner.is_disconnected {
token.zero = 0;
token.zero.0 = ptr::null_mut();
true
} else {
false
@ -159,11 +172,11 @@ impl<T> Channel<T> {
/// Reads a message from the packet.
pub(crate) unsafe fn read(&self, token: &mut Token) -> Result<T, ()> {
// If there is no packet, the channel is disconnected.
if token.zero == 0 {
if token.zero.0.is_null() {
return Err(());
}
let packet = &*(token.zero as *const Packet<T>);
let packet = &*(token.zero.0 as *const Packet<T>);
if packet.on_stack {
// The message has been in the packet from the beginning, so there is no need to wait
@ -177,7 +190,7 @@ impl<T> Channel<T> {
// heap-allocated packet.
packet.wait_ready();
let msg = packet.msg.get().replace(None).unwrap();
drop(Box::from_raw(packet as *const Packet<T> as *mut Packet<T>));
drop(Box::from_raw(token.zero.0 as *mut Packet<T>));
Ok(msg)
}
}
@ -189,7 +202,7 @@ impl<T> Channel<T> {
// If there's a waiting receiver, pair up with it.
if let Some(operation) = inner.receivers.try_select() {
token.zero = operation.packet;
token.zero.0 = operation.packet;
drop(inner);
unsafe {
self.write(token, msg).ok().unwrap();
@ -213,7 +226,7 @@ impl<T> Channel<T> {
// If there's a waiting receiver, pair up with it.
if let Some(operation) = inner.receivers.try_select() {
token.zero = operation.packet;
token.zero.0 = operation.packet;
drop(inner);
unsafe {
self.write(token, msg).ok().unwrap();
@ -228,10 +241,10 @@ impl<T> Channel<T> {
Context::with(|cx| {
// Prepare for blocking until a receiver wakes us up.
let oper = Operation::hook(token);
let packet = Packet::<T>::message_on_stack(msg);
let mut packet = Packet::<T>::message_on_stack(msg);
inner
.senders
.register_with_packet(oper, &packet as *const Packet<T> as usize, cx);
.register_with_packet(oper, &mut packet as *mut Packet<T> as *mut (), cx);
inner.receivers.notify();
drop(inner);
@ -266,7 +279,7 @@ impl<T> Channel<T> {
// If there's a waiting sender, pair up with it.
if let Some(operation) = inner.senders.try_select() {
token.zero = operation.packet;
token.zero.0 = operation.packet;
drop(inner);
unsafe { self.read(token).map_err(|_| TryRecvError::Disconnected) }
} else if inner.is_disconnected {
@ -283,7 +296,7 @@ impl<T> Channel<T> {
// If there's a waiting sender, pair up with it.
if let Some(operation) = inner.senders.try_select() {
token.zero = operation.packet;
token.zero.0 = operation.packet;
drop(inner);
unsafe {
return self.read(token).map_err(|_| RecvTimeoutError::Disconnected);
@ -297,10 +310,12 @@ impl<T> Channel<T> {
Context::with(|cx| {
// Prepare for blocking until a sender wakes us up.
let oper = Operation::hook(token);
let packet = Packet::<T>::empty_on_stack();
inner
.receivers
.register_with_packet(oper, &packet as *const Packet<T> as usize, cx);
let mut packet = Packet::<T>::empty_on_stack();
inner.receivers.register_with_packet(
oper,
&mut packet as *mut Packet<T> as *mut (),
cx,
);
inner.senders.notify();
drop(inner);
@ -385,7 +400,7 @@ impl<T> SelectHandle for Receiver<'_, T> {
let mut inner = self.0.inner.lock();
inner
.receivers
.register_with_packet(oper, packet as usize, cx);
.register_with_packet(oper, packet as *mut (), cx);
inner.senders.notify();
inner.senders.can_select() || inner.is_disconnected
}
@ -399,7 +414,7 @@ impl<T> SelectHandle for Receiver<'_, T> {
}
fn accept(&self, token: &mut Token, cx: &Context) -> bool {
token.zero = cx.wait_packet();
token.zero.0 = cx.wait_packet();
true
}
@ -435,7 +450,7 @@ impl<T> SelectHandle for Sender<'_, T> {
let mut inner = self.0.inner.lock();
inner
.senders
.register_with_packet(oper, packet as usize, cx);
.register_with_packet(oper, packet as *mut (), cx);
inner.receivers.notify();
inner.receivers.can_select() || inner.is_disconnected
}
@ -449,7 +464,7 @@ impl<T> SelectHandle for Sender<'_, T> {
}
fn accept(&self, token: &mut Token, cx: &Context) -> bool {
token.zero = cx.wait_packet();
token.zero.0 = cx.wait_packet();
true
}

Просмотреть файл

@ -19,6 +19,7 @@ use crate::utils;
/// `read` or `write`.
///
/// Each field contains data associated with a specific channel flavor.
// This is a private API that is used by the select macro.
#[derive(Debug, Default)]
pub struct Token {
pub at: flavors::at::AtToken,
@ -93,6 +94,7 @@ impl Into<usize> for Selected {
///
/// This is a handle that assists select in executing an operation, registration, deciding on the
/// appropriate deadline for blocking, etc.
// This is a private API (exposed inside crossbeam_channel::internal module) that is used by the select macro.
pub trait SelectHandle {
/// Attempts to select an operation and returns `true` on success.
fn try_select(&self, token: &mut Token) -> bool;
@ -442,6 +444,7 @@ fn run_ready(
}
/// Attempts to select one of the operations without blocking.
// This is a private API (exposed inside crossbeam_channel::internal module) that is used by the select macro.
#[inline]
pub fn try_select<'a>(
handles: &mut [(&'a dyn SelectHandle, usize, *const u8)],
@ -458,6 +461,7 @@ pub fn try_select<'a>(
}
/// Blocks until one of the operations becomes ready and selects it.
// This is a private API (exposed inside crossbeam_channel::internal module) that is used by the select macro.
#[inline]
pub fn select<'a>(
handles: &mut [(&'a dyn SelectHandle, usize, *const u8)],
@ -476,6 +480,7 @@ pub fn select<'a>(
}
/// Blocks for a limited time until one of the operations becomes ready and selects it.
// This is a private API (exposed inside crossbeam_channel::internal module) that is used by the select macro.
#[inline]
pub fn select_timeout<'a>(
handles: &mut [(&'a dyn SelectHandle, usize, *const u8)],

Просмотреть файл

@ -1,5 +1,6 @@
//! Waking mechanism for threads blocked on channel operations.
use std::ptr;
use std::sync::atomic::{AtomicBool, Ordering};
use std::thread::{self, ThreadId};
@ -13,7 +14,7 @@ pub(crate) struct Entry {
pub(crate) oper: Operation,
/// Optional packet.
pub(crate) packet: usize,
pub(crate) packet: *mut (),
/// Context associated with the thread owning this operation.
pub(crate) cx: Context,
@ -44,12 +45,12 @@ impl Waker {
/// Registers a select operation.
#[inline]
pub(crate) fn register(&mut self, oper: Operation, cx: &Context) {
self.register_with_packet(oper, 0, cx);
self.register_with_packet(oper, ptr::null_mut(), cx);
}
/// Registers a select operation and a packet.
#[inline]
pub(crate) fn register_with_packet(&mut self, oper: Operation, packet: usize, cx: &Context) {
pub(crate) fn register_with_packet(&mut self, oper: Operation, packet: *mut (), cx: &Context) {
self.selectors.push(Entry {
oper,
packet,
@ -76,34 +77,26 @@ impl Waker {
/// Attempts to find another thread's entry, select the operation, and wake it up.
#[inline]
pub(crate) fn try_select(&mut self) -> Option<Entry> {
let mut entry = None;
if !self.selectors.is_empty() {
let thread_id = current_thread_id();
for i in 0..self.selectors.len() {
self.selectors
.iter()
.position(|selector| {
// Does the entry belong to a different thread?
if self.selectors[i].cx.thread_id() != thread_id {
// Try selecting this operation.
let sel = Selected::Operation(self.selectors[i].oper);
let res = self.selectors[i].cx.try_select(sel);
if res.is_ok() {
selector.cx.thread_id() != current_thread_id()
&& selector // Try selecting this operation.
.cx
.try_select(Selected::Operation(selector.oper))
.is_ok()
&& {
// Provide the packet.
self.selectors[i].cx.store_packet(self.selectors[i].packet);
selector.cx.store_packet(selector.packet);
// Wake the thread up.
self.selectors[i].cx.unpark();
// Remove the entry from the queue to keep it clean and improve
// performance.
entry = Some(self.selectors.remove(i));
break;
selector.cx.unpark();
true
}
}
}
}
entry
})
// Remove the entry from the queue to keep it clean and improve
// performance.
.map(|pos| self.selectors.remove(pos))
}
/// Returns `true` if there is an entry which can be selected by the current thread.
@ -125,7 +118,7 @@ impl Waker {
pub(crate) fn watch(&mut self, oper: Operation, cx: &Context) {
self.observers.push(Entry {
oper,
packet: 0,
packet: ptr::null_mut(),
cx: cx.clone(),
});
}
@ -269,7 +262,7 @@ impl SyncWaker {
impl Drop for SyncWaker {
#[inline]
fn drop(&mut self) {
debug_assert_eq!(self.is_empty.load(Ordering::SeqCst), true);
debug_assert!(self.is_empty.load(Ordering::SeqCst));
}
}

Просмотреть файл

@ -1,5 +1,7 @@
//! Tests for the after channel flavor.
#![cfg(not(miri))] // TODO: many assertions failed due to Miri is slow
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
use std::thread;
@ -56,20 +58,20 @@ fn len_empty_full() {
let r = after(ms(50));
assert_eq!(r.len(), 0);
assert_eq!(r.is_empty(), true);
assert_eq!(r.is_full(), false);
assert!(r.is_empty());
assert!(!r.is_full());
thread::sleep(ms(100));
assert_eq!(r.len(), 1);
assert_eq!(r.is_empty(), false);
assert_eq!(r.is_full(), true);
assert!(!r.is_empty());
assert!(r.is_full());
r.try_recv().unwrap();
assert_eq!(r.len(), 0);
assert_eq!(r.is_empty(), true);
assert_eq!(r.is_full(), false);
assert!(r.is_empty());
assert!(!r.is_full());
}
#[test]
@ -211,7 +213,7 @@ fn select() {
break;
}
i => {
oper.recv(&v[i]).unwrap();
oper.recv(v[i]).unwrap();
hits.fetch_add(1, Ordering::SeqCst);
}
}

Просмотреть файл

@ -1,5 +1,7 @@
//! Tests for the array channel flavor.
#![cfg(not(miri))] // TODO: many assertions failed due to Miri is slow
use std::any::Any;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
@ -43,38 +45,38 @@ fn len_empty_full() {
let (s, r) = bounded(2);
assert_eq!(s.len(), 0);
assert_eq!(s.is_empty(), true);
assert_eq!(s.is_full(), false);
assert!(s.is_empty());
assert!(!s.is_full());
assert_eq!(r.len(), 0);
assert_eq!(r.is_empty(), true);
assert_eq!(r.is_full(), false);
assert!(r.is_empty());
assert!(!r.is_full());
s.send(()).unwrap();
assert_eq!(s.len(), 1);
assert_eq!(s.is_empty(), false);
assert_eq!(s.is_full(), false);
assert!(!s.is_empty());
assert!(!s.is_full());
assert_eq!(r.len(), 1);
assert_eq!(r.is_empty(), false);
assert_eq!(r.is_full(), false);
assert!(!r.is_empty());
assert!(!r.is_full());
s.send(()).unwrap();
assert_eq!(s.len(), 2);
assert_eq!(s.is_empty(), false);
assert_eq!(s.is_full(), true);
assert!(!s.is_empty());
assert!(s.is_full());
assert_eq!(r.len(), 2);
assert_eq!(r.is_empty(), false);
assert_eq!(r.is_full(), true);
assert!(!r.is_empty());
assert!(r.is_full());
r.recv().unwrap();
assert_eq!(s.len(), 1);
assert_eq!(s.is_empty(), false);
assert_eq!(s.is_full(), false);
assert!(!s.is_empty());
assert!(!s.is_full());
assert_eq!(r.len(), 1);
assert_eq!(r.is_empty(), false);
assert_eq!(r.is_full(), false);
assert!(!r.is_empty());
assert!(!r.is_full());
}
#[test]

Просмотреть файл

@ -9,6 +9,8 @@
//! - https://golang.org/LICENSE
//! - https://golang.org/PATENTS
#![allow(clippy::mutex_atomic, clippy::redundant_clone)]
use std::alloc::{GlobalAlloc, Layout, System};
use std::any::Any;
use std::cell::Cell;
@ -176,7 +178,7 @@ unsafe impl GlobalAlloc for Counter {
if !ret.is_null() {
ALLOCATED.fetch_add(layout.size(), SeqCst);
}
return ret;
ret
}
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
@ -232,6 +234,9 @@ macro_rules! go {
mod doubleselect {
use super::*;
#[cfg(miri)]
const ITERATIONS: i32 = 100;
#[cfg(not(miri))]
const ITERATIONS: i32 = 10_000;
fn sender(n: i32, c1: Chan<i32>, c2: Chan<i32>, c3: Chan<i32>, c4: Chan<i32>) {
@ -691,6 +696,11 @@ mod select {
mod select2 {
use super::*;
#[cfg(miri)]
const N: i32 = 1000;
#[cfg(not(miri))]
const N: i32 = 100000;
#[test]
fn main() {
fn sender(c: &Chan<i32>, n: i32) {
@ -702,9 +712,7 @@ mod select2 {
fn receiver(c: &Chan<i32>, dummy: &Chan<i32>, n: i32) {
for _ in 0..n {
select! {
recv(c.rx()) -> _ => {
()
}
recv(c.rx()) -> _ => {}
recv(dummy.rx()) -> _ => {
panic!("dummy");
}
@ -717,15 +725,18 @@ mod select2 {
ALLOCATED.store(0, SeqCst);
go!(c, sender(&c, 100000));
receiver(&c, &dummy, 100000);
go!(c, sender(&c, N));
receiver(&c, &dummy, N);
let alloc = ALLOCATED.load(SeqCst);
go!(c, sender(&c, 100000));
receiver(&c, &dummy, 100000);
go!(c, sender(&c, N));
receiver(&c, &dummy, N);
assert!(!(ALLOCATED.load(SeqCst) > alloc && (ALLOCATED.load(SeqCst) - alloc) > 110000))
assert!(
!(ALLOCATED.load(SeqCst) > alloc
&& (ALLOCATED.load(SeqCst) - alloc) > (N as usize + 10000))
)
}
}
@ -913,6 +924,9 @@ mod chan_test {
#[test]
fn test_chan() {
#[cfg(miri)]
const N: i32 = 20;
#[cfg(not(miri))]
const N: i32 = 200;
for cap in 0..N {
@ -1052,6 +1066,9 @@ mod chan_test {
#[test]
fn test_nonblock_recv_race() {
#[cfg(miri)]
const N: usize = 100;
#[cfg(not(miri))]
const N: usize = 1000;
for _ in 0..N {
@ -1073,6 +1090,9 @@ mod chan_test {
#[test]
fn test_nonblock_select_race() {
#[cfg(miri)]
const N: usize = 100;
#[cfg(not(miri))]
const N: usize = 1000;
let done = make::<bool>(1);
@ -1106,6 +1126,9 @@ mod chan_test {
#[test]
fn test_nonblock_select_race2() {
#[cfg(miri)]
const N: usize = 100;
#[cfg(not(miri))]
const N: usize = 1000;
let done = make::<bool>(1);
@ -1142,6 +1165,11 @@ mod chan_test {
// Ensure that send/recv on the same chan in select
// does not crash nor deadlock.
#[cfg(miri)]
const N: usize = 100;
#[cfg(not(miri))]
const N: usize = 1000;
for &cap in &[0, 10] {
let wg = WaitGroup::new();
wg.add(2);
@ -1151,7 +1179,7 @@ mod chan_test {
let p = p;
go!(wg, p, c, {
defer! { wg.done() }
for i in 0..1000 {
for i in 0..N {
if p == 0 || i % 2 == 0 {
select! {
send(c.tx(), p) -> _ => {}
@ -1180,6 +1208,11 @@ mod chan_test {
#[test]
fn test_select_stress() {
#[cfg(miri)]
const N: usize = 100;
#[cfg(not(miri))]
const N: usize = 10000;
let c = vec![
make::<i32>(0),
make::<i32>(0),
@ -1187,8 +1220,6 @@ mod chan_test {
make::<i32>(3),
];
const N: usize = 10000;
// There are 4 goroutines that send N values on each of the chans,
// + 4 goroutines that receive N values on each of the chans,
// + 1 goroutine that sends N values on each of the chans in a single select,
@ -1286,6 +1317,9 @@ mod chan_test {
#[test]
fn test_select_fairness() {
#[cfg(miri)]
const TRIALS: usize = 100;
#[cfg(not(miri))]
const TRIALS: usize = 10000;
let c1 = make::<u8>(TRIALS + 1);
@ -1369,6 +1403,9 @@ mod chan_test {
#[test]
fn test_pseudo_random_send() {
#[cfg(miri)]
const N: usize = 20;
#[cfg(not(miri))]
const N: usize = 100;
for cap in 0..N {
@ -1412,6 +1449,9 @@ mod chan_test {
#[test]
fn test_multi_consumer() {
const NWORK: usize = 23;
#[cfg(miri)]
const NITER: usize = 100;
#[cfg(not(miri))]
const NITER: usize = 271828;
let pn = [2, 3, 7, 11, 13, 17, 19, 23, 27, 31];
@ -1510,6 +1550,9 @@ mod chan1 {
use super::*;
// sent messages
#[cfg(miri)]
const N: usize = 100;
#[cfg(not(miri))]
const N: usize = 1000;
// receiving "goroutines"
const M: usize = 10;

Просмотреть файл

@ -93,7 +93,7 @@ fn recv_into_iter_owned() {
assert_eq!(iter.next().unwrap(), 1);
assert_eq!(iter.next().unwrap(), 2);
assert_eq!(iter.next().is_none(), true);
assert!(iter.next().is_none());
}
#[test]
@ -106,5 +106,5 @@ fn recv_into_iter_borrowed() {
let mut iter = (&r).into_iter();
assert_eq!(iter.next().unwrap(), 1);
assert_eq!(iter.next().unwrap(), 2);
assert_eq!(iter.next().is_none(), true);
assert!(iter.next().is_none());
}

Просмотреть файл

@ -41,29 +41,29 @@ fn len_empty_full() {
let (s, r) = unbounded();
assert_eq!(s.len(), 0);
assert_eq!(s.is_empty(), true);
assert_eq!(s.is_full(), false);
assert!(s.is_empty());
assert!(!s.is_full());
assert_eq!(r.len(), 0);
assert_eq!(r.is_empty(), true);
assert_eq!(r.is_full(), false);
assert!(r.is_empty());
assert!(!r.is_full());
s.send(()).unwrap();
assert_eq!(s.len(), 1);
assert_eq!(s.is_empty(), false);
assert_eq!(s.is_full(), false);
assert!(!s.is_empty());
assert!(!s.is_full());
assert_eq!(r.len(), 1);
assert_eq!(r.is_empty(), false);
assert_eq!(r.is_full(), false);
assert!(!r.is_empty());
assert!(!r.is_full());
r.recv().unwrap();
assert_eq!(s.len(), 0);
assert_eq!(s.is_empty(), true);
assert_eq!(s.is_full(), false);
assert!(s.is_empty());
assert!(!s.is_full());
assert_eq!(r.len(), 0);
assert_eq!(r.is_empty(), true);
assert_eq!(r.is_full(), false);
assert!(r.is_empty());
assert!(!r.is_full());
}
#[test]
@ -239,6 +239,9 @@ fn disconnect_wakes_receiver() {
#[test]
fn spsc() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 100_000;
let (s, r) = unbounded();
@ -261,6 +264,9 @@ fn spsc() {
#[test]
fn mpmc() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 25_000;
const THREADS: usize = 4;
@ -295,6 +301,9 @@ fn mpmc() {
#[test]
fn stress_oneshot() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
for _ in 0..COUNT {
@ -310,6 +319,9 @@ fn stress_oneshot() {
#[test]
fn stress_iter() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 100_000;
let (request_s, request_r) = unbounded();
@ -371,8 +383,11 @@ fn stress_timeout_two_threads() {
.unwrap();
}
#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn drops() {
const RUNS: usize = 100;
static DROPS: AtomicUsize = AtomicUsize::new(0);
#[derive(Debug, PartialEq)]
@ -386,7 +401,7 @@ fn drops() {
let mut rng = thread_rng();
for _ in 0..100 {
for _ in 0..RUNS {
let steps = rng.gen_range(0..10_000);
let additional = rng.gen_range(0..1000);
@ -421,6 +436,9 @@ fn drops() {
#[test]
fn linearizable() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 25_000;
const THREADS: usize = 4;
@ -441,6 +459,9 @@ fn linearizable() {
#[test]
fn fairness() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = unbounded::<()>();
@ -463,6 +484,9 @@ fn fairness() {
#[test]
fn fairness_duplicates() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s, r) = unbounded();
@ -496,6 +520,9 @@ fn recv_in_send() {
#[test]
fn channel_through_channel() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 1000;
type T = Box<dyn Any + Send>;

Просмотреть файл

@ -20,6 +20,12 @@
//! - https://github.com/rust-lang/rust/blob/master/COPYRIGHT
//! - https://www.rust-lang.org/en-US/legal.html
#![allow(
clippy::drop_copy,
clippy::match_single_binding,
clippy::redundant_clone
)]
use std::sync::mpsc::{RecvError, RecvTimeoutError, TryRecvError};
use std::sync::mpsc::{SendError, TrySendError};
use std::thread::JoinHandle;
@ -176,7 +182,7 @@ macro_rules! select {
) => ({
cc::crossbeam_channel_internal! {
$(
recv(($rx).inner) -> res => {
$meth(($rx).inner) -> res => {
let $name = res.map_err(|_| ::std::sync::mpsc::RecvError);
$code
}
@ -314,13 +320,18 @@ mod channel_tests {
#[test]
fn stress() {
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 10000;
let (tx, rx) = channel::<i32>();
let t = thread::spawn(move || {
for _ in 0..10000 {
for _ in 0..COUNT {
tx.send(1).unwrap();
}
});
for _ in 0..10000 {
for _ in 0..COUNT {
assert_eq!(rx.recv().unwrap(), 1);
}
t.join().ok().unwrap();
@ -328,6 +339,9 @@ mod channel_tests {
#[test]
fn stress_shared() {
#[cfg(miri)]
const AMT: u32 = 500;
#[cfg(not(miri))]
const AMT: u32 = 10000;
const NTHREADS: u32 = 8;
let (tx, rx) = channel::<i32>();
@ -336,10 +350,7 @@ mod channel_tests {
for _ in 0..AMT * NTHREADS {
assert_eq!(rx.recv().unwrap(), 1);
}
match rx.try_recv() {
Ok(..) => panic!(),
_ => {}
}
assert!(rx.try_recv().is_err());
});
let mut ts = Vec::with_capacity(NTHREADS as usize);
@ -735,12 +746,17 @@ mod channel_tests {
#[test]
fn recv_a_lot() {
#[cfg(miri)]
const N: usize = 100;
#[cfg(not(miri))]
const N: usize = 10000;
// Regression test that we don't run out of stack in scheduler context
let (tx, rx) = channel();
for _ in 0..10000 {
for _ in 0..N {
tx.send(()).unwrap();
}
for _ in 0..10000 {
for _ in 0..N {
rx.recv().unwrap();
}
}
@ -880,7 +896,7 @@ mod channel_tests {
};
assert_eq!(iter.next().unwrap(), 1);
assert_eq!(iter.next().unwrap(), 2);
assert_eq!(iter.next().is_none(), true);
assert!(iter.next().is_none());
}
#[test]
@ -892,7 +908,7 @@ mod channel_tests {
let mut iter = (&rx).into_iter();
assert_eq!(iter.next().unwrap(), 1);
assert_eq!(iter.next().unwrap(), 2);
assert_eq!(iter.next().is_none(), true);
assert!(iter.next().is_none());
}
#[test]
@ -1079,13 +1095,18 @@ mod sync_channel_tests {
#[test]
fn stress() {
#[cfg(miri)]
const N: usize = 100;
#[cfg(not(miri))]
const N: usize = 10000;
let (tx, rx) = sync_channel::<i32>(0);
let t = thread::spawn(move || {
for _ in 0..10000 {
for _ in 0..N {
tx.send(1).unwrap();
}
});
for _ in 0..10000 {
for _ in 0..N {
assert_eq!(rx.recv().unwrap(), 1);
}
t.join().unwrap();
@ -1093,10 +1114,15 @@ mod sync_channel_tests {
#[test]
fn stress_recv_timeout_two_threads() {
#[cfg(miri)]
const N: usize = 100;
#[cfg(not(miri))]
const N: usize = 10000;
let (tx, rx) = sync_channel::<i32>(0);
let t = thread::spawn(move || {
for _ in 0..10000 {
for _ in 0..N {
tx.send(1).unwrap();
}
});
@ -1113,12 +1139,15 @@ mod sync_channel_tests {
}
}
assert_eq!(recv_count, 10000);
assert_eq!(recv_count, N);
t.join().unwrap();
}
#[test]
fn stress_recv_timeout_shared() {
#[cfg(miri)]
const AMT: u32 = 100;
#[cfg(not(miri))]
const AMT: u32 = 1000;
const NTHREADS: u32 = 8;
let (tx, rx) = sync_channel::<i32>(0);
@ -1165,6 +1194,9 @@ mod sync_channel_tests {
#[test]
fn stress_shared() {
#[cfg(miri)]
const AMT: u32 = 100;
#[cfg(not(miri))]
const AMT: u32 = 1000;
const NTHREADS: u32 = 8;
let (tx, rx) = sync_channel::<i32>(0);
@ -1174,10 +1206,7 @@ mod sync_channel_tests {
for _ in 0..AMT * NTHREADS {
assert_eq!(rx.recv().unwrap(), 1);
}
match rx.try_recv() {
Ok(..) => panic!(),
_ => {}
}
assert!(rx.try_recv().is_err());
dtx.send(()).unwrap();
});
@ -1449,12 +1478,17 @@ mod sync_channel_tests {
#[test]
fn recv_a_lot() {
#[cfg(miri)]
const N: usize = 100;
#[cfg(not(miri))]
const N: usize = 10000;
// Regression test that we don't run out of stack in scheduler context
let (tx, rx) = sync_channel(10000);
for _ in 0..10000 {
let (tx, rx) = sync_channel(N);
for _ in 0..N {
tx.send(()).unwrap();
}
for _ in 0..10000 {
for _ in 0..N {
rx.recv().unwrap();
}
}
@ -1792,7 +1826,11 @@ mod select_tests {
#[test]
fn stress() {
#[cfg(miri)]
const AMT: i32 = 100;
#[cfg(not(miri))]
const AMT: i32 = 10000;
let (tx1, rx1) = channel::<i32>();
let (tx2, rx2) = channel::<i32>();
let (tx3, rx3) = channel::<()>();

Просмотреть файл

@ -65,8 +65,8 @@ fn capacity() {
fn len_empty_full() {
let r = never::<i32>();
assert_eq!(r.len(), 0);
assert_eq!(r.is_empty(), true);
assert_eq!(r.is_full(), true);
assert!(r.is_empty());
assert!(r.is_full());
}
#[test]

Просмотреть файл

@ -1,5 +1,7 @@
//! Tests for channel readiness using the `Select` struct.
#![allow(clippy::drop_copy)]
use std::any::Any;
use std::cell::Cell;
use std::thread;
@ -490,6 +492,9 @@ fn nesting() {
#[test]
fn stress_recv() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = unbounded();
@ -527,6 +532,9 @@ fn stress_recv() {
#[test]
fn stress_send() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = bounded(0);
@ -561,6 +569,9 @@ fn stress_send() {
#[test]
fn stress_mixed() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = bounded(0);
@ -666,6 +677,9 @@ fn send_recv_same_channel() {
#[test]
fn channel_through_channel() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 1000;
type T = Box<dyn Any + Send>;
@ -722,6 +736,9 @@ fn channel_through_channel() {
#[test]
fn fairness1() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = bounded::<()>(COUNT);
@ -767,6 +784,9 @@ fn fairness1() {
#[test]
fn fairness2() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 100_000;
let (s1, r1) = unbounded::<()>();

Просмотреть файл

@ -1,5 +1,7 @@
//! Tests for channel selection using the `Select` struct.
#![allow(clippy::drop_copy)]
use std::any::Any;
use std::cell::Cell;
use std::thread;
@ -406,6 +408,7 @@ fn both_ready() {
.unwrap();
}
#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn loop_try() {
const RUNS: usize = 20;
@ -690,6 +693,9 @@ fn nesting() {
#[test]
fn stress_recv() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = unbounded();
@ -728,6 +734,9 @@ fn stress_recv() {
#[test]
fn stress_send() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = bounded(0);
@ -763,6 +772,9 @@ fn stress_send() {
#[test]
fn stress_mixed() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = bounded(0);
@ -895,12 +907,12 @@ fn matching() {
for i in 0..THREADS {
scope.spawn(move |_| {
let mut sel = Select::new();
let oper1 = sel.recv(&r);
let oper2 = sel.send(&s);
let oper1 = sel.recv(r);
let oper2 = sel.send(s);
let oper = sel.select();
match oper.index() {
ix if ix == oper1 => assert_ne!(oper.recv(&r), Ok(i)),
ix if ix == oper2 => assert!(oper.send(&s, i).is_ok()),
ix if ix == oper1 => assert_ne!(oper.recv(r), Ok(i)),
ix if ix == oper2 => assert!(oper.send(s, i).is_ok()),
_ => unreachable!(),
}
});
@ -921,12 +933,12 @@ fn matching_with_leftover() {
for i in 0..THREADS {
scope.spawn(move |_| {
let mut sel = Select::new();
let oper1 = sel.recv(&r);
let oper2 = sel.send(&s);
let oper1 = sel.recv(r);
let oper2 = sel.send(s);
let oper = sel.select();
match oper.index() {
ix if ix == oper1 => assert_ne!(oper.recv(&r), Ok(i)),
ix if ix == oper2 => assert!(oper.send(&s, i).is_ok()),
ix if ix == oper1 => assert_ne!(oper.recv(r), Ok(i)),
ix if ix == oper2 => assert!(oper.send(s, i).is_ok()),
_ => unreachable!(),
}
});
@ -940,6 +952,9 @@ fn matching_with_leftover() {
#[test]
fn channel_through_channel() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 1000;
type T = Box<dyn Any + Send>;
@ -998,6 +1013,9 @@ fn channel_through_channel() {
#[test]
fn linearizable_try() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 100_000;
for step in 0..2 {
@ -1050,6 +1068,9 @@ fn linearizable_try() {
#[test]
fn linearizable_timeout() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 100_000;
for step in 0..2 {
@ -1102,6 +1123,9 @@ fn linearizable_timeout() {
#[test]
fn fairness1() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = bounded::<()>(COUNT);
@ -1148,6 +1172,9 @@ fn fairness1() {
#[test]
fn fairness2() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = unbounded::<()>();
@ -1212,8 +1239,8 @@ fn sync_and_clone() {
let (s, r) = &bounded::<usize>(0);
let mut sel = Select::new();
let oper1 = sel.recv(&r);
let oper2 = sel.send(&s);
let oper1 = sel.recv(r);
let oper2 = sel.send(s);
let sel = &sel;
scope(|scope| {
@ -1222,8 +1249,8 @@ fn sync_and_clone() {
let mut sel = sel.clone();
let oper = sel.select();
match oper.index() {
ix if ix == oper1 => assert_ne!(oper.recv(&r), Ok(i)),
ix if ix == oper2 => assert!(oper.send(&s, i).is_ok()),
ix if ix == oper1 => assert_ne!(oper.recv(r), Ok(i)),
ix if ix == oper2 => assert!(oper.send(s, i).is_ok()),
_ => unreachable!(),
}
});
@ -1241,8 +1268,8 @@ fn send_and_clone() {
let (s, r) = &bounded::<usize>(0);
let mut sel = Select::new();
let oper1 = sel.recv(&r);
let oper2 = sel.send(&s);
let oper1 = sel.recv(r);
let oper2 = sel.send(s);
scope(|scope| {
for i in 0..THREADS {
@ -1250,8 +1277,8 @@ fn send_and_clone() {
scope.spawn(move |_| {
let oper = sel.select();
match oper.index() {
ix if ix == oper1 => assert_ne!(oper.recv(&r), Ok(i)),
ix if ix == oper2 => assert!(oper.send(&s, i).is_ok()),
ix if ix == oper1 => assert_ne!(oper.recv(r), Ok(i)),
ix if ix == oper2 => assert!(oper.send(s, i).is_ok()),
_ => unreachable!(),
}
});
@ -1264,6 +1291,9 @@ fn send_and_clone() {
#[test]
fn reuse() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = bounded(0);

Просмотреть файл

@ -1,6 +1,7 @@
//! Tests for the `select!` macro.
#![forbid(unsafe_code)] // select! is safe.
#![allow(clippy::drop_copy, clippy::match_single_binding)]
use std::any::Any;
use std::cell::Cell;
@ -283,6 +284,7 @@ fn both_ready() {
.unwrap();
}
#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn loop_try() {
const RUNS: usize = 20;
@ -485,6 +487,9 @@ fn panic_receiver() {
#[test]
fn stress_recv() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = unbounded();
@ -518,6 +523,9 @@ fn stress_recv() {
#[test]
fn stress_send() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = bounded(0);
@ -548,6 +556,9 @@ fn stress_send() {
#[test]
fn stress_mixed() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = bounded(0);
@ -681,6 +692,9 @@ fn matching_with_leftover() {
#[test]
fn channel_through_channel() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 1000;
type T = Box<dyn Any + Send>;
@ -726,6 +740,9 @@ fn channel_through_channel() {
#[test]
fn linearizable_default() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 100_000;
for step in 0..2 {
@ -770,6 +787,9 @@ fn linearizable_default() {
#[test]
fn linearizable_timeout() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 100_000;
for step in 0..2 {
@ -814,6 +834,9 @@ fn linearizable_timeout() {
#[test]
fn fairness1() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = bounded::<()>(COUNT);
@ -838,6 +861,9 @@ fn fairness1() {
#[test]
fn fairness2() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = unbounded::<()>();
@ -875,6 +901,9 @@ fn fairness2() {
#[test]
fn fairness_recv() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = bounded::<()>(COUNT);
@ -897,6 +926,9 @@ fn fairness_recv() {
#[test]
fn fairness_send() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, _r1) = bounded::<()>(COUNT);
@ -912,6 +944,7 @@ fn fairness_send() {
assert!(hits.iter().all(|x| *x >= COUNT / 4));
}
#[allow(clippy::or_fun_call)] // This is intentional.
#[test]
fn references() {
let (s, r) = unbounded::<i32>();
@ -958,6 +991,7 @@ fn case_blocks() {
drop(s);
}
#[allow(clippy::redundant_closure_call)] // This is intentional.
#[test]
fn move_handles() {
let (s, r) = unbounded::<i32>();

Просмотреть файл

@ -1,5 +1,7 @@
//! Tests that make sure accessing thread-locals while exiting the thread doesn't cause panics.
#![cfg(not(miri))] // error: abnormal termination: the evaluated program aborted execution
use std::thread;
use std::time::Duration;

Просмотреть файл

@ -1,5 +1,7 @@
//! Tests for the tick channel flavor.
#![cfg(not(miri))] // TODO: many assertions failed due to Miri is slow
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
use std::thread;
@ -78,20 +80,20 @@ fn len_empty_full() {
let r = tick(ms(50));
assert_eq!(r.len(), 0);
assert_eq!(r.is_empty(), true);
assert_eq!(r.is_full(), false);
assert!(r.is_empty());
assert!(!r.is_full());
thread::sleep(ms(100));
assert_eq!(r.len(), 1);
assert_eq!(r.is_empty(), false);
assert_eq!(r.is_full(), true);
assert!(!r.is_empty());
assert!(r.is_full());
r.try_recv().unwrap();
assert_eq!(r.len(), 0);
assert_eq!(r.is_empty(), true);
assert_eq!(r.is_full(), false);
assert!(r.is_empty());
assert!(!r.is_full());
}
#[test]

Просмотреть файл

@ -35,11 +35,11 @@ fn len_empty_full() {
let (s, r) = bounded(0);
assert_eq!(s.len(), 0);
assert_eq!(s.is_empty(), true);
assert_eq!(s.is_full(), true);
assert!(s.is_empty());
assert!(s.is_full());
assert_eq!(r.len(), 0);
assert_eq!(r.is_empty(), true);
assert_eq!(r.is_full(), true);
assert!(r.is_empty());
assert!(r.is_full());
scope(|scope| {
scope.spawn(|_| s.send(0).unwrap());
@ -48,11 +48,11 @@ fn len_empty_full() {
.unwrap();
assert_eq!(s.len(), 0);
assert_eq!(s.is_empty(), true);
assert_eq!(s.is_full(), true);
assert!(s.is_empty());
assert!(s.is_full());
assert_eq!(r.len(), 0);
assert_eq!(r.is_empty(), true);
assert_eq!(r.is_full(), true);
assert!(r.is_empty());
assert!(r.is_full());
}
#[test]
@ -187,6 +187,9 @@ fn send_timeout() {
#[test]
fn len() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 25_000;
let (s, r) = bounded(0);
@ -249,6 +252,9 @@ fn disconnect_wakes_receiver() {
#[test]
fn spsc() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 100_000;
let (s, r) = bounded(0);
@ -271,6 +277,9 @@ fn spsc() {
#[test]
fn mpmc() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 25_000;
const THREADS: usize = 4;
@ -303,6 +312,9 @@ fn mpmc() {
#[test]
fn stress_oneshot() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
for _ in 0..COUNT {
@ -316,6 +328,7 @@ fn stress_oneshot() {
}
}
#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn stress_iter() {
const COUNT: usize = 1000;
@ -383,8 +396,11 @@ fn stress_timeout_two_threads() {
.unwrap();
}
#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn drops() {
const RUNS: usize = 100;
static DROPS: AtomicUsize = AtomicUsize::new(0);
#[derive(Debug, PartialEq)]
@ -398,7 +414,7 @@ fn drops() {
let mut rng = thread_rng();
for _ in 0..100 {
for _ in 0..RUNS {
let steps = rng.gen_range(0..3_000);
DROPS.store(0, Ordering::SeqCst);
@ -428,6 +444,9 @@ fn drops() {
#[test]
fn fairness() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = bounded::<()>(0);
@ -459,6 +478,9 @@ fn fairness() {
#[test]
fn fairness_duplicates() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s, r) = bounded::<()>(0);
@ -517,6 +539,9 @@ fn recv_in_send() {
#[test]
fn channel_through_channel() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 1000;
type T = Box<dyn Any + Send>;

Просмотреть файл

@ -1 +1 @@
{"files":{"CHANGELOG.md":"40b65a13f12e97a24c838fe2254a3563a5fe00922053ef7256ed4752876614fa","Cargo.lock":"35b1db42b892c01e72ff1f99fc7767e5e47208d083203866337f6f2f7d0738eb","Cargo.toml":"eab75399db818408fd4f45a91919b08e050e56547014816683a269270e292055","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"5734ed989dfca1f625b40281ee9f4530f91b2411ec01cb748223e7eb87e201ab","README.md":"f946b25082979595d3851d90c4e76424be921a779e88e982f8455d44d46057ec","benches/defer.rs":"c330b704d96b2ad1aed29f72c37a99da534adef8cb06a3976d5f93bf567abb20","benches/flush.rs":"0389ac6c473632f0e93c962f223404cc360257f6699b4ec90b9b3be16bb6d74f","benches/pin.rs":"80f9e65ba04a2ddec7a330172d0b0fbc698e20c221b3d8cdc70cc42e3b9099d1","build.rs":"c8684300062c73e96eae8877d03e145ee95e0cd99d4d933696caa582c08e2416","examples/sanitize.rs":"a39d1635fa61e643e59192d7a63becc97ff81f03c1f4e03d38cedefb1525026a","no_atomic.rs":"a2621c1b029c614fb0ab8e3f5cda2e839df88d90d26133181c1b901965f7eec4","src/atomic.rs":"631d3062e3c30d8e505fda3a7e2c68a88abf7617881035d6131c39cb8fdddce0","src/collector.rs":"7d636f3f96fafd033298d1c2ab126205438a46deb84895d8e28bea9eef67798a","src/default.rs":"e1449bd6e61d7c19e9cbdf183f81c67c3487775fcc55572947874ca535d3d54f","src/deferred.rs":"1ee67bd3200d3891076aac8cfc9767abdddc194602f2084d11455484096005ea","src/epoch.rs":"d31e66d8fe62299928e25867336d96391b26a4fe890a1cae0885dfcf36d6835b","src/guard.rs":"55c56ca1b2fbc067ae21108f0f7de4be91e5b41df2492055b635ed436782dd52","src/internal.rs":"f3f8131819b2a4ec4d1a6d392c734688324f3ae708bac6745e88f2930657eba1","src/lib.rs":"bcaa7c8dc9f9eb1ef6f56b4c0705db348d00b21325b6c0c1544cd7aec0613dc9","src/sync/list.rs":"10aa4c59845ab9ff1d8bcb6f594b70bbe23c320fa7a2b125fdf85df88b9d61e2","src/sync/mod.rs":"cbc6334460d73761c3dea7f99ed2ccbf267d5da3bc76c812e94f85c9f4565c6a","src/sync/queue.rs":"262e0d8f343e97df9e2a738461e4255e339710e81c479e484f9efe517ae47135","tests/loom.rs":"db772f4478966de6ec98774ca4093171dc942da635822a0d2d3257d31188cb9b"},"package":"4ec02e091aa634e2c3ada4a392989e7c3116673ef0ac5b72232439094d73b7fd"}
{"files":{"CHANGELOG.md":"7f3c7198f2e33ba93bb8270e1c1e8dc6d70c343987acd9d0706e3632cbb9e0ad","Cargo.lock":"10e3899295e7e8ce93d3f0b597efbec844bdda40f78ae717f5995341d41ee937","Cargo.toml":"d7e7ab87ca4a4e8cc4ae9644e1537eedc46473ff5f89399b4733c4bdf59058db","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"5734ed989dfca1f625b40281ee9f4530f91b2411ec01cb748223e7eb87e201ab","README.md":"f946b25082979595d3851d90c4e76424be921a779e88e982f8455d44d46057ec","benches/defer.rs":"c330b704d96b2ad1aed29f72c37a99da534adef8cb06a3976d5f93bf567abb20","benches/flush.rs":"0389ac6c473632f0e93c962f223404cc360257f6699b4ec90b9b3be16bb6d74f","benches/pin.rs":"2f649a5153745c7930efdb32a52f9dc522f7b8cf548a251c5e2c82ee25dc3fff","build.rs":"58a36da8f9ca3a9206d31a0d6e7548f200fe8746ebca5edca48679b0d29a8043","examples/sanitize.rs":"a39d1635fa61e643e59192d7a63becc97ff81f03c1f4e03d38cedefb1525026a","no_atomic.rs":"3529c0833bcd1e09a352d3bd1696d3666850c9b09fe2111bf1a783ec16a5f467","src/atomic.rs":"63843b5ecd51b3fc98336247abe8efa824d826f142e40a761636e530d06f3b41","src/collector.rs":"e2d9780d8707e49360b3c33f2f829f29f70e6929307e65e23449b8ba6def6358","src/default.rs":"e1449bd6e61d7c19e9cbdf183f81c67c3487775fcc55572947874ca535d3d54f","src/deferred.rs":"ea532517c8ca22010ed9a624b059471c8a57b25e7925f6a5dfb391be7646a1fa","src/epoch.rs":"d31e66d8fe62299928e25867336d96391b26a4fe890a1cae0885dfcf36d6835b","src/guard.rs":"55c56ca1b2fbc067ae21108f0f7de4be91e5b41df2492055b635ed436782dd52","src/internal.rs":"67a6811b8c58e1152fd1dc17e389884025a0d99d79ab03dee26efcd0d6896690","src/lib.rs":"bcaa7c8dc9f9eb1ef6f56b4c0705db348d00b21325b6c0c1544cd7aec0613dc9","src/sync/list.rs":"10aa4c59845ab9ff1d8bcb6f594b70bbe23c320fa7a2b125fdf85df88b9d61e2","src/sync/mod.rs":"cbc6334460d73761c3dea7f99ed2ccbf267d5da3bc76c812e94f85c9f4565c6a","src/sync/queue.rs":"06173b2255677d0d39178ceb49876fda2878f491e907c595eb65643dbb43c9ba","tests/loom.rs":"db772f4478966de6ec98774ca4093171dc942da635822a0d2d3257d31188cb9b"},"package":"97242a70df9b89a65d0b6df3c4bf5b9ce03c5b7309019777fbde37e7537f8762"}

12
third_party/rust/crossbeam-epoch/CHANGELOG.md поставляемый
Просмотреть файл

@ -1,12 +1,16 @@
# Version 0.9.6
- Add `Atomic::fetch_update`. (#706)
# Version 0.9.5
- Fix UB in `Pointable` impl of `[MaybeUninit<T>]` (#694)
- Support targets that do not have atomic CAS on stable Rust (#698)
- Fix breakage with nightly feature due to rust-lang/rust#84510 (#692)
- Fix UB in `Pointable` impl of `[MaybeUninit<T>]`. (#694)
- Support targets that do not have atomic CAS on stable Rust. (#698)
- Fix breakage with nightly feature due to rust-lang/rust#84510. (#692)
# Version 0.9.4
- Fix UB in `<[MaybeUninit<T>] as Pointable>::init` when global allocator failed allocation (#690)
- Fix UB in `<[MaybeUninit<T>] as Pointable>::init` when global allocator failed allocation. (#690)
- Bump `loom` dependency to version 0.5. (#686)
# Version 0.9.3

230
third_party/rust/crossbeam-epoch/Cargo.lock сгенерированный поставляемый
Просмотреть файл

@ -2,6 +2,15 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]]
name = "autocfg"
version = "1.0.1"
@ -10,9 +19,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "cc"
version = "1.0.68"
version = "1.0.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787"
checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee"
[[package]]
name = "cfg-if"
@ -22,13 +31,13 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "const_fn"
version = "0.4.8"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f92cfa0fd5690b3cf8c1ef2cabbd9b7ef22fa53cf5e1f92b05103f6d5d1cf6e7"
checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935"
[[package]]
name = "crossbeam-epoch"
version = "0.9.5"
version = "0.9.6"
dependencies = [
"cfg-if",
"const_fn",
@ -42,9 +51,9 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
version = "0.8.5"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db"
checksum = "cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120"
dependencies = [
"cfg-if",
"lazy_static",
@ -83,9 +92,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.95"
version = "0.2.112"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36"
checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
[[package]]
name = "log"
@ -98,35 +107,76 @@ dependencies = [
[[package]]
name = "loom"
version = "0.5.0"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7aa5348dc45fa5f2419b6dd4ea20345e6b01b1fcc9d176a322eada1ac3f382ba"
checksum = "edc5c7d328e32cc4954e8e01193d7f0ef5ab257b5090b70a964e099a36034309"
dependencies = [
"cfg-if",
"generator",
"scoped-tls",
"tracing",
"tracing-subscriber",
]
[[package]]
name = "matchers"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
dependencies = [
"regex-automata",
]
[[package]]
name = "memoffset"
version = "0.6.4"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9"
checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
dependencies = [
"autocfg",
]
[[package]]
name = "ppv-lite86"
version = "0.2.10"
name = "once_cell"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857"
checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
[[package]]
name = "pin-project-lite"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c"
[[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.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rand"
version = "0.8.3"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
dependencies = [
"libc",
"rand_chacha",
@ -136,9 +186,9 @@ dependencies = [
[[package]]
name = "rand_chacha"
version = "0.3.0"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core",
@ -146,27 +196,51 @@ dependencies = [
[[package]]
name = "rand_core"
version = "0.6.2"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7"
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
dependencies = [
"getrandom",
]
[[package]]
name = "rand_hc"
version = "0.3.0"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"
dependencies = [
"rand_core",
]
[[package]]
name = "rustversion"
version = "1.0.5"
name = "regex"
version = "1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
dependencies = [
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
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 = "rustversion"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f"
[[package]]
name = "scoped-tls"
@ -180,6 +254,108 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "sharded-slab"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31"
dependencies = [
"lazy_static",
]
[[package]]
name = "smallvec"
version = "1.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309"
[[package]]
name = "syn"
version = "1.0.85"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]]
name = "thread_local"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd"
dependencies = [
"once_cell",
]
[[package]]
name = "tracing"
version = "0.1.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105"
dependencies = [
"cfg-if",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing-core"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4"
dependencies = [
"lazy_static",
]
[[package]]
name = "tracing-log"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3"
dependencies = [
"lazy_static",
"log",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d81bfa81424cc98cb034b837c985b7a290f592e5b4322f353f94a0ab0f9f594"
dependencies = [
"ansi_term",
"lazy_static",
"matchers",
"regex",
"sharded-slab",
"smallvec",
"thread_local",
"tracing",
"tracing-core",
"tracing-log",
]
[[package]]
name = "unicode-xid"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "wasi"
version = "0.10.2+wasi-snapshot-preview1"

14
third_party/rust/crossbeam-epoch/Cargo.toml поставляемый
Просмотреть файл

@ -3,21 +3,19 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
rust-version = "1.36"
name = "crossbeam-epoch"
version = "0.9.5"
authors = ["The Crossbeam Project Developers"]
version = "0.9.6"
description = "Epoch-based garbage collection"
homepage = "https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-epoch"
documentation = "https://docs.rs/crossbeam-epoch"
keywords = ["lock-free", "rcu", "atomic", "garbage"]
categories = ["concurrency", "memory-management", "no-std"]
license = "MIT OR Apache-2.0"

Просмотреть файл

@ -8,7 +8,7 @@ use test::Bencher;
#[bench]
fn single_pin(b: &mut Bencher) {
b.iter(|| epoch::pin());
b.iter(epoch::pin);
}
#[bench]

16
third_party/rust/crossbeam-epoch/build.rs поставляемый
Просмотреть файл

@ -4,9 +4,19 @@ use std::env;
include!("no_atomic.rs");
// The rustc-cfg strings below are *not* public API. Please let us know by
// opening a GitHub issue if your build environment requires some way to enable
// these cfgs other than by executing our build script.
// The rustc-cfg listed below are considered public API, but it is *unstable*
// and outside of the normal semver guarantees:
//
// - `crossbeam_no_atomic_cas`
// Assume the target does *not* support atomic CAS operations.
// This is usually detected automatically by the build script, but you may
// need to enable it manually when building for custom targets or using
// non-cargo build systems that don't run the build script.
//
// With the exceptions mentioned above, the rustc-cfg strings below are
// *not* public API. Please let us know by opening a GitHub issue if your build
// environment requires some way to enable these cfgs other than by executing
// our build script.
fn main() {
let target = match env::var("TARGET") {
Ok(target) => target,

Просмотреть файл

@ -3,6 +3,8 @@
const NO_ATOMIC_CAS: &[&str] = &[
"avr-unknown-gnu-atmega328",
"bpfeb-unknown-none",
"bpfel-unknown-none",
"msp430-none-elf",
"riscv32i-unknown-none-elf",
"riscv32imc-unknown-none-elf",
@ -21,6 +23,7 @@ const NO_ATOMIC_64: &[&str] = &[
"armv7r-none-eabi",
"armv7r-none-eabihf",
"hexagon-unknown-linux-musl",
"m68k-unknown-linux-gnu",
"mips-unknown-linux-gnu",
"mips-unknown-linux-musl",
"mips-unknown-linux-uclibc",
@ -30,6 +33,7 @@ const NO_ATOMIC_64: &[&str] = &[
"mipsel-unknown-none",
"mipsisa32r6-unknown-linux-gnu",
"mipsisa32r6el-unknown-linux-gnu",
"powerpc-unknown-freebsd",
"powerpc-unknown-linux-gnu",
"powerpc-unknown-linux-gnuspe",
"powerpc-unknown-linux-musl",
@ -40,12 +44,14 @@ const NO_ATOMIC_64: &[&str] = &[
"riscv32gc-unknown-linux-gnu",
"riscv32gc-unknown-linux-musl",
"riscv32imac-unknown-none-elf",
"riscv32imc-esp-espidf",
"thumbv7em-none-eabi",
"thumbv7em-none-eabihf",
"thumbv7m-none-eabi",
"thumbv8m.base-none-eabi",
"thumbv8m.main-none-eabi",
"thumbv8m.main-none-eabihf",
"armv6k-nintendo-3ds",
"mipsel-sony-psp",
"thumbv4t-none-eabi",
"thumbv6m-none-eabi",

Просмотреть файл

@ -562,6 +562,65 @@ impl<T: ?Sized + Pointable> Atomic<T> {
})
}
/// Fetches the pointer, and then applies a function to it that returns a new value.
/// Returns a `Result` of `Ok(previous_value)` if the function returned `Some`, else `Err(_)`.
///
/// Note that the given function may be called multiple times if the value has been changed by
/// other threads in the meantime, as long as the function returns `Some(_)`, but the function
/// will have been applied only once to the stored value.
///
/// `fetch_update` takes two [`Ordering`] arguments to describe the memory
/// ordering of this operation. The first describes the required ordering for
/// when the operation finally succeeds while the second describes the
/// required ordering for loads. These correspond to the success and failure
/// orderings of [`Atomic::compare_exchange`] respectively.
///
/// Using [`Acquire`] as success ordering makes the store part of this
/// operation [`Relaxed`], and using [`Release`] makes the final successful
/// load [`Relaxed`]. The (failed) load ordering can only be [`SeqCst`],
/// [`Acquire`] or [`Relaxed`] and must be equivalent to or weaker than the
/// success ordering.
///
/// [`Relaxed`]: Ordering::Relaxed
/// [`Acquire`]: Ordering::Acquire
/// [`Release`]: Ordering::Release
/// [`SeqCst`]: Ordering::SeqCst
///
/// # Examples
///
/// ```
/// use crossbeam_epoch::{self as epoch, Atomic};
/// use std::sync::atomic::Ordering::SeqCst;
///
/// let a = Atomic::new(1234);
/// let guard = &epoch::pin();
///
/// let res1 = a.fetch_update(SeqCst, SeqCst, guard, |x| Some(x.with_tag(1)));
/// assert!(res1.is_ok());
///
/// let res2 = a.fetch_update(SeqCst, SeqCst, guard, |x| None);
/// assert!(res2.is_err());
/// ```
pub fn fetch_update<'g, F>(
&self,
set_order: Ordering,
fail_order: Ordering,
guard: &'g Guard,
mut func: F,
) -> Result<Shared<'g, T>, Shared<'g, T>>
where
F: FnMut(Shared<'g, T>) -> Option<Shared<'g, T>>,
{
let mut prev = self.load(fail_order, guard);
while let Some(next) = func(prev) {
match self.compare_exchange_weak(prev, next, set_order, fail_order, guard) {
Ok(shared) => return Ok(shared),
Err(next_prev) => prev = next_prev.current,
}
}
Err(prev)
}
/// Stores the pointer `new` (either `Shared` or `Owned`) into the atomic pointer if the current
/// value is the same as `current`. The tag is also taken into account, so two pointers to the
/// same object, but with different tags, will not be considered equal.

Просмотреть файл

@ -178,13 +178,18 @@ mod tests {
#[test]
fn pin_holds_advance() {
#[cfg(miri)]
const N: usize = 500;
#[cfg(not(miri))]
const N: usize = 500_000;
let collector = Collector::new();
thread::scope(|scope| {
for _ in 0..NUM_THREADS {
scope.spawn(|_| {
let handle = collector.register();
for _ in 0..500_000 {
for _ in 0..N {
let guard = &handle.pin();
let before = collector.global.epoch.load(Ordering::Relaxed);
@ -202,6 +207,9 @@ mod tests {
#[cfg(not(crossbeam_sanitize))] // TODO: assertions failed due to `cfg(crossbeam_sanitize)` reduce `internal::MAX_OBJECTS`
#[test]
fn incremental() {
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 100_000;
static DESTROYS: AtomicUsize = AtomicUsize::new(0);
@ -230,12 +238,16 @@ mod tests {
let guard = &handle.pin();
collector.global.collect(guard);
}
assert!(DESTROYS.load(Ordering::Relaxed) == 100_000);
assert!(DESTROYS.load(Ordering::Relaxed) == COUNT);
}
#[test]
fn buffering() {
const COUNT: usize = 10;
#[cfg(miri)]
const N: usize = 500;
#[cfg(not(miri))]
const N: usize = 100_000;
static DESTROYS: AtomicUsize = AtomicUsize::new(0);
let collector = Collector::new();
@ -252,7 +264,7 @@ mod tests {
}
}
for _ in 0..100_000 {
for _ in 0..N {
collector.global.collect(&handle.pin());
}
assert!(DESTROYS.load(Ordering::Relaxed) < COUNT);
@ -268,6 +280,9 @@ mod tests {
#[test]
fn count_drops() {
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 100_000;
static DROPS: AtomicUsize = AtomicUsize::new(0);
@ -301,6 +316,9 @@ mod tests {
#[test]
fn count_destroy() {
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 100_000;
static DESTROYS: AtomicUsize = AtomicUsize::new(0);
@ -367,6 +385,9 @@ mod tests {
#[test]
fn destroy_array() {
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 100_000;
static DESTROYS: AtomicUsize = AtomicUsize::new(0);
@ -402,6 +423,9 @@ mod tests {
#[test]
fn stress() {
const THREADS: usize = 8;
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 100_000;
static DROPS: AtomicUsize = AtomicUsize::new(0);

Просмотреть файл

@ -81,6 +81,8 @@ impl Deferred {
#[cfg(all(test, not(crossbeam_loom)))]
mod tests {
#![allow(clippy::drop_copy)]
use super::Deferred;
use std::cell::Cell;

Просмотреть файл

@ -101,7 +101,7 @@ impl Bag {
/// Seals the bag with the given epoch.
fn seal(self, epoch: Epoch) -> SealedBag {
SealedBag { epoch, bag: self }
SealedBag { epoch, _bag: self }
}
}
@ -216,7 +216,7 @@ fn no_op_func() {}
#[derive(Default, Debug)]
struct SealedBag {
epoch: Epoch,
bag: Bag,
_bag: Bag,
}
/// It is safe to share `SealedBag` because `is_expired` only inspects the epoch.
@ -311,7 +311,7 @@ impl Global {
// TODO(stjepang): `Local`s are stored in a linked list because linked lists are fairly
// easy to implement in a lock-free manner. However, traversal can be slow due to cache
// misses and data dependencies. We should experiment with other data structures as well.
for local in self.locals.iter(&guard) {
for local in self.locals.iter(guard) {
match local {
Err(IterError::Stalled) => {
// A concurrent thread stalled this iteration. That thread might also try to

Просмотреть файл

@ -259,6 +259,9 @@ mod test {
}
}
#[cfg(miri)]
const CONC_COUNT: i64 = 1000;
#[cfg(not(miri))]
const CONC_COUNT: i64 = 1000000;
#[test]
@ -422,8 +425,8 @@ mod test {
let mut vl2 = vl.clone();
let mut vr2 = vr.clone();
vl2.sort();
vr2.sort();
vl2.sort_unstable();
vr2.sort_unstable();
assert_eq!(vl, vl2);
assert_eq!(vr, vr2);

Просмотреть файл

@ -1 +1 @@
{"files":{"CHANGELOG.md":"5242f1740c65509c465c9a36326d344722facff5f5e58dd064f7b77806b83a46","Cargo.toml":"ac35a7b8ccb16f1ab256951576537aa4179a316c068929c2acef89e0adc12319","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"5734ed989dfca1f625b40281ee9f4530f91b2411ec01cb748223e7eb87e201ab","README.md":"dfa9fbed47c344c134a63c84b7c0e4651baeac1554b7b3266d0e38643743fc33","benches/atomic_cell.rs":"c927eb3cd1e5ecc4b91adbc3bde98af15ffab4086190792ba64d5cde0e24df3d","build.rs":"68cfc4be02429834a19411fba29cb1cb52c841f03ac8104d1bae59a8b2184f9c","no_atomic.rs":"a2621c1b029c614fb0ab8e3f5cda2e839df88d90d26133181c1b901965f7eec4","src/atomic/atomic_cell.rs":"1a3a1e073340317b5ce7a94e29c6a87db89ff7e00da6b92cb3c0339364c3b084","src/atomic/consume.rs":"7a7736fcd64f6473dfea7653559ffc5e1a2a234df43835f8aa8734862145ac15","src/atomic/mod.rs":"7f6afd5bd0da1f7b51765ab04da4e5f683588ac2d23506e61bf7007bb1e61ba2","src/atomic/seq_lock.rs":"27182e6b87a9db73c5f6831759f8625f9fcdec3c2828204c444aef04f427735a","src/atomic/seq_lock_wide.rs":"9888dd03116bb89ca36d4ab8d5a0b5032107a2983a7eb8024454263b09080088","src/backoff.rs":"7cc7754e15f69b52e92a70d4f49d1bc274693455a0933a2d7eb0605806566af3","src/cache_padded.rs":"6a512698115ad0d5a5b163dbd7a83247e1f1c146c4a30f3fc74b952e3b767b59","src/lib.rs":"6f1bcf157abe06ad8458a53e865bf8efab9fad4a9424790147cee8fefb3795d8","src/sync/mod.rs":"59986f559a8f170a4b3247ab2eea2460b09809d87c8110ed88e4e7103d3519dc","src/sync/parker.rs":"ba8f75bff31b8be9275808e8f393e71cc682dfc1109ceccb12f69a3700cff5be","src/sync/sharded_lock.rs":"14be659744918d0b27db24c56b41c618b0f0484b6761da46561023d96c4c120f","src/sync/wait_group.rs":"32e946a7581c55f8aa9904527b92b177c538fa0cf7cbcfa1d1f25990582cb6ea","src/thread.rs":"0eb5ec1d3c1b40600d88eb70539d14276e32307f5bed2b679f50f6a20777a01e","tests/atomic_cell.rs":"6c9453384ecbbe76f8b97b62f022d478d3a76b4eae1e960f49790970f5d52158","tests/cache_padded.rs":"1bfaff8354c8184e1ee1f902881ca9400b60effb273b0d3f752801a483d2b66d","tests/parker.rs":"6def4721287d9d70b1cfd63ebb34e1c83fbb3376edbad2bc8aac6ef69dd99d20","tests/sharded_lock.rs":"726025ce6351fb56ed629d5a56bdf6e833b7afc5dedfa08de0b056c726b6c26d","tests/thread.rs":"9a7d7d3028c552fd834c68598b04a1cc252a816bc20ab62cec060d6cd09cab10","tests/wait_group.rs":"ad8f0cdfed31f9594a2e0737234d418f8b924d784a4db8d7e469deab8c95f5f8"},"package":"d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db"}
{"files":{"CHANGELOG.md":"097eb3484f4f13471dfe6879ce61450cc60d4453aecb924f38a8f0e4af593cdd","Cargo.toml":"2734493ab832f12a4f849c333d2dd11760c6ce614b88355da21118f77acdcd70","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"5734ed989dfca1f625b40281ee9f4530f91b2411ec01cb748223e7eb87e201ab","README.md":"dfa9fbed47c344c134a63c84b7c0e4651baeac1554b7b3266d0e38643743fc33","benches/atomic_cell.rs":"c927eb3cd1e5ecc4b91adbc3bde98af15ffab4086190792ba64d5cde0e24df3d","build.rs":"39cf39e855e52559c8f68880a02b3e2778ae2d8f089650af1b3e34a85898aed7","no_atomic.rs":"3529c0833bcd1e09a352d3bd1696d3666850c9b09fe2111bf1a783ec16a5f467","src/atomic/atomic_cell.rs":"9d0785073f506b75c110270947f6a8367ead7faaf29c507d4ede37125310cff6","src/atomic/consume.rs":"7a7736fcd64f6473dfea7653559ffc5e1a2a234df43835f8aa8734862145ac15","src/atomic/mod.rs":"7f6afd5bd0da1f7b51765ab04da4e5f683588ac2d23506e61bf7007bb1e61ba2","src/atomic/seq_lock.rs":"27182e6b87a9db73c5f6831759f8625f9fcdec3c2828204c444aef04f427735a","src/atomic/seq_lock_wide.rs":"9888dd03116bb89ca36d4ab8d5a0b5032107a2983a7eb8024454263b09080088","src/backoff.rs":"7cc7754e15f69b52e92a70d4f49d1bc274693455a0933a2d7eb0605806566af3","src/cache_padded.rs":"6a512698115ad0d5a5b163dbd7a83247e1f1c146c4a30f3fc74b952e3b767b59","src/lib.rs":"6f1bcf157abe06ad8458a53e865bf8efab9fad4a9424790147cee8fefb3795d8","src/sync/mod.rs":"59986f559a8f170a4b3247ab2eea2460b09809d87c8110ed88e4e7103d3519dc","src/sync/parker.rs":"3f997f5b41fec286ccedcf3d36f801d741387badb574820b8e3456117ecd9154","src/sync/sharded_lock.rs":"14be659744918d0b27db24c56b41c618b0f0484b6761da46561023d96c4c120f","src/sync/wait_group.rs":"32e946a7581c55f8aa9904527b92b177c538fa0cf7cbcfa1d1f25990582cb6ea","src/thread.rs":"6a7676fd4e50af63aec6f655121a10cd6e8c704f4677125388186ba58dc5842d","tests/atomic_cell.rs":"ba2e34ed1e27f0d0d4f1bb8a5feb4eb8131f756adb27a719de52c26ee7b86b9c","tests/cache_padded.rs":"1bfaff8354c8184e1ee1f902881ca9400b60effb273b0d3f752801a483d2b66d","tests/parker.rs":"6def4721287d9d70b1cfd63ebb34e1c83fbb3376edbad2bc8aac6ef69dd99d20","tests/sharded_lock.rs":"eb6c5b59f007e0d290dd0f58758e8ccb5cacd38af34e3341368ced815f0c41be","tests/thread.rs":"9a7d7d3028c552fd834c68598b04a1cc252a816bc20ab62cec060d6cd09cab10","tests/wait_group.rs":"ad8f0cdfed31f9594a2e0737234d418f8b924d784a4db8d7e469deab8c95f5f8"},"package":"cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120"}

Просмотреть файл

@ -1,7 +1,12 @@
# Version 0.8.6
- Re-add `AtomicCell<{i,u}64>::{fetch_add,fetch_sub,fetch_and,fetch_or,fetch_xor}` that were accidentally removed in 0.8.0 on targets that do not support `Atomic{I,U}64`. (#767)
- Re-add `AtomicCell<{i,u}128>::{fetch_add,fetch_sub,fetch_and,fetch_or,fetch_xor}` that were accidentally removed in 0.8.0. (#767)
# Version 0.8.5
- Add `AtomicCell::fetch_update` (#704)
- Support targets that do not have atomic CAS on stable Rust (#698)
- Add `AtomicCell::fetch_update`. (#704)
- Support targets that do not have atomic CAS on stable Rust. (#698)
# Version 0.8.4

17
third_party/rust/crossbeam-utils/Cargo.toml поставляемый
Просмотреть файл

@ -3,21 +3,19 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
# editing this file be aware that the upstream Cargo.toml
# will likely look very different (and much more reasonable)
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
rust-version = "1.36"
name = "crossbeam-utils"
version = "0.8.5"
authors = ["The Crossbeam Project Developers"]
version = "0.8.6"
description = "Utilities for concurrent programming"
homepage = "https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-utils"
documentation = "https://docs.rs/crossbeam-utils"
keywords = ["scoped", "thread", "atomic", "cache"]
categories = ["algorithms", "concurrency", "data-structures", "no-std"]
license = "MIT OR Apache-2.0"
@ -31,6 +29,9 @@ optional = true
[dev-dependencies.rand]
version = "0.8"
[dev-dependencies.rustversion]
version = "1"
[features]
default = ["std"]
nightly = []

28
third_party/rust/crossbeam-utils/build.rs поставляемый
Просмотреть файл

@ -4,9 +4,31 @@ use std::env;
include!("no_atomic.rs");
// The rustc-cfg strings below are *not* public API. Please let us know by
// opening a GitHub issue if your build environment requires some way to enable
// these cfgs other than by executing our build script.
// The rustc-cfg listed below are considered public API, but it is *unstable*
// and outside of the normal semver guarantees:
//
// - `crossbeam_no_atomic_cas`
// Assume the target does *not* support atomic CAS operations.
// This is usually detected automatically by the build script, but you may
// need to enable it manually when building for custom targets or using
// non-cargo build systems that don't run the build script.
//
// - `crossbeam_no_atomic`
// Assume the target does *not* support any atomic operations.
// This is usually detected automatically by the build script, but you may
// need to enable it manually when building for custom targets or using
// non-cargo build systems that don't run the build script.
//
// - `crossbeam_no_atomic_64`
// Assume the target does *not* support AtomicU64/AtomicI64.
// This is usually detected automatically by the build script, but you may
// need to enable it manually when building for custom targets or using
// non-cargo build systems that don't run the build script.
//
// With the exceptions mentioned above, the rustc-cfg strings below are
// *not* public API. Please let us know by opening a GitHub issue if your build
// environment requires some way to enable these cfgs other than by executing
// our build script.
fn main() {
let target = match env::var("TARGET") {
Ok(target) => target,

Просмотреть файл

@ -3,6 +3,8 @@
const NO_ATOMIC_CAS: &[&str] = &[
"avr-unknown-gnu-atmega328",
"bpfeb-unknown-none",
"bpfel-unknown-none",
"msp430-none-elf",
"riscv32i-unknown-none-elf",
"riscv32imc-unknown-none-elf",
@ -21,6 +23,7 @@ const NO_ATOMIC_64: &[&str] = &[
"armv7r-none-eabi",
"armv7r-none-eabihf",
"hexagon-unknown-linux-musl",
"m68k-unknown-linux-gnu",
"mips-unknown-linux-gnu",
"mips-unknown-linux-musl",
"mips-unknown-linux-uclibc",
@ -30,6 +33,7 @@ const NO_ATOMIC_64: &[&str] = &[
"mipsel-unknown-none",
"mipsisa32r6-unknown-linux-gnu",
"mipsisa32r6el-unknown-linux-gnu",
"powerpc-unknown-freebsd",
"powerpc-unknown-linux-gnu",
"powerpc-unknown-linux-gnuspe",
"powerpc-unknown-linux-musl",
@ -40,12 +44,14 @@ const NO_ATOMIC_64: &[&str] = &[
"riscv32gc-unknown-linux-gnu",
"riscv32gc-unknown-linux-musl",
"riscv32imac-unknown-none-elf",
"riscv32imc-esp-espidf",
"thumbv7em-none-eabi",
"thumbv7em-none-eabihf",
"thumbv7m-none-eabi",
"thumbv8m.base-none-eabi",
"thumbv8m.main-none-eabi",
"thumbv8m.main-none-eabihf",
"armv6k-nintendo-3ds",
"mipsel-sony-psp",
"thumbv4t-none-eabi",
"thumbv6m-none-eabi",

Просмотреть файл

@ -295,7 +295,7 @@ impl<T: Copy + Eq> AtomicCell<T> {
}
macro_rules! impl_arithmetic {
($t:ty, $example:tt) => {
($t:ty, fallback, $example:tt) => {
impl AtomicCell<$t> {
/// Increments the current value by `val` and returns the previous value.
///
@ -313,10 +313,13 @@ macro_rules! impl_arithmetic {
/// ```
#[inline]
pub fn fetch_add(&self, val: $t) -> $t {
if can_transmute::<$t, atomic::AtomicUsize>() {
let a = unsafe { &*(self.value.get() as *const atomic::AtomicUsize) };
a.fetch_add(val as usize, Ordering::AcqRel) as $t
} else {
#[cfg(crossbeam_loom)]
{
let _ = val;
unimplemented!("loom does not support non-atomic atomic ops");
}
#[cfg(not(crossbeam_loom))]
{
let _guard = lock(self.value.get() as usize).write();
let value = unsafe { &mut *(self.value.get()) };
let old = *value;
@ -341,10 +344,13 @@ macro_rules! impl_arithmetic {
/// ```
#[inline]
pub fn fetch_sub(&self, val: $t) -> $t {
if can_transmute::<$t, atomic::AtomicUsize>() {
let a = unsafe { &*(self.value.get() as *const atomic::AtomicUsize) };
a.fetch_sub(val as usize, Ordering::AcqRel) as $t
} else {
#[cfg(crossbeam_loom)]
{
let _ = val;
unimplemented!("loom does not support non-atomic atomic ops");
}
#[cfg(not(crossbeam_loom))]
{
let _guard = lock(self.value.get() as usize).write();
let value = unsafe { &mut *(self.value.get()) };
let old = *value;
@ -367,10 +373,13 @@ macro_rules! impl_arithmetic {
/// ```
#[inline]
pub fn fetch_and(&self, val: $t) -> $t {
if can_transmute::<$t, atomic::AtomicUsize>() {
let a = unsafe { &*(self.value.get() as *const atomic::AtomicUsize) };
a.fetch_and(val as usize, Ordering::AcqRel) as $t
} else {
#[cfg(crossbeam_loom)]
{
let _ = val;
unimplemented!("loom does not support non-atomic atomic ops");
}
#[cfg(not(crossbeam_loom))]
{
let _guard = lock(self.value.get() as usize).write();
let value = unsafe { &mut *(self.value.get()) };
let old = *value;
@ -393,10 +402,13 @@ macro_rules! impl_arithmetic {
/// ```
#[inline]
pub fn fetch_or(&self, val: $t) -> $t {
if can_transmute::<$t, atomic::AtomicUsize>() {
let a = unsafe { &*(self.value.get() as *const atomic::AtomicUsize) };
a.fetch_or(val as usize, Ordering::AcqRel) as $t
} else {
#[cfg(crossbeam_loom)]
{
let _ = val;
unimplemented!("loom does not support non-atomic atomic ops");
}
#[cfg(not(crossbeam_loom))]
{
let _guard = lock(self.value.get() as usize).write();
let value = unsafe { &mut *(self.value.get()) };
let old = *value;
@ -419,10 +431,13 @@ macro_rules! impl_arithmetic {
/// ```
#[inline]
pub fn fetch_xor(&self, val: $t) -> $t {
if can_transmute::<$t, atomic::AtomicUsize>() {
let a = unsafe { &*(self.value.get() as *const atomic::AtomicUsize) };
a.fetch_xor(val as usize, Ordering::AcqRel) as $t
} else {
#[cfg(crossbeam_loom)]
{
let _ = val;
unimplemented!("loom does not support non-atomic atomic ops");
}
#[cfg(not(crossbeam_loom))]
{
let _guard = lock(self.value.get() as usize).write();
let value = unsafe { &mut *(self.value.get()) };
let old = *value;
@ -541,9 +556,15 @@ impl_arithmetic!(i32, atomic::AtomicI32, "let a = AtomicCell::new(7i32);");
impl_arithmetic!(u64, atomic::AtomicU64, "let a = AtomicCell::new(7u64);");
#[cfg(not(crossbeam_no_atomic_64))]
impl_arithmetic!(i64, atomic::AtomicI64, "let a = AtomicCell::new(7i64);");
#[cfg(crossbeam_no_atomic_64)]
impl_arithmetic!(u64, fallback, "let a = AtomicCell::new(7u64);");
#[cfg(crossbeam_no_atomic_64)]
impl_arithmetic!(i64, fallback, "let a = AtomicCell::new(7i64);");
// TODO: AtomicU128 is unstable
// impl_arithmetic!(u128, atomic::AtomicU128, "let a = AtomicCell::new(7u128);");
// impl_arithmetic!(i128, atomic::AtomicI128, "let a = AtomicCell::new(7i128);");
impl_arithmetic!(u128, fallback, "let a = AtomicCell::new(7u128);");
impl_arithmetic!(i128, fallback, "let a = AtomicCell::new(7i128);");
impl_arithmetic!(
usize,
@ -683,105 +704,13 @@ fn lock(addr: usize) -> &'static SeqLock {
// stored at addresses that are multiples of 3. It'd be too bad if `LEN` was divisible by 3.
// In order to protect from such cases, we simply choose a large prime number for `LEN`.
const LEN: usize = 97;
#[allow(clippy::declare_interior_mutable_const)]
const L: SeqLock = SeqLock::new();
static LOCKS: [SeqLock; LEN] = [
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
SeqLock::new(),
L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L,
L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L,
L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L, L,
L, L, L, L, L, L, L,
];
// If the modulus is a constant number, the compiler will use crazy math to transform this into
@ -833,7 +762,6 @@ macro_rules! atomic {
($t:ty, $a:ident, $atomic_op:expr, $fallback_op:expr) => {
loop {
atomic!(@check, $t, AtomicUnit, $a, $atomic_op);
atomic!(@check, $t, atomic::AtomicUsize, $a, $atomic_op);
atomic!(@check, $t, atomic::AtomicU8, $a, $atomic_op);
atomic!(@check, $t, atomic::AtomicU16, $a, $atomic_op);
@ -855,7 +783,6 @@ macro_rules! atomic {
const fn atomic_is_lock_free<T>() -> bool {
// HACK(taiki-e): This is equivalent to `atomic! { T, _a, true, false }`, but can be used in const fn even in Rust 1.36.
let is_lock_free = can_transmute::<T, AtomicUnit>()
| can_transmute::<T, atomic::AtomicUsize>()
| can_transmute::<T, atomic::AtomicU8>()
| can_transmute::<T, atomic::AtomicU16>()
| can_transmute::<T, atomic::AtomicU32>();

Просмотреть файл

@ -175,6 +175,7 @@ impl Parker {
///
/// let p = Parker::new();
/// let raw = Parker::into_raw(p);
/// # let _ = unsafe { Parker::from_raw(raw) };
/// ```
pub fn into_raw(this: Parker) -> *const () {
Unparker::into_raw(this.unparker)
@ -258,6 +259,7 @@ impl Unparker {
/// let p = Parker::new();
/// let u = p.unparker().clone();
/// let raw = Unparker::into_raw(u);
/// # let _ = unsafe { Unparker::from_raw(raw) };
/// ```
pub fn into_raw(this: Unparker) -> *const () {
Arc::into_raw(this.inner) as *const ()

Просмотреть файл

@ -446,7 +446,7 @@ impl<'scope, 'env> ScopedThreadBuilder<'scope, 'env> {
unsafe { mem::transmute(closure) };
// Finally, spawn the closure.
self.builder.spawn(move || closure())?
self.builder.spawn(closure)?
};
let thread = handle.thread().clone();

Просмотреть файл

@ -264,3 +264,22 @@ fn const_atomic_cell_new() {
CELL.store(1);
assert_eq!(CELL.load(), 1);
}
// https://github.com/crossbeam-rs/crossbeam/issues/748
#[cfg_attr(miri, ignore)] // TODO
#[rustversion::since(1.37)] // #[repr(align(N))] requires Rust 1.37
#[test]
fn issue_748() {
#[allow(dead_code)]
#[repr(align(8))]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum Test {
Field(u32),
FieldLess,
}
assert_eq!(mem::size_of::<Test>(), 8);
assert!(AtomicCell::<Test>::is_lock_free());
let x = AtomicCell::new(Test::FieldLess);
assert_eq!(x.load(), Test::FieldLess);
}

Просмотреть файл

@ -21,6 +21,9 @@ fn smoke() {
#[test]
fn frob() {
const N: u32 = 10;
#[cfg(miri)]
const M: usize = 100;
#[cfg(not(miri))]
const M: usize = 1000;
let r = Arc::new(ShardedLock::new(()));