diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-02-17 02:56:05 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-02-17 02:56:05 +0000 |
commit | 995b68e16220b5141d17c6afd2d844c827ee5598 (patch) | |
tree | 120eb9828a1b930505cfc8f0d1fad53f28232bac | |
parent | d30d30468d99ce9f5fd5a95bc870fbfd0b77a9aa (diff) | |
parent | 838e0f45e8b9d250c4403aa73c3a6b5238dab24c (diff) | |
download | rand_core-android13-frc-media-release.tar.gz |
Snap for 8191477 from 838e0f45e8b9d250c4403aa73c3a6b5238dab24c to tm-frc-media-releaset_frc_med_330443030android13-frc-media-release
Change-Id: If30d99ebfda7209bbab0d34b8f41750c0777b241
-rw-r--r-- | .cargo_vcs_info.json | 2 | ||||
-rw-r--r-- | Android.bp | 37 | ||||
-rw-r--r-- | CHANGELOG.md | 5 | ||||
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | Cargo.toml.orig | 2 | ||||
-rw-r--r-- | METADATA | 8 | ||||
-rw-r--r-- | TEST_MAPPING | 94 | ||||
-rw-r--r-- | cargo2android.json | 11 | ||||
-rw-r--r-- | src/block.rs | 6 | ||||
-rw-r--r-- | src/lib.rs | 9 |
10 files changed, 143 insertions, 33 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 3fd44e0..7f98fc0 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "3a03c9eb5350e03a3f540dba2ee34e0984f2c2c2" + "sha1": "8792268dfe57e49bb4518190bf4fe66176759a44" } } @@ -1,4 +1,5 @@ -// This file is generated by cargo2android.py --device --run --features=std --dependencies --tests. +// This file is generated by cargo2android.py --config cargo2android.json. +// Do not modify this file as changes will be overridden on upgrade. package { default_applicable_licenses: ["external_rust_crates_rand_core_license"], @@ -41,6 +42,8 @@ rust_library { name: "librand_core", host_supported: true, crate_name: "rand_core", + cargo_env_compat: true, + cargo_pkg_version: "0.6.3", srcs: ["src/lib.rs"], edition: "2018", features: [ @@ -51,14 +54,24 @@ rust_library { rustlibs: [ "libgetrandom", ], + apex_available: [ + "//apex_available:platform", + "com.android.virt", + ], } -rust_defaults { - name: "rand_core_defaults", +rust_test { + name: "rand_core_test_src_lib", + host_supported: true, crate_name: "rand_core", + cargo_env_compat: true, + cargo_pkg_version: "0.6.3", srcs: ["src/lib.rs"], test_suites: ["general-tests"], auto_gen_config: true, + test_options: { + unit_test: true, + }, edition: "2018", features: [ "alloc", @@ -69,21 +82,3 @@ rust_defaults { "libgetrandom", ], } - -rust_test_host { - name: "rand_core_host_test_src_lib", - defaults: ["rand_core_defaults"], - test_options: { - unit_test: true, - }, -} - -rust_test { - name: "rand_core_device_test_src_lib", - defaults: ["rand_core_defaults"], -} - -// dependent_library ["feature_list"] -// cfg-if-1.0.0 -// getrandom-0.2.2 "std" -// libc-0.2.86 diff --git a/CHANGELOG.md b/CHANGELOG.md index 23d1fa5..82c8300 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.6.3] - 2021-06-15 +### Changed +- Improved bound for `serde` impls on `BlockRng` (#1130) +- Minor doc additions (#1118) + ## [0.6.2] - 2021-02-12 ### Fixed - Fixed assertions in `le::read_u32_into` and `le::read_u64_into` which could @@ -13,7 +13,7 @@ [package] edition = "2018" name = "rand_core" -version = "0.6.2" +version = "0.6.3" authors = ["The Rand Project Developers", "The Rust Project Developers"] description = "Core random number generator traits and tools for implementation.\n" homepage = "https://rust-random.github.io/book" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index d460757..6604bc5 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "rand_core" -version = "0.6.2" +version = "0.6.3" authors = ["The Rand Project Developers", "The Rust Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md" @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/rand_core/rand_core-0.6.2.crate" + value: "https://static.crates.io/crates/rand_core/rand_core-0.6.3.crate" } - version: "0.6.2" + version: "0.6.3" license_type: NOTICE last_upgrade_date { year: 2021 - month: 2 - day: 17 + month: 6 + day: 21 } } diff --git a/TEST_MAPPING b/TEST_MAPPING index 963506b..cd4547e 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -1,17 +1,105 @@ // Generated by update_crate_tests.py for tests that depend on this crate. { + "imports": [ + { + "path": "external/rust/crates/base64" + }, + { + "path": "external/rust/crates/cast" + }, + { + "path": "external/rust/crates/crc32fast" + }, + { + "path": "external/rust/crates/crossbeam-deque" + }, + { + "path": "external/rust/crates/crossbeam-epoch" + }, + { + "path": "external/rust/crates/crossbeam-queue" + }, + { + "path": "external/rust/crates/crossbeam-utils" + }, + { + "path": "external/rust/crates/mio" + }, + { + "path": "external/rust/crates/quickcheck" + }, + { + "path": "external/rust/crates/rand_chacha" + }, + { + "path": "external/rust/crates/rand_xorshift" + }, + { + "path": "external/rust/crates/regex" + }, + { + "path": "external/rust/crates/ryu" + }, + { + "path": "external/rust/crates/tokio" + } + ], "presubmit": [ { - "name": "rand_xorshift_device_test_tests_mod" + "name": "ZipFuseTest" + }, + { + "name": "apkdmverity.test" + }, + { + "name": "authfs_device_test_src_lib" + }, + { + "name": "keystore2_test" + }, + { + "name": "keystore2_test_utils_test" + }, + { + "name": "legacykeystore_test" + }, + { + "name": "microdroid_manager_test" + }, + { + "name": "rand_core_test_src_lib" + }, + { + "name": "virtualizationservice_device_test" + } + ], + "presubmit-rust": [ + { + "name": "ZipFuseTest" + }, + { + "name": "apkdmverity.test" + }, + { + "name": "authfs_device_test_src_lib" }, { "name": "keystore2_test" }, { - "name": "rand_xorshift_device_test_src_lib" + "name": "keystore2_test_utils_test" + }, + { + "name": "legacykeystore_test" + }, + { + "name": "microdroid_manager_test" + }, + { + "name": "rand_core_test_src_lib" }, { - "name": "rand_core_device_test_src_lib" + "name": "virtualizationservice_device_test" } ] } diff --git a/cargo2android.json b/cargo2android.json new file mode 100644 index 0000000..b73c7b4 --- /dev/null +++ b/cargo2android.json @@ -0,0 +1,11 @@ +{ + "apex-available": [ + "//apex_available:platform", + "com.android.virt" + ], + "dependencies": true, + "device": true, + "features": "std", + "run": true, + "tests": true +}
\ No newline at end of file diff --git a/src/block.rs b/src/block.rs index 005d071..a54cadf 100644 --- a/src/block.rs +++ b/src/block.rs @@ -114,6 +114,12 @@ pub trait BlockRngCore { /// [`try_fill_bytes`]: RngCore::try_fill_bytes #[derive(Clone)] #[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +#[cfg_attr( + feature = "serde1", + serde( + bound = "for<'x> R: Serialize + Deserialize<'x> + Sized, for<'x> R::Results: Serialize + Deserialize<'x>" + ) +)] pub struct BlockRng<R: BlockRngCore + ?Sized> { results: R::Results, index: usize, @@ -76,12 +76,17 @@ pub mod le; /// [`next_u32`] or [`next_u64`] since the latter methods are almost always used /// with algorithmic generators (PRNGs), which are normally infallible. /// +/// Implementers should produce bits uniformly. Pathological RNGs (e.g. always +/// returning the same value, or never setting certain bits) can break rejection +/// sampling used by random distributions, and also break other RNGs when +/// seeding them via [`SeedableRng::from_rng`]. +/// /// Algorithmic generators implementing [`SeedableRng`] should normally have /// *portable, reproducible* output, i.e. fix Endianness when converting values /// to avoid platform differences, and avoid making any changes which affect /// output (except by communicating that the release has breaking changes). /// -/// Typically implementators will implement only one of the methods available +/// Typically an RNG will implement only one of the methods available /// in this trait directly, then use the helper functions from the /// [`impls`] module to implement the other methods. /// @@ -480,7 +485,7 @@ mod test { // This is the binomial distribution B(64, 0.5), so chance of // weight < 20 is binocdf(19, 64, 0.5) = 7.8e-4, and same for // weight > 44. - assert!(weight >= 20 && weight <= 44); + assert!((20..=44).contains(&weight)); for (i2, r2) in results.iter().enumerate() { if i1 == i2 { |