aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2021-04-08 20:28:21 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-04-08 20:28:21 +0000
commite8df80860d4452ae58f0c9d21ba9222849ce3ed3 (patch)
tree314a00150485f0dd1e05d4d860239d243a9c870d
parent795bf37eb8fa96bc2de6a321bc9e4d3ee3eb5c12 (diff)
parent00424e631273ffe9d76c5162a5a4da4eee51aad0 (diff)
downloadrand-e8df80860d4452ae58f0c9d21ba9222849ce3ed3.tar.gz
Upgrade rust/crates/rand to 0.8.3 am: 0a692f123c am: 3be35829eb am: 00424e6312
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/rand/+/1663039 Change-Id: I4b726f857b75e5e9b80b6c3cde184931d604ee1d
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--Android.bp45
-rw-r--r--CHANGELOG.md4
-rw-r--r--Cargo.lock50
-rw-r--r--Cargo.toml2
-rw-r--r--Cargo.toml.orig2
-rw-r--r--METADATA8
-rw-r--r--TEST_MAPPING269
-rw-r--r--patches/Android.bp.patch12
-rw-r--r--src/seq/index.rs11
-rw-r--r--src/seq/mod.rs12
11 files changed, 341 insertions, 76 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 2e6810b..c17e718 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,5 @@
{
"git": {
- "sha1": "6a6b9fd06dbf54538d250dfbc4c918f79daa9299"
+ "sha1": "6ecbe2626b2cc6110a25c97b1702b347574febc7"
}
}
diff --git a/Android.bp b/Android.bp
index 459b7f7..1e13618 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,41 +1,7 @@
-// This file is generated by cargo2android.py --device --run --dependencies.
+// This file is generated by cargo2android.py --device --run --dependencies --patch=patches/Android.bp.patch.
+// Do not modify this file as changes will be overridden on upgrade.
-package {
- default_applicable_licenses: ["external_rust_crates_rand_license"],
-}
-// Added automatically by a large-scale-change that took the approach of
-// 'apply every license found to every target'. While this makes sure we respect
-// every license restriction, it may not be entirely correct.
-//
-// e.g. GPL in an MIT project might only apply to the contrib/ directory.
-//
-// Please consider splitting the single license below into multiple licenses,
-// taking care not to lose any license_kind information, and overriding the
-// default license using the 'licenses: [...]' property on targets as needed.
-//
-// For unused files, consider creating a 'fileGroup' with "//visibility:private"
-// to attach the license to, and including a comment whether the files may be
-// used in the current project.
-//
-// large-scale-change included anything that looked like it might be a license
-// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc.
-//
-// Please consider removing redundant or irrelevant files from 'license_text:'.
-// See: http://go/android-license-faq
-license {
- name: "external_rust_crates_rand_license",
- visibility: [":__subpackages__"],
- license_kinds: [
- "SPDX-license-identifier-Apache-2.0",
- "SPDX-license-identifier-MIT",
- ],
- license_text: [
- "COPYRIGHT",
- "LICENSE-APACHE",
- "LICENSE-MIT",
- ],
-}
rust_library {
name: "librand",
@@ -62,8 +28,9 @@ rust_library {
// dependent_library ["feature_list"]
// cfg-if-1.0.0
-// getrandom-0.2.1 "std"
-// libc-0.2.82
+// getrandom-0.2.2 "std"
+// libc-0.2.93
// ppv-lite86-0.2.10 "simd,std"
// rand_chacha-0.3.0 "std"
-// rand_core-0.6.1 "alloc,getrandom,std"
+// rand_core-0.6.2 "alloc,getrandom,std"
+// rand_hc-0.3.0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c049530..536c510 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,10 @@ A [separate changelog is kept for rand_core](rand_core/CHANGELOG.md).
You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.html) useful.
+## [0.8.3] - 2021-01-25
+### Fixes
+- Fix `no-std` + `alloc` build by gating `choose_multiple_weighted` on `std` (#1088)
+
## [0.8.2] - 2021-01-12
### Fixes
- Fix panic in `UniformInt::sample_single_inclusive` and `Rng::gen_range` when
diff --git a/Cargo.lock b/Cargo.lock
index 81bbd9c..01304e6 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -12,9 +12,9 @@ dependencies = [
[[package]]
name = "byteorder"
-version = "1.3.4"
+version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
+checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b"
[[package]]
name = "cfg-if"
@@ -23,21 +23,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
+name = "cfg-if"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
+
+[[package]]
name = "getrandom"
-version = "0.2.0"
+version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ee8025cf36f917e6a52cce185b7c7177689b838b7ec138364e50cc2277a56cf4"
+checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
"libc",
"wasi",
]
[[package]]
name = "libc"
-version = "0.2.81"
+version = "0.2.82"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb"
+checksum = "89203f3fba0a3795506acaad8ebce3c80c0af93f994d5a1d7a0b1eeb23271929"
[[package]]
name = "libm"
@@ -47,11 +53,11 @@ checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a"
[[package]]
name = "log"
-version = "0.4.11"
+version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
+checksum = "fcf3805d4480bb5b86070dcfeb9e2cb2ebc148adb753c5cca5f884d1d65a42b2"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
]
[[package]]
@@ -60,7 +66,7 @@ version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3278e0492f961fd4ae70909f56b2723a7e8d01a228427294e19cdfdebda89a17"
dependencies = [
- "cfg-if",
+ "cfg-if 0.1.10",
"libm",
]
@@ -81,16 +87,16 @@ dependencies = [
[[package]]
name = "quote"
-version = "1.0.7"
+version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
+checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rand"
-version = "0.8.2"
+version = "0.8.3"
dependencies = [
"bincode",
"libc",
@@ -142,18 +148,18 @@ dependencies = [
[[package]]
name = "serde"
-version = "1.0.118"
+version = "1.0.120"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800"
+checksum = "166b2349061381baf54a58e4b13c89369feb0ef2eaa57198899e2312aac30aab"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.118"
+version = "1.0.120"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df"
+checksum = "0ca2a8cb5805ce9e3b95435e3765b7b553cecc762d938d409434338386cb5775"
dependencies = [
"proc-macro2",
"quote",
@@ -162,9 +168,9 @@ dependencies = [
[[package]]
name = "syn"
-version = "1.0.54"
+version = "1.0.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44"
+checksum = "07cb8b1b4ebf86a89ee88cbd201b022b94138c623644d035185c84d3f41b7e66"
dependencies = [
"proc-macro2",
"quote",
@@ -179,6 +185,6 @@ checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]]
name = "wasi"
-version = "0.9.0+wasi-snapshot-preview1"
+version = "0.10.1+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
+checksum = "93c6c3420963c5c64bca373b25e77acb562081b9bb4dd5bb864187742186cea9"
diff --git a/Cargo.toml b/Cargo.toml
index adbcc4c..1086335 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@
[package]
edition = "2018"
name = "rand"
-version = "0.8.2"
+version = "0.8.3"
authors = ["The Rand Project Developers", "The Rust Project Developers"]
include = ["src/", "LICENSE-*", "README.md", "CHANGELOG.md", "COPYRIGHT"]
autobenches = true
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 69a6844..afd1339 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "rand"
-version = "0.8.2"
+version = "0.8.3"
authors = ["The Rand Project Developers", "The Rust Project Developers"]
license = "MIT OR Apache-2.0"
readme = "README.md"
diff --git a/METADATA b/METADATA
index f07b101..7ad83fc 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/rand/rand-0.8.2.crate"
+ value: "https://static.crates.io/crates/rand/rand-0.8.3.crate"
}
- version: "0.8.2"
+ version: "0.8.3"
license_type: NOTICE
last_upgrade_date {
year: 2021
- month: 1
- day: 13
+ month: 4
+ day: 1
}
}
diff --git a/TEST_MAPPING b/TEST_MAPPING
new file mode 100644
index 0000000..2637267
--- /dev/null
+++ b/TEST_MAPPING
@@ -0,0 +1,269 @@
+// Generated by update_crate_tests.py for tests that depend on this crate.
+{
+ "presubmit": [
+ {
+ "name": "crossbeam-epoch_device_test_src_lib"
+ },
+ {
+ "name": "keystore2_test"
+ },
+ {
+ "name": "tokio_device_test_tests_async_send_sync"
+ },
+ {
+ "name": "tokio_device_test_tests_buffered"
+ },
+ {
+ "name": "tokio_device_test_tests_fs"
+ },
+ {
+ "name": "tokio_device_test_tests_fs_copy"
+ },
+ {
+ "name": "tokio_device_test_tests_fs_dir"
+ },
+ {
+ "name": "tokio_device_test_tests_fs_file"
+ },
+ {
+ "name": "tokio_device_test_tests_fs_file_mocked"
+ },
+ {
+ "name": "tokio_device_test_tests_fs_link"
+ },
+ {
+ "name": "tokio_device_test_tests_io_async_fd"
+ },
+ {
+ "name": "tokio_device_test_tests_io_async_read"
+ },
+ {
+ "name": "tokio_device_test_tests_io_chain"
+ },
+ {
+ "name": "tokio_device_test_tests_io_copy"
+ },
+ {
+ "name": "tokio_device_test_tests_io_driver"
+ },
+ {
+ "name": "tokio_device_test_tests_io_driver_drop"
+ },
+ {
+ "name": "tokio_device_test_tests_io_lines"
+ },
+ {
+ "name": "tokio_device_test_tests_io_mem_stream"
+ },
+ {
+ "name": "tokio_device_test_tests_io_read"
+ },
+ {
+ "name": "tokio_device_test_tests_io_read_buf"
+ },
+ {
+ "name": "tokio_device_test_tests_io_read_exact"
+ },
+ {
+ "name": "tokio_device_test_tests_io_read_line"
+ },
+ {
+ "name": "tokio_device_test_tests_io_read_to_end"
+ },
+ {
+ "name": "tokio_device_test_tests_io_read_to_string"
+ },
+ {
+ "name": "tokio_device_test_tests_io_read_until"
+ },
+ {
+ "name": "tokio_device_test_tests_io_split"
+ },
+ {
+ "name": "tokio_device_test_tests_io_take"
+ },
+ {
+ "name": "tokio_device_test_tests_io_write"
+ },
+ {
+ "name": "tokio_device_test_tests_io_write_all"
+ },
+ {
+ "name": "tokio_device_test_tests_io_write_buf"
+ },
+ {
+ "name": "tokio_device_test_tests_io_write_int"
+ },
+ {
+ "name": "tokio_device_test_tests_macros_join"
+ },
+ {
+ "name": "tokio_device_test_tests_macros_pin"
+ },
+ {
+ "name": "tokio_device_test_tests_macros_select"
+ },
+ {
+ "name": "tokio_device_test_tests_macros_test"
+ },
+ {
+ "name": "tokio_device_test_tests_macros_try_join"
+ },
+ {
+ "name": "tokio_device_test_tests_net_bind_resource"
+ },
+ {
+ "name": "tokio_device_test_tests_net_lookup_host"
+ },
+ {
+ "name": "tokio_device_test_tests_no_rt"
+ },
+ {
+ "name": "tokio_device_test_tests_process_issue_2174"
+ },
+ {
+ "name": "tokio_device_test_tests_process_issue_42"
+ },
+ {
+ "name": "tokio_device_test_tests_process_kill_on_drop"
+ },
+ {
+ "name": "tokio_device_test_tests_process_smoke"
+ },
+ {
+ "name": "tokio_device_test_tests_rt_basic"
+ },
+ {
+ "name": "tokio_device_test_tests_rt_common"
+ },
+ {
+ "name": "tokio_device_test_tests_rt_threaded"
+ },
+ {
+ "name": "tokio_device_test_tests_signal_ctrl_c"
+ },
+ {
+ "name": "tokio_device_test_tests_signal_drop_recv"
+ },
+ {
+ "name": "tokio_device_test_tests_signal_drop_rt"
+ },
+ {
+ "name": "tokio_device_test_tests_signal_drop_signal"
+ },
+ {
+ "name": "tokio_device_test_tests_signal_multi_rt"
+ },
+ {
+ "name": "tokio_device_test_tests_signal_no_rt"
+ },
+ {
+ "name": "tokio_device_test_tests_signal_notify_both"
+ },
+ {
+ "name": "tokio_device_test_tests_signal_twice"
+ },
+ {
+ "name": "tokio_device_test_tests_signal_usr1"
+ },
+ {
+ "name": "tokio_device_test_tests_sync_barrier"
+ },
+ {
+ "name": "tokio_device_test_tests_sync_broadcast"
+ },
+ {
+ "name": "tokio_device_test_tests_sync_errors"
+ },
+ {
+ "name": "tokio_device_test_tests_sync_mpsc"
+ },
+ {
+ "name": "tokio_device_test_tests_sync_mutex"
+ },
+ {
+ "name": "tokio_device_test_tests_sync_mutex_owned"
+ },
+ {
+ "name": "tokio_device_test_tests_sync_notify"
+ },
+ {
+ "name": "tokio_device_test_tests_sync_oneshot"
+ },
+ {
+ "name": "tokio_device_test_tests_sync_rwlock"
+ },
+ {
+ "name": "tokio_device_test_tests_sync_semaphore"
+ },
+ {
+ "name": "tokio_device_test_tests_sync_semaphore_owned"
+ },
+ {
+ "name": "tokio_device_test_tests_sync_watch"
+ },
+ {
+ "name": "tokio_device_test_tests_task_abort"
+ },
+ {
+ "name": "tokio_device_test_tests_task_blocking"
+ },
+ {
+ "name": "tokio_device_test_tests_task_local"
+ },
+ {
+ "name": "tokio_device_test_tests_task_local_set"
+ },
+ {
+ "name": "tokio_device_test_tests_tcp_accept"
+ },
+ {
+ "name": "tokio_device_test_tests_tcp_connect"
+ },
+ {
+ "name": "tokio_device_test_tests_tcp_echo"
+ },
+ {
+ "name": "tokio_device_test_tests_tcp_into_split"
+ },
+ {
+ "name": "tokio_device_test_tests_tcp_into_std"
+ },
+ {
+ "name": "tokio_device_test_tests_tcp_peek"
+ },
+ {
+ "name": "tokio_device_test_tests_tcp_shutdown"
+ },
+ {
+ "name": "tokio_device_test_tests_tcp_socket"
+ },
+ {
+ "name": "tokio_device_test_tests_tcp_split"
+ },
+ {
+ "name": "tokio_device_test_tests_tcp_stream"
+ },
+ {
+ "name": "tokio_device_test_tests_test_clock"
+ },
+ {
+ "name": "tokio_device_test_tests_udp"
+ },
+ {
+ "name": "tokio_device_test_tests_uds_cred"
+ },
+ {
+ "name": "tokio_device_test_tests_uds_datagram"
+ },
+ {
+ "name": "tokio_device_test_tests_uds_split"
+ },
+ {
+ "name": "tokio_device_test_tests_uds_stream"
+ },
+ {
+ "name": "vpnprofilestore_test"
+ }
+ ]
+}
diff --git a/patches/Android.bp.patch b/patches/Android.bp.patch
new file mode 100644
index 0000000..59579a5
--- /dev/null
+++ b/patches/Android.bp.patch
@@ -0,0 +1,12 @@
+diff --git a/Android.bp b/Android.bp
+index 49626bd..5c40f99 100644
+--- a/Android.bp
++++ b/Android.bp
+@@ -23,7 +23,6 @@ rust_library {
+ "liblibc",
+ "librand_chacha",
+ "librand_core",
+- "librand_hc",
+ ],
+ }
+
diff --git a/src/seq/index.rs b/src/seq/index.rs
index c09e580..8b155e1 100644
--- a/src/seq/index.rs
+++ b/src/seq/index.rs
@@ -17,7 +17,9 @@ use alloc::collections::BTreeSet;
#[cfg(feature = "std")] use std::collections::HashSet;
#[cfg(feature = "alloc")]
-use crate::distributions::{uniform::SampleUniform, Distribution, Uniform, WeightedError};
+use crate::distributions::{uniform::SampleUniform, Distribution, Uniform};
+#[cfg(feature = "std")]
+use crate::distributions::WeightedError;
use crate::Rng;
#[cfg(feature = "serde1")]
@@ -270,6 +272,8 @@ where R: Rng + ?Sized {
/// `O(length + amount * log length)` time otherwise.
///
/// Panics if `amount > length`.
+#[cfg(feature = "std")]
+#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
pub fn sample_weighted<R, F, X>(
rng: &mut R, length: usize, weight: F, amount: usize,
) -> Result<IndexVec, WeightedError>
@@ -301,6 +305,7 @@ where
/// + amount * log length)` time otherwise.
///
/// Panics if `amount > length`.
+#[cfg(feature = "std")]
fn sample_efraimidis_spirakis<R, F, X, N>(
rng: &mut R, length: N, weight: F, amount: N,
) -> Result<IndexVec, WeightedError>
@@ -375,9 +380,6 @@ where
#[cfg(not(feature = "nightly"))]
{
- #[cfg(all(feature = "alloc", not(feature = "std")))]
- use crate::alloc::collections::BinaryHeap;
- #[cfg(feature = "std")]
use std::collections::BinaryHeap;
// Partially sort the array such that the `amount` elements with the largest
@@ -619,6 +621,7 @@ mod test {
assert_eq!(v1, v2);
}
+ #[cfg(feature = "std")]
#[test]
fn test_sample_weighted() {
let seed_rng = crate::test::rng;
diff --git a/src/seq/mod.rs b/src/seq/mod.rs
index 9e6ffaf..4375fa1 100644
--- a/src/seq/mod.rs
+++ b/src/seq/mod.rs
@@ -212,7 +212,11 @@ pub trait SliceRandom {
/// println!("{:?}", choices.choose_multiple_weighted(&mut rng, 2, |item| item.1).unwrap().collect::<Vec<_>>());
/// ```
/// [`choose_multiple`]: SliceRandom::choose_multiple
- #[cfg(feature = "alloc")]
+ //
+ // Note: this is feature-gated on std due to usage of f64::powf.
+ // If necessary, we may use alloc+libm as an alternative (see PR #1089).
+ #[cfg(feature = "std")]
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
fn choose_multiple_weighted<R, F, X>(
&self, rng: &mut R, amount: usize, weight: F,
) -> Result<SliceChooseIter<Self, Self::Item>, WeightedError>
@@ -556,7 +560,7 @@ impl<T> SliceRandom for [T] {
Ok(&mut self[distr.sample(rng)])
}
- #[cfg(feature = "alloc")]
+ #[cfg(feature = "std")]
fn choose_multiple_weighted<R, F, X>(
&self, rng: &mut R, amount: usize, weight: F,
) -> Result<SliceChooseIter<Self, Self::Item>, WeightedError>
@@ -1228,7 +1232,7 @@ mod test {
}
#[test]
- #[cfg(feature = "alloc")]
+ #[cfg(feature = "std")]
fn test_multiple_weighted_edge_cases() {
use super::*;
@@ -1308,7 +1312,7 @@ mod test {
}
#[test]
- #[cfg(feature = "alloc")]
+ #[cfg(feature = "std")]
fn test_multiple_weighted_distributions() {
use super::*;