diff -Nru cargo-0.57.0+ubuntu/build.rs cargo-0.58.0/build.rs --- cargo-0.57.0+ubuntu/build.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/build.rs 2021-10-21 14:30:11.000000000 +0000 @@ -5,6 +5,10 @@ fn main() { compress_man(); + println!( + "cargo:rustc-env=RUST_HOST_TARGET={}", + std::env::var("TARGET").unwrap() + ); } fn compress_man() { diff -Nru cargo-0.57.0+ubuntu/Cargo.toml cargo-0.58.0/Cargo.toml --- cargo-0.57.0+ubuntu/Cargo.toml 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/Cargo.toml 2021-10-21 14:30:11.000000000 +0000 @@ -1,6 +1,6 @@ [package] name = "cargo" -version = "0.57.0" +version = "0.58.0" edition = "2018" authors = ["Yehuda Katz ", "Carl Lerche ", @@ -25,14 +25,14 @@ cargo-util = { path = "crates/cargo-util", version = "0.1.1" } crates-io = { path = "crates/crates-io", version = "0.33.0" } crossbeam-utils = "0.8" -curl = { version = "0.4.38", features = ["http2"] } -curl-sys = "0.4.48" +curl = { version = "0.4.39", features = ["http2"] } +curl-sys = "0.4.49" env_logger = "0.9.0" pretty_env_logger = { version = "0.4", optional = true } anyhow = "1.0" filetime = "0.2.9" flate2 = { version = "1.0.3", default-features = false, features = ["zlib"] } -git2 = "0.13.16" +git2 = "0.13.23" git2-curl = "0.14.1" glob = "0.3.0" hex = "0.4" @@ -44,10 +44,11 @@ lazycell = "1.2.0" libc = "0.2" log = "0.4.6" -libgit2-sys = "0.12.18" +libgit2-sys = "0.12.24" memchr = "2.1.3" num_cpus = "1.0" opener = "0.5" +os_info = "3.0.7" percent-encoding = "2.0" rustfix = "0.6.0" semver = { version = "1.0.3", features = ["serde"] } diff -Nru cargo-0.57.0+ubuntu/CHANGELOG.md cargo-0.58.0/CHANGELOG.md --- cargo-0.57.0+ubuntu/CHANGELOG.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/CHANGELOG.md 2021-10-21 14:30:11.000000000 +0000 @@ -1,19 +1,62 @@ # Changelog +## Cargo 1.57 (2021-12-02) +[18751dd3...HEAD](https://github.com/rust-lang/cargo/compare/18751dd3...HEAD) + +### Added + +- The `rev` option for a git dependency now supports git references that start + with `refs/`. An example where this can be used is to depend on a pull + request from a service like GitHub before it is merged. + [#9859](https://github.com/rust-lang/cargo/pull/9859) + +### Changed + +### Fixed + +- Removed a log message (from `CARGO_LOG`) that may leak tokens. + [#9873](https://github.com/rust-lang/cargo/pull/9873) + +### Nightly only + + ## Cargo 1.56 (2021-10-21) -[cebef295...HEAD](https://github.com/rust-lang/cargo/compare/cebef295...HEAD) +[cebef295...rust-1.56.0](https://github.com/rust-lang/cargo/compare/cebef295...rust-1.56.0) ### Added -- Added support for the [`rust-version`](https://doc.rust-lang.org/nightly/cargo/reference/manifest.html#the-rust-version-field) - field in a crate's metadata and the `--ignore-rust-version` command line option. -- Build scripts can now pass additional linker arguments for binaries or all +- 🎉 Cargo now supports the 2021 edition. + More information may be found in the [edition + guide](https://doc.rust-lang.org/nightly/edition-guide/rust-2021/index.html). + [#9800](https://github.com/rust-lang/cargo/pull/9800) +- 🎉 Added the + [`rust-version`](https://doc.rust-lang.org/nightly/cargo/reference/manifest.html#the-rust-version-field) + field to `Cargo.toml` to specify the minimum supported Rust version, and the + `--ignore-rust-version` command line option to override it. + [#9732](https://github.com/rust-lang/cargo/pull/9732) +- Added the `[env]` table to config files to specify environment variables to + set. + [docs](https://doc.rust-lang.org/nightly/cargo/reference/config.html#env) + [#9411](https://github.com/rust-lang/cargo/pull/9411) +- `[patch]` tables may now be specified in config files. + [docs](https://doc.rust-lang.org/nightly/cargo/reference/config.html#patch) + [#9839](https://github.com/rust-lang/cargo/pull/9839) +- `cargo doc` now supports the `--example` and `--examples` flags. + [#9808](https://github.com/rust-lang/cargo/pull/9808) +- 🎉 Build scripts can now pass additional linker arguments for binaries or all linkable targets. [docs](https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#outputs-of-the-build-script) [#9557](https://github.com/rust-lang/cargo/pull/9557) - Added support for the `-p` flag for `cargo publish` to publish a specific package in a workspace. `cargo package` also now supports `-p` and `--workspace`. [#9559](https://github.com/rust-lang/cargo/pull/9559) +- Added documentation about third-party registries. + [#9830](https://github.com/rust-lang/cargo/pull/9830) +- Added the `{sha256-checksum}` placeholder for URLs in a registry `config.json`. + [docs](https://doc.rust-lang.org/nightly/cargo/reference/registries.html#index-format) + [#9801](https://github.com/rust-lang/cargo/pull/9801) +- Added a warning when a dependency does not have a library. + [#9771](https://github.com/rust-lang/cargo/pull/9771) ### Changed @@ -27,11 +70,56 @@ filename. This allows multiple copies to be cached at once, and matches the behavior on other platforms (except `msvc`). [#9653](https://github.com/rust-lang/cargo/pull/9653) +- `cargo new` now generates an example that doesn't generate a warning with + clippy. + [#9796](https://github.com/rust-lang/cargo/pull/9796) +- `cargo fix --edition` now only applies edition-specific lints. + [#9846](https://github.com/rust-lang/cargo/pull/9846) +- Improve resolver message to include dependency requirements. + [#9827](https://github.com/rust-lang/cargo/pull/9827) +- `cargo fix` now has more debug logging available with the `CARGO_LOG` + environment variable. + [#9831](https://github.com/rust-lang/cargo/pull/9831) +- Changed `cargo fix --edition` to emit a warning when on the latest stable + edition when running on stable instead of generating an error. + [#9792](https://github.com/rust-lang/cargo/pull/9792) +- `cargo install` will now determine all of the packages to install before + starting the installation, which should help with reporting errors without + partially installing. + [#9793](https://github.com/rust-lang/cargo/pull/9793) +- The resolver report for `cargo fix --edition` now includes differences for + dev-dependencies. + [#9803](https://github.com/rust-lang/cargo/pull/9803) +- `cargo fix` will now show better diagnostics for abnormal errors from `rustc`. + [#9799](https://github.com/rust-lang/cargo/pull/9799) +- Entries in `cargo --list` are now deduplicated. + [#9773](https://github.com/rust-lang/cargo/pull/9773) +- Aliases are now included in `cargo --list`. + [#9764](https://github.com/rust-lang/cargo/pull/9764) ### Fixed +- Fixed panic with build-std of a proc-macro. + [#9834](https://github.com/rust-lang/cargo/pull/9834) +- Fixed running `cargo` recursively from proc-macros while running `cargo fix`. + [#9818](https://github.com/rust-lang/cargo/pull/9818) +- Return an error instead of a stack overflow for command alias loops. + [#9791](https://github.com/rust-lang/cargo/pull/9791) + ### Nightly only +- Added `[future-incompat-report]` config section. + [#9774](https://github.com/rust-lang/cargo/pull/9774) +- Fixed value-after-table error with custom named profiles. + [#9789](https://github.com/rust-lang/cargo/pull/9789) +- Added the `different-binary-name` feature to support specifying a + non-rust-identifier for a binary name. + [docs](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#different-binary-name) + [#9627](https://github.com/rust-lang/cargo/pull/9627) +- Added a profile option to select the codegen backend. + [docs](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#codegen-backend) + [#9118](https://github.com/rust-lang/cargo/pull/9118) + ## Cargo 1.55 (2021-09-09) [aa8b0929...rust-1.55.0](https://github.com/rust-lang/cargo/compare/aa8b0929...rust-1.55.0) @@ -100,6 +188,9 @@ includes several changes, such as new behavior when run on WSL, and using the system `xdg-open` on Linux. [#9583](https://github.com/rust-lang/cargo/pull/9583) +- Updated to libcurl 7.78. + [#9809](https://github.com/rust-lang/cargo/pull/9809) + [#9810](https://github.com/rust-lang/cargo/pull/9810) ### Fixed diff -Nru cargo-0.57.0+ubuntu/ci/fetch-smoke-test.sh cargo-0.58.0/ci/fetch-smoke-test.sh --- cargo-0.57.0+ubuntu/ci/fetch-smoke-test.sh 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/ci/fetch-smoke-test.sh 2021-10-21 14:30:11.000000000 +0000 @@ -0,0 +1,27 @@ +#!/bin/bash +# This script builds with static curl, and verifies that fetching works. + +set -ex + +if [[ -z "$RUNNER_TEMP" ]] +then + echo "RUNNER_TEMP must be set" + exit 1 +fi + +if [ ! -f Cargo.toml ]; then + echo "Must be run from root of project." + exit 1 +fi + + +# Building openssl on Windows is a pain. +if [[ $(rustc -Vv | grep host:) != *windows* ]]; then + FEATURES='vendored-openssl,curl-sys/static-curl,curl-sys/force-system-lib-on-osx' + export LIBZ_SYS_STATIC=1 +fi + +cargo build --features "$FEATURES" +export CARGO_HOME=$RUNNER_TEMP/chome +target/debug/cargo fetch +rm -rf $CARGO_HOME diff -Nru cargo-0.57.0+ubuntu/crates/cargo-test-support/src/tools.rs cargo-0.58.0/crates/cargo-test-support/src/tools.rs --- cargo-0.57.0+ubuntu/crates/cargo-test-support/src/tools.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/crates/cargo-test-support/src/tools.rs 2021-10-21 14:30:11.000000000 +0000 @@ -2,11 +2,12 @@ use crate::{basic_manifest, paths, project, Project}; use lazy_static::lazy_static; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::sync::Mutex; lazy_static! { static ref ECHO_WRAPPER: Mutex> = Mutex::new(None); + static ref ECHO: Mutex> = Mutex::new(None); } /// Returns the path to an executable that works as a wrapper around rustc. @@ -38,6 +39,45 @@ *lock = Some(path.clone()); path } + +/// Returns the path to an executable that prints its arguments. +/// +/// Do not expect this to be anything fancy. +pub fn echo() -> PathBuf { + let mut lock = ECHO.lock().unwrap(); + if let Some(path) = &*lock { + return path.clone(); + } + if let Ok(path) = cargo_util::paths::resolve_executable(Path::new("echo")) { + *lock = Some(path.clone()); + return path; + } + // Often on Windows, `echo` is not available. + let p = project() + .at(paths::global_root().join("basic-echo")) + .file("Cargo.toml", &basic_manifest("basic-echo", "1.0.0")) + .file( + "src/main.rs", + r#" + fn main() { + let mut s = String::new(); + let mut it = std::env::args().skip(1).peekable(); + while let Some(n) = it.next() { + s.push_str(&n); + if it.peek().is_some() { + s.push(' '); + } + } + println!("{}", s); + } + "#, + ) + .build(); + p.cargo("build").run(); + let path = p.bin("basic-echo"); + *lock = Some(path.clone()); + path +} /// Returns a project which builds a cargo-echo simple subcommand pub fn echo_subcommand() -> Project { diff -Nru cargo-0.57.0+ubuntu/debian/changelog cargo-0.58.0/debian/changelog --- cargo-0.57.0+ubuntu/debian/changelog 2021-12-15 21:39:46.000000000 +0000 +++ cargo-0.58.0/debian/changelog 2022-01-25 01:06:06.000000000 +0000 @@ -1,3 +1,14 @@ +cargo (0.58.0-0ubuntu1) jammy; urgency=medium + + * New upstream version. (LP: #1952104) + * d/patches/2110-use-mfpu-on-armhf.patch: delete, fixed upstream. + * d/patches/filetime-pr-75.patch: Backport fix from filetime crate to + fix ftbfs on s390x. + * d/patches/libc-pr-2642.patch: Partially backport upstream PR to fix + another ftbfs on s390x. + + -- Michael Hudson-Doyle Tue, 25 Jan 2022 14:06:06 +1300 + cargo (0.57.0+ubuntu-0ubuntu1) jammy; urgency=medium * Merge from Debian unstable (LP: #1952104). diff -Nru cargo-0.57.0+ubuntu/debian/make_orig_multi-pre-vendor.sh cargo-0.58.0/debian/make_orig_multi-pre-vendor.sh --- cargo-0.57.0+ubuntu/debian/make_orig_multi-pre-vendor.sh 2021-12-12 22:29:30.000000000 +0000 +++ cargo-0.58.0/debian/make_orig_multi-pre-vendor.sh 2022-01-21 01:59:18.000000000 +0000 @@ -15,7 +15,21 @@ # Drop the "vendored" feature since we patch it out of debcargo sed -i /vendored/d Cargo.toml -# For cargo 0.57.0 / rustc 1.56.0 -cargo update -p tempfile --precise 3.1.0 -cargo update -p filetime --precise 0.2.12 -cargo update -p regex --precise 1.3.9 +# For cargo 0.58.0 / rustc 1.57.0 +cargo update -p tempfile --precise 3.2.0 +cargo update -p filetime --precise 0.2.15 +cargo update -p regex --precise 1.5.4 +cargo update -p git2 --precise 0.13.23 +cargo update -p libgit2-sys --precise 0.12.24+1.3.0 +cargo update -p commoncrypto --precise "0.2.0" +cargo update -p commoncrypto-sys --precise "0.2.0" +cargo update -p curl --precise "0.4.39" +cargo update -p curl-sys --precise "0.4.49+curl-7.79.1" +cargo update -p getrandom --precise "0.2.0" +cargo update -p num_cpus --precise "1.13.0" +cargo update -p openssl-sys --precise "0.9.65" +cargo update -p rand --precise "0.8.4" +cargo update -p redox_syscall --precise "0.2.10" +cargo update -p syn --precise "1.0.77" +cargo update -p tar --precise "0.4.37" +cargo update -p tempfile --precise "3.2.0" diff -Nru cargo-0.57.0+ubuntu/debian/patches/2110-use-mfpu-on-armhf.patch cargo-0.58.0/debian/patches/2110-use-mfpu-on-armhf.patch --- cargo-0.57.0+ubuntu/debian/patches/2110-use-mfpu-on-armhf.patch 2021-12-13 01:05:25.000000000 +0000 +++ cargo-0.58.0/debian/patches/2110-use-mfpu-on-armhf.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,18 +0,0 @@ -Already in debcargo-conf.git, can be deleted for next source import. - -The upstream code uses -march but not -mfpu on debian armhf, this works -with gcc-10 but produces an error with gcc-11, set mfpu to fix this. - ---- a/vendor/cc/src/lib.rs 1973-11-29 21:33:09.000000000 +0000 -+++ b/vendor/cc/src/lib.rs 2021-10-23 23:05:21.409460780 +0000 -@@ -1638,6 +1638,10 @@ - && (target.contains("-linux-") || target.contains("-kmc-solid_")) - { - cmd.args.push("-march=armv7-a".into()); -+ if target.ends_with("eabihf") { -+ // lowest common denominator FPU -+ cmd.args.push("-mfpu=vfpv3-d16".into()); -+ } - } - - // (x86 Android doesn't say "eabi") diff -Nru cargo-0.57.0+ubuntu/debian/patches/filetime-pr-75.patch cargo-0.58.0/debian/patches/filetime-pr-75.patch --- cargo-0.57.0+ubuntu/debian/patches/filetime-pr-75.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/debian/patches/filetime-pr-75.patch 2022-01-24 21:24:43.000000000 +0000 @@ -0,0 +1,92 @@ +From 4bf69e074b288cd99965884c4501aa198efe9e3c Mon Sep 17 00:00:00 2001 +From: Alain Zscheile +Date: Mon, 13 Dec 2021 16:34:28 +0100 +Subject: [PATCH] mark some functions as `const fn`, and some fix compiler + warnings (#75) + +* mark fixed init functions and getters as const + +* fix compiler warnings +--- + src/lib.rs | 14 +++++++------- + src/unix/utimes.rs | 1 + + 2 files changed, 8 insertions(+), 7 deletions(-) + +diff --git a/vendor/filetime/src/lib.rs b/vendor/filetime/src/lib.rs +index e29050e..817915c 100644 +--- a/vendor/filetime/src/lib.rs ++++ b/vendor/filetime/src/lib.rs +@@ -71,14 +71,14 @@ impl FileTime { + /// Creates a new timestamp representing a 0 time. + /// + /// Useful for creating the base of a cmp::max chain of times. +- pub fn zero() -> FileTime { ++ pub const fn zero() -> FileTime { + FileTime { + seconds: 0, + nanos: 0, + } + } + +- fn emulate_second_only_system(self) -> FileTime { ++ const fn emulate_second_only_system(self) -> FileTime { + if cfg!(emulate_second_only_system) { + FileTime { + seconds: self.seconds, +@@ -118,7 +118,7 @@ impl FileTime { + /// from, but on Windows the native time stamp is relative to January 1, + /// 1601 so the return value of `seconds` from the returned `FileTime` + /// instance may not be the same as that passed in. +- pub fn from_unix_time(seconds: i64, nanos: u32) -> FileTime { ++ pub const fn from_unix_time(seconds: i64, nanos: u32) -> FileTime { + FileTime { + seconds: seconds + if cfg!(windows) { 11644473600 } else { 0 }, + nanos, +@@ -193,7 +193,7 @@ impl FileTime { + /// Note that this value's meaning is **platform specific**. On Unix + /// platform time stamps are typically relative to January 1, 1970, but on + /// Windows platforms time stamps are relative to January 1, 1601. +- pub fn seconds(&self) -> i64 { ++ pub const fn seconds(&self) -> i64 { + self.seconds + } + +@@ -202,7 +202,7 @@ impl FileTime { + /// + /// Note that this does not return the same value as `seconds` for Windows + /// platforms as seconds are relative to a different date there. +- pub fn unix_seconds(&self) -> i64 { ++ pub const fn unix_seconds(&self) -> i64 { + self.seconds - if cfg!(windows) { 11644473600 } else { 0 } + } + +@@ -211,7 +211,7 @@ impl FileTime { + /// The returned value is always less than one billion and represents a + /// portion of a second forward from the seconds returned by the `seconds` + /// method. +- pub fn nanoseconds(&self) -> u32 { ++ pub const fn nanoseconds(&self) -> u32 { + self.nanos + } + } +@@ -630,7 +630,7 @@ mod tests { + fn set_symlink_dir_times_test() { + let td = Builder::new().prefix("filetime").tempdir().unwrap(); + let path = td.path().join("foo"); +- fs::create_dir(&path); ++ fs::create_dir(&path).unwrap(); + + let metadata = fs::metadata(&path).unwrap(); + let mtime = FileTime::from_last_modification_time(&metadata); +diff --git a/vendor/filetime/src/unix/utimes.rs b/vendor/filetime/src/unix/utimes.rs +index 9926921..34bb882 100644 +--- a/vendor/filetime/src/unix/utimes.rs ++++ b/vendor/filetime/src/unix/utimes.rs +@@ -118,6 +118,7 @@ fn to_timeval(ft: &FileTime) -> libc::timeval { + } + } + ++#[cfg(target_env = "uclibc")] + fn to_timespec(ft: &FileTime) -> libc::timespec { + libc::timespec { + tv_sec: ft.seconds() as libc::time_t, diff -Nru cargo-0.57.0+ubuntu/debian/patches/libc-pr-2642.patch cargo-0.58.0/debian/patches/libc-pr-2642.patch --- cargo-0.57.0+ubuntu/debian/patches/libc-pr-2642.patch 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/debian/patches/libc-pr-2642.patch 2022-01-24 22:18:20.000000000 +0000 @@ -0,0 +1,147 @@ +From da84eefd712167bac47c904de3ac6056521c7f18 Mon Sep 17 00:00:00 2001 +From: Tamir Duberstein +Date: Sat, 22 Jan 2022 08:13:30 -0500 +Subject: [PATCH] Define ip_mreqn on all Linux platforms + +Updates #1558. +--- + libc-test/build.rs | 5 +++++ + libc-test/semver/linux-aarch64.txt | 1 - + libc-test/semver/linux-i686.txt | 1 - + libc-test/semver/linux-mips.txt | 1 - + libc-test/semver/linux-powerpc.txt | 1 - + libc-test/semver/linux-powerpc64.txt | 1 - + libc-test/semver/linux-powerpc64le.txt | 1 - + libc-test/semver/linux-riscv64gc.txt | 1 - + libc-test/semver/linux-x86_64.txt | 1 - + libc-test/semver/linux.txt | 1 + + src/unix/linux_like/android/mod.rs | 6 ------ + src/unix/linux_like/linux/gnu/b32/mod.rs | 6 ------ + src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs | 6 ------ + src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs | 6 ------ + src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs | 6 ------ + src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs | 6 ------ + src/unix/linux_like/linux/musl/mod.rs | 6 ------ + src/unix/linux_like/mod.rs | 6 ++++++ + 18 files changed, 12 insertions(+), 50 deletions(-) + +--- a/vendor/libc/src/unix/linux_like/android/mod.rs ++++ b/vendor/libc/src/unix/linux_like/android/mod.rs +@@ -73,12 +73,6 @@ + pub cmsg_type: ::c_int, + } + +- pub struct ip_mreqn { +- pub imr_multiaddr: ::in_addr, +- pub imr_address: ::in_addr, +- pub imr_ifindex: ::c_int, +- } +- + pub struct termios { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, +--- a/vendor/libc/src/unix/linux_like/linux/gnu/b32/mod.rs ++++ b/vendor/libc/src/unix/linux_like/linux/gnu/b32/mod.rs +@@ -135,12 +135,6 @@ + pub _f: [::c_char; 8], + } + +- pub struct ip_mreqn { +- pub imr_multiaddr: ::in_addr, +- pub imr_address: ::in_addr, +- pub imr_ifindex: ::c_int, +- } +- + pub struct semid_ds { + pub sem_perm: ipc_perm, + #[cfg(target_arch = "powerpc")] +--- a/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs ++++ b/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +@@ -197,12 +197,6 @@ + pub ss_size: ::size_t + } + +- pub struct ip_mreqn { +- pub imr_multiaddr: ::in_addr, +- pub imr_address: ::in_addr, +- pub imr_ifindex: ::c_int, +- } +- + pub struct seccomp_notif_sizes { + pub seccomp_notif: ::__u16, + pub seccomp_notif_resp: ::__u16, +--- a/vendor/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs ++++ b/vendor/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +@@ -191,12 +191,6 @@ + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } +- +- pub struct ip_mreqn { +- pub imr_multiaddr: ::in_addr, +- pub imr_address: ::in_addr, +- pub imr_ifindex: ::c_int, +- } + } + + pub const POSIX_FADV_DONTNEED: ::c_int = 4; +--- a/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs ++++ b/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +@@ -192,12 +192,6 @@ + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } +- +- pub struct ip_mreqn { +- pub imr_multiaddr: ::in_addr, +- pub imr_address: ::in_addr, +- pub imr_ifindex: ::c_int, +- } + } + + pub const POSIX_FADV_DONTNEED: ::c_int = 4; +--- a/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs ++++ b/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs +@@ -260,12 +260,6 @@ + __unused5: u64 + } + +- pub struct ip_mreqn { +- pub imr_multiaddr: ::in_addr, +- pub imr_address: ::in_addr, +- pub imr_ifindex: ::c_int, +- } +- + pub struct seccomp_notif_sizes { + pub seccomp_notif: ::__u16, + pub seccomp_notif_resp: ::__u16, +--- a/vendor/libc/src/unix/linux_like/linux/musl/mod.rs ++++ b/vendor/libc/src/unix/linux_like/linux/musl/mod.rs +@@ -218,12 +218,6 @@ + pub rt_irtt: ::c_ushort, + } + +- pub struct ip_mreqn { +- pub imr_multiaddr: ::in_addr, +- pub imr_address: ::in_addr, +- pub imr_ifindex: ::c_int, +- } +- + pub struct __exit_status { + pub e_termination: ::c_short, + pub e_exit: ::c_short, +--- a/vendor/libc/src/unix/linux_like/mod.rs ++++ b/vendor/libc/src/unix/linux_like/mod.rs +@@ -25,6 +25,12 @@ + pub imr_interface: in_addr, + } + ++ pub struct ip_mreqn { ++ pub imr_multiaddr: in_addr, ++ pub imr_address: in_addr, ++ pub imr_ifindex: ::c_int, ++ } ++ + pub struct ip_mreq_source { + pub imr_multiaddr: in_addr, + pub imr_interface: in_addr, diff -Nru cargo-0.57.0+ubuntu/debian/patches/series cargo-0.58.0/debian/patches/series --- cargo-0.57.0+ubuntu/debian/patches/series 2021-12-13 01:02:37.000000000 +0000 +++ cargo-0.58.0/debian/patches/series 2022-01-24 22:18:20.000000000 +0000 @@ -1,4 +1,5 @@ 2002_disable-net-tests.patch -2110-use-mfpu-on-armhf.patch 2111-curl-no-rebuild.patch 2112-handle-4-siphasher-algorithms.patch +filetime-pr-75.patch +libc-pr-2642.patch diff -Nru cargo-0.57.0+ubuntu/.github/ISSUE_TEMPLATE/bug_report.md cargo-0.58.0/.github/ISSUE_TEMPLATE/bug_report.md --- cargo-0.57.0+ubuntu/.github/ISSUE_TEMPLATE/bug_report.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/.github/ISSUE_TEMPLATE/bug_report.md 2021-10-21 14:30:11.000000000 +0000 @@ -22,7 +22,7 @@ **Notes** -Output of `cargo version`: +Output of `cargo version --verbose`: diff -Nru cargo-0.57.0+ubuntu/.github/workflows/main.yml cargo-0.58.0/.github/workflows/main.yml --- cargo-0.57.0+ubuntu/.github/workflows/main.yml 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/.github/workflows/main.yml 2021-10-21 14:30:11.000000000 +0000 @@ -79,6 +79,8 @@ if: matrix.os == 'macos-latest' - run: cargo build --manifest-path crates/credential/cargo-credential-wincred/Cargo.toml if: matrix.os == 'windows-latest' + - name: Fetch smoke test + run: ci/fetch-smoke-test.sh resolver: runs-on: ubuntu-latest diff -Nru cargo-0.57.0+ubuntu/src/bin/cargo/cli.rs cargo-0.58.0/src/bin/cargo/cli.rs --- cargo-0.57.0+ubuntu/src/bin/cargo/cli.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/bin/cargo/cli.rs 2021-10-21 14:30:11.000000000 +0000 @@ -4,6 +4,7 @@ use clap::{AppSettings, Arg, ArgMatches}; use itertools::Itertools; use std::collections::HashMap; +use std::fmt::Write; use super::commands; use super::list_commands; @@ -43,7 +44,12 @@ } }; - if args.value_of("unstable-features") == Some("help") { + // Global args need to be extracted before expanding aliases because the + // clap code for extracting a subcommand discards global options + // (appearing before the subcommand). + let (expanded_args, global_args) = expand_aliases(config, args, vec![])?; + + if expanded_args.value_of("unstable-features") == Some("help") { let options = CliUnstable::help(); let non_hidden_options: Vec<(String, String)> = options .iter() @@ -95,20 +101,20 @@ return Ok(()); } - let is_verbose = args.occurrences_of("verbose") > 0; - if args.is_present("version") { + let is_verbose = expanded_args.occurrences_of("verbose") > 0; + if expanded_args.is_present("version") { let version = get_version_string(is_verbose); drop_print!(config, "{}", version); return Ok(()); } - if let Some(code) = args.value_of("explain") { + if let Some(code) = expanded_args.value_of("explain") { let mut procss = config.load_global_rustc(None)?.process(); procss.arg("--explain").arg(code).exec()?; return Ok(()); } - if args.is_present("list") { + if expanded_args.is_present("list") { drop_println!(config, "Installed Commands:"); for (name, command) in list_commands(config) { let known_external_desc = KNOWN_EXTERNAL_COMMAND_DESCRIPTIONS.get(name.as_str()); @@ -140,10 +146,6 @@ return Ok(()); } - // Global args need to be extracted before expanding aliases because the - // clap code for extracting a subcommand discards global options - // (appearing before the subcommand). - let (expanded_args, global_args) = expand_aliases(config, args, vec![])?; let (cmd, subcommand_args) = match expanded_args.subcommand() { (cmd, Some(args)) => (cmd, args), _ => { @@ -172,10 +174,64 @@ version_string.push_str(&format!("commit-date: {}\n", ci.commit_date)); } } + writeln!(version_string, "host: {}", env!("RUST_HOST_TARGET")).unwrap(); + add_libgit2(&mut version_string); + add_curl(&mut version_string); + add_ssl(&mut version_string); + writeln!(version_string, "os: {}", os_info::get()).unwrap(); } version_string } +fn add_libgit2(version_string: &mut String) { + let git2_v = git2::Version::get(); + let lib_v = git2_v.libgit2_version(); + let vendored = if git2_v.vendored() { + format!("vendored") + } else { + format!("system") + }; + writeln!( + version_string, + "libgit2: {}.{}.{} (sys:{} {})", + lib_v.0, + lib_v.1, + lib_v.2, + git2_v.crate_version(), + vendored + ) + .unwrap(); +} + +fn add_curl(version_string: &mut String) { + let curl_v = curl::Version::get(); + let vendored = if curl_v.vendored() { + format!("vendored") + } else { + format!("system") + }; + writeln!( + version_string, + "libcurl: {} (sys:{} {} ssl:{})", + curl_v.version(), + curl_sys::rust_crate_version(), + vendored, + curl_v.ssl_version().unwrap_or("none") + ) + .unwrap(); +} + +fn add_ssl(version_string: &mut String) { + #[cfg(feature = "openssl")] + { + writeln!(version_string, "ssl: {}", openssl::version::version()).unwrap(); + } + #[cfg(not(feature = "openssl"))] + { + let _ = version_string; // Silence unused warning. + } +} + fn expand_aliases( config: &mut Config, args: ArgMatches<'static>, diff -Nru cargo-0.57.0+ubuntu/src/cargo/core/compiler/custom_build.rs cargo-0.58.0/src/cargo/core/compiler/custom_build.rs --- cargo-0.57.0+ubuntu/src/cargo/core/compiler/custom_build.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/core/compiler/custom_build.rs 2021-10-21 14:30:11.000000000 +0000 @@ -566,7 +566,11 @@ let (key, value) = match (key, value) { (Some(a), Some(b)) => (a, b.trim_end()), // Line started with `cargo:` but didn't match `key=value`. - _ => bail!("Wrong output in {}: `{}`", whence, line), + _ => bail!("invalid output in {}: `{}`\n\ + Expected a line with `cargo:key=value` with an `=` character, \ + but none was found.\n\ + See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script \ + for more information about build script outputs.", whence, line), }; // This will rewrite paths if the target directory has been moved. diff -Nru cargo-0.57.0+ubuntu/src/cargo/core/compiler/job_queue.rs cargo-0.58.0/src/cargo/core/compiler/job_queue.rs --- cargo-0.57.0+ubuntu/src/cargo/core/compiler/job_queue.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/core/compiler/job_queue.rs 2021-10-21 14:30:11.000000000 +0000 @@ -998,20 +998,30 @@ fn name_for_progress(&self, unit: &Unit) -> String { let pkg_name = unit.pkg.name(); + let target_name = unit.target.name(); match unit.mode { CompileMode::Doc { .. } => format!("{}(doc)", pkg_name), CompileMode::RunCustomBuild => format!("{}(build)", pkg_name), - _ => { - let annotation = match unit.target.kind() { - TargetKind::Lib(_) => return pkg_name.to_string(), - TargetKind::CustomBuild => return format!("{}(build.rs)", pkg_name), - TargetKind::Bin => "bin", - TargetKind::Test => "test", - TargetKind::Bench => "bench", - TargetKind::ExampleBin | TargetKind::ExampleLib(_) => "example", - }; - format!("{}({})", unit.target.name(), annotation) - } + CompileMode::Test | CompileMode::Check { test: true } => match unit.target.kind() { + TargetKind::Lib(_) => format!("{}(test)", target_name), + TargetKind::CustomBuild => panic!("cannot test build script"), + TargetKind::Bin => format!("{}(bin test)", target_name), + TargetKind::Test => format!("{}(test)", target_name), + TargetKind::Bench => format!("{}(bench)", target_name), + TargetKind::ExampleBin | TargetKind::ExampleLib(_) => { + format!("{}(example test)", target_name) + } + }, + _ => match unit.target.kind() { + TargetKind::Lib(_) => pkg_name.to_string(), + TargetKind::CustomBuild => format!("{}(build.rs)", pkg_name), + TargetKind::Bin => format!("{}(bin)", target_name), + TargetKind::Test => format!("{}(test)", target_name), + TargetKind::Bench => format!("{}(bench)", target_name), + TargetKind::ExampleBin | TargetKind::ExampleLib(_) => { + format!("{}(example)", target_name) + } + }, } } diff -Nru cargo-0.57.0+ubuntu/src/cargo/core/dependency.rs cargo-0.58.0/src/cargo/core/dependency.rs --- cargo-0.57.0+ubuntu/src/cargo/core/dependency.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/core/dependency.rs 2021-10-21 14:30:11.000000000 +0000 @@ -320,7 +320,6 @@ /// Locks this dependency to depending on the specified package ID. pub fn lock_to(&mut self, id: PackageId) -> &mut Dependency { assert_eq!(self.inner.source_id, id.source_id()); - assert!(self.inner.req.matches(id.version())); trace!( "locking dep from `{}` with `{}` at {} to {}", self.package_name(), @@ -329,7 +328,7 @@ id ); let me = Rc::make_mut(&mut self.inner); - me.req = OptVersionReq::exact(id.version()); + me.req.lock_to(id.version()); // Only update the `precise` of this source to preserve other // information about dependency's source which may not otherwise be @@ -340,10 +339,20 @@ self } - /// Returns `true` if this is a "locked" dependency, basically whether it has - /// an exact version req. + /// Locks this dependency to a specified version. + /// + /// Mainly used in dependency patching like `[patch]` or `[replace]`, which + /// doesn't need to lock the entire dependency to a specific [`PackageId`]. + pub fn lock_version(&mut self, version: &semver::Version) -> &mut Dependency { + let me = Rc::make_mut(&mut self.inner); + me.req.lock_to(version); + self + } + + /// Returns `true` if this is a "locked" dependency. Basically a locked + /// dependency has an exact version req, but not vice versa. pub fn is_locked(&self) -> bool { - self.inner.req.is_exact() + self.inner.req.is_locked() } /// Returns `false` if the dependency is only used to build the local package. diff -Nru cargo-0.57.0+ubuntu/src/cargo/core/features.rs cargo-0.58.0/src/cargo/core/features.rs --- cargo-0.57.0+ubuntu/src/cargo/core/features.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/core/features.rs 2021-10-21 14:30:11.000000000 +0000 @@ -387,7 +387,7 @@ (unstable, public_dependency, "", "reference/unstable.html#public-dependency"), // Allow to specify profiles other than 'dev', 'release', 'test', etc. - (unstable, named_profiles, "", "reference/unstable.html#custom-named-profiles"), + (stable, named_profiles, "1.57", "reference/profiles.html#custom-profiles"), // Opt-in new-resolver behavior. (stable, resolver, "1.51", "reference/resolver.html#resolver-versions"), @@ -643,7 +643,6 @@ minimal_versions: bool = ("Resolve minimal dependency versions instead of maximum"), mtime_on_use: bool = ("Configure Cargo to update the mtime of used files"), multitarget: bool = ("Allow passing multiple `--target` flags to the cargo subcommand selected"), - named_profiles: bool = ("Allow defining custom profiles"), namespaced_features: bool = ("Allow features with `dep:` prefix"), no_index_update: bool = ("Do not update the registry index even if the cache is outdated"), panic_abort_tests: bool = ("Enable support to run tests with -Cpanic=abort"), @@ -699,6 +698,10 @@ const STABILIZED_PATCH_IN_CONFIG: &str = "The patch-in-config feature is now always enabled."; +const STABILIZED_NAMED_PROFILES: &str = "The named-profiles feature is now always enabled.\n\ + See https://doc.rust-lang.org/nightly/cargo/reference/profiles.html#custom-profiles \ + for more information"; + fn deserialize_build_std<'de, D>(deserializer: D) -> Result>, D::Error> where D: serde::Deserializer<'de>, @@ -830,7 +833,7 @@ "dual-proc-macros" => self.dual_proc_macros = parse_empty(k, v)?, // can also be set in .cargo/config or with and ENV "mtime-on-use" => self.mtime_on_use = parse_empty(k, v)?, - "named-profiles" => self.named_profiles = parse_empty(k, v)?, + "named-profiles" => stabilized_warn(k, "1.57", STABILIZED_NAMED_PROFILES), "binary-dep-depinfo" => self.binary_dep_depinfo = parse_empty(k, v)?, "build-std" => { self.build_std = Some(crate::core::compiler::standard_lib::parse_unstable_flag(v)) diff -Nru cargo-0.57.0+ubuntu/src/cargo/core/manifest.rs cargo-0.58.0/src/cargo/core/manifest.rs --- cargo-0.57.0+ubuntu/src/cargo/core/manifest.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/core/manifest.rs 2021-10-21 14:30:11.000000000 +0000 @@ -259,7 +259,7 @@ /// Serialized as a list of strings for historical reasons. kind: &'a TargetKind, /// Corresponds to `--crate-type` compiler attribute. - /// See https://doc.rust-lang.org/reference/linkage.html + /// See crate_types: Vec, name: &'a str, src_path: Option<&'a PathBuf>, @@ -267,7 +267,7 @@ #[serde(rename = "required-features", skip_serializing_if = "Option::is_none")] required_features: Option>, /// Whether docs should be built for the target via `cargo doc` - /// See https://doc.rust-lang.org/cargo/commands/cargo-doc.html#target-selection + /// See doc: bool, doctest: bool, /// Whether tests should be run for the target (`test` field in `Cargo.toml`) diff -Nru cargo-0.57.0+ubuntu/src/cargo/core/profiles.rs cargo-0.58.0/src/cargo/core/profiles.rs --- cargo-0.57.0+ubuntu/src/cargo/core/profiles.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/core/profiles.rs 2021-10-21 14:30:11.000000000 +0000 @@ -20,6 +20,11 @@ dir_names: HashMap, /// The profile makers. Key is the profile name. by_name: HashMap, + /// The original profiles written by the user in the manifest and config. + /// + /// This is here to assist with error reporting, as the `ProfileMaker` + /// values have the inherits chains all merged together. + original_profiles: BTreeMap, /// Whether or not unstable "named" profiles are enabled. named_profiles_enabled: bool, /// The profile the user requested to use. @@ -44,6 +49,7 @@ named_profiles_enabled: false, dir_names: Self::predefined_dir_names(), by_name: HashMap::new(), + original_profiles: profiles.clone(), requested_profile, rustc_host, }; @@ -97,6 +103,7 @@ named_profiles_enabled: true, dir_names: Self::predefined_dir_names(), by_name: HashMap::new(), + original_profiles: profiles.clone(), requested_profile, rustc_host, }; @@ -420,6 +427,19 @@ resolve: &Resolve, ) -> CargoResult<()> { for (name, profile) in &self.by_name { + // If the user did not specify an override, skip this. This is here + // to avoid generating errors for inherited profiles which don't + // specify package overrides. The `by_name` profile has had the inherits + // chain merged, so we need to look at the original source to check + // if an override was specified. + if self + .original_profiles + .get(name) + .and_then(|orig| orig.package.as_ref()) + .is_none() + { + continue; + } let found = validate_packages_unique(resolve, name, &profile.toml)?; // We intentionally do not validate unmatched packages for config // profiles, in case they are defined in a central location. This @@ -456,6 +476,10 @@ /// The starting, hard-coded defaults for the profile. default: Profile, /// The TOML profile defined in `Cargo.toml` or config. + /// + /// This is None if the user did not specify one, in which case the + /// `default` is used. Note that the built-in defaults for test/bench/doc + /// always set this since they need to declare the `inherits` value. toml: Option, } diff -Nru cargo-0.57.0+ubuntu/src/cargo/core/registry.rs cargo-0.58.0/src/cargo/core/registry.rs --- cargo-0.57.0+ubuntu/src/cargo/core/registry.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/core/registry.rs 2021-10-21 14:30:11.000000000 +0000 @@ -5,10 +5,9 @@ use crate::sources::config::SourceConfigMap; use crate::util::errors::CargoResult; use crate::util::interning::InternedString; -use crate::util::{profile, CanonicalUrl, Config, VersionReqExt}; +use crate::util::{profile, CanonicalUrl, Config}; use anyhow::{bail, Context as _}; use log::{debug, trace}; -use semver::VersionReq; use url::Url; /// Source of information about a group of packages. @@ -765,8 +764,7 @@ if locked.source_id() == dep.source_id() { dep.lock_to(locked); } else { - let req = VersionReq::exact(locked.version()); - dep.set_version_req(req); + dep.lock_version(locked.version()); } return dep; } diff -Nru cargo-0.57.0+ubuntu/src/cargo/core/resolver/errors.rs cargo-0.58.0/src/cargo/core/resolver/errors.rs --- cargo-0.57.0+ubuntu/src/cargo/core/resolver/errors.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/core/resolver/errors.rs 2021-10-21 14:30:11.000000000 +0000 @@ -387,10 +387,16 @@ } else { dep.name_in_toml().to_string() }; + let locked_version = dep + .version_req() + .locked_version() + .map(|v| format!("(locked to {}) ", v)) + .unwrap_or_default(); + write!( dep_path_desc, - "\n ... which satisfies {}dependency `{}` of package `{}`", - source_kind, requirement, pkg + "\n ... which satisfies {}dependency `{}` {}of package `{}`", + source_kind, requirement, locked_version, pkg ) .unwrap(); } diff -Nru cargo-0.57.0+ubuntu/src/cargo/core/resolver/version_prefs.rs cargo-0.58.0/src/cargo/core/resolver/version_prefs.rs --- cargo-0.57.0+ubuntu/src/cargo/core/resolver/version_prefs.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/core/resolver/version_prefs.rs 2021-10-21 14:30:11.000000000 +0000 @@ -9,8 +9,8 @@ /// A collection of preferences for particular package versions. /// -/// This is built up with [`prefer_package_id`] and [`prefer_dep`], then used to sort the set of -/// summaries for a package during resolution via [`sort_summaries`]. +/// This is built up with [`Self::prefer_package_id`] and [`Self::prefer_dependency`], then used to sort the set of +/// summaries for a package during resolution via [`Self::sort_summaries`]. /// /// As written, a version is either "preferred" or "not preferred". Later extensions may /// introduce more granular preferences. diff -Nru cargo-0.57.0+ubuntu/src/cargo/ops/cargo_generate_lockfile.rs cargo-0.58.0/src/cargo/ops/cargo_generate_lockfile.rs --- cargo-0.57.0+ubuntu/src/cargo/ops/cargo_generate_lockfile.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/ops/cargo_generate_lockfile.rs 2021-10-21 14:30:11.000000000 +0000 @@ -1,8 +1,3 @@ -use std::collections::{BTreeMap, HashSet}; - -use log::debug; -use termcolor::Color::{self, Cyan, Green, Red}; - use crate::core::registry::PackageRegistry; use crate::core::resolver::features::{CliFeatures, HasDevUnits}; use crate::core::{PackageId, PackageIdSpec}; @@ -10,6 +5,10 @@ use crate::ops; use crate::util::config::Config; use crate::util::CargoResult; +use anyhow::Context; +use log::debug; +use std::collections::{BTreeMap, HashSet}; +use termcolor::Color::{self, Cyan, Green, Red}; pub struct UpdateOptions<'a> { pub config: &'a Config, @@ -95,6 +94,9 @@ // seems like a pretty hokey reason to single out // the registry as well. let precise = if dep.source_id().is_registry() { + semver::Version::parse(precise).with_context(|| { + format!("invalid version format for precise version `{}`", precise) + })?; format!("{}={}->{}", dep.name(), dep.version(), precise) } else { precise.to_string() diff -Nru cargo-0.57.0+ubuntu/src/cargo/ops/cargo_install.rs cargo-0.58.0/src/cargo/ops/cargo_install.rs --- cargo-0.57.0+ubuntu/src/cargo/ops/cargo_install.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/ops/cargo_install.rs 2021-10-21 14:30:11.000000000 +0000 @@ -681,7 +681,7 @@ where T: Source, { - if !dep.is_locked() { + if !dep.version_req().is_exact() { // If the version isn't exact, we may need to update the registry and look for a newer // version - we can't know if the package is installed without doing so. return Ok(None); diff -Nru cargo-0.57.0+ubuntu/src/cargo/ops/cargo_new.rs cargo-0.58.0/src/cargo/ops/cargo_new.rs --- cargo-0.57.0+ubuntu/src/cargo/ops/cargo_new.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/ops/cargo_new.rs 2021-10-21 14:30:11.000000000 +0000 @@ -185,7 +185,7 @@ This can be done by setting the binary filename to `src/bin/{name}.rs` \ or change the name in Cargo.toml with:\n\ \n \ - [bin]\n \ + [[bin]]\n \ name = \"{name}\"\n \ path = \"src/main.rs\"\n\ ", diff -Nru cargo-0.57.0+ubuntu/src/cargo/ops/cargo_package.rs cargo-0.58.0/src/cargo/ops/cargo_package.rs --- cargo-0.57.0+ubuntu/src/cargo/ops/cargo_package.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/ops/cargo_package.rs 2021-10-21 14:30:11.000000000 +0000 @@ -20,6 +20,7 @@ use flate2::read::GzDecoder; use flate2::{Compression, GzBuilder}; use log::debug; +use serde::Serialize; use tar::{Archive, Builder, EntryType, Header, HeaderMode}; pub struct PackageOpts<'cfg> { @@ -58,8 +59,20 @@ Manifest, /// Generates `Cargo.lock` in some cases (like if there is a binary). Lockfile, - /// Adds a `.cargo-vcs_info.json` file if in a (clean) git repo. - VcsInfo(String), + /// Adds a `.cargo_vcs_info.json` file if in a (clean) git repo. + VcsInfo(VcsInfo), +} + +#[derive(Serialize)] +struct VcsInfo { + git: GitVcsInfo, + /// Path to the package within repo (empty string if root). / not \ + path_in_vcs: String, +} + +#[derive(Serialize)] +struct GitVcsInfo { + sha1: String, } pub fn package_one( @@ -88,7 +101,6 @@ let vcs_info = if !opts.allow_dirty { // This will error if a dirty repo is found. check_repo_state(pkg, &src_files, config)? - .map(|h| format!("{{\n \"git\": {{\n \"sha1\": \"{}\"\n }}\n}}\n", h)) } else { None }; @@ -189,7 +201,7 @@ ws: &Workspace<'_>, pkg: &Package, src_files: Vec, - vcs_info: Option, + vcs_info: Option, ) -> CargoResult> { let mut result = Vec::new(); let root = pkg.root(); @@ -386,7 +398,7 @@ p: &Package, src_files: &[PathBuf], config: &Config, -) -> CargoResult> { +) -> CargoResult> { if let Ok(repo) = git2::Repository::discover(p.root()) { if let Some(workdir) = repo.workdir() { debug!("found a git repo at {:?}", workdir); @@ -398,7 +410,15 @@ "found (git) Cargo.toml at {:?} in workdir {:?}", path, workdir ); - return git(p, src_files, &repo); + let path_in_vcs = path + .parent() + .and_then(|p| p.to_str()) + .unwrap_or("") + .replace("\\", "/"); + return Ok(Some(VcsInfo { + git: git(p, src_files, &repo)?, + path_in_vcs, + })); } } config.shell().verbose(|shell| { @@ -419,11 +439,7 @@ // directory is dirty or not, thus we have to assume that it's clean. return Ok(None); - fn git( - p: &Package, - src_files: &[PathBuf], - repo: &git2::Repository, - ) -> CargoResult> { + fn git(p: &Package, src_files: &[PathBuf], repo: &git2::Repository) -> CargoResult { // This is a collection of any dirty or untracked files. This covers: // - new/modified/deleted/renamed/type change (index or worktree) // - untracked files (which are "new" worktree files) @@ -450,7 +466,9 @@ .collect(); if dirty_src_files.is_empty() { let rev_obj = repo.revparse_single("HEAD")?; - Ok(Some(rev_obj.id().to_string())) + Ok(GitVcsInfo { + sha1: rev_obj.id().to_string(), + }) } else { anyhow::bail!( "{} files in the working directory contain changes that were \ @@ -562,7 +580,7 @@ let contents = match generated_kind { GeneratedFile::Manifest => pkg.to_registry_toml(ws)?, GeneratedFile::Lockfile => build_lock(ws, pkg)?, - GeneratedFile::VcsInfo(s) => s, + GeneratedFile::VcsInfo(ref s) => serde_json::to_string_pretty(s)?, }; header.set_entry_type(EntryType::file()); header.set_mode(0o644); diff -Nru cargo-0.57.0+ubuntu/src/cargo/ops/fix.rs cargo-0.58.0/src/cargo/ops/fix.rs --- cargo-0.57.0+ubuntu/src/cargo/ops/fix.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/ops/fix.rs 2021-10-21 14:30:11.000000000 +0000 @@ -514,7 +514,7 @@ // We'll generate new errors below. file.errors_applying_fixes.clear(); } - rustfix_and_fix(&mut fixes, rustc, filename, args)?; + rustfix_and_fix(&mut fixes, rustc, filename, args, config)?; let mut progress_yet_to_be_made = false; for (path, file) in fixes.files.iter_mut() { if file.errors_applying_fixes.is_empty() { @@ -556,6 +556,7 @@ rustc: &ProcessBuilder, filename: &Path, args: &FixArgs, + config: &Config, ) -> Result<(), Error> { // If not empty, filter by these lints. // TODO: implement a way to specify this. @@ -609,6 +610,8 @@ // Collect suggestions by file so we can apply them one at a time later. let mut file_map = HashMap::new(); let mut num_suggestion = 0; + // It's safe since we won't read any content under home dir. + let home_path = config.home().as_path_unlocked(); for suggestion in suggestions { trace!("suggestion"); // Make sure we've got a file associated with this suggestion and all @@ -627,6 +630,11 @@ continue; }; + // Do not write into registry cache. See rust-lang/cargo#9857. + if Path::new(&file_name).starts_with(home_path) { + continue; + } + if !file_names.clone().all(|f| f == &file_name) { trace!("rejecting as it changes multiple files: {:?}", suggestion); continue; diff -Nru cargo-0.57.0+ubuntu/src/cargo/ops/registry.rs cargo-0.58.0/src/cargo/ops/registry.rs --- cargo-0.57.0+ubuntu/src/cargo/ops/registry.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/ops/registry.rs 2021-10-21 14:30:11.000000000 +0000 @@ -482,7 +482,6 @@ registry.as_deref(), &api_host, )?; - log::debug!("found token {:?}", token); Some(token) } } diff -Nru cargo-0.57.0+ubuntu/src/cargo/sources/git/utils.rs cargo-0.58.0/src/cargo/sources/git/utils.rs --- cargo-0.57.0+ubuntu/src/cargo/sources/git/utils.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/sources/git/utils.rs 2021-10-21 14:30:11.000000000 +0000 @@ -785,27 +785,34 @@ // which need to get fetched. Additionally record if we're fetching tags. let mut refspecs = Vec::new(); let mut tags = false; + // The `+` symbol on the refspec means to allow a forced (fast-forward) + // update which is needed if there is ever a force push that requires a + // fast-forward. match reference { // For branches and tags we can fetch simply one reference and copy it // locally, no need to fetch other branches/tags. GitReference::Branch(b) => { - refspecs.push(format!("refs/heads/{0}:refs/remotes/origin/{0}", b)); + refspecs.push(format!("+refs/heads/{0}:refs/remotes/origin/{0}", b)); } GitReference::Tag(t) => { - refspecs.push(format!("refs/tags/{0}:refs/remotes/origin/tags/{0}", t)); + refspecs.push(format!("+refs/tags/{0}:refs/remotes/origin/tags/{0}", t)); } GitReference::DefaultBranch => { - refspecs.push(String::from("HEAD:refs/remotes/origin/HEAD")); + refspecs.push(String::from("+HEAD:refs/remotes/origin/HEAD")); } - // For `rev` dependencies we don't know what the rev will point to. To - // handle this situation we fetch all branches and tags, and then we - // pray it's somewhere in there. - GitReference::Rev(_) => { - refspecs.push(String::from("refs/heads/*:refs/remotes/origin/*")); - refspecs.push(String::from("HEAD:refs/remotes/origin/HEAD")); - tags = true; + GitReference::Rev(rev) => { + if rev.starts_with("refs/") { + refspecs.push(format!("+{0}:{0}", rev)); + } else { + // We don't know what the rev will point to. To handle this + // situation we fetch all branches and tags, and then we pray + // it's somewhere in there. + refspecs.push(String::from("+refs/heads/*:refs/remotes/origin/*")); + refspecs.push(String::from("+HEAD:refs/remotes/origin/HEAD")); + tags = true; + } } } @@ -1025,9 +1032,13 @@ GitReference::Branch(branch) => branch, GitReference::Tag(tag) => tag, GitReference::DefaultBranch => "HEAD", - GitReference::Rev(_) => { - debug!("can't use github fast path with `rev`"); - return Ok(false); + GitReference::Rev(rev) => { + if rev.starts_with("refs/") { + rev + } else { + debug!("can't use github fast path with `rev = \"{}\"`", rev); + return Ok(false); + } } }; diff -Nru cargo-0.57.0+ubuntu/src/cargo/sources/registry/index.rs cargo-0.58.0/src/cargo/sources/registry/index.rs --- cargo-0.57.0+ubuntu/src/cargo/sources/registry/index.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/sources/registry/index.rs 2021-10-21 14:30:11.000000000 +0000 @@ -460,19 +460,40 @@ // this source, `` is the version installed and ` is the // version requested (argument to `--precise`). let name = dep.package_name().as_str(); - let summaries = summaries.filter(|s| match source_id.precise() { + let precise = match source_id.precise() { Some(p) if p.starts_with(name) && p[name.len()..].starts_with('=') => { let mut vers = p[name.len() + 1..].splitn(2, "->"); - if dep - .version_req() - .matches(&vers.next().unwrap().to_semver().unwrap()) - { - vers.next().unwrap() == s.version().to_string() + let current_vers = vers.next().unwrap().to_semver().unwrap(); + let requested_vers = vers.next().unwrap().to_semver().unwrap(); + Some((current_vers, requested_vers)) + } + _ => None, + }; + let summaries = summaries.filter(|s| match &precise { + Some((current, requested)) => { + if dep.version_req().matches(current) { + // Unfortunately crates.io allows versions to differ only + // by build metadata. This shouldn't be allowed, but since + // it is, this will honor it if requested. However, if not + // specified, then ignore it. + let s_vers = s.version(); + match (s_vers.build.is_empty(), requested.build.is_empty()) { + (true, true) => s_vers == requested, + (true, false) => false, + (false, true) => { + // Strip out the metadata. + s_vers.major == requested.major + && s_vers.minor == requested.minor + && s_vers.patch == requested.patch + && s_vers.pre == requested.pre + } + (false, false) => s_vers == requested, + } } else { true } } - _ => true, + None => true, }); let mut count = 0; diff -Nru cargo-0.57.0+ubuntu/src/cargo/sources/registry/remote.rs cargo-0.58.0/src/cargo/sources/registry/remote.rs --- cargo-0.57.0+ubuntu/src/cargo/sources/registry/remote.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/sources/registry/remote.rs 2021-10-21 14:30:11.000000000 +0000 @@ -88,8 +88,9 @@ // things that we don't want. let mut opts = git2::RepositoryInitOptions::new(); opts.external_template(false); - Ok(git2::Repository::init_opts(&path, &opts) - .with_context(|| "failed to initialize index git repository")?) + Ok(git2::Repository::init_opts(&path, &opts).with_context(|| { + format!("failed to initialize index git repository (in {:?})", path) + })?) } } }) diff -Nru cargo-0.57.0+ubuntu/src/cargo/util/command_prelude.rs cargo-0.58.0/src/cargo/util/command_prelude.rs --- cargo-0.57.0+ubuntu/src/cargo/util/command_prelude.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/util/command_prelude.rs 2021-10-21 14:30:11.000000000 +0000 @@ -363,16 +363,22 @@ // This is an early exit, since it allows combination with `--release`. match (specified_profile, profile_checking) { // `cargo rustc` has legacy handling of these names - (Some(name @ ("dev" | "test" | "bench" | "check")), ProfileChecking::LegacyRustc) | + (Some(name @ ("dev" | "test" | "bench" | "check")), ProfileChecking::LegacyRustc) // `cargo fix` and `cargo check` has legacy handling of this profile name - (Some(name @ "test"), ProfileChecking::LegacyTestOnly) => return Ok(InternedString::new(name)), + | (Some(name @ "test"), ProfileChecking::LegacyTestOnly) => { + if self._is_present("release") { + config.shell().warn( + "the `--release` flag should not be specified with the `--profile` flag\n\ + The `--release` flag will be ignored.\n\ + This was historically accepted, but will become an error \ + in a future release." + )?; + } + return Ok(InternedString::new(name)); + } _ => {} } - if specified_profile.is_some() && !config.cli_unstable().unstable_options { - bail!("usage of `--profile` requires `-Z unstable-options`"); - } - let conflict = |flag: &str, equiv: &str, specified: &str| -> anyhow::Error { anyhow::format_err!( "conflicting usage of --profile={} and --{flag}\n\ diff -Nru cargo-0.57.0+ubuntu/src/cargo/util/lev_distance.rs cargo-0.58.0/src/cargo/util/lev_distance.rs --- cargo-0.57.0+ubuntu/src/cargo/util/lev_distance.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/util/lev_distance.rs 2021-10-21 14:30:11.000000000 +0000 @@ -1,14 +1,15 @@ use std::cmp; pub fn lev_distance(me: &str, t: &str) -> usize { + let t_len = t.chars().count(); if me.is_empty() { - return t.chars().count(); + return t_len; } if t.is_empty() { return me.chars().count(); } - let mut dcol = (0..=t.len()).collect::>(); + let mut dcol = (0..=t_len).collect::>(); let mut t_last = 0; for (i, sc) in me.chars().enumerate() { diff -Nru cargo-0.57.0+ubuntu/src/cargo/util/rustc.rs cargo-0.58.0/src/cargo/util/rustc.rs --- cargo-0.57.0+ubuntu/src/cargo/util/rustc.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/util/rustc.rs 2021-10-21 14:30:11.000000000 +0000 @@ -135,8 +135,8 @@ /// for no-op builds, we cache it here, based on compiler's mtime and rustup's /// current toolchain. /// -/// https://github.com/rust-lang/cargo/issues/5315 -/// https://github.com/rust-lang/rust/issues/49761 +/// +/// #[derive(Debug)] struct Cache { cache_location: Option, diff -Nru cargo-0.57.0+ubuntu/src/cargo/util/semver_ext.rs cargo-0.58.0/src/cargo/util/semver_ext.rs --- cargo-0.57.0+ubuntu/src/cargo/util/semver_ext.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/util/semver_ext.rs 2021-10-21 14:30:11.000000000 +0000 @@ -5,6 +5,8 @@ pub enum OptVersionReq { Any, Req(VersionReq), + /// The exact locked version and the original version requirement. + Locked(Version, VersionReq), } pub trait VersionExt { @@ -49,6 +51,30 @@ cmp.op == Op::Exact && cmp.minor.is_some() && cmp.patch.is_some() } } + OptVersionReq::Locked(..) => true, + } + } + + pub fn lock_to(&mut self, version: &Version) { + assert!(self.matches(version), "cannot lock {} to {}", self, version); + use OptVersionReq::*; + let version = version.clone(); + *self = match self { + Any => Locked(version, VersionReq::STAR), + Req(req) => Locked(version, req.clone()), + Locked(_, req) => Locked(version, req.clone()), + }; + } + + pub fn is_locked(&self) -> bool { + matches!(self, OptVersionReq::Locked(..)) + } + + /// Gets the version to which this req is locked, if any. + pub fn locked_version(&self) -> Option<&Version> { + match self { + OptVersionReq::Locked(version, _) => Some(version), + _ => None, } } @@ -56,15 +82,22 @@ match self { OptVersionReq::Any => true, OptVersionReq::Req(req) => req.matches(version), + OptVersionReq::Locked(v, _) => { + v.major == version.major + && v.minor == version.minor + && v.patch == version.patch + && v.pre == version.pre + } } } } impl Display for OptVersionReq { - fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - OptVersionReq::Any => formatter.write_str("*"), - OptVersionReq::Req(req) => Display::fmt(req, formatter), + OptVersionReq::Any => f.write_str("*"), + OptVersionReq::Req(req) => Display::fmt(req, f), + OptVersionReq::Locked(_, req) => Display::fmt(req, f), } } } @@ -74,3 +107,40 @@ OptVersionReq::Req(req) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn locked_has_the_same_with_exact() { + fn test_versions(target_ver: &str, vers: &[&str]) { + let ver = Version::parse(target_ver).unwrap(); + let exact = OptVersionReq::exact(&ver); + let mut locked = exact.clone(); + locked.lock_to(&ver); + for v in vers { + let v = Version::parse(v).unwrap(); + assert_eq!(exact.matches(&v), locked.matches(&v)); + } + } + + test_versions( + "1.0.0", + &["1.0.0", "1.0.1", "0.9.9", "0.10.0", "0.1.0", "1.0.0-pre"], + ); + test_versions("0.9.0", &["0.9.0", "0.9.1", "1.9.0", "0.0.9", "0.9.0-pre"]); + test_versions("0.0.2", &["0.0.2", "0.0.1", "0.0.3", "0.0.2-pre"]); + test_versions( + "0.1.0-beta2.a", + &[ + "0.1.0-beta2.a", + "0.9.1", + "0.1.0", + "0.1.1-beta2.a", + "0.1.0-beta2", + ], + ); + test_versions("0.1.0+meta", &["0.1.0", "0.1.0+meta", "0.1.0+any"]); + } +} diff -Nru cargo-0.57.0+ubuntu/src/cargo/util/toml/mod.rs cargo-0.58.0/src/cargo/util/toml/mod.rs --- cargo-0.57.0+ubuntu/src/cargo/util/toml/mod.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/cargo/util/toml/mod.rs 2021-10-21 14:30:11.000000000 +0000 @@ -150,50 +150,10 @@ /// The purpose of this wrapper is to detect invalid TOML which was previously /// accepted and display a warning to the user in that case. The `file` and `config` /// parameters are only used by this fallback path. -pub fn parse(toml: &str, file: &Path, config: &Config) -> CargoResult { - let first_error = match toml.parse() { - Ok(ret) => return Ok(ret), - Err(e) => e, - }; - - let mut second_parser = toml::de::Deserializer::new(toml); - second_parser.set_require_newline_after_table(false); - if let Ok(ret) = toml::Value::deserialize(&mut second_parser) { - let msg = format!( - "\ -TOML file found which contains invalid syntax and will soon not parse -at `{}`. - -The TOML spec requires newlines after table definitions (e.g., `[a] b = 1` is -invalid), but this file has a table header which does not have a newline after -it. A newline needs to be added and this warning will soon become a hard error -in the future.", - file.display() - ); - config.shell().warn(&msg)?; - return Ok(ret); - } - - let mut third_parser = toml::de::Deserializer::new(toml); - third_parser.set_allow_duplicate_after_longer_table(true); - if let Ok(ret) = toml::Value::deserialize(&mut third_parser) { - let msg = format!( - "\ -TOML file found which contains invalid syntax and will soon not parse -at `{}`. - -The TOML spec requires that each table header is defined at most once, but -historical versions of Cargo have erroneously accepted this file. The table -definitions will need to be merged together with one table header to proceed, -and this will become a hard error in the future.", - file.display() - ); - config.shell().warn(&msg)?; - return Ok(ret); - } - - let first_error = anyhow::Error::from(first_error); - Err(first_error.context("could not parse input as TOML")) +pub fn parse(toml: &str, _file: &Path, _config: &Config) -> CargoResult { + // At the moment, no compatibility checks are needed. + toml.parse() + .map_err(|e| anyhow::Error::from(e).context("could not parse input as TOML")) } type TomlLibTarget = TomlTarget; @@ -642,6 +602,7 @@ | "rust" | "rustc" | "rustdoc" + | "target" | "tmp" | "uninstall" ) || lower_name.starts_with("cargo") @@ -1438,8 +1399,12 @@ ); if project.license_file.is_some() && project.license.is_some() { manifest.warnings_mut().add_warning( - "only one of `license` or \ - `license-file` is necessary" + "only one of `license` or `license-file` is necessary\n\ + `license` should be used if the package license can be expressed \ + with a standard SPDX expression.\n\ + `license-file` should be used if the package uses a non-standard license.\n\ + See https://doc.rust-lang.org/cargo/reference/manifest.html#the-license-and-license-file-fields \ + for more information." .to_string(), ); } @@ -1589,16 +1554,15 @@ } let mut dep = replacement.to_dependency(spec.name().as_str(), cx, None)?; - { - let version = spec.version().ok_or_else(|| { - anyhow!( - "replacements must specify a version \ - to replace, but `{}` does not", - spec - ) - })?; - dep.set_version_req(VersionReq::exact(version)); - } + let version = spec.version().ok_or_else(|| { + anyhow!( + "replacements must specify a version \ + to replace, but `{}` does not", + spec + ) + })?; + dep.set_version_req(VersionReq::exact(version)) + .lock_version(version); replace.push((spec, dep)); } Ok(replace) diff -Nru cargo-0.57.0+ubuntu/src/doc/contrib/src/process/working-on-cargo.md cargo-0.58.0/src/doc/contrib/src/process/working-on-cargo.md --- cargo-0.57.0+ubuntu/src/doc/contrib/src/process/working-on-cargo.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/contrib/src/process/working-on-cargo.md 2021-10-21 14:30:11.000000000 +0000 @@ -83,7 +83,6 @@ * All code changes are expected to comply with the formatting suggested by `rustfmt`. You can use `rustup component add rustfmt` to install `rustfmt` and use `cargo fmt` to automatically format your code. -* [Commit as you go][githelp]. * Include tests that cover all non-trivial code. See the [Testing chapter] for more about writing and running tests. * All code should be warning-free. This is checked during tests. @@ -136,7 +135,6 @@ [git]: https://git-scm.com/ [GitHub]: https://github.com/ [how-to-clone]: https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository -[githelp]: https://dont-be-afraid-to-commit.readthedocs.io/en/latest/git/commandlinegit.html [Testing chapter]: ../tests/index.md [GitHub's keywords]: https://docs.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue [rust-highfive]: https://github.com/rust-highfive diff -Nru cargo-0.57.0+ubuntu/src/doc/contrib/src/tests/writing.md cargo-0.58.0/src/doc/contrib/src/tests/writing.md --- cargo-0.57.0+ubuntu/src/doc/contrib/src/tests/writing.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/contrib/src/tests/writing.md 2021-10-21 14:30:11.000000000 +0000 @@ -123,6 +123,34 @@ If you need to test git dependencies, see [`support::git`] to create a git dependency. +## Debugging tests + +In some cases, you may need to dig into a test that is not working as you +expect, or you just generally want to experiment within the sandbox +environment. The general process is: + +1. Build the sandbox for the test you want to investigate. For example: + + `cargo test --test testsuite -- features2::inactivate_targets`. +2. In another terminal, head into the sandbox directory to inspect the files and run `cargo` directly. + 1. The sandbox directories start with `t0` for the first test. + + `cd target/tmp/cit/t0` + 2. Set up the environment so that the sandbox configuration takes effect: + + `export CARGO_HOME=$(pwd)/home/.cargo` + 3. Most tests create a `foo` project, so head into that: + + `cd foo` +3. Run whatever cargo command you want. See [Running Cargo] for more details + on running the correct `cargo` process. Some examples: + + * `/path/to/my/cargo/target/debug/cargo check` + * Using a debugger like `lldb` or `gdb`: + 1. `lldb /path/to/my/cargo/target/debug/cargo` + 2. Set a breakpoint, for example: `b generate_targets` + 3. Run with arguments: `r check` + [`testsuite`]: https://github.com/rust-lang/cargo/tree/master/tests/testsuite/ [`ProjectBuilder`]: https://github.com/rust-lang/cargo/blob/e4b65bdc80f2a293447f2f6a808fa7c84bf9a357/crates/cargo-test-support/src/lib.rs#L225-L231 [`Execs`]: https://github.com/rust-lang/cargo/blob/e4b65bdc80f2a293447f2f6a808fa7c84bf9a357/crates/cargo-test-support/src/lib.rs#L558-L579 @@ -130,3 +158,4 @@ [`support::compare`]: https://github.com/rust-lang/cargo/blob/master/crates/cargo-test-support/src/compare.rs [`support::registry::Package`]: https://github.com/rust-lang/cargo/blob/e4b65bdc80f2a293447f2f6a808fa7c84bf9a357/crates/cargo-test-support/src/registry.rs#L73-L149 [`support::git`]: https://github.com/rust-lang/cargo/blob/master/crates/cargo-test-support/src/git.rs +[Running Cargo]: ../process/working-on-cargo.md#running-cargo diff -Nru cargo-0.57.0+ubuntu/src/doc/man/cargo-bench.md cargo-0.58.0/src/doc/man/cargo-bench.md --- cargo-0.57.0+ubuntu/src/doc/man/cargo-bench.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/cargo-bench.md 2021-10-21 14:30:11.000000000 +0000 @@ -46,6 +46,14 @@ > running benchmarks on the stable channel, such as > [Criterion](https://crates.io/crates/criterion). +By default, `cargo bench` uses the [`bench` profile], which enables +optimizations and disables debugging information. If you need to debug a +benchmark, you can use the `--profile=dev` command-line option to switch to +the dev profile. You can then run the debug-enabled benchmark within a +debugger. + +[`bench` profile]: ../reference/profiles.html#bench + ## OPTIONS ### Benchmark Options @@ -83,6 +91,8 @@ {{> options-target-triple }} +{{> options-profile }} + {{> options-ignore-rust-version }} {{/options}} @@ -129,23 +139,6 @@ {{> options-jobs }} {{/options}} -## PROFILES - -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See -[the reference](../reference/profiles.html) -for more details. - -Benchmarks are always built with the `bench` profile. Binary and lib targets -are built separately as benchmarks with the `bench` profile. Library targets -are built with the `release` profiles when linked to binaries and benchmarks. -Dependencies use the `release` profile. - -If you need a debug build of a benchmark, try building it with -{{man "cargo-build" 1}} which will use the `test` profile which is by default -unoptimized and includes debug information. You can then run the debug-enabled -benchmark manually. - {{> section-environment }} {{> section-exit-status }} diff -Nru cargo-0.57.0+ubuntu/src/doc/man/cargo-build.md cargo-0.58.0/src/doc/man/cargo-build.md --- cargo-0.57.0+ubuntu/src/doc/man/cargo-build.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/cargo-build.md 2021-10-21 14:30:11.000000000 +0000 @@ -35,6 +35,8 @@ {{> options-release }} +{{> options-profile }} + {{> options-ignore-rust-version }} {{/options}} @@ -89,8 +91,6 @@ {{> options-jobs }} {{/options}} -{{> section-profiles }} - {{> section-environment }} {{> section-exit-status }} diff -Nru cargo-0.57.0+ubuntu/src/doc/man/cargo-check.md cargo-0.58.0/src/doc/man/cargo-check.md --- cargo-0.57.0+ubuntu/src/doc/man/cargo-check.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/cargo-check.md 2021-10-21 14:30:11.000000000 +0000 @@ -40,7 +40,7 @@ {{> options-release }} -{{> options-profile }} +{{> options-profile-legacy-check }} {{> options-ignore-rust-version }} @@ -76,8 +76,6 @@ {{> options-jobs }} {{/options}} -{{> section-profiles }} - {{> section-environment }} {{> section-exit-status }} diff -Nru cargo-0.57.0+ubuntu/src/doc/man/cargo-clean.md cargo-0.58.0/src/doc/man/cargo-clean.md --- cargo-0.57.0+ubuntu/src/doc/man/cargo-clean.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/cargo-clean.md 2021-10-21 14:30:11.000000000 +0000 @@ -40,7 +40,11 @@ {{/option}} {{#option "`--release`" }} -Clean all artifacts that were built with the `release` or `bench` profiles. +Remove all artifacts in the `release` directory. +{{/option}} + +{{#option "`--profile` _name_" }} +Remove all artifacts in the directory with the given profile name. {{/option}} {{> options-target-dir }} diff -Nru cargo-0.57.0+ubuntu/src/doc/man/cargo-doc.md cargo-0.58.0/src/doc/man/cargo-doc.md --- cargo-0.57.0+ubuntu/src/doc/man/cargo-doc.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/cargo-doc.md 2021-10-21 14:30:11.000000000 +0000 @@ -74,6 +74,8 @@ {{> options-release }} +{{> options-profile }} + {{> options-ignore-rust-version }} {{/options}} @@ -108,8 +110,6 @@ {{> options-jobs }} {{/options}} -{{> section-profiles }} - {{> section-environment }} {{> section-exit-status }} diff -Nru cargo-0.57.0+ubuntu/src/doc/man/cargo-fix.md cargo-0.58.0/src/doc/man/cargo-fix.md --- cargo-0.57.0+ubuntu/src/doc/man/cargo-fix.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/cargo-fix.md 2021-10-21 14:30:11.000000000 +0000 @@ -120,7 +120,7 @@ {{> options-release }} -{{> options-profile }} +{{> options-profile-legacy-check }} {{> options-ignore-rust-version }} @@ -156,8 +156,6 @@ {{> options-jobs }} {{/options}} -{{> section-profiles }} - {{> section-environment }} {{> section-exit-status }} diff -Nru cargo-0.57.0+ubuntu/src/doc/man/cargo-install.md cargo-0.58.0/src/doc/man/cargo-install.md --- cargo-0.57.0+ubuntu/src/doc/man/cargo-install.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/cargo-install.md 2021-10-21 14:30:11.000000000 +0000 @@ -42,7 +42,7 @@ - The package version and source. - The set of binary names installed. - The chosen features. -- The release mode (`--debug`). +- The profile (`--profile`). - The target (`--target`). Installing with `--path` will always build and install, unless there are @@ -162,8 +162,11 @@ {{#option "`--debug`" }} Build with the `dev` profile instead the `release` profile. +See also the `--profile` option for choosing a specific profile by name. {{/option}} +{{> options-profile }} + {{/options}} ### Manifest Options diff -Nru cargo-0.57.0+ubuntu/src/doc/man/cargo-package.md cargo-0.58.0/src/doc/man/cargo-package.md --- cargo-0.57.0+ubuntu/src/doc/man/cargo-package.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/cargo-package.md 2021-10-21 14:30:11.000000000 +0000 @@ -43,6 +43,22 @@ See [the reference](../reference/publishing.html) for more details about packaging and publishing. +### .cargo_vcs_info.json format + +Will generate a `.cargo_vcs_info.json` in the following format + +```javascript +{ + "git": { + "sha1": "aac20b6e7e543e6dd4118b246c77225e3a3a1302" + }, + "path_in_vcs": "" +} +``` + +`path_in_vcs` will be set to a repo-relative path for packages +in subdirectories of the version control repository. + ## OPTIONS ### Package Options diff -Nru cargo-0.57.0+ubuntu/src/doc/man/cargo-run.md cargo-0.58.0/src/doc/man/cargo-run.md --- cargo-0.57.0+ubuntu/src/doc/man/cargo-run.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/cargo-run.md 2021-10-21 14:30:11.000000000 +0000 @@ -50,6 +50,8 @@ {{> options-release }} +{{> options-profile }} + {{> options-ignore-rust-version }} {{/options}} @@ -88,8 +90,6 @@ {{> options-jobs }} {{/options}} -{{> section-profiles }} - {{> section-environment }} {{> section-exit-status }} diff -Nru cargo-0.57.0+ubuntu/src/doc/man/cargo-rustc.md cargo-0.58.0/src/doc/man/cargo-rustc.md --- cargo-0.57.0+ubuntu/src/doc/man/cargo-rustc.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/cargo-rustc.md 2021-10-21 14:30:11.000000000 +0000 @@ -47,6 +47,23 @@ {{> options-release }} +{{#option "`--profile` _name_" }} +Build with the given profile. + +The `rustc` subcommand will treat the following named profiles with special behaviors: + +* `check` — Builds in the same way as the {{man "cargo-check" 1}} command with + the `dev` profile. +* `test` — Builds in the same way as the {{man "cargo-test" 1}} command, + enabling building in test mode which will enable tests and enable the `test` + cfg option. See [rustc + tests](https://doc.rust-lang.org/rustc/tests/index.html) for more detail. +* `bench` — Builds in the same was as the {{man "cargo-bench" 1}} command, + similar to the `test` profile. + +See the [the reference](../reference/profiles.html) for more details on profiles. +{{/option}} + {{> options-ignore-rust-version }} {{/options}} @@ -85,8 +102,6 @@ {{> options-jobs }} {{/options}} -{{> section-profiles }} - {{> section-environment }} {{> section-exit-status }} diff -Nru cargo-0.57.0+ubuntu/src/doc/man/cargo-rustdoc.md cargo-0.58.0/src/doc/man/cargo-rustdoc.md --- cargo-0.57.0+ubuntu/src/doc/man/cargo-rustdoc.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/cargo-rustdoc.md 2021-10-21 14:30:11.000000000 +0000 @@ -62,6 +62,8 @@ {{> options-release }} +{{> options-profile }} + {{> options-ignore-rust-version }} {{/options}} @@ -96,8 +98,6 @@ {{> options-jobs }} {{/options}} -{{> section-profiles }} - {{> section-environment }} {{> section-exit-status }} diff -Nru cargo-0.57.0+ubuntu/src/doc/man/cargo-test.md cargo-0.58.0/src/doc/man/cargo-test.md --- cargo-0.57.0+ubuntu/src/doc/man/cargo-test.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/cargo-test.md 2021-10-21 14:30:11.000000000 +0000 @@ -102,6 +102,8 @@ {{> options-release }} +{{> options-profile }} + {{> options-ignore-rust-version }} {{/options}} @@ -154,16 +156,6 @@ {{/options}} -{{> section-profiles }} - -Unit tests are separate executable artifacts which use the `test`/`bench` -profiles. Example targets are built the same as with `cargo build` (using the -`dev`/`release` profiles) unless you are building them with the test harness -(by setting `test = true` in the manifest or using the `--example` flag) in -which case they use the `test`/`bench` profiles. Library targets are built -with the `dev`/`release` profiles when linked to an integration test, binary, -or doctest. - {{> section-environment }} {{> section-exit-status }} diff -Nru cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-bench.txt cargo-0.58.0/src/doc/man/generated_txt/cargo-bench.txt --- cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-bench.txt 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/generated_txt/cargo-bench.txt 2021-10-21 14:30:11.000000000 +0000 @@ -41,6 +41,13 @@ benchmarks on the stable channel, such as Criterion . + By default, cargo bench uses the bench profile + , which + enables optimizations and disables debugging information. If you need to + debug a benchmark, you can use the --profile=dev command-line option to + switch to the dev profile. You can then run the debug-enabled benchmark + within a debugger. + OPTIONS Benchmark Options --no-run @@ -202,6 +209,11 @@ documentation for more details. + --profile name + Benchmark with the given profile. See the the reference + for more + details on profiles. + --ignore-rust-version Benchmark the target even if the selected Rust compiler is older than the required Rust version as configured in the project's @@ -329,22 +341,6 @@ . Defaults to the number of CPUs. -PROFILES - Profiles may be used to configure compiler options such as optimization - levels and debug settings. See the reference - for more - details. - - Benchmarks are always built with the bench profile. Binary and lib - targets are built separately as benchmarks with the bench profile. - Library targets are built with the release profiles when linked to - binaries and benchmarks. Dependencies use the release profile. - - If you need a debug build of a benchmark, try building it with - cargo-build(1) which will use the test profile which is by default - unoptimized and includes debug information. You can then run the - debug-enabled benchmark manually. - ENVIRONMENT See the reference diff -Nru cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-build.txt cargo-0.58.0/src/doc/man/generated_txt/cargo-build.txt --- cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-build.txt 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/generated_txt/cargo-build.txt 2021-10-21 14:30:11.000000000 +0000 @@ -143,8 +143,13 @@ documentation for more details. --release - Build optimized artifacts with the release profile. See the PROFILES - section for details on how this affects profile selection. + Build optimized artifacts with the release profile. See also the + --profile option for choosing a specific profile by name. + + --profile name + Build with the given profile. See the the reference + for more + details on profiles. --ignore-rust-version Build the target even if the selected Rust compiler is older than @@ -282,28 +287,6 @@ . Defaults to the number of CPUs. -PROFILES - Profiles may be used to configure compiler options such as optimization - levels and debug settings. See the reference - for more - details. - - Profile selection depends on the target and crate being built. By - default the dev or test profiles are used. If the --release flag is - given, then the release or bench profiles are used. - - +----------------------------------------+-------------+--------------+ - | Target | Default | --release | - | | Profile | Profile | - +----------------------------------------+-------------+--------------+ - | lib, bin, example | dev | release | - +----------------------------------------+-------------+--------------+ - | test, bench, or any target in "test" | test | bench | - | or "bench" mode | | | - +----------------------------------------+-------------+--------------+ - - Dependencies use the dev/release profiles. - ENVIRONMENT See the reference diff -Nru cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-check.txt cargo-0.58.0/src/doc/man/generated_txt/cargo-check.txt --- cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-check.txt 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/generated_txt/cargo-check.txt 2021-10-21 14:30:11.000000000 +0000 @@ -149,14 +149,20 @@ documentation for more details. --release - Check optimized artifacts with the release profile. See the PROFILES - section for details on how this affects profile selection. + Check optimized artifacts with the release profile. See also the + --profile option for choosing a specific profile by name. --profile name - Changes check behavior. Currently only test is supported, which will - check with the #[cfg(test)] attribute enabled. This is useful to - have it check unit tests which are usually excluded via the cfg - attribute. This does not change the actual profile used. + Check with the given profile. + + As a special case, specifying the test profile will also enable + checking in test mode which will enable checking tests and enable + the test cfg option. See rustc tests + for more detail. + + See the the reference + for more + details on profiles. --ignore-rust-version Check the target even if the selected Rust compiler is older than @@ -275,28 +281,6 @@ . Defaults to the number of CPUs. -PROFILES - Profiles may be used to configure compiler options such as optimization - levels and debug settings. See the reference - for more - details. - - Profile selection depends on the target and crate being built. By - default the dev or test profiles are used. If the --release flag is - given, then the release or bench profiles are used. - - +----------------------------------------+-------------+--------------+ - | Target | Default | --release | - | | Profile | Profile | - +----------------------------------------+-------------+--------------+ - | lib, bin, example | dev | release | - +----------------------------------------+-------------+--------------+ - | test, bench, or any target in "test" | test | bench | - | or "bench" mode | | | - +----------------------------------------+-------------+--------------+ - - Dependencies use the dev/release profiles. - ENVIRONMENT See the reference diff -Nru cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-clean.txt cargo-0.58.0/src/doc/man/generated_txt/cargo-clean.txt --- cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-clean.txt 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/generated_txt/cargo-clean.txt 2021-10-21 14:30:11.000000000 +0000 @@ -27,8 +27,10 @@ in the target directory. --release - Clean all artifacts that were built with the release or bench - profiles. + Remove all artifacts in the release directory. + + --profile name + Remove all artifacts in the directory with the given profile name. --target-dir directory Directory for all generated artifacts and intermediate files. May diff -Nru cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-doc.txt cargo-0.58.0/src/doc/man/generated_txt/cargo-doc.txt --- cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-doc.txt 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/generated_txt/cargo-doc.txt 2021-10-21 14:30:11.000000000 +0000 @@ -127,8 +127,13 @@ documentation for more details. --release - Document optimized artifacts with the release profile. See the - PROFILES section for details on how this affects profile selection. + Document optimized artifacts with the release profile. See also the + --profile option for choosing a specific profile by name. + + --profile name + Document with the given profile. See the the reference + for more + details on profiles. --ignore-rust-version Document the target even if the selected Rust compiler is older than @@ -247,28 +252,6 @@ . Defaults to the number of CPUs. -PROFILES - Profiles may be used to configure compiler options such as optimization - levels and debug settings. See the reference - for more - details. - - Profile selection depends on the target and crate being built. By - default the dev or test profiles are used. If the --release flag is - given, then the release or bench profiles are used. - - +----------------------------------------+-------------+--------------+ - | Target | Default | --release | - | | Profile | Profile | - +----------------------------------------+-------------+--------------+ - | lib, bin, example | dev | release | - +----------------------------------------+-------------+--------------+ - | test, bench, or any target in "test" | test | bench | - | or "bench" mode | | | - +----------------------------------------+-------------+--------------+ - - Dependencies use the dev/release profiles. - ENVIRONMENT See the reference diff -Nru cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-fix.txt cargo-0.58.0/src/doc/man/generated_txt/cargo-fix.txt --- cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-fix.txt 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/generated_txt/cargo-fix.txt 2021-10-21 14:30:11.000000000 +0000 @@ -222,14 +222,20 @@ documentation for more details. --release - Fix optimized artifacts with the release profile. See the PROFILES - section for details on how this affects profile selection. + Fix optimized artifacts with the release profile. See also the + --profile option for choosing a specific profile by name. --profile name - Changes fix behavior. Currently only test is supported, which will - fix with the #[cfg(test)] attribute enabled. This is useful to have - it fix unit tests which are usually excluded via the cfg attribute. - This does not change the actual profile used. + Fix with the given profile. + + As a special case, specifying the test profile will also enable + checking in test mode which will enable checking tests and enable + the test cfg option. See rustc tests + for more detail. + + See the the reference + for more + details on profiles. --ignore-rust-version Fix the target even if the selected Rust compiler is older than the @@ -348,28 +354,6 @@ . Defaults to the number of CPUs. -PROFILES - Profiles may be used to configure compiler options such as optimization - levels and debug settings. See the reference - for more - details. - - Profile selection depends on the target and crate being built. By - default the dev or test profiles are used. If the --release flag is - given, then the release or bench profiles are used. - - +----------------------------------------+-------------+--------------+ - | Target | Default | --release | - | | Profile | Profile | - +----------------------------------------+-------------+--------------+ - | lib, bin, example | dev | release | - +----------------------------------------+-------------+--------------+ - | test, bench, or any target in "test" | test | bench | - | or "bench" mode | | | - +----------------------------------------+-------------+--------------+ - - Dependencies use the dev/release profiles. - ENVIRONMENT See the reference diff -Nru cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-install.txt cargo-0.58.0/src/doc/man/generated_txt/cargo-install.txt --- cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-install.txt 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/generated_txt/cargo-install.txt 2021-10-21 14:30:11.000000000 +0000 @@ -51,7 +51,7 @@ o The chosen features. - o The release mode (--debug). + o The profile (--profile). o The target (--target). @@ -197,7 +197,13 @@ workspace of the local crate unless --target-dir is specified. --debug - Build with the dev profile instead the release profile. + Build with the dev profile instead the release profile. See also the + --profile option for choosing a specific profile by name. + + --profile name + Install with the given profile. See the the reference + for more + details on profiles. Manifest Options --frozen, --locked diff -Nru cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-package.txt cargo-0.58.0/src/doc/man/generated_txt/cargo-package.txt --- cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-package.txt 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/generated_txt/cargo-package.txt 2021-10-21 14:30:11.000000000 +0000 @@ -45,6 +45,19 @@ for more details about packaging and publishing. + .cargo_vcs_info.json format + Will generate a .cargo_vcs_info.json in the following format + + { + "git": { + "sha1": "aac20b6e7e543e6dd4118b246c77225e3a3a1302" + }, + "path_in_vcs": "" + } + + path_in_vcs will be set to a repo-relative path for packages in + subdirectories of the version control repository. + OPTIONS Package Options -l, --list diff -Nru cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-run.txt cargo-0.58.0/src/doc/man/generated_txt/cargo-run.txt --- cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-run.txt 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/generated_txt/cargo-run.txt 2021-10-21 14:30:11.000000000 +0000 @@ -72,8 +72,13 @@ documentation for more details. --release - Run optimized artifacts with the release profile. See the PROFILES - section for details on how this affects profile selection. + Run optimized artifacts with the release profile. See also the + --profile option for choosing a specific profile by name. + + --profile name + Run with the given profile. See the the reference + for more + details on profiles. --ignore-rust-version Run the target even if the selected Rust compiler is older than the @@ -192,28 +197,6 @@ . Defaults to the number of CPUs. -PROFILES - Profiles may be used to configure compiler options such as optimization - levels and debug settings. See the reference - for more - details. - - Profile selection depends on the target and crate being built. By - default the dev or test profiles are used. If the --release flag is - given, then the release or bench profiles are used. - - +----------------------------------------+-------------+--------------+ - | Target | Default | --release | - | | Profile | Profile | - +----------------------------------------+-------------+--------------+ - | lib, bin, example | dev | release | - +----------------------------------------+-------------+--------------+ - | test, bench, or any target in "test" | test | bench | - | or "bench" mode | | | - +----------------------------------------+-------------+--------------+ - - Dependencies use the dev/release profiles. - ENVIRONMENT See the reference diff -Nru cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-rustc.txt cargo-0.58.0/src/doc/man/generated_txt/cargo-rustc.txt --- cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-rustc.txt 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/generated_txt/cargo-rustc.txt 2021-10-21 14:30:11.000000000 +0000 @@ -134,8 +134,30 @@ documentation for more details. --release - Build optimized artifacts with the release profile. See the PROFILES - section for details on how this affects profile selection. + Build optimized artifacts with the release profile. See also the + --profile option for choosing a specific profile by name. + + --profile name + Build with the given profile. + + The rustc subcommand will treat the following named profiles with + special behaviors: + + o check — Builds in the same way as the cargo-check(1) command + with the dev profile. + + o test — Builds in the same way as the cargo-test(1) command, + enabling building in test mode which will enable tests and enable + the test cfg option. See rustc tests + for more + detail. + + o bench — Builds in the same was as the cargo-bench(1) command, + similar to the test profile. + + See the the reference + for more + details on profiles. --ignore-rust-version Build the target even if the selected Rust compiler is older than @@ -254,28 +276,6 @@ . Defaults to the number of CPUs. -PROFILES - Profiles may be used to configure compiler options such as optimization - levels and debug settings. See the reference - for more - details. - - Profile selection depends on the target and crate being built. By - default the dev or test profiles are used. If the --release flag is - given, then the release or bench profiles are used. - - +----------------------------------------+-------------+--------------+ - | Target | Default | --release | - | | Profile | Profile | - +----------------------------------------+-------------+--------------+ - | lib, bin, example | dev | release | - +----------------------------------------+-------------+--------------+ - | test, bench, or any target in "test" | test | bench | - | or "bench" mode | | | - +----------------------------------------+-------------+--------------+ - - Dependencies use the dev/release profiles. - ENVIRONMENT See the reference diff -Nru cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-rustdoc.txt cargo-0.58.0/src/doc/man/generated_txt/cargo-rustdoc.txt --- cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-rustdoc.txt 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/generated_txt/cargo-rustdoc.txt 2021-10-21 14:30:11.000000000 +0000 @@ -143,8 +143,13 @@ documentation for more details. --release - Document optimized artifacts with the release profile. See the - PROFILES section for details on how this affects profile selection. + Document optimized artifacts with the release profile. See also the + --profile option for choosing a specific profile by name. + + --profile name + Document with the given profile. See the the reference + for more + details on profiles. --ignore-rust-version Document the target even if the selected Rust compiler is older than @@ -263,28 +268,6 @@ . Defaults to the number of CPUs. -PROFILES - Profiles may be used to configure compiler options such as optimization - levels and debug settings. See the reference - for more - details. - - Profile selection depends on the target and crate being built. By - default the dev or test profiles are used. If the --release flag is - given, then the release or bench profiles are used. - - +----------------------------------------+-------------+--------------+ - | Target | Default | --release | - | | Profile | Profile | - +----------------------------------------+-------------+--------------+ - | lib, bin, example | dev | release | - +----------------------------------------+-------------+--------------+ - | test, bench, or any target in "test" | test | bench | - | or "bench" mode | | | - +----------------------------------------+-------------+--------------+ - - Dependencies use the dev/release profiles. - ENVIRONMENT See the reference diff -Nru cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-test.txt cargo-0.58.0/src/doc/man/generated_txt/cargo-test.txt --- cargo-0.57.0+ubuntu/src/doc/man/generated_txt/cargo-test.txt 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/generated_txt/cargo-test.txt 2021-10-21 14:30:11.000000000 +0000 @@ -220,8 +220,13 @@ documentation for more details. --release - Test optimized artifacts with the release profile. See the PROFILES - section for details on how this affects profile selection. + Test optimized artifacts with the release profile. See also the + --profile option for choosing a specific profile by name. + + --profile name + Test with the given profile. See the the reference + for more + details on profiles. --ignore-rust-version Test the target even if the selected Rust compiler is older than the @@ -352,36 +357,6 @@ . Defaults to the number of CPUs. -PROFILES - Profiles may be used to configure compiler options such as optimization - levels and debug settings. See the reference - for more - details. - - Profile selection depends on the target and crate being built. By - default the dev or test profiles are used. If the --release flag is - given, then the release or bench profiles are used. - - +----------------------------------------+-------------+--------------+ - | Target | Default | --release | - | | Profile | Profile | - +----------------------------------------+-------------+--------------+ - | lib, bin, example | dev | release | - +----------------------------------------+-------------+--------------+ - | test, bench, or any target in "test" | test | bench | - | or "bench" mode | | | - +----------------------------------------+-------------+--------------+ - - Dependencies use the dev/release profiles. - - Unit tests are separate executable artifacts which use the test/bench - profiles. Example targets are built the same as with cargo build (using - the dev/release profiles) unless you are building them with the test - harness (by setting test = true in the manifest or using the --example - flag) in which case they use the test/bench profiles. Library targets - are built with the dev/release profiles when linked to an integration - test, binary, or doctest. - ENVIRONMENT See the reference diff -Nru cargo-0.57.0+ubuntu/src/doc/man/includes/options-profile-legacy-check.md cargo-0.58.0/src/doc/man/includes/options-profile-legacy-check.md --- cargo-0.57.0+ubuntu/src/doc/man/includes/options-profile-legacy-check.md 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/src/doc/man/includes/options-profile-legacy-check.md 2021-10-21 14:30:11.000000000 +0000 @@ -0,0 +1,10 @@ +{{#option "`--profile` _name_" }} +{{actionverb}} with the given profile. + +As a special case, specifying the `test` profile will also enable checking in +test mode which will enable checking tests and enable the `test` cfg option. +See [rustc tests](https://doc.rust-lang.org/rustc/tests/index.html) for more +detail. + +See the [the reference](../reference/profiles.html) for more details on profiles. +{{/option}} diff -Nru cargo-0.57.0+ubuntu/src/doc/man/includes/options-profile.md cargo-0.58.0/src/doc/man/includes/options-profile.md --- cargo-0.57.0+ubuntu/src/doc/man/includes/options-profile.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/includes/options-profile.md 2021-10-21 14:30:11.000000000 +0000 @@ -1,7 +1,4 @@ {{#option "`--profile` _name_" }} -Changes {{lower actionverb}} behavior. Currently only `test` is supported, -which will {{lower actionverb}} with the `#[cfg(test)]` attribute enabled. -This is useful to have it {{lower actionverb}} unit tests which are usually -excluded via the `cfg` attribute. This does not change the actual profile -used. +{{actionverb}} with the given profile. +See the [the reference](../reference/profiles.html) for more details on profiles. {{/option}} diff -Nru cargo-0.57.0+ubuntu/src/doc/man/includes/options-release.md cargo-0.58.0/src/doc/man/includes/options-release.md --- cargo-0.57.0+ubuntu/src/doc/man/includes/options-release.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/includes/options-release.md 2021-10-21 14:30:11.000000000 +0000 @@ -1,5 +1,4 @@ {{#option "`--release`"}} -{{actionverb}} optimized artifacts with the `release` profile. See the -[PROFILES](#profiles) section for details on how this affects profile -selection. +{{actionverb}} optimized artifacts with the `release` profile. +See also the `--profile` option for choosing a specific profile by name. {{/option}} diff -Nru cargo-0.57.0+ubuntu/src/doc/man/includes/section-profiles.md cargo-0.58.0/src/doc/man/includes/section-profiles.md --- cargo-0.57.0+ubuntu/src/doc/man/includes/section-profiles.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/man/includes/section-profiles.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -## PROFILES - -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See [the reference](../reference/profiles.html) for more -details. - -Profile selection depends on the target and crate being built. By default the -`dev` or `test` profiles are used. If the `--release` flag is given, then the -`release` or `bench` profiles are used. - -Target | Default Profile | `--release` Profile --------|-----------------|--------------------- -lib, bin, example | `dev` | `release` -test, bench, or any target in "test" or "bench" mode | `test` | `bench` - -Dependencies use the `dev`/`release` profiles. diff -Nru cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-bench.md cargo-0.58.0/src/doc/src/commands/cargo-bench.md --- cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-bench.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/commands/cargo-bench.md 2021-10-21 14:30:11.000000000 +0000 @@ -46,6 +46,14 @@ > running benchmarks on the stable channel, such as > [Criterion](https://crates.io/crates/criterion). +By default, `cargo bench` uses the [`bench` profile], which enables +optimizations and disables debugging information. If you need to debug a +benchmark, you can use the `--profile=dev` command-line option to switch to +the dev profile. You can then run the debug-enabled benchmark within a +debugger. + +[`bench` profile]: ../reference/profiles.html#bench + ## OPTIONS ### Benchmark Options @@ -245,6 +253,12 @@ +
--profile name
+
Benchmark with the given profile. +See the the reference for more details on profiles.
+ + +
--ignore-rust-version
Benchmark the target even if the selected Rust compiler is older than the required Rust version as configured in the project's rust-version field.
@@ -402,23 +416,6 @@ -## PROFILES - -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See -[the reference](../reference/profiles.html) -for more details. - -Benchmarks are always built with the `bench` profile. Binary and lib targets -are built separately as benchmarks with the `bench` profile. Library targets -are built with the `release` profiles when linked to binaries and benchmarks. -Dependencies use the `release` profile. - -If you need a debug build of a benchmark, try building it with -[cargo-build(1)](cargo-build.html) which will use the `test` profile which is by default -unoptimized and includes debug information. You can then run the debug-enabled -benchmark manually. - ## ENVIRONMENT See [the reference](../reference/environment-variables.html) for diff -Nru cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-build.md cargo-0.58.0/src/doc/src/commands/cargo-build.md --- cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-build.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/commands/cargo-build.md 2021-10-21 14:30:11.000000000 +0000 @@ -182,9 +182,14 @@
--release
-
Build optimized artifacts with the release profile. See the -PROFILES section for details on how this affects profile -selection.
+
Build optimized artifacts with the release profile. +See also the --profile option for choosing a specific profile by name.
+ + + +
--profile name
+
Build with the given profile. +See the the reference for more details on profiles.
@@ -351,24 +356,6 @@ -## PROFILES - -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See [the reference](../reference/profiles.html) for more -details. - -Profile selection depends on the target and crate being built. By default the -`dev` or `test` profiles are used. If the `--release` flag is given, then the -`release` or `bench` profiles are used. - -Target | Default Profile | `--release` Profile --------|-----------------|--------------------- -lib, bin, example | `dev` | `release` -test, bench, or any target in "test" or "bench" mode | `test` | `bench` - -Dependencies use the `dev`/`release` profiles. - - ## ENVIRONMENT See [the reference](../reference/environment-variables.html) for diff -Nru cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-check.md cargo-0.58.0/src/doc/src/commands/cargo-check.md --- cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-check.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/commands/cargo-check.md 2021-10-21 14:30:11.000000000 +0000 @@ -187,18 +187,18 @@
--release
-
Check optimized artifacts with the release profile. See the -PROFILES section for details on how this affects profile -selection.
+
Check optimized artifacts with the release profile. +See also the --profile option for choosing a specific profile by name.
--profile name
-
Changes check behavior. Currently only test is supported, -which will check with the #[cfg(test)] attribute enabled. -This is useful to have it check unit tests which are usually -excluded via the cfg attribute. This does not change the actual profile -used.
+
Check with the given profile.

+

As a special case, specifying the test profile will also enable checking in +test mode which will enable checking tests and enable the test cfg option. +See rustc tests for more +detail.

+

See the the reference for more details on profiles.

@@ -347,24 +347,6 @@ -## PROFILES - -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See [the reference](../reference/profiles.html) for more -details. - -Profile selection depends on the target and crate being built. By default the -`dev` or `test` profiles are used. If the `--release` flag is given, then the -`release` or `bench` profiles are used. - -Target | Default Profile | `--release` Profile --------|-----------------|--------------------- -lib, bin, example | `dev` | `release` -test, bench, or any target in "test" or "bench" mode | `test` | `bench` - -Dependencies use the `dev`/`release` profiles. - - ## ENVIRONMENT See [the reference](../reference/environment-variables.html) for diff -Nru cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-clean.md cargo-0.58.0/src/doc/src/commands/cargo-clean.md --- cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-clean.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/commands/cargo-clean.md 2021-10-21 14:30:11.000000000 +0000 @@ -41,7 +41,11 @@
--release
-
Clean all artifacts that were built with the release or bench profiles.
+
Remove all artifacts in the release directory.
+ + +
--profile name
+
Remove all artifacts in the directory with the given profile name.
--target-dir directory
diff -Nru cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-doc.md cargo-0.58.0/src/doc/src/commands/cargo-doc.md --- cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-doc.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/commands/cargo-doc.md 2021-10-21 14:30:11.000000000 +0000 @@ -165,9 +165,14 @@
--release
-
Document optimized artifacts with the release profile. See the -PROFILES section for details on how this affects profile -selection.
+
Document optimized artifacts with the release profile. +See also the --profile option for choosing a specific profile by name.
+ + + +
--profile name
+
Document with the given profile. +See the the reference for more details on profiles.
@@ -316,24 +321,6 @@ -## PROFILES - -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See [the reference](../reference/profiles.html) for more -details. - -Profile selection depends on the target and crate being built. By default the -`dev` or `test` profiles are used. If the `--release` flag is given, then the -`release` or `bench` profiles are used. - -Target | Default Profile | `--release` Profile --------|-----------------|--------------------- -lib, bin, example | `dev` | `release` -test, bench, or any target in "test" or "bench" mode | `test` | `bench` - -Dependencies use the `dev`/`release` profiles. - - ## ENVIRONMENT See [the reference](../reference/environment-variables.html) for diff -Nru cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-fix.md cargo-0.58.0/src/doc/src/commands/cargo-fix.md --- cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-fix.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/commands/cargo-fix.md 2021-10-21 14:30:11.000000000 +0000 @@ -267,18 +267,18 @@
--release
-
Fix optimized artifacts with the release profile. See the -PROFILES section for details on how this affects profile -selection.
+
Fix optimized artifacts with the release profile. +See also the --profile option for choosing a specific profile by name.
--profile name
-
Changes fix behavior. Currently only test is supported, -which will fix with the #[cfg(test)] attribute enabled. -This is useful to have it fix unit tests which are usually -excluded via the cfg attribute. This does not change the actual profile -used.
+
Fix with the given profile.

+

As a special case, specifying the test profile will also enable checking in +test mode which will enable checking tests and enable the test cfg option. +See rustc tests for more +detail.

+

See the the reference for more details on profiles.

@@ -427,24 +427,6 @@ -## PROFILES - -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See [the reference](../reference/profiles.html) for more -details. - -Profile selection depends on the target and crate being built. By default the -`dev` or `test` profiles are used. If the `--release` flag is given, then the -`release` or `bench` profiles are used. - -Target | Default Profile | `--release` Profile --------|-----------------|--------------------- -lib, bin, example | `dev` | `release` -test, bench, or any target in "test" or "bench" mode | `test` | `bench` - -Dependencies use the `dev`/`release` profiles. - - ## ENVIRONMENT See [the reference](../reference/environment-variables.html) for diff -Nru cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-install.md cargo-0.58.0/src/doc/src/commands/cargo-install.md --- cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-install.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/commands/cargo-install.md 2021-10-21 14:30:11.000000000 +0000 @@ -49,7 +49,7 @@ - The package version and source. - The set of binary names installed. - The chosen features. -- The release mode (`--debug`). +- The profile (`--profile`). - The target (`--target`). Installing with `--path` will always build and install, unless there are @@ -226,7 +226,14 @@
--debug
-
Build with the dev profile instead the release profile.
+
Build with the dev profile instead the release profile. +See also the --profile option for choosing a specific profile by name.
+ + +
--profile name
+
Install with the given profile. +See the the reference for more details on profiles.
+ diff -Nru cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-package.md cargo-0.58.0/src/doc/src/commands/cargo-package.md --- cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-package.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/commands/cargo-package.md 2021-10-21 14:30:11.000000000 +0000 @@ -43,6 +43,22 @@ See [the reference](../reference/publishing.html) for more details about packaging and publishing. +### .cargo_vcs_info.json format + +Will generate a `.cargo_vcs_info.json` in the following format + +```javascript +{ + "git": { + "sha1": "aac20b6e7e543e6dd4118b246c77225e3a3a1302" + }, + "path_in_vcs": "" +} +``` + +`path_in_vcs` will be set to a repo-relative path for packages +in subdirectories of the version control repository. + ## OPTIONS ### Package Options diff -Nru cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-run.md cargo-0.58.0/src/doc/src/commands/cargo-run.md --- cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-run.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/commands/cargo-run.md 2021-10-21 14:30:11.000000000 +0000 @@ -100,9 +100,14 @@
--release
-
Run optimized artifacts with the release profile. See the -PROFILES section for details on how this affects profile -selection.
+
Run optimized artifacts with the release profile. +See also the --profile option for choosing a specific profile by name.
+ + + +
--profile name
+
Run with the given profile. +See the the reference for more details on profiles.
@@ -255,24 +260,6 @@ -## PROFILES - -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See [the reference](../reference/profiles.html) for more -details. - -Profile selection depends on the target and crate being built. By default the -`dev` or `test` profiles are used. If the `--release` flag is given, then the -`release` or `bench` profiles are used. - -Target | Default Profile | `--release` Profile --------|-----------------|--------------------- -lib, bin, example | `dev` | `release` -test, bench, or any target in "test" or "bench" mode | `test` | `bench` - -Dependencies use the `dev`/`release` profiles. - - ## ENVIRONMENT See [the reference](../reference/environment-variables.html) for diff -Nru cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-rustc.md cargo-0.58.0/src/doc/src/commands/cargo-rustc.md --- cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-rustc.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/commands/cargo-rustc.md 2021-10-21 14:30:11.000000000 +0000 @@ -169,12 +169,27 @@
--release
-
Build optimized artifacts with the release profile. See the -PROFILES section for details on how this affects profile -selection.
+
Build optimized artifacts with the release profile. +See also the --profile option for choosing a specific profile by name.
+
--profile name
+
Build with the given profile.

+

The rustc subcommand will treat the following named profiles with special behaviors:

+
    +
  • check — Builds in the same way as the cargo-check(1) command with +the dev profile.
  • +
  • test — Builds in the same way as the cargo-test(1) command, +enabling building in test mode which will enable tests and enable the test +cfg option. See rustc +tests for more detail.
  • +
  • bench — Builds in the same was as the cargo-bench(1) command, +similar to the test profile.
  • +
+

See the the reference for more details on profiles.

+ +
--ignore-rust-version
Build the target even if the selected Rust compiler is older than the required Rust version as configured in the project's rust-version field.
@@ -324,24 +339,6 @@ -## PROFILES - -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See [the reference](../reference/profiles.html) for more -details. - -Profile selection depends on the target and crate being built. By default the -`dev` or `test` profiles are used. If the `--release` flag is given, then the -`release` or `bench` profiles are used. - -Target | Default Profile | `--release` Profile --------|-----------------|--------------------- -lib, bin, example | `dev` | `release` -test, bench, or any target in "test" or "bench" mode | `test` | `bench` - -Dependencies use the `dev`/`release` profiles. - - ## ENVIRONMENT See [the reference](../reference/environment-variables.html) for diff -Nru cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-rustdoc.md cargo-0.58.0/src/doc/src/commands/cargo-rustdoc.md --- cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-rustdoc.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/commands/cargo-rustdoc.md 2021-10-21 14:30:11.000000000 +0000 @@ -184,9 +184,14 @@
--release
-
Document optimized artifacts with the release profile. See the -PROFILES section for details on how this affects profile -selection.
+
Document optimized artifacts with the release profile. +See also the --profile option for choosing a specific profile by name.
+ + + +
--profile name
+
Document with the given profile. +See the the reference for more details on profiles.
@@ -335,24 +340,6 @@ -## PROFILES - -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See [the reference](../reference/profiles.html) for more -details. - -Profile selection depends on the target and crate being built. By default the -`dev` or `test` profiles are used. If the `--release` flag is given, then the -`release` or `bench` profiles are used. - -Target | Default Profile | `--release` Profile --------|-----------------|--------------------- -lib, bin, example | `dev` | `release` -test, bench, or any target in "test" or "bench" mode | `test` | `bench` - -Dependencies use the `dev`/`release` profiles. - - ## ENVIRONMENT See [the reference](../reference/environment-variables.html) for diff -Nru cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-test.md cargo-0.58.0/src/doc/src/commands/cargo-test.md --- cargo-0.57.0+ubuntu/src/doc/src/commands/cargo-test.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/commands/cargo-test.md 2021-10-21 14:30:11.000000000 +0000 @@ -263,9 +263,14 @@
--release
-
Test optimized artifacts with the release profile. See the -PROFILES section for details on how this affects profile -selection.
+
Test optimized artifacts with the release profile. +See also the --profile option for choosing a specific profile by name.
+ + + +
--profile name
+
Test with the given profile. +See the the reference for more details on profiles.
@@ -432,32 +437,6 @@ -## PROFILES - -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See [the reference](../reference/profiles.html) for more -details. - -Profile selection depends on the target and crate being built. By default the -`dev` or `test` profiles are used. If the `--release` flag is given, then the -`release` or `bench` profiles are used. - -Target | Default Profile | `--release` Profile --------|-----------------|--------------------- -lib, bin, example | `dev` | `release` -test, bench, or any target in "test" or "bench" mode | `test` | `bench` - -Dependencies use the `dev`/`release` profiles. - - -Unit tests are separate executable artifacts which use the `test`/`bench` -profiles. Example targets are built the same as with `cargo build` (using the -`dev`/`release` profiles) unless you are building them with the test harness -(by setting `test = true` in the manifest or using the `--example` flag) in -which case they use the `test`/`bench` profiles. Library targets are built -with the `dev`/`release` profiles when linked to an integration test, binary, -or doctest. - ## ENVIRONMENT See [the reference](../reference/environment-variables.html) for diff -Nru cargo-0.57.0+ubuntu/src/doc/src/guide/build-cache.md cargo-0.58.0/src/doc/src/guide/build-cache.md --- cargo-0.57.0+ubuntu/src/doc/src/guide/build-cache.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/guide/build-cache.md 2021-10-21 14:30:11.000000000 +0000 @@ -9,21 +9,27 @@ The directory layout depends on whether or not you are using the `--target` flag to build for a specific platform. If `--target` is not specified, Cargo runs in a mode where it builds for the host architecture. The output goes into -the root of the target directory, separated based on whether or not it is a -release build: +the root of the target directory, with each [profile] stored in a separate +subdirectory: Directory | Description ----------|------------ -target/debug/ | Contains debug build output. -target/release/ | Contains release build output (with `--release` flag). +target/debug/ | Contains output for the `dev` profile. +target/release/ | Contains output for the `release` profile (with the `--release` option). +target/foo/ | Contains build output for the `foo` profile (with the `--profile=foo` option). + +For historical reasons, the `dev` and `test` profiles are stored in the +`debug` directory, and the `release` and `bench` profiles are stored in the +`release` directory. User-defined profiles are stored in a directory with the +same name as the profile. When building for another target with `--target`, the output is placed in a directory with the name of the target: Directory | Example ----------|-------- -target/<triple>/debug/target/thumbv7em-none-eabihf/debug/ -target/<triple>/release/target/thumbv7em-none-eabihf/release/ +target/<triple>/debug/ | target/thumbv7em-none-eabihf/debug/ +target/<triple>/release/ | target/thumbv7em-none-eabihf/release/ > **Note**: When not using `--target`, this has a consequence that Cargo will > share your dependencies with build scripts and proc macros. [`RUSTFLAGS`] @@ -31,13 +37,13 @@ > build scripts and proc macros are built separately (for the host > architecture), and do not share `RUSTFLAGS`. -Within the profile directory (`debug` or `release`), artifacts are placed into -the following directories: +Within the profile directory (such as `debug` or `release`), artifacts are +placed into the following directories: Directory | Description ----------|------------ -target/debug/ | Contains the output of the package being built (the `[[bin]]` executables and `[lib]` library targets). -target/debug/examples/ | Contains examples (`[[example]]` targets). +target/debug/ | Contains the output of the package being built (the [binary executables] and [library targets]). +target/debug/examples/ | Contains [example targets]. Some commands place their output in dedicated directories in the top level of the `target` directory: @@ -53,9 +59,9 @@ Directory | Description ----------|------------ -target/debug/deps/ |  Dependencies and other artifacts. -target/debug/incremental/ |  `rustc` [incremental output], a cache used to speed up subsequent builds. -target/debug/build/ |  Output from [build scripts]. +target/debug/deps/ | Dependencies and other artifacts. +target/debug/incremental/ | `rustc` [incremental output], a cache used to speed up subsequent builds. +target/debug/build/ | Output from [build scripts]. ### Dep-info files @@ -95,3 +101,7 @@ [environment variable]: ../reference/environment-variables.md [incremental output]: ../reference/profiles.md#incremental [sccache]: https://github.com/mozilla/sccache +[profile]: ../reference/profiles.md +[binary executables]: ../reference/cargo-targets.md#binaries +[library targets]: ../reference/cargo-targets.md#library +[example targets]: ../reference/cargo-targets.md#examples diff -Nru cargo-0.57.0+ubuntu/src/doc/src/guide/cargo-home.md cargo-0.58.0/src/doc/src/guide/cargo-home.md --- cargo-0.57.0+ubuntu/src/doc/src/guide/cargo-home.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/guide/cargo-home.md 2021-10-21 14:30:11.000000000 +0000 @@ -18,8 +18,8 @@ * `credentials.toml` Private login credentials from [`cargo login`] in order to log in to a [registry][def-registry]. -* `.crates.toml` - This hidden file contains [package][def-package] information of crates installed via [`cargo install`]. Do NOT edit by hand! +* `.crates.toml`, `.crates2.json` + These hidden files contain [package][def-package] information of crates installed via [`cargo install`]. Do NOT edit by hand! ## Directories: diff -Nru cargo-0.57.0+ubuntu/src/doc/src/images/profile-selection.svg cargo-0.58.0/src/doc/src/images/profile-selection.svg --- cargo-0.57.0+ubuntu/src/doc/src/images/profile-selection.svg 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/images/profile-selection.svg 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ - - -
lib
profile: dev
lib<br>profile: dev
lib (unit test)
profile: test
[Not supported by viewer]
dependency1
profile: dev
[Not supported by viewer]
integration test
profile: test
[Not supported by viewer]
bin (unit test)
profile: test
[Not supported by viewer]
bin (executable)
profile: dev
bin (executable)<br>profile: dev
dependency2
profile: dev
[Not supported by viewer]
dependency3
profile: dev
[Not supported by viewer]
Executables
[Not supported by viewer]
Profile selection for cargo test
Profile selection for <font face="Courier New">cargo test</font>
\ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/src/doc/src/reference/build-scripts.md cargo-0.58.0/src/doc/src/reference/build-scripts.md --- cargo-0.57.0+ubuntu/src/doc/src/reference/build-scripts.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/reference/build-scripts.md 2021-10-21 14:30:11.000000000 +0000 @@ -371,8 +371,8 @@ * The library crate should link to the native library `libfoo`. This will often probe the current system for `libfoo` before resorting to building from source. -* The library crate should provide **declarations** for functions in `libfoo`, - but **not** bindings or higher-level abstractions. +* The library crate should provide **declarations** for types and functions in + `libfoo`, but **not** higher-level abstractions. The set of `*-sys` packages provides a common set of dependencies for linking to native libraries. There are a number of benefits earned from having this diff -Nru cargo-0.57.0+ubuntu/src/doc/src/reference/config.md cargo-0.58.0/src/doc/src/reference/config.md --- cargo-0.57.0+ubuntu/src/doc/src/reference/config.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/reference/config.md 2021-10-21 14:30:11.000000000 +0000 @@ -109,7 +109,7 @@ [net] retry = 2 # network retries git-fetch-with-cli = true # use the `git` executable for git operations -offline = false # do not access the network +offline = true # do not access the network [patch.] # Same keys as for [patch] in Cargo.toml @@ -612,6 +612,9 @@ Sets the path to the root directory for installing executables for [`cargo install`]. Executables go into a `bin` directory underneath the root. +To track information of installed executables, some extra files, such as +`.crates.toml` and `.crates2.json`, are also created under this root. + The default if not specified is Cargo's home directory (default `.cargo` in your home directory). diff -Nru cargo-0.57.0+ubuntu/src/doc/src/reference/environment-variables.md cargo-0.58.0/src/doc/src/reference/environment-variables.md --- cargo-0.57.0+ubuntu/src/doc/src/reference/environment-variables.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/reference/environment-variables.md 2021-10-21 14:30:11.000000000 +0000 @@ -333,7 +333,11 @@ compatible [jobserver] for sub-make invocations. * `OPT_LEVEL`, `DEBUG` — values of the corresponding variables for the profile currently being built. -* `PROFILE` — `release` for release builds, `debug` for other builds. +* `PROFILE` — `release` for release builds, `debug` for other builds. This is + determined based on if the [profile] inherits from the [`dev`] or + [`release`] profile. Using this environment variable is not recommended. + Using other environment variables like `OPT_LEVEL` provide a more correct + view of the actual settings being used. * `DEP__` — For more information about this set of environment variables, see build script documentation about [`links`][links]. * `RUSTC`, `RUSTDOC` — the compiler and documentation generator that Cargo has @@ -371,6 +375,9 @@ [cargo-config]: config.md [Target Triple]: ../appendix/glossary.md#target [variables set for crates]: #environment-variables-cargo-sets-for-crates +[profile]: profiles.md +[`dev`]: profiles.md#dev +[`release`]: profiles.md#release ### Environment variables Cargo sets for 3rd party subcommands diff -Nru cargo-0.57.0+ubuntu/src/doc/src/reference/profiles.md cargo-0.58.0/src/doc/src/reference/profiles.md --- cargo-0.57.0+ubuntu/src/doc/src/reference/profiles.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/reference/profiles.md 2021-10-21 14:30:11.000000000 +0000 @@ -3,10 +3,10 @@ Profiles provide a way to alter the compiler settings, influencing things like optimizations and debugging symbols. -Cargo has 4 built-in profiles: `dev`, `release`, `test`, and `bench`. It -automatically chooses the profile based on which command is being run, the -package and target that is being built, and command-line flags like -`--release`. The selection process is [described below](#profile-selection). +Cargo has 4 built-in profiles: `dev`, `release`, `test`, and `bench`. The +profile is automatically chosen based on which command is being run if a +profile is not specified on the command-line. In addition to the built-in +profiles, custom user-defined profiles can also be specified. Profile settings can be changed in [`Cargo.toml`](manifest.md) with the `[profile]` table. Within each named profile, individual settings can be changed @@ -267,44 +267,14 @@ #### test The `test` profile is used for building tests, or when benchmarks are built in -debug mode with `cargo build`. - -The default settings for the `test` profile are: - -```toml -[profile.test] -opt-level = 0 -debug = 2 -split-debuginfo = '...' # Platform-specific. -debug-assertions = true -overflow-checks = true -lto = false -panic = 'unwind' # This setting is always ignored. -incremental = true -codegen-units = 256 -rpath = false -``` +debug mode with `cargo build`. By default, the `test` profile inherits the +settings from the [`dev`](#dev) profile. #### bench The `bench` profile is used for building benchmarks, or when tests are built -with the `--release` flag. - -The default settings for the `bench` profile are: - -```toml -[profile.bench] -opt-level = 3 -debug = false -split-debuginfo = '...' # Platform-specific. -debug-assertions = false -overflow-checks = false -lto = false -panic = 'unwind' # This setting is always ignored. -incremental = false -codegen-units = 16 -rpath = false -``` +with the `--release` flag. By default, the `bench` profile inherits the +settings from the [`release`](#release) profile. #### Build Dependencies @@ -325,35 +295,50 @@ Build dependencies otherwise inherit settings from the active profile in use, as described below. -### Profile selection +### Custom profiles -The profile used depends on the command, the package, the Cargo target, and -command-line flags like `--release`. +In addition to the built-in profiles, additional custom profiles can be +defined. These may be useful for setting up multiple workflows and build +modes. When defining a custom profile, you must specify the `inherits` key to +specify which profile the custom profile inherits settings from when the +setting is not specified. + +For example, let's say you want to compare a normal release build with a +release build with [LTO](#lto) optimizations, you can specify something like +the following in `Cargo.toml`: -Build commands like [`cargo build`], [`cargo rustc`], [`cargo check`], and -[`cargo run`] default to using the `dev` profile. The `--release` flag may be -used to switch to the `release` profile. - -The [`cargo install`] command defaults to the `release` profile, and may use -the `--debug` flag to switch to the `dev` profile. - -Test targets are built with the `test` profile by default. The `--release` -flag switches tests to the `bench` profile. - -Bench targets are built with the `bench` profile by default. The [`cargo -build`] command can be used to build a bench target with the `test` profile to -enable debugging. - -Note that when using the [`cargo test`] and [`cargo bench`] commands, the -`test`/`bench` profiles only apply to the final test executable. Dependencies -will continue to use the `dev`/`release` profiles. Also note that when a -library is built for unit tests, then the library is built with the `test` -profile. However, when building an integration test target, the library target -is built with the `dev` profile and linked into the integration test -executable. +```toml +[profile.release-lto] +inherits = "release" +lto = true +``` + +The `--profile` flag can then be used to choose this custom profile: + +```console +cargo build --profile release-lto +``` + +The output for each profile will be placed in a directory of the same name +as the profile in the [`target` directory]. As in the example above, the +output would go into the `target/release-lto` directory. + +[`target` directory]: ../guide/build-cache.md + +### Profile selection -![Profile selection for cargo test](../images/profile-selection.svg) +The profile used depends on the command, the command-line flags like +`--release` or `--profile`, and the package (in the case of +[overrides](#overrides)). The default profile if none is specified is: + +* Build commands like [`cargo build`], [`cargo rustc`], [`cargo check`], and +[`cargo run`]: [`dev` profile](#dev) +* [`cargo test`]: [`test` profile](#test) +* [`cargo bench`]: [`bench` profile](#bench) +* [`cargo install`]: [`release` profile](#release) +The profile for specific packages can be specified with +[overrides](#overrides), described below. [`cargo bench`]: ../commands/cargo-bench.md [`cargo build`]: ../commands/cargo-build.md diff -Nru cargo-0.57.0+ubuntu/src/doc/src/reference/specifying-dependencies.md cargo-0.58.0/src/doc/src/reference/specifying-dependencies.md --- cargo-0.57.0+ubuntu/src/doc/src/reference/specifying-dependencies.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/reference/specifying-dependencies.md 2021-10-21 14:30:11.000000000 +0000 @@ -147,6 +147,13 @@ regex = { git = "https://github.com/rust-lang/regex", branch = "next" } ``` +Anything that is not a branch or tag falls under `rev`. This can be a commit +hash like `rev = "4c59b707"`, or a named reference exposed by the remote +repository such as `rev = "refs/pull/493/head"`. What references are available +varies by where the repo is hosted; GitHub in particular exposes a reference to +the most recent commit of every pull request as shown, but other git hosts often +provide something equivalent, possibly under a different naming scheme. + Once a `git` dependency has been added, Cargo will lock that dependency to the latest commit at the time. New commits will not be pulled down automatically once the lock is in place. However, they can be pulled down manually with diff -Nru cargo-0.57.0+ubuntu/src/doc/src/reference/unstable.md cargo-0.58.0/src/doc/src/reference/unstable.md --- cargo-0.57.0+ubuntu/src/doc/src/reference/unstable.md 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/doc/src/reference/unstable.md 2021-10-21 14:30:11.000000000 +0000 @@ -87,7 +87,6 @@ * [`doctest-in-workspace`](#doctest-in-workspace) — Fixes workspace-relative paths when running doctests. * [rustdoc-map](#rustdoc-map) — Provides mappings for documentation to link to external sites like [docs.rs](https://docs.rs/). * `Cargo.toml` extensions - * [Custom named profiles](#custom-named-profiles) — Adds custom named profiles in addition to the standard names. * [Profile `strip` option](#profile-strip-option) — Forces the removal of debug information and symbols from executables. * [per-package-target](#per-package-target) — Sets the `--target` to use for each individual package. * Information and metadata @@ -238,49 +237,6 @@ cargo test --target x86_64-unknown-linux-gnu --target i686-unknown-linux-gnu ``` -### Custom named profiles - -* Tracking Issue: [rust-lang/cargo#6988](https://github.com/rust-lang/cargo/issues/6988) -* RFC: [#2678](https://github.com/rust-lang/rfcs/pull/2678) - -With this feature you can define custom profiles having new names. With the -custom profile enabled, build artifacts can be emitted by default to -directories other than `release` or `debug`, based on the custom profile's -name. - -For example: - -```toml -cargo-features = ["named-profiles"] - -[profile.release-lto] -inherits = "release" -lto = true -```` - -An `inherits` key is used in order to receive attributes from other profiles, -so that a new custom profile can be based on the standard `dev` or `release` -profile presets. Cargo emits errors in case `inherits` loops are detected. When -considering inheritance hierarchy, all profiles directly or indirectly inherit -from either from `release` or from `dev`. - -Valid profile names are: must not be empty, use only alphanumeric characters or -`-` or `_`. - -Passing `--profile` with the profile's name to various Cargo commands, directs -operations to use the profile's attributes. Overrides that are specified in the -profiles from which the custom profile inherits are inherited too. - -For example, using `cargo build` with `--profile` and the manifest from above: - -```sh -cargo +nightly build --profile release-lto -Z unstable-options -``` - -When a custom profile is used, build artifacts go to a different target by -default. In the example above, you can expect to see the outputs under -`target/release-lto`. - #### New `dir-name` attribute @@ -1421,3 +1377,8 @@ The 2021 edition has been stabilized in the 1.56 release. See the [`edition` field](manifest.md#the-edition-field) for more information on setting the edition. See [`cargo fix --edition`](../commands/cargo-fix.md) and [The Edition Guide](../../edition-guide/index.html) for more information on migrating existing projects. + +### Custom named profiles + +Custom named profiles have been stabilized in the 1.57 release. See the +[profiles chapter](profiles.md#custom-profiles) for more information. diff -Nru cargo-0.57.0+ubuntu/src/etc/_cargo cargo-0.58.0/src/etc/_cargo --- cargo-0.57.0+ubuntu/src/etc/_cargo 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/etc/_cargo 2021-10-21 14:30:11.000000000 +0000 @@ -39,7 +39,7 @@ # appropriate command's `_arguments` where appropriate. command_scope_spec=( '(--bin --example --test --lib)--bench=[specify benchmark name]: :_cargo_benchmark_names' - '(--bench --bin --test --lib)--example=[specify example name]:example name' + '(--bench --bin --test --lib)--example=[specify example name]:example name:_cargo_example_names' '(--bench --example --test --lib)--bin=[specify binary name]:binary name' '(--bench --bin --example --test)--lib=[specify library name]:library name' '(--bench --bin --example --lib)--test=[specify test name]:test name' @@ -77,7 +77,7 @@ '*:args:_default' ;; - build) + build | b) _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ '--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \ "${command_scope_spec[@]}" \ @@ -86,7 +86,7 @@ '--build-plan[output the build plan in JSON]' \ ;; - check) + check | c) _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ '--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \ "${command_scope_spec[@]}" \ @@ -101,7 +101,7 @@ '--doc[clean just the documentation directory]' ;; - doc) + doc | d) _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ '--no-deps[do not build docs for dependencies]' \ '--document-private-items[include non-public items in the documentation]' \ @@ -148,7 +148,7 @@ '--bin=[only install the specified binary]:binary' \ '--branch=[branch to use when installing from git]:branch' \ '--debug[build in debug mode instead of release mode]' \ - '--example=[install the specified example instead of binaries]:example' \ + '--example=[install the specified example instead of binaries]:example:_cargo_example_names' \ '--git=[specify URL from which to install the crate]:url:_urls' \ '--path=[local filesystem path to crate to install]: :_directories' \ '--rev=[specific commit to use when installing from git]:commit' \ @@ -220,9 +220,9 @@ _arguments -s -S $common $manifest ;; - run) + run | r) _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ - '--example=[name of the bin target]:name' \ + '--example=[name of the bin target]:name:_cargo_example_names' \ '--bin=[name of the bin target]:name' \ '(-p --package)'{-p+,--package=}'[specify package with the target to run]:package:_cargo_package_names' \ '--release[build in release mode]' \ @@ -255,7 +255,7 @@ '*: :_guard "^-*" "query"' ;; - test) + test | t) _arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \ '--test=[test name]: :_cargo_test_names' \ '--no-fail-fast[run all tests regardless of failure]' \ @@ -267,7 +267,7 @@ '(--doc --bin --example --test --bench)--lib[only test library]' \ '(--lib --bin --example --test --bench)--doc[only test documentation]' \ '(--lib --doc --example --test --bench)--bin=[binary name]' \ - '(--lib --doc --bin --test --bench)--example=[example name]' \ + '(--lib --doc --bin --test --bench)--example=[example name]:_cargo_example_names' \ '(--lib --doc --bin --example --bench)--test=[test name]' \ '(--lib --doc --bin --example --test)--bench=[benchmark name]' \ '*: :_default' @@ -416,4 +416,11 @@ _cargo_names_from_array "bench" } +_cargo_example_names() { + if [[ -d examples ]]; then + local -a files=(${(@f)$(echo examples/*.rs(:t:r))}) + _values 'example' "${files[@]}" + fi +} + _cargo diff -Nru cargo-0.57.0+ubuntu/src/etc/cargo.bashcomp.sh cargo-0.58.0/src/etc/cargo.bashcomp.sh --- cargo-0.57.0+ubuntu/src/etc/cargo.bashcomp.sh 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/etc/cargo.bashcomp.sh 2021-10-21 14:30:11.000000000 +0000 @@ -50,9 +50,12 @@ local opt___nocmd="$opt_common -V --version --list --explain" local opt__bench="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_jobs $opt_targets --message-format --target --no-run --no-fail-fast --target-dir" local opt__build="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_jobs $opt_targets --message-format --target --release --profile --target-dir" + local opt__b="$opt__build" local opt__check="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_jobs $opt_targets --message-format --target --release --profile --target-dir" + local opt__c="$opt__check" local opt__clean="$opt_common $opt_pkg $opt_mani $opt_lock --target --release --doc --target-dir --profile" local opt__doc="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_jobs --message-format --bin --bins --lib --target --open --no-deps --release --document-private-items --target-dir --profile" + local opt__d="$opt__doc" local opt__fetch="$opt_common $opt_mani $opt_lock --target" local opt__fix="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_jobs $opt_targets $opt_lock --release --target --message-format --broken-code --edition --edition-idioms --allow-no-vcs --allow-dirty --allow-staged --profile --target-dir" local opt__generate_lockfile="$opt_common $opt_mani $opt_lock" @@ -69,10 +72,12 @@ local opt__publish="$opt_common $opt_mani $opt_feat $opt_lock $opt_jobs --allow-dirty --dry-run --token --no-verify --index --registry --target --target-dir" local opt__read_manifest="$opt_help $opt_quiet $opt_verbose $opt_mani $opt_color $opt_lock --no-deps" local opt__run="$opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $opt_jobs --message-format --target --bin --example --release --target-dir --profile" + local opt__r="$opt__run" local opt__rustc="$opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $opt_jobs $opt_targets -L --crate-type --extern --message-format --profile --target --release --target-dir" local opt__rustdoc="$opt_common $opt_pkg $opt_feat $opt_mani $opt_lock $opt_jobs $opt_targets --message-format --target --release --open --target-dir --profile" local opt__search="$opt_common $opt_lock --limit --index --registry" local opt__test="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_jobs $opt_targets --message-format --doc --target --no-run --release --no-fail-fast --target-dir --profile" + local opt__t="$opt__test" local opt__tree="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock --target -i --invert --prefix --no-dedupe --duplicates -d --charset -f --format -e --edges" local opt__uninstall="$opt_common $opt_lock $opt_pkg --bin --root" local opt__update="$opt_common $opt_mani $opt_lock $opt_pkg --aggressive --precise --dry-run" diff -Nru cargo-0.57.0+ubuntu/src/etc/man/cargo-bench.1 cargo-0.58.0/src/etc/man/cargo-bench.1 --- cargo-0.57.0+ubuntu/src/etc/man/cargo-bench.1 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/etc/man/cargo-bench.1 2021-10-21 14:30:11.000000000 +0000 @@ -50,6 +50,12 @@ .br .RE .ll +.sp +By default, \fBcargo bench\fR uses the \fI\f(BIbench\fI profile\fR , which enables +optimizations and disables debugging information. If you need to debug a +benchmark, you can use the \fB\-\-profile=dev\fR command\-line option to switch to +the dev profile. You can then run the debug\-enabled benchmark within a +debugger. .SH "OPTIONS" .SS "Benchmark Options" .sp @@ -251,6 +257,12 @@ \fIbuild cache\fR documentation for more details. .RE .sp +\fB\-\-profile\fR \fIname\fR +.RS 4 +Benchmark with the given profile. +See the \fIthe reference\fR for more details on profiles. +.RE +.sp \fB\-\-ignore\-rust\-version\fR .RS 4 Benchmark the target even if the selected Rust compiler is older than the @@ -420,21 +432,6 @@ \fBbuild.jobs\fR \fIconfig value\fR \&. Defaults to the number of CPUs. .RE -.SH "PROFILES" -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See -\fIthe reference\fR -for more details. -.sp -Benchmarks are always built with the \fBbench\fR profile. Binary and lib targets -are built separately as benchmarks with the \fBbench\fR profile. Library targets -are built with the \fBrelease\fR profiles when linked to binaries and benchmarks. -Dependencies use the \fBrelease\fR profile. -.sp -If you need a debug build of a benchmark, try building it with -\fBcargo\-build\fR(1) which will use the \fBtest\fR profile which is by default -unoptimized and includes debug information. You can then run the debug\-enabled -benchmark manually. .SH "ENVIRONMENT" See \fIthe reference\fR for details on environment variables that Cargo reads. diff -Nru cargo-0.57.0+ubuntu/src/etc/man/cargo-build.1 cargo-0.58.0/src/etc/man/cargo-build.1 --- cargo-0.57.0+ubuntu/src/etc/man/cargo-build.1 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/etc/man/cargo-build.1 2021-10-21 14:30:11.000000000 +0000 @@ -171,9 +171,14 @@ .sp \fB\-\-release\fR .RS 4 -Build optimized artifacts with the \fBrelease\fR profile. See the -PROFILES section for details on how this affects profile -selection. +Build optimized artifacts with the \fBrelease\fR profile. +See also the \fB\-\-profile\fR option for choosing a specific profile by name. +.RE +.sp +\fB\-\-profile\fR \fIname\fR +.RS 4 +Build with the given profile. +See the \fIthe reference\fR for more details on profiles. .RE .sp \fB\-\-ignore\-rust\-version\fR @@ -354,43 +359,6 @@ \fBbuild.jobs\fR \fIconfig value\fR \&. Defaults to the number of CPUs. .RE -.SH "PROFILES" -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See \fIthe reference\fR for more -details. -.sp -Profile selection depends on the target and crate being built. By default the -\fBdev\fR or \fBtest\fR profiles are used. If the \fB\-\-release\fR flag is given, then the -\fBrelease\fR or \fBbench\fR profiles are used. - -.TS -allbox tab(:); -lt lt lt. -T{ -Target -T}:T{ -Default Profile -T}:T{ -\fB\-\-release\fR Profile -T} -T{ -lib, bin, example -T}:T{ -\fBdev\fR -T}:T{ -\fBrelease\fR -T} -T{ -test, bench, or any target in "test" or "bench" mode -T}:T{ -\fBtest\fR -T}:T{ -\fBbench\fR -T} -.TE -.sp -.sp -Dependencies use the \fBdev\fR/\fBrelease\fR profiles. .SH "ENVIRONMENT" See \fIthe reference\fR for details on environment variables that Cargo reads. diff -Nru cargo-0.57.0+ubuntu/src/etc/man/cargo-check.1 cargo-0.58.0/src/etc/man/cargo-check.1 --- cargo-0.57.0+ubuntu/src/etc/man/cargo-check.1 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/etc/man/cargo-check.1 2021-10-21 14:30:11.000000000 +0000 @@ -176,18 +176,20 @@ .sp \fB\-\-release\fR .RS 4 -Check optimized artifacts with the \fBrelease\fR profile. See the -PROFILES section for details on how this affects profile -selection. +Check optimized artifacts with the \fBrelease\fR profile. +See also the \fB\-\-profile\fR option for choosing a specific profile by name. .RE .sp \fB\-\-profile\fR \fIname\fR .RS 4 -Changes check behavior. Currently only \fBtest\fR is supported, -which will check with the \fB#[cfg(test)]\fR attribute enabled. -This is useful to have it check unit tests which are usually -excluded via the \fBcfg\fR attribute. This does not change the actual profile -used. +Check with the given profile. +.sp +As a special case, specifying the \fBtest\fR profile will also enable checking in +test mode which will enable checking tests and enable the \fBtest\fR cfg option. +See \fIrustc tests\fR for more +detail. +.sp +See the \fIthe reference\fR for more details on profiles. .RE .sp \fB\-\-ignore\-rust\-version\fR @@ -347,43 +349,6 @@ \fBbuild.jobs\fR \fIconfig value\fR \&. Defaults to the number of CPUs. .RE -.SH "PROFILES" -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See \fIthe reference\fR for more -details. -.sp -Profile selection depends on the target and crate being built. By default the -\fBdev\fR or \fBtest\fR profiles are used. If the \fB\-\-release\fR flag is given, then the -\fBrelease\fR or \fBbench\fR profiles are used. - -.TS -allbox tab(:); -lt lt lt. -T{ -Target -T}:T{ -Default Profile -T}:T{ -\fB\-\-release\fR Profile -T} -T{ -lib, bin, example -T}:T{ -\fBdev\fR -T}:T{ -\fBrelease\fR -T} -T{ -test, bench, or any target in "test" or "bench" mode -T}:T{ -\fBtest\fR -T}:T{ -\fBbench\fR -T} -.TE -.sp -.sp -Dependencies use the \fBdev\fR/\fBrelease\fR profiles. .SH "ENVIRONMENT" See \fIthe reference\fR for details on environment variables that Cargo reads. diff -Nru cargo-0.57.0+ubuntu/src/etc/man/cargo-clean.1 cargo-0.58.0/src/etc/man/cargo-clean.1 --- cargo-0.57.0+ubuntu/src/etc/man/cargo-clean.1 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/etc/man/cargo-clean.1 2021-10-21 14:30:11.000000000 +0000 @@ -33,7 +33,12 @@ .sp \fB\-\-release\fR .RS 4 -Clean all artifacts that were built with the \fBrelease\fR or \fBbench\fR profiles. +Remove all artifacts in the \fBrelease\fR directory. +.RE +.sp +\fB\-\-profile\fR \fIname\fR +.RS 4 +Remove all artifacts in the directory with the given profile name. .RE .sp \fB\-\-target\-dir\fR \fIdirectory\fR diff -Nru cargo-0.57.0+ubuntu/src/etc/man/cargo-doc.1 cargo-0.58.0/src/etc/man/cargo-doc.1 --- cargo-0.57.0+ubuntu/src/etc/man/cargo-doc.1 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/etc/man/cargo-doc.1 2021-10-21 14:30:11.000000000 +0000 @@ -149,9 +149,14 @@ .sp \fB\-\-release\fR .RS 4 -Document optimized artifacts with the \fBrelease\fR profile. See the -PROFILES section for details on how this affects profile -selection. +Document optimized artifacts with the \fBrelease\fR profile. +See also the \fB\-\-profile\fR option for choosing a specific profile by name. +.RE +.sp +\fB\-\-profile\fR \fIname\fR +.RS 4 +Document with the given profile. +See the \fIthe reference\fR for more details on profiles. .RE .sp \fB\-\-ignore\-rust\-version\fR @@ -311,43 +316,6 @@ \fBbuild.jobs\fR \fIconfig value\fR \&. Defaults to the number of CPUs. .RE -.SH "PROFILES" -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See \fIthe reference\fR for more -details. -.sp -Profile selection depends on the target and crate being built. By default the -\fBdev\fR or \fBtest\fR profiles are used. If the \fB\-\-release\fR flag is given, then the -\fBrelease\fR or \fBbench\fR profiles are used. - -.TS -allbox tab(:); -lt lt lt. -T{ -Target -T}:T{ -Default Profile -T}:T{ -\fB\-\-release\fR Profile -T} -T{ -lib, bin, example -T}:T{ -\fBdev\fR -T}:T{ -\fBrelease\fR -T} -T{ -test, bench, or any target in "test" or "bench" mode -T}:T{ -\fBtest\fR -T}:T{ -\fBbench\fR -T} -.TE -.sp -.sp -Dependencies use the \fBdev\fR/\fBrelease\fR profiles. .SH "ENVIRONMENT" See \fIthe reference\fR for details on environment variables that Cargo reads. diff -Nru cargo-0.57.0+ubuntu/src/etc/man/cargo-fix.1 cargo-0.58.0/src/etc/man/cargo-fix.1 --- cargo-0.57.0+ubuntu/src/etc/man/cargo-fix.1 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/etc/man/cargo-fix.1 2021-10-21 14:30:11.000000000 +0000 @@ -271,18 +271,20 @@ .sp \fB\-\-release\fR .RS 4 -Fix optimized artifacts with the \fBrelease\fR profile. See the -PROFILES section for details on how this affects profile -selection. +Fix optimized artifacts with the \fBrelease\fR profile. +See also the \fB\-\-profile\fR option for choosing a specific profile by name. .RE .sp \fB\-\-profile\fR \fIname\fR .RS 4 -Changes fix behavior. Currently only \fBtest\fR is supported, -which will fix with the \fB#[cfg(test)]\fR attribute enabled. -This is useful to have it fix unit tests which are usually -excluded via the \fBcfg\fR attribute. This does not change the actual profile -used. +Fix with the given profile. +.sp +As a special case, specifying the \fBtest\fR profile will also enable checking in +test mode which will enable checking tests and enable the \fBtest\fR cfg option. +See \fIrustc tests\fR for more +detail. +.sp +See the \fIthe reference\fR for more details on profiles. .RE .sp \fB\-\-ignore\-rust\-version\fR @@ -442,43 +444,6 @@ \fBbuild.jobs\fR \fIconfig value\fR \&. Defaults to the number of CPUs. .RE -.SH "PROFILES" -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See \fIthe reference\fR for more -details. -.sp -Profile selection depends on the target and crate being built. By default the -\fBdev\fR or \fBtest\fR profiles are used. If the \fB\-\-release\fR flag is given, then the -\fBrelease\fR or \fBbench\fR profiles are used. - -.TS -allbox tab(:); -lt lt lt. -T{ -Target -T}:T{ -Default Profile -T}:T{ -\fB\-\-release\fR Profile -T} -T{ -lib, bin, example -T}:T{ -\fBdev\fR -T}:T{ -\fBrelease\fR -T} -T{ -test, bench, or any target in "test" or "bench" mode -T}:T{ -\fBtest\fR -T}:T{ -\fBbench\fR -T} -.TE -.sp -.sp -Dependencies use the \fBdev\fR/\fBrelease\fR profiles. .SH "ENVIRONMENT" See \fIthe reference\fR for details on environment variables that Cargo reads. diff -Nru cargo-0.57.0+ubuntu/src/etc/man/cargo-install.1 cargo-0.58.0/src/etc/man/cargo-install.1 --- cargo-0.57.0+ubuntu/src/etc/man/cargo-install.1 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/etc/man/cargo-install.1 2021-10-21 14:30:11.000000000 +0000 @@ -71,7 +71,7 @@ .RE .sp .RS 4 -\h'-04'\(bu\h'+02'The release mode (\fB\-\-debug\fR). +\h'-04'\(bu\h'+02'The profile (\fB\-\-profile\fR). .RE .sp .RS 4 @@ -258,6 +258,13 @@ \fB\-\-debug\fR .RS 4 Build with the \fBdev\fR profile instead the \fBrelease\fR profile. +See also the \fB\-\-profile\fR option for choosing a specific profile by name. +.RE +.sp +\fB\-\-profile\fR \fIname\fR +.RS 4 +Install with the given profile. +See the \fIthe reference\fR for more details on profiles. .RE .SS "Manifest Options" .sp diff -Nru cargo-0.57.0+ubuntu/src/etc/man/cargo-package.1 cargo-0.58.0/src/etc/man/cargo-package.1 --- cargo-0.57.0+ubuntu/src/etc/man/cargo-package.1 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/etc/man/cargo-package.1 2021-10-21 14:30:11.000000000 +0000 @@ -67,6 +67,22 @@ .sp See \fIthe reference\fR for more details about packaging and publishing. +.SS ".cargo_vcs_info.json format" +Will generate a \fB\&.cargo_vcs_info.json\fR in the following format +.sp +.RS 4 +.nf +{ + "git": { + "sha1": "aac20b6e7e543e6dd4118b246c77225e3a3a1302" + }, + "path_in_vcs": "" +} +.fi +.RE +.sp +\fBpath_in_vcs\fR will be set to a repo\-relative path for packages +in subdirectories of the version control repository. .SH "OPTIONS" .SS "Package Options" .sp diff -Nru cargo-0.57.0+ubuntu/src/etc/man/cargo-run.1 cargo-0.58.0/src/etc/man/cargo-run.1 --- cargo-0.57.0+ubuntu/src/etc/man/cargo-run.1 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/etc/man/cargo-run.1 2021-10-21 14:30:11.000000000 +0000 @@ -82,9 +82,14 @@ .sp \fB\-\-release\fR .RS 4 -Run optimized artifacts with the \fBrelease\fR profile. See the -PROFILES section for details on how this affects profile -selection. +Run optimized artifacts with the \fBrelease\fR profile. +See also the \fB\-\-profile\fR option for choosing a specific profile by name. +.RE +.sp +\fB\-\-profile\fR \fIname\fR +.RS 4 +Run with the given profile. +See the \fIthe reference\fR for more details on profiles. .RE .sp \fB\-\-ignore\-rust\-version\fR @@ -244,43 +249,6 @@ \fBbuild.jobs\fR \fIconfig value\fR \&. Defaults to the number of CPUs. .RE -.SH "PROFILES" -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See \fIthe reference\fR for more -details. -.sp -Profile selection depends on the target and crate being built. By default the -\fBdev\fR or \fBtest\fR profiles are used. If the \fB\-\-release\fR flag is given, then the -\fBrelease\fR or \fBbench\fR profiles are used. - -.TS -allbox tab(:); -lt lt lt. -T{ -Target -T}:T{ -Default Profile -T}:T{ -\fB\-\-release\fR Profile -T} -T{ -lib, bin, example -T}:T{ -\fBdev\fR -T}:T{ -\fBrelease\fR -T} -T{ -test, bench, or any target in "test" or "bench" mode -T}:T{ -\fBtest\fR -T}:T{ -\fBbench\fR -T} -.TE -.sp -.sp -Dependencies use the \fBdev\fR/\fBrelease\fR profiles. .SH "ENVIRONMENT" See \fIthe reference\fR for details on environment variables that Cargo reads. diff -Nru cargo-0.57.0+ubuntu/src/etc/man/cargo-rustc.1 cargo-0.58.0/src/etc/man/cargo-rustc.1 --- cargo-0.57.0+ubuntu/src/etc/man/cargo-rustc.1 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/etc/man/cargo-rustc.1 2021-10-21 14:30:11.000000000 +0000 @@ -157,9 +157,34 @@ .sp \fB\-\-release\fR .RS 4 -Build optimized artifacts with the \fBrelease\fR profile. See the -PROFILES section for details on how this affects profile -selection. +Build optimized artifacts with the \fBrelease\fR profile. +See also the \fB\-\-profile\fR option for choosing a specific profile by name. +.RE +.sp +\fB\-\-profile\fR \fIname\fR +.RS 4 +Build with the given profile. +.sp +The \fBrustc\fR subcommand will treat the following named profiles with special behaviors: +.sp +.RS 4 +\h'-04'\(bu\h'+02'\fBcheck\fR \[em] Builds in the same way as the \fBcargo\-check\fR(1) command with +the \fBdev\fR profile. +.RE +.sp +.RS 4 +\h'-04'\(bu\h'+02'\fBtest\fR \[em] Builds in the same way as the \fBcargo\-test\fR(1) command, +enabling building in test mode which will enable tests and enable the \fBtest\fR +cfg option. See \fIrustc +tests\fR for more detail. +.RE +.sp +.RS 4 +\h'-04'\(bu\h'+02'\fBbench\fR \[em] Builds in the same was as the \fBcargo\-bench\fR(1) command, +similar to the \fBtest\fR profile. +.RE +.sp +See the \fIthe reference\fR for more details on profiles. .RE .sp \fB\-\-ignore\-rust\-version\fR @@ -319,43 +344,6 @@ \fBbuild.jobs\fR \fIconfig value\fR \&. Defaults to the number of CPUs. .RE -.SH "PROFILES" -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See \fIthe reference\fR for more -details. -.sp -Profile selection depends on the target and crate being built. By default the -\fBdev\fR or \fBtest\fR profiles are used. If the \fB\-\-release\fR flag is given, then the -\fBrelease\fR or \fBbench\fR profiles are used. - -.TS -allbox tab(:); -lt lt lt. -T{ -Target -T}:T{ -Default Profile -T}:T{ -\fB\-\-release\fR Profile -T} -T{ -lib, bin, example -T}:T{ -\fBdev\fR -T}:T{ -\fBrelease\fR -T} -T{ -test, bench, or any target in "test" or "bench" mode -T}:T{ -\fBtest\fR -T}:T{ -\fBbench\fR -T} -.TE -.sp -.sp -Dependencies use the \fBdev\fR/\fBrelease\fR profiles. .SH "ENVIRONMENT" See \fIthe reference\fR for details on environment variables that Cargo reads. diff -Nru cargo-0.57.0+ubuntu/src/etc/man/cargo-rustdoc.1 cargo-0.58.0/src/etc/man/cargo-rustdoc.1 --- cargo-0.57.0+ubuntu/src/etc/man/cargo-rustdoc.1 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/etc/man/cargo-rustdoc.1 2021-10-21 14:30:11.000000000 +0000 @@ -168,9 +168,14 @@ .sp \fB\-\-release\fR .RS 4 -Document optimized artifacts with the \fBrelease\fR profile. See the -PROFILES section for details on how this affects profile -selection. +Document optimized artifacts with the \fBrelease\fR profile. +See also the \fB\-\-profile\fR option for choosing a specific profile by name. +.RE +.sp +\fB\-\-profile\fR \fIname\fR +.RS 4 +Document with the given profile. +See the \fIthe reference\fR for more details on profiles. .RE .sp \fB\-\-ignore\-rust\-version\fR @@ -330,43 +335,6 @@ \fBbuild.jobs\fR \fIconfig value\fR \&. Defaults to the number of CPUs. .RE -.SH "PROFILES" -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See \fIthe reference\fR for more -details. -.sp -Profile selection depends on the target and crate being built. By default the -\fBdev\fR or \fBtest\fR profiles are used. If the \fB\-\-release\fR flag is given, then the -\fBrelease\fR or \fBbench\fR profiles are used. - -.TS -allbox tab(:); -lt lt lt. -T{ -Target -T}:T{ -Default Profile -T}:T{ -\fB\-\-release\fR Profile -T} -T{ -lib, bin, example -T}:T{ -\fBdev\fR -T}:T{ -\fBrelease\fR -T} -T{ -test, bench, or any target in "test" or "bench" mode -T}:T{ -\fBtest\fR -T}:T{ -\fBbench\fR -T} -.TE -.sp -.sp -Dependencies use the \fBdev\fR/\fBrelease\fR profiles. .SH "ENVIRONMENT" See \fIthe reference\fR for details on environment variables that Cargo reads. diff -Nru cargo-0.57.0+ubuntu/src/etc/man/cargo-test.1 cargo-0.58.0/src/etc/man/cargo-test.1 --- cargo-0.57.0+ubuntu/src/etc/man/cargo-test.1 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/src/etc/man/cargo-test.1 2021-10-21 14:30:11.000000000 +0000 @@ -268,9 +268,14 @@ .sp \fB\-\-release\fR .RS 4 -Test optimized artifacts with the \fBrelease\fR profile. See the -PROFILES section for details on how this affects profile -selection. +Test optimized artifacts with the \fBrelease\fR profile. +See also the \fB\-\-profile\fR option for choosing a specific profile by name. +.RE +.sp +\fB\-\-profile\fR \fIname\fR +.RS 4 +Test with the given profile. +See the \fIthe reference\fR for more details on profiles. .RE .sp \fB\-\-ignore\-rust\-version\fR @@ -448,51 +453,6 @@ \fBbuild.jobs\fR \fIconfig value\fR \&. Defaults to the number of CPUs. .RE -.SH "PROFILES" -Profiles may be used to configure compiler options such as optimization levels -and debug settings. See \fIthe reference\fR for more -details. -.sp -Profile selection depends on the target and crate being built. By default the -\fBdev\fR or \fBtest\fR profiles are used. If the \fB\-\-release\fR flag is given, then the -\fBrelease\fR or \fBbench\fR profiles are used. - -.TS -allbox tab(:); -lt lt lt. -T{ -Target -T}:T{ -Default Profile -T}:T{ -\fB\-\-release\fR Profile -T} -T{ -lib, bin, example -T}:T{ -\fBdev\fR -T}:T{ -\fBrelease\fR -T} -T{ -test, bench, or any target in "test" or "bench" mode -T}:T{ -\fBtest\fR -T}:T{ -\fBbench\fR -T} -.TE -.sp -.sp -Dependencies use the \fBdev\fR/\fBrelease\fR profiles. -.sp -Unit tests are separate executable artifacts which use the \fBtest\fR/\fBbench\fR -profiles. Example targets are built the same as with \fBcargo build\fR (using the -\fBdev\fR/\fBrelease\fR profiles) unless you are building them with the test harness -(by setting \fBtest = true\fR in the manifest or using the \fB\-\-example\fR flag) in -which case they use the \fBtest\fR/\fBbench\fR profiles. Library targets are built -with the \fBdev\fR/\fBrelease\fR profiles when linked to an integration test, binary, -or doctest. .SH "ENVIRONMENT" See \fIthe reference\fR for details on environment variables that Cargo reads. diff -Nru cargo-0.57.0+ubuntu/tests/testsuite/bad_config.rs cargo-0.58.0/tests/testsuite/bad_config.rs --- cargo-0.57.0+ubuntu/tests/testsuite/bad_config.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/tests/testsuite/bad_config.rs 2021-10-21 14:30:11.000000000 +0000 @@ -773,26 +773,15 @@ } #[cargo_test] -fn invalid_toml_historically_allowed_is_warned() { +fn invalid_toml_historically_allowed_fails() { let p = project() .file(".cargo/config", "[bar] baz = 2") .file("src/main.rs", "fn main() {}") .build(); p.cargo("build") - .with_stderr( - "\ -warning: TOML file found which contains invalid syntax and will soon not parse -at `[..]config`. - -The TOML spec requires newlines after table definitions (e.g., `[a] b = 1` is -invalid), but this file has a table header which does not have a newline after -it. A newline needs to be added and this warning will soon become a hard error -in the future. -[COMPILING] foo v0.0.1 ([..]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -", - ) + .with_status(101) + .with_stderr_contains(" expected newline, found an identifier at line 1 column 7") .run(); } diff -Nru cargo-0.57.0+ubuntu/tests/testsuite/build_script.rs cargo-0.58.0/tests/testsuite/build_script.rs --- cargo-0.57.0+ubuntu/tests/testsuite/build_script.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/tests/testsuite/build_script.rs 2021-10-21 14:30:11.000000000 +0000 @@ -1000,7 +1000,7 @@ but a native library can be linked only once package `bar v0.1.0` - ... which satisfies dependency `bar = \"=0.1.0\"` of package `foo v0.1.0 ([..]foo)` + ... which satisfies dependency `bar = \"^0.1\"` (locked to 0.1.0) of package `foo v0.1.0 ([..]foo)` links to native library `a` package `foo v0.1.0 ([..]foo)` @@ -4942,3 +4942,31 @@ .run(); } } + +#[cargo_test] +fn wrong_output() { + let p = project() + .file("src/lib.rs", "") + .file( + "build.rs", + r#" + fn main() { + println!("cargo:example"); + } + "#, + ) + .build(); + + p.cargo("build") + .with_status(101) + .with_stderr( + "\ +[COMPILING] foo [..] +error: invalid output in build script of `foo v0.0.1 ([ROOT]/foo)`: `cargo:example` +Expected a line with `cargo:key=value` with an `=` character, but none was found. +See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script \ +for more information about build script outputs. +", + ) + .run(); +} diff -Nru cargo-0.57.0+ubuntu/tests/testsuite/doc.rs cargo-0.58.0/tests/testsuite/doc.rs --- cargo-0.57.0+ubuntu/tests/testsuite/doc.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/tests/testsuite/doc.rs 2021-10-21 14:30:11.000000000 +0000 @@ -4,7 +4,7 @@ use cargo_test_support::paths::CargoPathExt; use cargo_test_support::registry::Package; use cargo_test_support::{basic_lib_manifest, basic_manifest, git, project}; -use cargo_test_support::{is_nightly, rustc_host, symlink_supported}; +use cargo_test_support::{is_nightly, rustc_host, symlink_supported, tools}; use std::fs; use std::str; @@ -1250,7 +1250,6 @@ } #[cargo_test] -#[cfg(not(windows))] // `echo` may not be available fn doc_workspace_open_help_message() { let p = project() .file( @@ -1268,7 +1267,7 @@ // The order in which bar is compiled or documented is not deterministic p.cargo("doc --workspace --open") - .env("BROWSER", "echo") + .env("BROWSER", tools::echo()) .with_stderr_contains("[..] Documenting bar v0.1.0 ([..])") .with_stderr_contains("[..] Documenting foo v0.1.0 ([..])") .with_stderr_contains("[..] Opening [..]/bar/index.html") @@ -1276,7 +1275,6 @@ } #[cargo_test] -#[cfg(not(windows))] // `echo` may not be available fn doc_extern_map_local() { if !is_nightly() { // -Zextern-html-root-url is unstable @@ -1297,7 +1295,7 @@ .build(); p.cargo("doc -v --no-deps -Zrustdoc-map --open") - .env("BROWSER", "echo") + .env("BROWSER", tools::echo()) .masquerade_as_nightly_cargo() .with_stderr( "\ @@ -1311,7 +1309,6 @@ } #[cargo_test] -#[cfg(not(windows))] // `echo` may not be available fn doc_workspace_open_different_library_and_package_names() { let p = project() .file( @@ -1335,7 +1332,7 @@ .build(); p.cargo("doc --open") - .env("BROWSER", "echo") + .env("BROWSER", tools::echo()) .with_stderr_contains("[..] Documenting foo v0.1.0 ([..])") .with_stderr_contains("[..] [CWD]/target/doc/foolib/index.html") .with_stdout_contains("[CWD]/target/doc/foolib/index.html") @@ -1343,21 +1340,23 @@ p.change_file( ".cargo/config.toml", - r#" - [doc] - browser = ["echo", "a"] - "#, + &format!( + r#" + [doc] + browser = ["{}", "a"] + "#, + tools::echo().display().to_string().replace('\\', "\\\\") + ), ); // check that the cargo config overrides the browser env var p.cargo("doc --open") - .env("BROWSER", "true") + .env("BROWSER", "do_not_run_me") .with_stdout_contains("a [CWD]/target/doc/foolib/index.html") .run(); } #[cargo_test] -#[cfg(not(windows))] // `echo` may not be available fn doc_workspace_open_binary() { let p = project() .file( @@ -1382,14 +1381,13 @@ .build(); p.cargo("doc --open") - .env("BROWSER", "echo") + .env("BROWSER", tools::echo()) .with_stderr_contains("[..] Documenting foo v0.1.0 ([..])") .with_stderr_contains("[..] Opening [CWD]/target/doc/foobin/index.html") .run(); } #[cargo_test] -#[cfg(not(windows))] // `echo` may not be available fn doc_workspace_open_binary_and_library() { let p = project() .file( @@ -1417,7 +1415,7 @@ .build(); p.cargo("doc --open") - .env("BROWSER", "echo") + .env("BROWSER", tools::echo()) .with_stderr_contains("[..] Documenting foo v0.1.0 ([..])") .with_stderr_contains("[..] Opening [CWD]/target/doc/foolib/index.html") .run(); diff -Nru cargo-0.57.0+ubuntu/tests/testsuite/fix.rs cargo-0.58.0/tests/testsuite/fix.rs --- cargo-0.57.0+ubuntu/tests/testsuite/fix.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/tests/testsuite/fix.rs 2021-10-21 14:30:11.000000000 +0000 @@ -1791,3 +1791,47 @@ // Check that it made the edition migration. assert!(contents.contains("from_utf8(crate::foo::FOO)")); } + +// For rust-lang/cargo#9857 +#[cargo_test] +fn fix_in_dependency() { + Package::new("bar", "1.0.0") + .file( + "src/lib.rs", + r#" + #[macro_export] + macro_rules! m { + ($i:tt) => { + let $i = 1; + }; + } + "#, + ) + .publish(); + + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + + [dependencies] + bar = "1.0" + "#, + ) + .file( + "src/lib.rs", + r#" + pub fn foo() { + bar::m!(abc); + } + "#, + ) + .build(); + + p.cargo("fix --allow-no-vcs") + .with_stderr_does_not_contain("[FIXED] [..]") + .run(); +} diff -Nru cargo-0.57.0+ubuntu/tests/testsuite/git.rs cargo-0.58.0/tests/testsuite/git.rs --- cargo-0.57.0+ubuntu/tests/testsuite/git.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/tests/testsuite/git.rs 2021-10-21 14:30:11.000000000 +0000 @@ -231,6 +231,68 @@ } #[cargo_test] +fn cargo_compile_git_dep_pull_request() { + let project = project(); + let git_project = git::new("dep1", |project| { + project + .file("Cargo.toml", &basic_lib_manifest("dep1")) + .file( + "src/dep1.rs", + r#" + pub fn hello() -> &'static str { + "hello world" + } + "#, + ) + }); + + // Make a reference in GitHub's pull request ref naming convention. + let repo = git2::Repository::open(&git_project.root()).unwrap(); + let oid = repo.refname_to_id("HEAD").unwrap(); + let force = false; + let log_message = "open pull request"; + repo.reference("refs/pull/330/head", oid, force, log_message) + .unwrap(); + + let project = project + .file( + "Cargo.toml", + &format!( + r#" + [project] + name = "foo" + version = "0.0.0" + + [dependencies] + dep1 = {{ git = "{}", rev = "refs/pull/330/head" }} + "#, + git_project.url() + ), + ) + .file( + "src/main.rs", + &main_file(r#""{}", dep1::hello()"#, &["dep1"]), + ) + .build(); + + let git_root = git_project.root(); + + project + .cargo("build") + .with_stderr(&format!( + "[UPDATING] git repository `{}`\n\ + [COMPILING] dep1 v0.5.0 ({}?rev=refs/pull/330/head#[..])\n\ + [COMPILING] foo v0.0.0 ([CWD])\n\ + [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n", + path2url(&git_root), + path2url(&git_root), + )) + .run(); + + assert!(project.bin("foo").is_file()); +} + +#[cargo_test] fn cargo_compile_with_nested_paths() { let git_project = git::new("dep1", |project| { project @@ -3218,3 +3280,105 @@ let bar_source = format!("git+{}", git_project.url()); p.cargo("metadata").with_json(&metadata(&bar_source)).run(); } + +#[cargo_test] +fn git_with_force_push() { + // Checks that cargo can handle force-pushes to git repos. + // This works by having a git dependency that is updated with an amend + // commit, and tries with various forms (default branch, branch, rev, + // tag). + let main = |text| format!(r#"pub fn f() {{ println!("{}"); }}"#, text); + let (git_project, repo) = git::new_repo("dep1", |project| { + project + .file("Cargo.toml", &basic_lib_manifest("dep1")) + .file("src/lib.rs", &main("one")) + }); + let manifest = |extra| { + format!( + r#" + [project] + name = "foo" + version = "0.0.1" + edition = "2018" + + [dependencies] + dep1 = {{ git = "{}"{} }} + "#, + git_project.url(), + extra + ) + }; + let p = project() + .file("Cargo.toml", &manifest("")) + .file("src/main.rs", "fn main() { dep1::f(); }") + .build(); + // Download the original and make sure it is OK. + p.cargo("build").run(); + p.rename_run("foo", "foo1").with_stdout("one").run(); + + let find_head = || t!(t!(repo.head()).peel_to_commit()); + + let amend_commit = |text| { + // commit --amend a change that will require a force fetch. + git_project.change_file("src/lib.rs", &main(text)); + git::add(&repo); + let commit = find_head(); + let tree_id = t!(t!(repo.index()).write_tree()); + t!(commit.amend( + Some("HEAD"), + None, + None, + None, + None, + Some(&t!(repo.find_tree(tree_id))) + )); + }; + + let mut rename_annoyance = 1; + + let mut verify = |text: &str| { + // Perform the fetch. + p.cargo("update").run(); + p.cargo("build").run(); + rename_annoyance += 1; + p.rename_run("foo", &format!("foo{}", rename_annoyance)) + .with_stdout(text) + .run(); + }; + + amend_commit("two"); + verify("two"); + + // Try with a rev. + let head1 = find_head().id().to_string(); + let extra = format!(", rev = \"{}\"", head1); + p.change_file("Cargo.toml", &manifest(&extra)); + verify("two"); + amend_commit("three"); + let head2 = find_head().id().to_string(); + assert_ne!(&head1, &head2); + let extra = format!(", rev = \"{}\"", head2); + p.change_file("Cargo.toml", &manifest(&extra)); + verify("three"); + + // Try with a tag. + git::tag(&repo, "my-tag"); + p.change_file("Cargo.toml", &manifest(", tag = \"my-tag\"")); + verify("three"); + amend_commit("tag-three"); + let head = t!(t!(repo.head()).peel(git2::ObjectType::Commit)); + t!(repo.tag("my-tag", &head, &t!(repo.signature()), "move tag", true)); + verify("tag-three"); + + // Try with a branch. + let br = t!(repo.branch("awesome-stuff", &find_head(), false)); + t!(repo.checkout_tree(&t!(br.get().peel(git2::ObjectType::Tree)), None)); + t!(repo.set_head("refs/heads/awesome-stuff")); + git_project.change_file("src/lib.rs", &main("awesome-three")); + git::add(&repo); + git::commit(&repo); + p.change_file("Cargo.toml", &manifest(", branch = \"awesome-stuff\"")); + verify("awesome-three"); + amend_commit("awesome-four"); + verify("awesome-four"); +} diff -Nru cargo-0.57.0+ubuntu/tests/testsuite/help.rs cargo-0.58.0/tests/testsuite/help.rs --- cargo-0.57.0+ubuntu/tests/testsuite/help.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/tests/testsuite/help.rs 2021-10-21 14:30:11.000000000 +0000 @@ -138,3 +138,54 @@ .unwrap(); help_with_man_and_path("", "my-alias", "build", Path::new("")); } + +#[cargo_test] +fn alias_z_flag_help() { + cargo_process("build -Z help") + .with_stdout_contains( + " -Z allow-features[..]-- Allow *only* the listed unstable features", + ) + .run(); + + cargo_process("run -Z help") + .with_stdout_contains( + " -Z allow-features[..]-- Allow *only* the listed unstable features", + ) + .run(); + + cargo_process("check -Z help") + .with_stdout_contains( + " -Z allow-features[..]-- Allow *only* the listed unstable features", + ) + .run(); + + cargo_process("test -Z help") + .with_stdout_contains( + " -Z allow-features[..]-- Allow *only* the listed unstable features", + ) + .run(); + + cargo_process("b -Z help") + .with_stdout_contains( + " -Z allow-features[..]-- Allow *only* the listed unstable features", + ) + .run(); + + cargo_process("r -Z help") + .with_stdout_contains( + " -Z allow-features[..]-- Allow *only* the listed unstable features", + ) + .run(); + + cargo_process("c -Z help") + .with_stdout_contains( + " -Z allow-features[..]-- Allow *only* the listed unstable features", + ) + .run(); + + cargo_process("t -Z help") + .with_stdout_contains( + " -Z allow-features[..]-- Allow *only* the listed unstable features", + ) + .run(); +} diff -Nru cargo-0.57.0+ubuntu/tests/testsuite/init.rs cargo-0.58.0/tests/testsuite/init.rs --- cargo-0.57.0+ubuntu/tests/testsuite/init.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/tests/testsuite/init.rs 2021-10-21 14:30:11.000000000 +0000 @@ -290,7 +290,7 @@ This can be done by setting the binary filename to `src/bin/foo.bar.rs` \ or change the name in Cargo.toml with: - [bin] + [[bin]] name = \"foo.bar\" path = \"src/main.rs\" @@ -317,7 +317,7 @@ This can be done by setting the binary filename to `src/bin/test.rs` \ or change the name in Cargo.toml with: - [bin] + [[bin]] name = \"test\" path = \"src/main.rs\" diff -Nru cargo-0.57.0+ubuntu/tests/testsuite/lto.rs cargo-0.58.0/tests/testsuite/lto.rs --- cargo-0.57.0+ubuntu/tests/testsuite/lto.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/tests/testsuite/lto.rs 2021-10-21 14:30:11.000000000 +0000 @@ -351,6 +351,15 @@ .run(); } +/// Basic setup: +/// +/// foo v0.0.0 +/// ├── bar v0.0.0 +/// │ ├── registry v0.0.1 +/// │ └── registry-shared v0.0.1 +/// └── registry-shared v0.0.1 +/// +/// Where `bar` will have the given crate types. fn project_with_dep(crate_types: &str) -> Project { Package::new("registry", "0.0.1") .file("src/lib.rs", r#"pub fn foo() { println!("registry"); }"#) @@ -419,6 +428,10 @@ .build() } +/// Helper for checking which LTO behavior is used for a specific crate. +/// +/// `krate_info` is extra compiler flags used to distinguish this if the same +/// crate name is being built multiple times. fn verify_lto(output: &Output, krate: &str, krate_info: &str, expected_lto: Lto) { let stderr = std::str::from_utf8(&output.stderr).unwrap(); let mut matches = stderr.lines().filter(|line| { @@ -467,18 +480,22 @@ fn cdylib_and_rlib() { let p = project_with_dep("'cdylib', 'rlib'"); let output = p.cargo("build --release -v").exec_with_output().unwrap(); + // `registry` is ObjectAndBitcode because because it needs Object for the + // rlib, and Bitcode for the cdylib (which doesn't support LTO). verify_lto( &output, "registry", "--crate-type lib", Lto::ObjectAndBitcode, ); + // Same as `registry` verify_lto( &output, "registry_shared", "--crate-type lib", Lto::ObjectAndBitcode, ); + // Same as `registry` verify_lto( &output, "bar", @@ -493,8 +510,8 @@ [FRESH] registry-shared v0.0.1 [FRESH] bar v0.0.0 [..] [COMPILING] foo [..] -[RUNNING] `rustc --crate-name foo [..]-C embed-bitcode=no [..]--test[..] -[RUNNING] `rustc --crate-name a [..]-C embed-bitcode=no [..]--test[..] +[RUNNING] `rustc --crate-name foo [..]-C lto [..]--test[..] +[RUNNING] `rustc --crate-name a [..]-C lto [..]--test[..] [FINISHED] [..] [RUNNING] [..] [RUNNING] [..] @@ -514,19 +531,16 @@ p.cargo("test --release -v --manifest-path bar/Cargo.toml") .with_stderr_unordered( "\ -[COMPILING] registry v0.0.1 -[COMPILING] registry-shared v0.0.1 -[RUNNING] `rustc --crate-name registry [..]-C embed-bitcode=no[..] -[RUNNING] `rustc --crate-name registry_shared [..]-C embed-bitcode=no[..] +[FRESH] registry-shared v0.0.1 +[FRESH] registry v0.0.1 [COMPILING] bar [..] -[RUNNING] `rustc --crate-name bar [..]--crate-type cdylib --crate-type rlib [..]-C embed-bitcode=no[..] -[RUNNING] `rustc --crate-name bar [..]-C embed-bitcode=no [..]--test[..] -[RUNNING] `rustc --crate-name b [..]-C embed-bitcode=no [..]--test[..] +[RUNNING] `rustc --crate-name bar [..]-C lto[..]--test[..] +[RUNNING] `rustc --crate-name b [..]-C lto[..]--test[..] [FINISHED] [..] [RUNNING] [..]target/release/deps/bar-[..] [RUNNING] [..]target/release/deps/b-[..] [DOCTEST] bar -[RUNNING] `rustdoc --crate-type cdylib --crate-type rlib --crate-name bar --test [..]-C embed-bitcode=no[..] +[RUNNING] `rustdoc --crate-type cdylib --crate-type rlib --crate-name bar --test [..]-C lto[..] ", ) .run(); @@ -536,15 +550,23 @@ fn dylib() { let p = project_with_dep("'dylib'"); let output = p.cargo("build --release -v").exec_with_output().unwrap(); + // `registry` is OnlyObject because rustc doesn't support LTO with dylibs. verify_lto(&output, "registry", "--crate-type lib", Lto::OnlyObject); + // `registry_shared` is both because it is needed by both bar (Object) and + // foo (Bitcode for LTO). verify_lto( &output, "registry_shared", "--crate-type lib", Lto::ObjectAndBitcode, ); + // `bar` is OnlyObject because rustc doesn't support LTO with dylibs. verify_lto(&output, "bar", "--crate-type dylib", Lto::OnlyObject); + // `foo` is LTO because it is a binary, and the profile specifies `lto=true`. verify_lto(&output, "foo", "--crate-type bin", Lto::Run(None)); + // `cargo test` should not rebuild dependencies. It builds the test + // executables with `lto=true` because the tests are built with the + // `--release` flag. p.cargo("test --release -v") .with_stderr_unordered( "\ @@ -552,14 +574,19 @@ [FRESH] registry-shared v0.0.1 [FRESH] bar v0.0.0 [..] [COMPILING] foo [..] -[RUNNING] `rustc --crate-name foo [..]-C embed-bitcode=no [..]--test[..] -[RUNNING] `rustc --crate-name a [..]-C embed-bitcode=no [..]--test[..] +[RUNNING] `rustc --crate-name foo [..]-C lto [..]--test[..] +[RUNNING] `rustc --crate-name a [..]-C lto [..]--test[..] [FINISHED] [..] [RUNNING] [..] [RUNNING] [..] ", ) .run(); + // Building just `bar` causes `registry-shared` to get rebuilt because it + // switches to OnlyObject because it is now only being used with a dylib + // which does not support LTO. + // + // `bar` gets rebuilt because `registry_shared` got rebuilt. p.cargo("build --release -v --manifest-path bar/Cargo.toml") .with_stderr_unordered( "\ @@ -572,14 +599,21 @@ ", ) .run(); + // Testing just `bar` causes `registry` to get rebuilt because it switches + // to needing both Object (for the `bar` dylib) and Bitcode (for the test + // built with LTO). + // + // `bar` the dylib gets rebuilt because `registry` got rebuilt. p.cargo("test --release -v --manifest-path bar/Cargo.toml") .with_stderr_unordered( "\ [FRESH] registry-shared v0.0.1 -[FRESH] registry v0.0.1 +[COMPILING] registry v0.0.1 +[RUNNING] `rustc --crate-name registry [..] [COMPILING] bar [..] -[RUNNING] `rustc --crate-name bar [..]-C embed-bitcode=no [..]--test[..] -[RUNNING] `rustc --crate-name b [..]-C embed-bitcode=no [..]--test[..] +[RUNNING] `rustc --crate-name bar [..]--crate-type dylib [..]-C embed-bitcode=no[..] +[RUNNING] `rustc --crate-name bar [..]-C lto [..]--test[..] +[RUNNING] `rustc --crate-name b [..]-C lto [..]--test[..] [FINISHED] [..] [RUNNING] [..] [RUNNING] [..] @@ -641,59 +675,6 @@ } #[cargo_test] -fn dev_profile() { - // Mixing dev=LTO with test=not-LTO - Package::new("bar", "0.0.1") - .file("src/lib.rs", "pub fn foo() -> i32 { 123 } ") - .publish(); - - let p = project() - .file( - "Cargo.toml", - r#" - [package] - name = "foo" - version = "0.1.0" - edition = "2018" - - [profile.dev] - lto = 'thin' - - [dependencies] - bar = "*" - "#, - ) - .file( - "src/lib.rs", - r#" - #[test] - fn t1() { - assert_eq!(123, bar::foo()); - } - "#, - ) - .build(); - - p.cargo("test -v") - // unordered because the two `foo` builds start in parallel - .with_stderr_unordered("\ -[UPDATING] [..] -[DOWNLOADING] [..] -[DOWNLOADED] [..] -[COMPILING] bar v0.0.1 -[RUNNING] `rustc --crate-name bar [..]crate-type lib[..] -[COMPILING] foo [..] -[RUNNING] `rustc --crate-name foo [..]--crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no [..] -[RUNNING] `rustc --crate-name foo [..]--emit=dep-info,link -C embed-bitcode=no [..]--test[..] -[FINISHED] [..] -[RUNNING] [..] -[DOCTEST] foo -[RUNNING] `rustdoc [..] -") - .run(); -} - -#[cargo_test] fn doctest() { let p = project() .file( @@ -732,18 +713,24 @@ .build(); p.cargo("test --doc --release -v") - .with_stderr_contains("[..]`rustc --crate-name bar[..]-C embed-bitcode=no[..]") - .with_stderr_contains("[..]`rustc --crate-name foo[..]-C embed-bitcode=no[..]") + .with_stderr_contains("[..]`rustc --crate-name bar[..]-C linker-plugin-lto[..]") + .with_stderr_contains("[..]`rustc --crate-name foo[..]-C linker-plugin-lto[..]") // embed-bitcode should be harmless here - .with_stderr_contains("[..]`rustdoc [..]-C embed-bitcode=no[..]") + .with_stderr_contains("[..]`rustdoc [..]-C lto[..]") .run(); // Try with bench profile. p.cargo("test --doc --release -v") .env("CARGO_PROFILE_BENCH_LTO", "true") - .with_stderr_contains("[..]`rustc --crate-name bar[..]-C linker-plugin-lto[..]") - .with_stderr_contains("[..]`rustc --crate-name foo[..]-C linker-plugin-lto[..]") - .with_stderr_contains("[..]`rustdoc [..]-C lto[..]") + .with_stderr_unordered( + "\ +[FRESH] bar v0.1.0 [..] +[FRESH] foo v0.1.0 [..] +[FINISHED] release [..] +[DOCTEST] foo +[RUNNING] `rustdoc [..]-C lto[..] +", + ) .run(); } @@ -821,15 +808,13 @@ p.cargo("test --release -v") .with_stderr_unordered( "\ -[COMPILING] bar v1.0.0 -[RUNNING] `rustc --crate-name bar [..]-C embed-bitcode=no[..] +[FRESH] bar v1.0.0 [COMPILING] foo v0.1.0 [..] -[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib[..]-C embed-bitcode=no[..] -[RUNNING] `rustc --crate-name foo src/lib.rs [..]-C embed-bitcode=no[..]--test[..] +[RUNNING] `rustc --crate-name foo src/lib.rs [..]-C lto[..]--test[..] [FINISHED] [..] [RUNNING] `[..]/foo[..]` [DOCTEST] foo -[RUNNING] `rustdoc [..]-C embed-bitcode=no[..] +[RUNNING] `rustdoc [..]-C lto[..] ", ) .run(); diff -Nru cargo-0.57.0+ubuntu/tests/testsuite/new.rs cargo-0.58.0/tests/testsuite/new.rs --- cargo-0.57.0+ubuntu/tests/testsuite/new.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/tests/testsuite/new.rs 2021-10-21 14:30:11.000000000 +0000 @@ -121,7 +121,7 @@ This can be done by setting the binary filename to `src/bin/foo.rs.rs` \ or change the name in Cargo.toml with: - [bin] + [[bin]] name = \"foo.rs\" path = \"src/main.rs\" @@ -143,7 +143,7 @@ This can be done by setting the binary filename to `src/bin/test.rs` \ or change the name in Cargo.toml with: - [bin] + [[bin]] name = \"test\" path = \"src/main.rs\" @@ -188,7 +188,7 @@ This can be done by setting the binary filename to `src/bin/pub.rs` \ or change the name in Cargo.toml with: - [bin] + [[bin]] name = \"pub\" path = \"src/main.rs\" @@ -210,7 +210,7 @@ This can be done by setting the binary filename to `src/bin/core.rs` \ or change the name in Cargo.toml with: - [bin] + [[bin]] name = \"core\" path = \"src/main.rs\" @@ -322,7 +322,7 @@ This can be done by setting the binary filename to `src/bin/10-invalid.rs` \ or change the name in Cargo.toml with: - [bin] + [[bin]] name = \"10-invalid\" path = \"src/main.rs\" @@ -443,7 +443,7 @@ This can be done by setting the binary filename to `src/bin/ⒶⒷⒸ.rs` \ or change the name in Cargo.toml with: - [bin] + [[bin]] name = \"ⒶⒷⒸ\" path = \"src/main.rs\" @@ -463,7 +463,7 @@ This can be done by setting the binary filename to `src/bin/a¼.rs` \ or change the name in Cargo.toml with: - [bin] + [[bin]] name = \"a¼\" path = \"src/main.rs\" diff -Nru cargo-0.57.0+ubuntu/tests/testsuite/package.rs cargo-0.58.0/tests/testsuite/package.rs --- cargo-0.57.0+ubuntu/tests/testsuite/package.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/tests/testsuite/package.rs 2021-10-21 14:30:11.000000000 +0000 @@ -140,8 +140,8 @@ let repo = git::repo(&root) .file("Cargo.toml", &basic_manifest("foo", "0.0.1")) .file("src/main.rs", "fn main() {}") - .file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) - .file("a/src/lib.rs", "") + .file("a/a/Cargo.toml", &basic_manifest("a", "0.0.1")) + .file("a/a/src/lib.rs", "") .build(); cargo_process("build").cwd(repo.root()).run(); @@ -167,7 +167,8 @@ r#"{{ "git": {{ "sha1": "{}" - }} + }}, + "path_in_vcs": "" }} "#, repo.revparse_head() @@ -187,7 +188,7 @@ println!("package sub-repo"); cargo_process("package -v --no-verify") - .cwd(repo.root().join("a")) + .cwd(repo.root().join("a/a")) .with_stderr( "\ [WARNING] manifest has no description[..] @@ -200,6 +201,29 @@ ", ) .run(); + + let f = File::open(&repo.root().join("a/a/target/package/a-0.0.1.crate")).unwrap(); + let vcs_contents = format!( + r#"{{ + "git": {{ + "sha1": "{}" + }}, + "path_in_vcs": "a/a" +}} +"#, + repo.revparse_head() + ); + validate_crate_contents( + f, + "a-0.0.1.crate", + &[ + "Cargo.toml", + "Cargo.toml.orig", + "src/lib.rs", + ".cargo_vcs_info.json", + ], + &[(".cargo_vcs_info.json", &vcs_contents)], + ); } #[cargo_test] diff -Nru cargo-0.57.0+ubuntu/tests/testsuite/profile_config.rs cargo-0.58.0/tests/testsuite/profile_config.rs --- cargo-0.57.0+ubuntu/tests/testsuite/profile_config.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/tests/testsuite/profile_config.rs 2021-10-21 14:30:11.000000000 +0000 @@ -5,41 +5,6 @@ use cargo_test_support::{basic_lib_manifest, paths, project}; #[cargo_test] -fn named_profile_gated() { - // Named profile in config requires enabling in Cargo.toml. - let p = project() - .file("src/lib.rs", "") - .file( - ".cargo/config", - r#" - [profile.foo] - inherits = 'dev' - opt-level = 1 - "#, - ) - .build(); - p.cargo("build --profile foo -Zunstable-options") - .masquerade_as_nightly_cargo() - .with_stderr( - "\ -[ERROR] config profile `foo` is not valid (defined in `[..]/foo/.cargo/config`) - -Caused by: - feature `named-profiles` is required - - The package requires the Cargo feature called `named-profiles`, \ - but that feature is not stabilized in this version of Cargo (1.[..]). - Consider adding `cargo-features = [\"named-profiles\"]` to the top of Cargo.toml \ - (above the [package] table) to tell Cargo you are opting in to use this unstable feature. - See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#custom-named-profiles \ - for more information about the status of this feature. -", - ) - .with_status(101) - .run(); -} - -#[cargo_test] fn profile_config_validate_warnings() { let p = project() .file("Cargo.toml", &basic_lib_manifest("foo")) @@ -378,8 +343,6 @@ fs::write( paths::root().join("Cargo.toml"), r#" - cargo-features = ['named-profiles'] - [workspace] [profile.middle] @@ -397,7 +360,7 @@ "#, ) .unwrap(); - let config = ConfigBuilder::new().nightly_features_allowed(true).build(); + let config = ConfigBuilder::new().build(); let profile_name = InternedString::new("foo"); let ws = Workspace::new(&paths::root().join("Cargo.toml"), &config).unwrap(); let profiles = Profiles::new(&ws, profile_name).unwrap(); @@ -443,7 +406,6 @@ .file( "Cargo.toml", r#" - cargo-features = ["named-profiles"] [package] name = "foo" version = "0.1.0" @@ -452,8 +414,7 @@ .file("src/lib.rs", "") .build(); - p.cargo("build -v -Zunstable-options --profile=other") - .masquerade_as_nightly_cargo() + p.cargo("build -v --profile=other") .env("CARGO_PROFILE_OTHER_CODEGEN_UNITS", "1") .env("CARGO_PROFILE_OTHER_INHERITS", "dev") .with_stderr_contains("[..]-C codegen-units=1 [..]") @@ -462,7 +423,8 @@ #[cargo_test] fn test_with_dev_profile() { - // `cargo test` uses "dev" profile for dependencies. + // The `test` profile inherits from `dev` for both local crates and + // dependencies. Package::new("somedep", "1.0.0").publish(); let p = project() .file( @@ -488,7 +450,7 @@ [COMPILING] somedep v1.0.0 [RUNNING] `rustc --crate-name somedep [..]-C debuginfo=0[..] [COMPILING] foo v0.1.0 [..] -[RUNNING] `rustc --crate-name foo [..]-C debuginfo=2[..] +[RUNNING] `rustc --crate-name foo [..]-C debuginfo=0[..] [FINISHED] [..] ", ) diff -Nru cargo-0.57.0+ubuntu/tests/testsuite/profile_custom.rs cargo-0.58.0/tests/testsuite/profile_custom.rs --- cargo-0.57.0+ubuntu/tests/testsuite/profile_custom.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/tests/testsuite/profile_custom.rs 2021-10-21 14:30:11.000000000 +0000 @@ -4,30 +4,11 @@ use cargo_test_support::{basic_lib_manifest, project}; #[cargo_test] -fn gated() { - let p = project().file("src/lib.rs", "").build(); - // `rustc`, `fix`, and `check` have had `--profile` before custom named profiles. - // Without unstable, these shouldn't be allowed to access non-legacy names. - for command in [ - "rustc", "fix", "check", "bench", "clean", "install", "test", "build", "doc", "run", - "rustdoc", - ] { - p.cargo(command) - .arg("--profile=release") - .with_status(101) - .with_stderr("error: usage of `--profile` requires `-Z unstable-options`") - .run(); - } -} - -#[cargo_test] fn inherits_on_release() { let p = project() .file( "Cargo.toml", r#" - cargo-features = ["named-profiles"] - [package] name = "foo" version = "0.0.1" @@ -41,7 +22,6 @@ .build(); p.cargo("build") - .masquerade_as_nightly_cargo() .with_status(101) .with_stderr( "\ @@ -57,8 +37,6 @@ .file( "Cargo.toml", r#" - cargo-features = ["named-profiles"] - [package] name = "foo" version = "0.0.1" @@ -72,7 +50,6 @@ .build(); p.cargo("build") - .masquerade_as_nightly_cargo() .with_status(101) .with_stderr( "\ @@ -89,8 +66,6 @@ .file( "Cargo.toml", r#" - cargo-features = ["named-profiles"] - [package] name = "foo" version = "0.0.1" @@ -105,7 +80,6 @@ .build(); p.cargo("build") - .masquerade_as_nightly_cargo() .with_status(101) .with_stderr( "\ @@ -126,8 +100,6 @@ .file( "Cargo.toml", r#" - cargo-features = ["named-profiles"] - [package] name = "foo" version = "0.0.1" @@ -143,7 +115,6 @@ .build(); p.cargo("build") - .masquerade_as_nightly_cargo() .with_status(101) .with_stderr( "\ @@ -161,8 +132,6 @@ .file( "Cargo.toml", r#" - cargo-features = ["named-profiles"] - [package] name = "foo" version = "0.1.0" @@ -177,7 +146,6 @@ .build(); p.cargo("build") - .masquerade_as_nightly_cargo() .with_status(101) .with_stderr( "\ @@ -197,8 +165,6 @@ .file( "Cargo.toml", r#" - cargo-features = ["named-profiles"] - [package] name = "foo" version = "0.0.1" @@ -213,7 +179,6 @@ .build(); p.cargo("build") - .masquerade_as_nightly_cargo() .with_status(101) .with_stderr( "error: profile `release-lto` inherits from `.release`, \ @@ -228,8 +193,6 @@ .file( "Cargo.toml", r#" - cargo-features = ["named-profiles"] - [package] name = "foo" version = "0.0.1" @@ -244,7 +207,6 @@ .build(); p.cargo("build") - .masquerade_as_nightly_cargo() .with_status(101) .with_stderr( "\ @@ -260,8 +222,6 @@ .file( "Cargo.toml", r#" - cargo-features = ["named-profiles"] - [package] name = "foo" version = "0.0.1" @@ -276,7 +236,6 @@ .build(); p.cargo("build") - .masquerade_as_nightly_cargo() .with_status(101) .with_stderr( "\ @@ -292,8 +251,6 @@ .file( "Cargo.toml", r#" - cargo-features = ["named-profiles"] - [package] name = "foo" version = "0.0.1" @@ -312,7 +269,6 @@ .build(); p.cargo("build") - .masquerade_as_nightly_cargo() .with_status(101) .with_stderr( "\ @@ -328,8 +284,6 @@ .file( "Cargo.toml", r#" - cargo-features = ["named-profiles"] - [package] name = "foo" version = "0.0.1" @@ -365,7 +319,6 @@ // profile overrides are inherited between profiles using inherits and have a // higher priority than profile options provided by custom profiles p.cargo("build -v") - .masquerade_as_nightly_cargo() .with_stderr_unordered( "\ [COMPILING] xxx [..] @@ -380,8 +333,7 @@ .run(); // This also verifies that the custom profile names appears in the finished line. - p.cargo("build --profile=other -Z unstable-options -v") - .masquerade_as_nightly_cargo() + p.cargo("build --profile=other -v") .with_stderr_unordered( "\ [COMPILING] xxx [..] @@ -408,11 +360,44 @@ authors = [] "#, ) - .file("src/lib.rs", "") + .file("src/main.rs", "fn main() {}") .build(); - p.cargo("build -Z unstable-options --profile=dev --release") - .masquerade_as_nightly_cargo() + p.cargo("build --profile=dev --release") + .with_status(101) + .with_stderr( + "\ +error: conflicting usage of --profile=dev and --release +The `--release` flag is the same as `--profile=release`. +Remove one flag or the other to continue. +", + ) + .run(); + + p.cargo("install --profile=release --debug") + .with_status(101) + .with_stderr( + "\ +error: conflicting usage of --profile=release and --debug +The `--debug` flag is the same as `--profile=dev`. +Remove one flag or the other to continue. +", + ) + .run(); + + p.cargo("rustc --profile=dev --release") + .with_stderr( + "\ +warning: the `--release` flag should not be specified with the `--profile` flag +The `--release` flag will be ignored. +This was historically accepted, but will become an error in a future release. +[COMPILING] foo [..] +[FINISHED] dev [..] +", + ) + .run(); + + p.cargo("check --profile=dev --release") .with_status(101) .with_stderr( "\ @@ -423,8 +408,49 @@ ) .run(); - p.cargo("install -Z unstable-options --profile=release --debug") - .masquerade_as_nightly_cargo() + p.cargo("check --profile=test --release") + .with_stderr( + "\ +warning: the `--release` flag should not be specified with the `--profile` flag +The `--release` flag will be ignored. +This was historically accepted, but will become an error in a future release. +[CHECKING] foo [..] +[FINISHED] test [..] +", + ) + .run(); + + // This is OK since the two are the same. + p.cargo("rustc --profile=release --release") + .with_stderr( + "\ +[COMPILING] foo [..] +[FINISHED] release [..] +", + ) + .run(); + + p.cargo("build --profile=release --release") + .with_stderr( + "\ +[FINISHED] release [..] +", + ) + .run(); + + p.cargo("install --path . --profile=dev --debug") + .with_stderr( + "\ +[INSTALLING] foo [..] +[FINISHED] dev [..] +[INSTALLING] [..] +[INSTALLED] [..] +[WARNING] be sure to add [..] +", + ) + .run(); + + p.cargo("install --path . --profile=release --debug") .with_status(101) .with_stderr( "\ @@ -442,8 +468,6 @@ .file( "Cargo.toml", r#" - cargo-features = ["named-profiles"] - [package] name = "foo" version = "0.0.1" @@ -457,7 +481,6 @@ .build(); p.cargo("build --release") - .masquerade_as_nightly_cargo() .with_stdout("") .with_stderr( "\ @@ -470,7 +493,6 @@ p.cargo("clean -p foo").masquerade_as_nightly_cargo().run(); p.cargo("build --release") - .masquerade_as_nightly_cargo() .with_stdout("") .with_stderr( "\ @@ -479,12 +501,9 @@ ) .run(); - p.cargo("clean -p foo --release") - .masquerade_as_nightly_cargo() - .run(); + p.cargo("clean -p foo --release").run(); p.cargo("build --release") - .masquerade_as_nightly_cargo() .with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -494,7 +513,6 @@ .run(); p.cargo("build") - .masquerade_as_nightly_cargo() .with_stdout("") .with_stderr( "\ @@ -504,8 +522,7 @@ ) .run(); - p.cargo("build -Z unstable-options --profile=other") - .masquerade_as_nightly_cargo() + p.cargo("build --profile=other") .with_stderr( "\ [COMPILING] foo v0.0.1 ([..]) @@ -514,10 +531,7 @@ ) .run(); - p.cargo("clean") - .arg("--release") - .masquerade_as_nightly_cargo() - .run(); + p.cargo("clean").arg("--release").run(); // Make sure that 'other' was not cleaned assert!(p.build_dir().is_dir()); @@ -526,10 +540,7 @@ assert!(!p.build_dir().join("release").is_dir()); // This should clean 'other' - p.cargo("clean -Z unstable-options --profile=other") - .masquerade_as_nightly_cargo() - .with_stderr("") - .run(); + p.cargo("clean --profile=other").with_stderr("").run(); assert!(p.build_dir().join("debug").is_dir()); assert!(!p.build_dir().join("other").is_dir()); } @@ -540,8 +551,6 @@ .file( "Cargo.toml", r#" - cargo-features = ["named-profiles"] - [package] name = "foo" version = "0.0.1" @@ -550,14 +559,12 @@ .file("src/lib.rs", "") .build(); - p.cargo("build --profile alpha -Zunstable-options") - .masquerade_as_nightly_cargo() + p.cargo("build --profile alpha") .with_stderr("[ERROR] profile `alpha` is not defined") .with_status(101) .run(); // Clean has a separate code path, need to check it too. - p.cargo("clean --profile alpha -Zunstable-options") - .masquerade_as_nightly_cargo() + p.cargo("clean --profile alpha") .with_stderr("[ERROR] profile `alpha` is not defined") .with_status(101) .run(); @@ -580,15 +587,13 @@ .file("src/lib.rs", "") .build(); - p.cargo("build --profile=doc -Zunstable-options") - .masquerade_as_nightly_cargo() + p.cargo("build --profile=doc") .with_status(101) .with_stderr("error: profile `doc` is reserved and not allowed to be explicitly specified") .run(); // Not an exhaustive list, just a sample. for name in ["build", "cargo", "check", "rustc", "CaRgO_startswith"] { - p.cargo(&format!("build --profile={} -Zunstable-options", name)) - .masquerade_as_nightly_cargo() + p.cargo(&format!("build --profile={}", name)) .with_status(101) .with_stderr(&format!( "\ @@ -605,8 +610,6 @@ "Cargo.toml", &format!( r#" - cargo-features = ["named-profiles"] - [package] name = "foo" version = "0.1.0" @@ -619,7 +622,6 @@ ); p.cargo("build") - .masquerade_as_nightly_cargo() .with_status(101) .with_stderr(&format!( "\ @@ -638,8 +640,6 @@ p.change_file( "Cargo.toml", r#" - cargo-features = ["named-profiles"] - [package] name = "foo" version = "0.1.0" @@ -652,7 +652,6 @@ ); p.cargo("build") - .masquerade_as_nightly_cargo() .with_status(101) .with_stderr( "\ @@ -674,8 +673,6 @@ .file( "Cargo.toml", r#" - cargo-features = ["named-profiles"] - [package] name = "foo" version = "0.1.0" @@ -694,9 +691,7 @@ pb.arg("--allow-no-vcs"); } pb.arg("--profile=super-dev") - .arg("-Zunstable-options") .arg("-v") - .masquerade_as_nightly_cargo() .with_stderr_contains("[RUNNING] [..]codegen-units=3[..]") .run(); p.build_dir().rm_rf(); diff -Nru cargo-0.57.0+ubuntu/tests/testsuite/profiles.rs cargo-0.58.0/tests/testsuite/profiles.rs --- cargo-0.57.0+ubuntu/tests/testsuite/profiles.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/tests/testsuite/profiles.rs 2021-10-21 14:30:11.000000000 +0000 @@ -470,8 +470,6 @@ } #[cargo_test] -// Strip doesn't work on macos. -#[cfg_attr(target_os = "macos", ignore)] fn strip_works() { if !is_nightly() { // -Zstrip is unstable diff -Nru cargo-0.57.0+ubuntu/tests/testsuite/profile_targets.rs cargo-0.58.0/tests/testsuite/profile_targets.rs --- cargo-0.57.0+ubuntu/tests/testsuite/profile_targets.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/tests/testsuite/profile_targets.rs 2021-10-21 14:30:11.000000000 +0000 @@ -2,7 +2,7 @@ //! example, the `test` profile applying to test targets, but not other //! targets, etc. -use cargo_test_support::{basic_manifest, is_nightly, project, Project}; +use cargo_test_support::{basic_manifest, project, Project}; fn all_target_project() -> Project { // This abuses the `codegen-units` setting so that we can verify exactly @@ -10,41 +10,32 @@ project() .file( "Cargo.toml", - &format!( - r#" - cargo-features = [{named_profiles}] - - [package] - name = "foo" - version = "0.0.1" - - [dependencies] - bar = {{ path = "bar" }} - - [build-dependencies] - bdep = {{ path = "bdep" }} - - [profile.dev] - codegen-units = 1 - panic = "abort" - [profile.release] - codegen-units = 2 - panic = "abort" - [profile.test] - codegen-units = 3 - [profile.bench] - codegen-units = 4 - [profile.dev.build-override] - codegen-units = 5 - [profile.release.build-override] - codegen-units = 6 - "#, - named_profiles = if is_nightly() { - "\"named-profiles\", " - } else { - "" - } - ), + r#" + [package] + name = "foo" + version = "0.0.1" + + [dependencies] + bar = { path = "bar" } + + [build-dependencies] + bdep = { path = "bdep" } + + [profile.dev] + codegen-units = 1 + panic = "abort" + [profile.release] + codegen-units = 2 + panic = "abort" + [profile.test] + codegen-units = 3 + [profile.bench] + codegen-units = 4 + [profile.dev.build-override] + codegen-units = 5 + [profile.release.build-override] + codegen-units = 6 + "#, ) .file("src/lib.rs", "extern crate bar;") .file("src/main.rs", "extern crate foo; fn main() {}") @@ -91,7 +82,7 @@ // NOTES: // - bdep `panic` is not set because it thinks `build.rs` is a plugin. // - build_script_build is built without panic because it thinks `build.rs` is a plugin. - p.cargo("build -vv").masquerade_as_nightly_cargo().with_stderr_unordered("\ + p.cargo("build -vv").with_stderr_unordered("\ [COMPILING] bar [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] @@ -106,7 +97,6 @@ [FINISHED] dev [unoptimized + debuginfo] [..] ").run(); p.cargo("build -vv") - .masquerade_as_nightly_cargo() .with_stderr_unordered( "\ [FRESH] bar [..] @@ -123,7 +113,7 @@ let p = all_target_project(); // `build --release` - p.cargo("build --release -vv").masquerade_as_nightly_cargo().with_stderr_unordered("\ + p.cargo("build --release -vv").with_stderr_unordered("\ [COMPILING] bar [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..] @@ -138,7 +128,6 @@ [FINISHED] release [optimized] [..] ").run(); p.cargo("build --release -vv") - .masquerade_as_nightly_cargo() .with_stderr_unordered( "\ [FRESH] bar [..] @@ -153,7 +142,6 @@ #[cargo_test] fn profile_selection_build_all_targets() { let p = all_target_project(); - let affected = if is_nightly() { 1 } else { 3 }; // `build` // NOTES: // - bdep `panic` is not set because it thinks `build.rs` is a plugin. @@ -181,7 +169,7 @@ // bin dev dev // bin dev build // example dev build - p.cargo("build --all-targets -vv").masquerade_as_nightly_cargo().with_stderr_unordered(format!("\ + p.cargo("build --all-targets -vv").with_stderr_unordered("\ [COMPILING] bar [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..] @@ -193,17 +181,16 @@ [RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build` [foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0 [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]` -[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link[..]-C codegen-units={affected} -C debuginfo=2 --test [..]` +[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 --test [..]` [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 [..]` -[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]-C codegen-units={affected} -C debuginfo=2 --test [..]` -[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link[..]-C codegen-units={affected} -C debuginfo=2 --test [..]` -[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link[..]-C codegen-units={affected} -C debuginfo=2 --test [..]` +[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 --test [..]` +[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 --test [..]` +[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link[..]-C codegen-units=1 -C debuginfo=2 --test [..]` [RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]` [RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link -C panic=abort[..]-C codegen-units=1 -C debuginfo=2 [..]` [FINISHED] dev [unoptimized + debuginfo] [..] -", affected=affected)).run(); +").run(); p.cargo("build -vv") - .masquerade_as_nightly_cargo() .with_stderr_unordered( "\ [FRESH] bar [..] @@ -218,7 +205,6 @@ #[cargo_test] fn profile_selection_build_all_targets_release() { let p = all_target_project(); - let affected = if is_nightly() { 2 } else { 4 }; // `build --all-targets --release` // NOTES: // - bdep `panic` is not set because it thinks `build.rs` is a plugin. @@ -249,7 +235,7 @@ // bin release test (bench/test de-duped) // bin release build // example release build - p.cargo("build --all-targets --release -vv").masquerade_as_nightly_cargo().with_stderr_unordered(format!("\ + p.cargo("build --all-targets --release -vv").with_stderr_unordered("\ [COMPILING] bar [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units=2 [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..] @@ -261,17 +247,16 @@ [RUNNING] `[..]/target/release/build/foo-[..]/build-script-build` [foo 0.0.1] foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3 [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]` -[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units={affected} --test [..]` +[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..]` [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units=2 [..]` -[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units={affected} --test [..]` -[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units={affected} --test [..]` -[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units={affected} --test [..]` +[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..]` +[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..]` +[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..]` [RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]` [RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..]` [FINISHED] release [optimized] [..] -", affected=affected)).run(); +").run(); p.cargo("build --all-targets --release -vv") - .masquerade_as_nightly_cargo() .with_stderr_unordered( "\ [FRESH] bar [..] @@ -286,7 +271,6 @@ #[cargo_test] fn profile_selection_test() { let p = all_target_project(); - let affected = if is_nightly() { 3 } else { 1 }; // `test` // NOTES: // - Dependency profiles: @@ -308,33 +292,32 @@ // bin test test // bin test build // - p.cargo("test -vv").masquerade_as_nightly_cargo().with_stderr_unordered(format!("\ + p.cargo("test -vv").with_stderr_unordered("\ [COMPILING] bar [..] -[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units={affected} -C debuginfo=2 [..] +[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] -[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units={affected} -C debuginfo=2 [..] +[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=3 -C debuginfo=2 [..] [COMPILING] bdep [..] [RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] [COMPILING] foo [..] [RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] [RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build` [foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0 -[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units={affected} -C debuginfo=2 [..] -[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units={affected} -C debuginfo=2 [..] +[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C panic=abort[..]-C codegen-units=3 -C debuginfo=2 [..] +[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 [..] [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 --test [..] [RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 --test [..] -[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units={affected} -C debuginfo=2 [..] +[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 [..] [RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link[..]-C codegen-units=3 -C debuginfo=2 --test [..] -[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C panic=abort[..]-C codegen-units={affected} -C debuginfo=2 [..] +[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C panic=abort[..]-C codegen-units=3 -C debuginfo=2 [..] [FINISHED] test [unoptimized + debuginfo] [..] [RUNNING] `[..]/deps/foo-[..]` [RUNNING] `[..]/deps/foo-[..]` [RUNNING] `[..]/deps/test1-[..]` [DOCTEST] foo [RUNNING] `rustdoc [..]--test [..] -", affected=affected)).run(); +").run(); p.cargo("test -vv") - .masquerade_as_nightly_cargo() .with_stderr_unordered( "\ [FRESH] bar [..] @@ -354,7 +337,6 @@ #[cargo_test] fn profile_selection_test_release() { let p = all_target_project(); - let affected = if is_nightly() { 2 } else { 4 }; // `test --release` // NOTES: @@ -377,7 +359,7 @@ // bin release test // bin release build // - p.cargo("test --release -vv").masquerade_as_nightly_cargo().with_stderr_unordered(format!("\ + p.cargo("test --release -vv").with_stderr_unordered("\ [COMPILING] bar [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..] @@ -390,9 +372,9 @@ [foo 0.0.1] foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3 [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..] [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units=2 [..] -[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units={affected} --test [..] -[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units={affected} --test [..] -[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units={affected} --test [..] +[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..] +[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..] +[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=2 --test [..] [RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--crate-type bin --emit=[..]link -C opt-level=3[..]-C codegen-units=2 [..] [RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=2 [..] [FINISHED] release [optimized] [..] @@ -401,9 +383,8 @@ [RUNNING] `[..]/deps/test1-[..]` [DOCTEST] foo [RUNNING] `rustdoc [..]--test [..]` -", affected=affected)).run(); +").run(); p.cargo("test --release -vv") - .masquerade_as_nightly_cargo() .with_stderr_unordered( "\ [FRESH] bar [..] @@ -423,7 +404,6 @@ #[cargo_test] fn profile_selection_bench() { let p = all_target_project(); - let affected = if is_nightly() { 4 } else { 2 }; // `bench` // NOTES: @@ -445,10 +425,10 @@ // bin bench test(bench) // bin bench build // - p.cargo("bench -vv").masquerade_as_nightly_cargo().with_stderr_unordered(format!("\ + p.cargo("bench -vv").with_stderr_unordered("\ [COMPILING] bar [..] -[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units={affected} [..] -[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units={affected} [..] +[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units=4 [..] +[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=4 [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..] [COMPILING] bdep [..] [RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..] @@ -456,19 +436,18 @@ [RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=6 [..] [RUNNING] `[..]target/release/build/foo-[..]/build-script-build` [foo 0.0.1] foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3 -[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units={affected} [..] -[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units={affected} [..] +[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=4 [..] +[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link -C opt-level=3[..]-C codegen-units=4 [..] [RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=4 --test [..] [RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=4 --test [..] [RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]link -C opt-level=3[..]-C codegen-units=4 --test [..] -[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units={affected} [..] +[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=[..]link -C opt-level=3 -C panic=abort[..]-C codegen-units=4 [..] [FINISHED] bench [optimized] [..] [RUNNING] `[..]/deps/foo-[..] --bench` [RUNNING] `[..]/deps/foo-[..] --bench` [RUNNING] `[..]/deps/bench1-[..] --bench` -", affected=affected)).run(); +").run(); p.cargo("bench -vv") - .masquerade_as_nightly_cargo() .with_stderr_unordered( "\ [FRESH] bar [..] @@ -511,7 +490,7 @@ // bin dev check // bin dev-panic check-test (checking bin as a unittest) // - p.cargo("check --all-targets -vv").masquerade_as_nightly_cargo().with_stderr_unordered("\ + p.cargo("check --all-targets -vv").with_stderr_unordered("\ [COMPILING] bar [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata[..]-C codegen-units=1 -C debuginfo=2 [..] @@ -537,7 +516,6 @@ // rechecked. // See PR rust-lang/rust#49289 and issue rust-lang/cargo#3624. p.cargo("check --all-targets -vv") - .masquerade_as_nightly_cargo() .with_stderr_unordered( "\ [FRESH] bar [..] @@ -557,7 +535,7 @@ // This is a pretty straightforward variant of // `profile_selection_check_all_targets` that uses `release` instead of // `dev` for all targets. - p.cargo("check --all-targets --release -vv").masquerade_as_nightly_cargo().with_stderr_unordered("\ + p.cargo("check --all-targets --release -vv").with_stderr_unordered("\ [COMPILING] bar [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=6 [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata -C opt-level=3[..]-C codegen-units=2 [..] @@ -580,7 +558,6 @@ ").run(); p.cargo("check --all-targets --release -vv") - .masquerade_as_nightly_cargo() .with_stderr_unordered( "\ [FRESH] bar [..] @@ -595,7 +572,6 @@ #[cargo_test] fn profile_selection_check_all_targets_test() { let p = all_target_project(); - let affected = if is_nightly() { 3 } else { 1 }; // `check --profile=test` // - Dependency profiles: @@ -618,27 +594,26 @@ // bench test-panic check-test // bin test-panic check-test // - p.cargo("check --all-targets --profile=test -vv").masquerade_as_nightly_cargo().with_stderr_unordered(format!("\ + p.cargo("check --all-targets --profile=test -vv").with_stderr_unordered("\ [COMPILING] bar [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] -[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata[..]-C codegen-units={affected} -C debuginfo=2 [..] +[RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 [..] [COMPILING] bdep[..] [RUNNING] `[..] rustc --crate-name bdep bdep/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] [COMPILING] foo [..] [RUNNING] `[..] rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] [RUNNING] `[..]target/debug/build/foo-[..]/build-script-build` [foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0 -[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]metadata[..]-C codegen-units={affected} -C debuginfo=2 [..] -[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]metadata[..]-C codegen-units={affected} -C debuginfo=2 --test [..] -[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]metadata[..]-C codegen-units={affected} -C debuginfo=2 --test [..] -[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]metadata[..]-C codegen-units={affected} -C debuginfo=2 --test [..] -[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]metadata[..]-C codegen-units={affected} -C debuginfo=2 --test [..] -[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--emit=[..]metadata[..]-C codegen-units={affected} -C debuginfo=2 --test [..] +[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 [..] +[RUNNING] `[..] rustc --crate-name foo src/lib.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 --test [..] +[RUNNING] `[..] rustc --crate-name test1 tests/test1.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 --test [..] +[RUNNING] `[..] rustc --crate-name foo src/main.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 --test [..] +[RUNNING] `[..] rustc --crate-name bench1 benches/bench1.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 --test [..] +[RUNNING] `[..] rustc --crate-name ex1 examples/ex1.rs [..]--emit=[..]metadata[..]-C codegen-units=3 -C debuginfo=2 --test [..] [FINISHED] test [unoptimized + debuginfo] [..] -", affected=affected)).run(); +").run(); p.cargo("check --all-targets --profile=test -vv") - .masquerade_as_nightly_cargo() .with_stderr_unordered( "\ [FRESH] bar [..] @@ -664,7 +639,7 @@ // foo custom dev* link For build.rs // // `*` = wants panic, but it is cleared when args are built. - p.cargo("doc -vv").masquerade_as_nightly_cargo().with_stderr_unordered("\ + p.cargo("doc -vv").with_stderr_unordered("\ [COMPILING] bar [..] [DOCUMENTING] bar [..] [RUNNING] `[..] rustc --crate-name bar bar/src/lib.rs [..]--crate-type lib --emit=[..]link[..]-C codegen-units=5 -C debuginfo=2 [..] diff -Nru cargo-0.57.0+ubuntu/tests/testsuite/tool_paths.rs cargo-0.58.0/tests/testsuite/tool_paths.rs --- cargo-0.57.0+ubuntu/tests/testsuite/tool_paths.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/tests/testsuite/tool_paths.rs 2021-10-21 14:30:11.000000000 +0000 @@ -342,11 +342,6 @@ #[cargo_test] fn target_in_environment_contains_lower_case() { - if cfg!(windows) && !cargo_test_support::is_nightly() { - // Remove this check when 1.55 is stabilized. - // https://github.com/rust-lang/rust/pull/85270 - return; - } let p = project().file("src/main.rs", "fn main() {}").build(); let target = rustc_host(); diff -Nru cargo-0.57.0+ubuntu/tests/testsuite/update.rs cargo-0.58.0/tests/testsuite/update.rs --- cargo-0.57.0+ubuntu/tests/testsuite/update.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/tests/testsuite/update.rs 2021-10-21 14:30:11.000000000 +0000 @@ -678,3 +678,81 @@ assert!(!lock1.contains("0.0.2")); assert!(!lock2.contains("0.0.1")); } + +#[cargo_test] +fn precise_with_build_metadata() { + // +foo syntax shouldn't be necessary with --precise + Package::new("bar", "0.1.0+extra-stuff.0").publish(); + let p = project() + .file( + "Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + + [dependencies] + bar = "0.1" + "#, + ) + .file("src/lib.rs", "") + .build(); + p.cargo("generate-lockfile").run(); + Package::new("bar", "0.1.1+extra-stuff.1").publish(); + Package::new("bar", "0.1.2+extra-stuff.2").publish(); + + p.cargo("update -p bar --precise 0.1") + .with_status(101) + .with_stderr( + "\ +error: invalid version format for precise version `0.1` + +Caused by: + unexpected end of input while parsing minor version number +", + ) + .run(); + + p.cargo("update -p bar --precise 0.1.1+does-not-match") + .with_status(101) + .with_stderr( + "\ +[UPDATING] [..] index +error: no matching package named `bar` found +location searched: registry `crates-io` +required by package `foo v0.1.0 ([ROOT]/foo)` +", + ) + .run(); + + p.cargo("update -p bar --precise 0.1.1") + .with_stderr( + "\ +[UPDATING] [..] index +[UPDATING] bar v0.1.0+extra-stuff.0 -> v0.1.1+extra-stuff.1 +", + ) + .run(); + + Package::new("bar", "0.1.3").publish(); + p.cargo("update -p bar --precise 0.1.3+foo") + .with_status(101) + .with_stderr( + "\ +[UPDATING] [..] index +error: no matching package named `bar` found +location searched: registry `crates-io` +required by package `foo v0.1.0 ([ROOT]/foo)` +", + ) + .run(); + + p.cargo("update -p bar --precise 0.1.3") + .with_stderr( + "\ +[UPDATING] [..] index +[UPDATING] bar v0.1.1+extra-stuff.1 -> v0.1.3 +", + ) + .run(); +} diff -Nru cargo-0.57.0+ubuntu/tests/testsuite/version.rs cargo-0.58.0/tests/testsuite/version.rs --- cargo-0.57.0+ubuntu/tests/testsuite/version.rs 2021-10-04 17:24:20.000000000 +0000 +++ cargo-0.58.0/tests/testsuite/version.rs 2021-10-21 14:30:11.000000000 +0000 @@ -1,6 +1,6 @@ //! Tests for displaying the cargo version. -use cargo_test_support::project; +use cargo_test_support::{cargo_process, project}; #[cargo_test] fn simple() { @@ -41,3 +41,15 @@ .build(); p.cargo("version").run(); } + +#[cargo_test] +fn verbose() { + // This is mainly to check that it doesn't explode. + cargo_process("-vV") + .with_stdout_contains(&format!("cargo {}", cargo::version())) + .with_stdout_contains("host: [..]") + .with_stdout_contains("libgit2: [..]") + .with_stdout_contains("libcurl: [..]") + .with_stdout_contains("os: [..]") + .run(); +} diff -Nru cargo-0.57.0+ubuntu/vendor/ansi_term/.cargo-checksum.json cargo-0.58.0/vendor/ansi_term/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/ansi_term/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ansi_term/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"} \ No newline at end of file +{"files":{},"package":"d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/ansi_term/Cargo.lock cargo-0.58.0/vendor/ansi_term/Cargo.lock --- cargo-0.57.0+ubuntu/vendor/ansi_term/Cargo.lock 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/ansi_term/Cargo.lock 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,168 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "aho-corasick" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +dependencies = [ + "doc-comment 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "doc-comment" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "itoa" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "memchr" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "regex-syntax" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ryu" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serde" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde_derive 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_derive" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_json" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syn" +version = "0.15.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "thread_local" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[metadata] +"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" +"checksum doc-comment 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "923dea538cea0aa3025e8685b20d6ee21ef99c4f77e954a30febbaac5ec73a97" +"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" +"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +"checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" +"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +"checksum regex 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88c3d9193984285d544df4a30c23a4e62ead42edf70a4452ceb76dac1ce05c26" +"checksum regex-syntax 0.6.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b143cceb2ca5e56d5671988ef8b15615733e7ee16cd348e064333b251b89343f" +"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" +"checksum serde 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)" = "076a696fdea89c19d3baed462576b8f6d663064414b5c793642da8dfeb99475b" +"checksum serde_derive 1.0.94 (registry+https://github.com/rust-lang/crates.io-index)" = "ef45eb79d6463b22f5f9e16d283798b7c0175ba6050bc25c1a946c122727fe7b" +"checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" +"checksum syn 0.15.39 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d960b829a55e56db167e861ddb43602c003c7be0bee1d345021703fac2fb7c" +"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" +"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" +"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff -Nru cargo-0.57.0+ubuntu/vendor/ansi_term/Cargo.toml cargo-0.58.0/vendor/ansi_term/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/ansi_term/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ansi_term/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -3,7 +3,7 @@ # 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 @@ -12,16 +12,32 @@ [package] name = "ansi_term" -version = "0.11.0" +version = "0.12.1" authors = ["ogham@bsago.me", "Ryan Scheel (Havvy) ", "Josh Triplett "] description = "Library for ANSI terminal colours and styles (bold, underline)" homepage = "https://github.com/ogham/rust-ansi-term" documentation = "https://docs.rs/ansi_term" readme = "README.md" license = "MIT" +repository = "https://github.com/ogham/rust-ansi-term" [lib] name = "ansi_term" +[dependencies.serde] +version = "1.0.90" +features = ["derive"] +optional = true +[dev-dependencies.doc-comment] +version = "0.3" + +[dev-dependencies.regex] +version = "1.1.9" + +[dev-dependencies.serde_json] +version = "1.0.39" + +[features] +derive_serde_style = ["serde"] [target."cfg(target_os=\"windows\")".dependencies.winapi] version = "0.3.4" -features = ["errhandlingapi", "consoleapi", "processenv"] +features = ["consoleapi", "errhandlingapi", "fileapi", "handleapi", "processenv"] diff -Nru cargo-0.57.0+ubuntu/vendor/ansi_term/examples/256_colours.rs cargo-0.58.0/vendor/ansi_term/examples/256_colours.rs --- cargo-0.57.0+ubuntu/vendor/ansi_term/examples/256_colours.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/ansi_term/examples/256_colours.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,73 @@ +extern crate ansi_term; +use ansi_term::Colour; + +// This example prints out the 256 colours. +// They're arranged like this: +// +// - 0 to 8 are the eight standard colours. +// - 9 to 15 are the eight bold colours. +// - 16 to 231 are six blocks of six-by-six colour squares. +// - 232 to 255 are shades of grey. + +fn main() { + + // First two lines + for c in 0..8 { + glow(c, c != 0); + print!(" "); + } + print!("\n"); + for c in 8..16 { + glow(c, c != 8); + print!(" "); + } + print!("\n\n"); + + // Six lines of the first three squares + for row in 0..6 { + for square in 0..3 { + for column in 0..6 { + glow(16 + square * 36 + row * 6 + column, row >= 3); + print!(" "); + } + + print!(" "); + } + + print!("\n"); + } + print!("\n"); + + // Six more lines of the other three squares + for row in 0..6 { + for square in 0..3 { + for column in 0..6 { + glow(124 + square * 36 + row * 6 + column, row >= 3); + print!(" "); + } + + print!(" "); + } + + print!("\n"); + } + print!("\n"); + + // The last greyscale lines + for c in 232..=243 { + glow(c, false); + print!(" "); + } + print!("\n"); + for c in 244..=255 { + glow(c, true); + print!(" "); + } + print!("\n"); +} + +fn glow(c: u8, light_bg: bool) { + let base = if light_bg { Colour::Black } else { Colour::White }; + let style = base.on(Colour::Fixed(c)); + print!("{}", style.paint(&format!(" {:3} ", c))); +} diff -Nru cargo-0.57.0+ubuntu/vendor/ansi_term/examples/basic_colours.rs cargo-0.58.0/vendor/ansi_term/examples/basic_colours.rs --- cargo-0.57.0+ubuntu/vendor/ansi_term/examples/basic_colours.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/ansi_term/examples/basic_colours.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,18 @@ +extern crate ansi_term; +use ansi_term::{Style, Colour::*}; + +// This example prints out the 16 basic colours. + +fn main() { + let normal = Style::default(); + + println!("{} {}", normal.paint("Normal"), normal.bold().paint("bold")); + println!("{} {}", Black.paint("Black"), Black.bold().paint("bold")); + println!("{} {}", Red.paint("Red"), Red.bold().paint("bold")); + println!("{} {}", Green.paint("Green"), Green.bold().paint("bold")); + println!("{} {}", Yellow.paint("Yellow"), Yellow.bold().paint("bold")); + println!("{} {}", Blue.paint("Blue"), Blue.bold().paint("bold")); + println!("{} {}", Purple.paint("Purple"), Purple.bold().paint("bold")); + println!("{} {}", Cyan.paint("Cyan"), Cyan.bold().paint("bold")); + println!("{} {}", White.paint("White"), White.bold().paint("bold")); +} diff -Nru cargo-0.57.0+ubuntu/vendor/ansi_term/examples/colours.rs cargo-0.58.0/vendor/ansi_term/examples/colours.rs --- cargo-0.57.0+ubuntu/vendor/ansi_term/examples/colours.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ansi_term/examples/colours.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -extern crate ansi_term; -use ansi_term::Colour::*; - -fn main() { - println!("{}", Black.paint("Black")); - println!("{}", Red.paint("Red")); - println!("{}", Green.paint("Green")); - println!("{}", Yellow.paint("Yellow")); - println!("{}", Blue.paint("Blue")); - println!("{}", Purple.paint("Purple")); - println!("{}", Cyan.paint("Cyan")); - println!("{}", White.paint("White")); -} diff -Nru cargo-0.57.0+ubuntu/vendor/ansi_term/examples/rgb_colours.rs cargo-0.58.0/vendor/ansi_term/examples/rgb_colours.rs --- cargo-0.57.0+ubuntu/vendor/ansi_term/examples/rgb_colours.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/ansi_term/examples/rgb_colours.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,23 @@ +extern crate ansi_term; +use ansi_term::{Style, Colour}; + +// This example prints out a colour gradient in a grid by calculating each +// character’s red, green, and blue components, and using 24-bit colour codes +// to display them. + +const WIDTH: i32 = 80; +const HEIGHT: i32 = 24; + +fn main() { + for row in 0 .. HEIGHT { + for col in 0 .. WIDTH { + let r = (row * 255 / HEIGHT) as u8; + let g = (col * 255 / WIDTH) as u8; + let b = 128; + + print!("{}", Style::default().on(Colour::RGB(r, g, b)).paint(" ")); + } + + print!("\n"); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/ansi_term/LICENCE cargo-0.58.0/vendor/ansi_term/LICENCE --- cargo-0.57.0+ubuntu/vendor/ansi_term/LICENCE 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ansi_term/LICENCE 2022-01-21 02:47:39.000000000 +0000 @@ -1,21 +1,21 @@ -The MIT License (MIT) - -Copyright (c) 2014 Benjamin Sago - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +The MIT License (MIT) + +Copyright (c) 2014 Benjamin Sago + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff -Nru cargo-0.57.0+ubuntu/vendor/ansi_term/README.md cargo-0.58.0/vendor/ansi_term/README.md --- cargo-0.57.0+ubuntu/vendor/ansi_term/README.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ansi_term/README.md 2022-01-21 02:47:39.000000000 +0000 @@ -1,174 +1,183 @@ -# rust-ansi-term [![ansi-term on crates.io](http://meritbadge.herokuapp.com/ansi-term)](https://crates.io/crates/ansi_term) [![Build status](https://travis-ci.org/ogham/rust-ansi-term.svg?branch=master)](https://travis-ci.org/ogham/rust-ansi-term) [![Coverage status](https://coveralls.io/repos/ogham/rust-ansi-term/badge.svg?branch=master&service=github)](https://coveralls.io/github/ogham/rust-ansi-term?branch=master) - -This is a library for controlling colours and formatting, such as red bold text or blue underlined text, on ANSI terminals. - -### [View the Rustdoc](https://docs.rs/ansi_term/0.9.0/ansi_term/) - - -# Installation - -This crate works with [Cargo](http://crates.io). Add the following to your `Cargo.toml` dependencies section: - -```toml -[dependencies] -ansi_term = "0.9" -``` - - -## Basic usage - -There are two main data structures in this crate that you need to be concerned with: `ANSIString` and `Style`. -A `Style` holds stylistic information: colours, whether the text should be bold, or blinking, or whatever. -There are also `Colour` variants that represent simple foreground colour styles. -An `ANSIString` is a string paired with a `Style`. - -(Yes, it’s British English, but you won’t have to write “colour” very often. `Style` is used the majority of the time.) - -To format a string, call the `paint` method on a `Style` or a `Colour`, passing in the string you want to format as the argument. -For example, here’s how to get some red text: - -```rust -use ansi_term::Colour::Red; -println!("This is in red: {}", Red.paint("a red string")); -``` - -It’s important to note that the `paint` method does *not* actually return a string with the ANSI control characters surrounding it. -Instead, it returns an `ANSIString` value that has a `Display` implementation that, when formatted, returns the characters. -This allows strings to be printed with a minimum of `String` allocations being performed behind the scenes. - -If you *do* want to get at the escape codes, then you can convert the `ANSIString` to a string as you would any other `Display` value: - -```rust -use ansi_term::Colour::Red; -use std::string::ToString; -let red_string = Red.paint("a red string").to_string(); -``` - -**Note for Windows 10 users:** On Windows 10, the application must enable ANSI support first: - -```rust -let enabled = ansi_term::enable_ansi_support(); -``` - -## Bold, underline, background, and other styles - -For anything more complex than plain foreground colour changes, you need to construct `Style` objects themselves, rather than beginning with a `Colour`. -You can do this by chaining methods based on a new `Style`, created with `Style::new()`. -Each method creates a new style that has that specific property set. -For example: - -```rust -use ansi_term::Style; -println!("How about some {} and {}?", - Style::new().bold().paint("bold"), - Style::new().underline().paint("underline")); -``` - -For brevity, these methods have also been implemented for `Colour` values, so you can give your styles a foreground colour without having to begin with an empty `Style` value: - -```rust -use ansi_term::Colour::{Blue, Yellow}; -println!("Demonstrating {} and {}!", - Blue.bold().paint("blue bold"), - Yellow.underline().paint("yellow underline")); -println!("Yellow on blue: {}", Yellow.on(Blue).paint("wow!")); -``` - -The complete list of styles you can use are: -`bold`, `dimmed`, `italic`, `underline`, `blink`, `reverse`, `hidden`, and `on` for background colours. - -In some cases, you may find it easier to change the foreground on an existing `Style` rather than starting from the appropriate `Colour`. -You can do this using the `fg` method: - -```rust - use ansi_term::Style; - use ansi_term::Colour::{Blue, Cyan, Yellow}; - println!("Yellow on blue: {}", Style::new().on(Blue).fg(Yellow).paint("yow!")); - println!("Also yellow on blue: {}", Cyan.on(Blue).fg(Yellow).paint("zow!")); -``` - -Finally, you can turn a `Colour` into a `Style` with the `normal` method. -This will produce the exact same `ANSIString` as if you just used the `paint` method on the `Colour` directly, but it’s useful in certain cases: for example, you may have a method that returns `Styles`, and need to represent both the “red bold” and “red, but not bold” styles with values of the same type. The `Style` struct also has a `Default` implementation if you want to have a style with *nothing* set. - -```rust -use ansi_term::Style; -use ansi_term::Colour::Red; -Red.normal().paint("yet another red string"); -Style::default().paint("a completely regular string"); -``` - - -## Extended colours - -You can access the extended range of 256 colours by using the `Fixed` colour variant, which takes an argument of the colour number to use. -This can be included wherever you would use a `Colour`: - -```rust -use ansi_term::Colour::Fixed; -Fixed(134).paint("A sort of light purple"); -Fixed(221).on(Fixed(124)).paint("Mustard in the ketchup"); -``` - -The first sixteen of these values are the same as the normal and bold standard colour variants. -There’s nothing stopping you from using these as `Fixed` colours instead, but there’s nothing to be gained by doing so either. - -You can also access full 24-bit color by using the `RGB` colour variant, which takes separate `u8` arguments for red, green, and blue: - -```rust - use ansi_term::Colour::RGB; - RGB(70, 130, 180).paint("Steel blue"); -``` - -## Combining successive coloured strings - -The benefit of writing ANSI escape codes to the terminal is that they *stack*: you do not need to end every coloured string with a reset code if the text that follows it is of a similar style. -For example, if you want to have some blue text followed by some blue bold text, it’s possible to send the ANSI code for blue, followed by the ANSI code for bold, and finishing with a reset code without having to have an extra one between the two strings. - -This crate can optimise the ANSI codes that get printed in situations like this, making life easier for your terminal renderer. -The `ANSIStrings` struct takes a slice of several `ANSIString` values, and will iterate over each of them, printing only the codes for the styles that need to be updated as part of its formatting routine. - -The following code snippet uses this to enclose a binary number displayed in red bold text inside some red, but not bold, brackets: - -```rust -use ansi_term::Colour::Red; -use ansi_term::{ANSIString, ANSIStrings}; -let some_value = format!("{:b}", 42); -let strings: &[ANSIString<'static>] = &[ - Red.paint("["), - Red.bold().paint(some_value), - Red.paint("]"), -]; -println!("Value: {}", ANSIStrings(strings)); -``` - -There are several things to note here. -Firstly, the `paint` method can take *either* an owned `String` or a borrowed `&str`. -Internally, an `ANSIString` holds a copy-on-write (`Cow`) string value to deal with both owned and borrowed strings at the same time. -This is used here to display a `String`, the result of the `format!` call, using the same mechanism as some statically-available `&str` slices. -Secondly, that the `ANSIStrings` value works in the same way as its singular counterpart, with a `Display` implementation that only performs the formatting when required. - -## Byte strings - -This library also supports formatting `[u8]` byte strings; this supports -applications working with text in an unknown encoding. `Style` and -`Color` support painting `[u8]` values, resulting in an `ANSIByteString`. -This type does not implement `Display`, as it may not contain UTF-8, but -it does provide a method `write_to` to write the result to any -`io::Write`: - -```rust -use ansi_term::Colour::Green; -Green.paint("user data".as_bytes()).write_to(&mut std::io::stdout()).unwrap(); -``` - -Similarly, the type `ANSIByteStrings` supports writing a list of -`ANSIByteString` values with minimal escape sequences: - -```rust -use ansi_term::Colour::Green; -use ansi_term::ANSIByteStrings; -ANSIByteStrings(&[ - Green.paint("user data 1\n".as_bytes()), - Green.bold().paint("user data 2\n".as_bytes()), -]).write_to(&mut std::io::stdout()).unwrap(); -``` +# rust-ansi-term [![ansi-term on crates.io](http://meritbadge.herokuapp.com/ansi-term)](https://crates.io/crates/ansi_term) [![Build status](https://img.shields.io/travis/ogham/rust-ansi-term/master.svg?style=flat)](https://travis-ci.org/ogham/rust-ansi-term) [![Build status](https://img.shields.io/appveyor/ci/ogham/rust-ansi-term/master.svg?style=flat&logo=AppVeyor&logoColor=silver)](https://ci.appveyor.com/project/ogham/rust-ansi-term) [![Coverage status](https://coveralls.io/repos/ogham/rust-ansi-term/badge.svg?branch=master&service=github)](https://coveralls.io/github/ogham/rust-ansi-term?branch=master) + +This is a library for controlling colours and formatting, such as red bold text or blue underlined text, on ANSI terminals. + +### [View the Rustdoc](https://docs.rs/ansi_term/) + + +# Installation + +This crate works with [Cargo](http://crates.io). Add the following to your `Cargo.toml` dependencies section: + +```toml +[dependencies] +ansi_term = "0.12" +``` + + +## Basic usage + +There are three main types in this crate that you need to be concerned with: `ANSIString`, `Style`, and `Colour`. + +A `Style` holds stylistic information: foreground and background colours, whether the text should be bold, or blinking, or other properties. +The `Colour` enum represents the available colours. +And an `ANSIString` is a string paired with a `Style`. + +`Color` is also available as an alias to `Colour`. + +To format a string, call the `paint` method on a `Style` or a `Colour`, passing in the string you want to format as the argument. +For example, here’s how to get some red text: + +```rust +use ansi_term::Colour::Red; + +println!("This is in red: {}", Red.paint("a red string")); +``` + +It’s important to note that the `paint` method does *not* actually return a string with the ANSI control characters surrounding it. +Instead, it returns an `ANSIString` value that has a `Display` implementation that, when formatted, returns the characters. +This allows strings to be printed with a minimum of `String` allocations being performed behind the scenes. + +If you *do* want to get at the escape codes, then you can convert the `ANSIString` to a string as you would any other `Display` value: + +```rust +use ansi_term::Colour::Red; + +let red_string = Red.paint("a red string").to_string(); +``` + +**Note for Windows 10 users:** On Windows 10, the application must enable ANSI support first: + +```rust,ignore +let enabled = ansi_term::enable_ansi_support(); +``` + +## Bold, underline, background, and other styles + +For anything more complex than plain foreground colour changes, you need to construct `Style` values themselves, rather than beginning with a `Colour`. +You can do this by chaining methods based on a new `Style`, created with `Style::new()`. +Each method creates a new style that has that specific property set. +For example: + +```rust +use ansi_term::Style; + +println!("How about some {} and {}?", + Style::new().bold().paint("bold"), + Style::new().underline().paint("underline")); +``` + +For brevity, these methods have also been implemented for `Colour` values, so you can give your styles a foreground colour without having to begin with an empty `Style` value: + +```rust +use ansi_term::Colour::{Blue, Yellow}; + +println!("Demonstrating {} and {}!", + Blue.bold().paint("blue bold"), + Yellow.underline().paint("yellow underline")); + +println!("Yellow on blue: {}", Yellow.on(Blue).paint("wow!")); +``` + +The complete list of styles you can use are: +`bold`, `dimmed`, `italic`, `underline`, `blink`, `reverse`, `hidden`, and `on` for background colours. + +In some cases, you may find it easier to change the foreground on an existing `Style` rather than starting from the appropriate `Colour`. +You can do this using the `fg` method: + +```rust +use ansi_term::Style; +use ansi_term::Colour::{Blue, Cyan, Yellow}; + +println!("Yellow on blue: {}", Style::new().on(Blue).fg(Yellow).paint("yow!")); +println!("Also yellow on blue: {}", Cyan.on(Blue).fg(Yellow).paint("zow!")); +``` + +You can turn a `Colour` into a `Style` with the `normal` method. +This will produce the exact same `ANSIString` as if you just used the `paint` method on the `Colour` directly, but it’s useful in certain cases: for example, you may have a method that returns `Styles`, and need to represent both the “red bold” and “red, but not bold” styles with values of the same type. The `Style` struct also has a `Default` implementation if you want to have a style with *nothing* set. + +```rust +use ansi_term::Style; +use ansi_term::Colour::Red; + +Red.normal().paint("yet another red string"); +Style::default().paint("a completely regular string"); +``` + + +## Extended colours + +You can access the extended range of 256 colours by using the `Colour::Fixed` variant, which takes an argument of the colour number to use. +This can be included wherever you would use a `Colour`: + +```rust +use ansi_term::Colour::Fixed; + +Fixed(134).paint("A sort of light purple"); +Fixed(221).on(Fixed(124)).paint("Mustard in the ketchup"); +``` + +The first sixteen of these values are the same as the normal and bold standard colour variants. +There’s nothing stopping you from using these as `Fixed` colours instead, but there’s nothing to be gained by doing so either. + +You can also access full 24-bit colour by using the `Colour::RGB` variant, which takes separate `u8` arguments for red, green, and blue: + +```rust +use ansi_term::Colour::RGB; + +RGB(70, 130, 180).paint("Steel blue"); +``` + +## Combining successive coloured strings + +The benefit of writing ANSI escape codes to the terminal is that they *stack*: you do not need to end every coloured string with a reset code if the text that follows it is of a similar style. +For example, if you want to have some blue text followed by some blue bold text, it’s possible to send the ANSI code for blue, followed by the ANSI code for bold, and finishing with a reset code without having to have an extra one between the two strings. + +This crate can optimise the ANSI codes that get printed in situations like this, making life easier for your terminal renderer. +The `ANSIStrings` struct takes a slice of several `ANSIString` values, and will iterate over each of them, printing only the codes for the styles that need to be updated as part of its formatting routine. + +The following code snippet uses this to enclose a binary number displayed in red bold text inside some red, but not bold, brackets: + +```rust +use ansi_term::Colour::Red; +use ansi_term::{ANSIString, ANSIStrings}; + +let some_value = format!("{:b}", 42); +let strings: &[ANSIString<'static>] = &[ + Red.paint("["), + Red.bold().paint(some_value), + Red.paint("]"), +]; + +println!("Value: {}", ANSIStrings(strings)); +``` + +There are several things to note here. +Firstly, the `paint` method can take *either* an owned `String` or a borrowed `&str`. +Internally, an `ANSIString` holds a copy-on-write (`Cow`) string value to deal with both owned and borrowed strings at the same time. +This is used here to display a `String`, the result of the `format!` call, using the same mechanism as some statically-available `&str` slices. +Secondly, that the `ANSIStrings` value works in the same way as its singular counterpart, with a `Display` implementation that only performs the formatting when required. + +## Byte strings + +This library also supports formatting `[u8]` byte strings; this supports applications working with text in an unknown encoding. +`Style` and `Colour` support painting `[u8]` values, resulting in an `ANSIByteString`. +This type does not implement `Display`, as it may not contain UTF-8, but it does provide a method `write_to` to write the result to any value that implements `Write`: + +```rust +use ansi_term::Colour::Green; + +Green.paint("user data".as_bytes()).write_to(&mut std::io::stdout()).unwrap(); +``` + +Similarly, the type `ANSIByteStrings` supports writing a list of `ANSIByteString` values with minimal escape sequences: + +```rust +use ansi_term::Colour::Green; +use ansi_term::ANSIByteStrings; + +ANSIByteStrings(&[ + Green.paint("user data 1\n".as_bytes()), + Green.bold().paint("user data 2\n".as_bytes()), +]).write_to(&mut std::io::stdout()).unwrap(); +``` diff -Nru cargo-0.57.0+ubuntu/vendor/ansi_term/src/ansi.rs cargo-0.58.0/vendor/ansi_term/src/ansi.rs --- cargo-0.57.0+ubuntu/vendor/ansi_term/src/ansi.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ansi_term/src/ansi.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,258 +1,374 @@ -use style::{Colour, Style}; - -use std::fmt; - -use write::AnyWrite; - - -// ---- generating ANSI codes ---- - -impl Style { - - /// Write any ANSI codes that go *before* a piece of text. These should be - /// the codes to set the terminal to a different colour or font style. - fn write_prefix(&self, f: &mut W) -> Result<(), W::Error> { - - // If there are actually no styles here, then don’t write *any* codes - // as the prefix. An empty ANSI code may not affect the terminal - // output at all, but a user may just want a code-free string. - if self.is_plain() { - return Ok(()); - } - - // Write the codes’ prefix, then write numbers, separated by - // semicolons, for each text style we want to apply. - write!(f, "\x1B[")?; - let mut written_anything = false; - - { - let mut write_char = |c| { - if written_anything { write!(f, ";")?; } - written_anything = true; - write!(f, "{}", c)?; - Ok(()) - }; - - if self.is_bold { write_char('1')? } - if self.is_dimmed { write_char('2')? } - if self.is_italic { write_char('3')? } - if self.is_underline { write_char('4')? } - if self.is_blink { write_char('5')? } - if self.is_reverse { write_char('7')? } - if self.is_hidden { write_char('8')? } - if self.is_strikethrough { write_char('9')? } - } - - // The foreground and background colours, if specified, need to be - // handled specially because the number codes are more complicated. - // (see `write_background_code` and `write_foreground_code`) - if let Some(bg) = self.background { - if written_anything { write!(f, ";")?; } - written_anything = true; - bg.write_background_code(f)?; - } - - if let Some(fg) = self.foreground { - if written_anything { write!(f, ";")?; } - fg.write_foreground_code(f)?; - } - - // All the codes end with an `m`, because reasons. - write!(f, "m")?; - - Ok(()) - } - - /// Write any ANSI codes that go *after* a piece of text. These should be - /// the codes to *reset* the terminal back to its normal colour and style. - fn write_suffix(&self, f: &mut W) -> Result<(), W::Error> { - if self.is_plain() { - Ok(()) - } - else { - write!(f, "{}", RESET) - } - } -} - - -/// The code to send to reset all styles and return to `Style::default()`. -pub static RESET: &str = "\x1B[0m"; - - - -impl Colour { - fn write_foreground_code(&self, f: &mut W) -> Result<(), W::Error> { - match *self { - Colour::Black => write!(f, "30"), - Colour::Red => write!(f, "31"), - Colour::Green => write!(f, "32"), - Colour::Yellow => write!(f, "33"), - Colour::Blue => write!(f, "34"), - Colour::Purple => write!(f, "35"), - Colour::Cyan => write!(f, "36"), - Colour::White => write!(f, "37"), - Colour::Fixed(num) => write!(f, "38;5;{}", &num), - Colour::RGB(r,g,b) => write!(f, "38;2;{};{};{}", &r, &g, &b), - } - } - - fn write_background_code(&self, f: &mut W) -> Result<(), W::Error> { - match *self { - Colour::Black => write!(f, "40"), - Colour::Red => write!(f, "41"), - Colour::Green => write!(f, "42"), - Colour::Yellow => write!(f, "43"), - Colour::Blue => write!(f, "44"), - Colour::Purple => write!(f, "45"), - Colour::Cyan => write!(f, "46"), - Colour::White => write!(f, "47"), - Colour::Fixed(num) => write!(f, "48;5;{}", &num), - Colour::RGB(r,g,b) => write!(f, "48;2;{};{};{}", &r, &g, &b), - } - } -} - - -/// Like `ANSIString`, but only displays the style prefix. -#[derive(Clone, Copy, Debug)] -pub struct Prefix(Style); - -/// Like `ANSIString`, but only displays the difference between two -/// styles. -#[derive(Clone, Copy, Debug)] -pub struct Infix(Style, Style); - -/// Like `ANSIString`, but only displays the style suffix. -#[derive(Clone, Copy, Debug)] -pub struct Suffix(Style); - - -impl Style { - - /// The prefix for this style. - pub fn prefix(self) -> Prefix { - Prefix(self) - } - - /// The infix between this style and another. - pub fn infix(self, other: Style) -> Infix { - Infix(self, other) - } - - /// The suffix for this style. - pub fn suffix(self) -> Suffix { - Suffix(self) - } -} - - -impl Colour { - - /// The prefix for this colour. - pub fn prefix(self) -> Prefix { - Prefix(self.normal()) - } - - /// The infix between this colour and another. - pub fn infix(self, other: Colour) -> Infix { - Infix(self.normal(), other.normal()) - } - - /// The suffix for this colour. - pub fn suffix(self) -> Suffix { - Suffix(self.normal()) - } -} - - -impl fmt::Display for Prefix { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let f: &mut fmt::Write = f; - self.0.write_prefix(f) - } -} - - -impl fmt::Display for Infix { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - use difference::Difference; - - match Difference::between(&self.0, &self.1) { - Difference::ExtraStyles(style) => { - let f: &mut fmt::Write = f; - style.write_prefix(f) - }, - Difference::Reset => { - let f: &mut fmt::Write = f; - write!(f, "{}{}", RESET, self.0.prefix()) - }, - Difference::NoDifference => { - Ok(()) // nothing to write - }, - } - } -} - - -impl fmt::Display for Suffix { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let f: &mut fmt::Write = f; - self.0.write_suffix(f) - } -} - - - -#[cfg(test)] -mod test { - use style::Style; - use style::Colour::*; - - macro_rules! test { - ($name: ident: $style: expr; $input: expr => $result: expr) => { - #[test] - fn $name() { - assert_eq!($style.paint($input).to_string(), $result.to_string()); - - let mut v = Vec::new(); - $style.paint($input.as_bytes()).write_to(&mut v).unwrap(); - assert_eq!(v.as_slice(), $result.as_bytes()); - } - }; - } - - test!(plain: Style::default(); "text/plain" => "text/plain"); - test!(red: Red; "hi" => "\x1B[31mhi\x1B[0m"); - test!(black: Black.normal(); "hi" => "\x1B[30mhi\x1B[0m"); - test!(yellow_bold: Yellow.bold(); "hi" => "\x1B[1;33mhi\x1B[0m"); - test!(yellow_bold_2: Yellow.normal().bold(); "hi" => "\x1B[1;33mhi\x1B[0m"); - test!(blue_underline: Blue.underline(); "hi" => "\x1B[4;34mhi\x1B[0m"); - test!(green_bold_ul: Green.bold().underline(); "hi" => "\x1B[1;4;32mhi\x1B[0m"); - test!(green_bold_ul_2: Green.underline().bold(); "hi" => "\x1B[1;4;32mhi\x1B[0m"); - test!(purple_on_white: Purple.on(White); "hi" => "\x1B[47;35mhi\x1B[0m"); - test!(purple_on_white_2: Purple.normal().on(White); "hi" => "\x1B[47;35mhi\x1B[0m"); - test!(yellow_on_blue: Style::new().on(Blue).fg(Yellow); "hi" => "\x1B[44;33mhi\x1B[0m"); - test!(yellow_on_blue_2: Cyan.on(Blue).fg(Yellow); "hi" => "\x1B[44;33mhi\x1B[0m"); - test!(cyan_bold_on_white: Cyan.bold().on(White); "hi" => "\x1B[1;47;36mhi\x1B[0m"); - test!(cyan_ul_on_white: Cyan.underline().on(White); "hi" => "\x1B[4;47;36mhi\x1B[0m"); - test!(cyan_bold_ul_on_white: Cyan.bold().underline().on(White); "hi" => "\x1B[1;4;47;36mhi\x1B[0m"); - test!(cyan_ul_bold_on_white: Cyan.underline().bold().on(White); "hi" => "\x1B[1;4;47;36mhi\x1B[0m"); - test!(fixed: Fixed(100); "hi" => "\x1B[38;5;100mhi\x1B[0m"); - test!(fixed_on_purple: Fixed(100).on(Purple); "hi" => "\x1B[45;38;5;100mhi\x1B[0m"); - test!(fixed_on_fixed: Fixed(100).on(Fixed(200)); "hi" => "\x1B[48;5;200;38;5;100mhi\x1B[0m"); - test!(rgb: RGB(70,130,180); "hi" => "\x1B[38;2;70;130;180mhi\x1B[0m"); - test!(rgb_on_blue: RGB(70,130,180).on(Blue); "hi" => "\x1B[44;38;2;70;130;180mhi\x1B[0m"); - test!(blue_on_rgb: Blue.on(RGB(70,130,180)); "hi" => "\x1B[48;2;70;130;180;34mhi\x1B[0m"); - test!(rgb_on_rgb: RGB(70,130,180).on(RGB(5,10,15)); "hi" => "\x1B[48;2;5;10;15;38;2;70;130;180mhi\x1B[0m"); - test!(bold: Style::new().bold(); "hi" => "\x1B[1mhi\x1B[0m"); - test!(underline: Style::new().underline(); "hi" => "\x1B[4mhi\x1B[0m"); - test!(bunderline: Style::new().bold().underline(); "hi" => "\x1B[1;4mhi\x1B[0m"); - test!(dimmed: Style::new().dimmed(); "hi" => "\x1B[2mhi\x1B[0m"); - test!(italic: Style::new().italic(); "hi" => "\x1B[3mhi\x1B[0m"); - test!(blink: Style::new().blink(); "hi" => "\x1B[5mhi\x1B[0m"); - test!(reverse: Style::new().reverse(); "hi" => "\x1B[7mhi\x1B[0m"); - test!(hidden: Style::new().hidden(); "hi" => "\x1B[8mhi\x1B[0m"); - test!(stricken: Style::new().strikethrough(); "hi" => "\x1B[9mhi\x1B[0m"); - -} +use style::{Colour, Style}; + +use std::fmt; + +use write::AnyWrite; + + +// ---- generating ANSI codes ---- + +impl Style { + + /// Write any bytes that go *before* a piece of text to the given writer. + fn write_prefix(&self, f: &mut W) -> Result<(), W::Error> { + + // If there are actually no styles here, then don’t write *any* codes + // as the prefix. An empty ANSI code may not affect the terminal + // output at all, but a user may just want a code-free string. + if self.is_plain() { + return Ok(()); + } + + // Write the codes’ prefix, then write numbers, separated by + // semicolons, for each text style we want to apply. + write!(f, "\x1B[")?; + let mut written_anything = false; + + { + let mut write_char = |c| { + if written_anything { write!(f, ";")?; } + written_anything = true; + write!(f, "{}", c)?; + Ok(()) + }; + + if self.is_bold { write_char('1')? } + if self.is_dimmed { write_char('2')? } + if self.is_italic { write_char('3')? } + if self.is_underline { write_char('4')? } + if self.is_blink { write_char('5')? } + if self.is_reverse { write_char('7')? } + if self.is_hidden { write_char('8')? } + if self.is_strikethrough { write_char('9')? } + } + + // The foreground and background colours, if specified, need to be + // handled specially because the number codes are more complicated. + // (see `write_background_code` and `write_foreground_code`) + if let Some(bg) = self.background { + if written_anything { write!(f, ";")?; } + written_anything = true; + bg.write_background_code(f)?; + } + + if let Some(fg) = self.foreground { + if written_anything { write!(f, ";")?; } + fg.write_foreground_code(f)?; + } + + // All the codes end with an `m`, because reasons. + write!(f, "m")?; + + Ok(()) + } + + /// Write any bytes that go *after* a piece of text to the given writer. + fn write_suffix(&self, f: &mut W) -> Result<(), W::Error> { + if self.is_plain() { + Ok(()) + } + else { + write!(f, "{}", RESET) + } + } +} + + +/// The code to send to reset all styles and return to `Style::default()`. +pub static RESET: &str = "\x1B[0m"; + + + +impl Colour { + fn write_foreground_code(&self, f: &mut W) -> Result<(), W::Error> { + match *self { + Colour::Black => write!(f, "30"), + Colour::Red => write!(f, "31"), + Colour::Green => write!(f, "32"), + Colour::Yellow => write!(f, "33"), + Colour::Blue => write!(f, "34"), + Colour::Purple => write!(f, "35"), + Colour::Cyan => write!(f, "36"), + Colour::White => write!(f, "37"), + Colour::Fixed(num) => write!(f, "38;5;{}", &num), + Colour::RGB(r,g,b) => write!(f, "38;2;{};{};{}", &r, &g, &b), + } + } + + fn write_background_code(&self, f: &mut W) -> Result<(), W::Error> { + match *self { + Colour::Black => write!(f, "40"), + Colour::Red => write!(f, "41"), + Colour::Green => write!(f, "42"), + Colour::Yellow => write!(f, "43"), + Colour::Blue => write!(f, "44"), + Colour::Purple => write!(f, "45"), + Colour::Cyan => write!(f, "46"), + Colour::White => write!(f, "47"), + Colour::Fixed(num) => write!(f, "48;5;{}", &num), + Colour::RGB(r,g,b) => write!(f, "48;2;{};{};{}", &r, &g, &b), + } + } +} + + +/// Like `ANSIString`, but only displays the style prefix. +/// +/// This type implements the `Display` trait, meaning it can be written to a +/// `std::fmt` formatting without doing any extra allocation, and written to a +/// string with the `.to_string()` method. For examples, see +/// [`Style::prefix`](struct.Style.html#method.prefix). +#[derive(Clone, Copy, Debug)] +pub struct Prefix(Style); + +/// Like `ANSIString`, but only displays the difference between two +/// styles. +/// +/// This type implements the `Display` trait, meaning it can be written to a +/// `std::fmt` formatting without doing any extra allocation, and written to a +/// string with the `.to_string()` method. For examples, see +/// [`Style::infix`](struct.Style.html#method.infix). +#[derive(Clone, Copy, Debug)] +pub struct Infix(Style, Style); + +/// Like `ANSIString`, but only displays the style suffix. +/// +/// This type implements the `Display` trait, meaning it can be written to a +/// `std::fmt` formatting without doing any extra allocation, and written to a +/// string with the `.to_string()` method. For examples, see +/// [`Style::suffix`](struct.Style.html#method.suffix). +#[derive(Clone, Copy, Debug)] +pub struct Suffix(Style); + + +impl Style { + + /// The prefix bytes for this style. These are the bytes that tell the + /// terminal to use a different colour or font style. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::{Style, Colour::Blue}; + /// + /// let style = Style::default().bold(); + /// assert_eq!("\x1b[1m", + /// style.prefix().to_string()); + /// + /// let style = Blue.bold(); + /// assert_eq!("\x1b[1;34m", + /// style.prefix().to_string()); + /// + /// let style = Style::default(); + /// assert_eq!("", + /// style.prefix().to_string()); + /// ``` + pub fn prefix(self) -> Prefix { + Prefix(self) + } + + /// The infix bytes between this style and `next` style. These are the bytes + /// that tell the terminal to change the style to `next`. These may include + /// a reset followed by the next colour and style, depending on the two styles. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::{Style, Colour::Green}; + /// + /// let style = Style::default().bold(); + /// assert_eq!("\x1b[32m", + /// style.infix(Green.bold()).to_string()); + /// + /// let style = Green.normal(); + /// assert_eq!("\x1b[1m", + /// style.infix(Green.bold()).to_string()); + /// + /// let style = Style::default(); + /// assert_eq!("", + /// style.infix(style).to_string()); + /// ``` + pub fn infix(self, next: Style) -> Infix { + Infix(self, next) + } + + /// The suffix for this style. These are the bytes that tell the terminal + /// to reset back to its normal colour and font style. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::{Style, Colour::Green}; + /// + /// let style = Style::default().bold(); + /// assert_eq!("\x1b[0m", + /// style.suffix().to_string()); + /// + /// let style = Green.normal().bold(); + /// assert_eq!("\x1b[0m", + /// style.suffix().to_string()); + /// + /// let style = Style::default(); + /// assert_eq!("", + /// style.suffix().to_string()); + /// ``` + pub fn suffix(self) -> Suffix { + Suffix(self) + } +} + + +impl Colour { + + /// The prefix bytes for this colour as a `Style`. These are the bytes + /// that tell the terminal to use a different colour or font style. + /// + /// See also [`Style::prefix`](struct.Style.html#method.prefix). + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Colour::Green; + /// + /// assert_eq!("\x1b[0m", + /// Green.suffix().to_string()); + /// ``` + pub fn prefix(self) -> Prefix { + Prefix(self.normal()) + } + + /// The infix bytes between this colour and `next` colour. These are the bytes + /// that tell the terminal to use the `next` colour, or to do nothing if + /// the two colours are equal. + /// + /// See also [`Style::infix`](struct.Style.html#method.infix). + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Colour::{Red, Yellow}; + /// + /// assert_eq!("\x1b[33m", + /// Red.infix(Yellow).to_string()); + /// ``` + pub fn infix(self, next: Colour) -> Infix { + Infix(self.normal(), next.normal()) + } + + /// The suffix for this colour as a `Style`. These are the bytes that + /// tell the terminal to reset back to its normal colour and font style. + /// + /// See also [`Style::suffix`](struct.Style.html#method.suffix). + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Colour::Purple; + /// + /// assert_eq!("\x1b[0m", + /// Purple.suffix().to_string()); + /// ``` + pub fn suffix(self) -> Suffix { + Suffix(self.normal()) + } +} + + +impl fmt::Display for Prefix { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let f: &mut fmt::Write = f; + self.0.write_prefix(f) + } +} + + +impl fmt::Display for Infix { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + use difference::Difference; + + match Difference::between(&self.0, &self.1) { + Difference::ExtraStyles(style) => { + let f: &mut fmt::Write = f; + style.write_prefix(f) + }, + Difference::Reset => { + let f: &mut fmt::Write = f; + write!(f, "{}{}", RESET, self.1.prefix()) + }, + Difference::NoDifference => { + Ok(()) // nothing to write + }, + } + } +} + + +impl fmt::Display for Suffix { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let f: &mut fmt::Write = f; + self.0.write_suffix(f) + } +} + + + +#[cfg(test)] +mod test { + use style::Style; + use style::Colour::*; + + macro_rules! test { + ($name: ident: $style: expr; $input: expr => $result: expr) => { + #[test] + fn $name() { + assert_eq!($style.paint($input).to_string(), $result.to_string()); + + let mut v = Vec::new(); + $style.paint($input.as_bytes()).write_to(&mut v).unwrap(); + assert_eq!(v.as_slice(), $result.as_bytes()); + } + }; + } + + test!(plain: Style::default(); "text/plain" => "text/plain"); + test!(red: Red; "hi" => "\x1B[31mhi\x1B[0m"); + test!(black: Black.normal(); "hi" => "\x1B[30mhi\x1B[0m"); + test!(yellow_bold: Yellow.bold(); "hi" => "\x1B[1;33mhi\x1B[0m"); + test!(yellow_bold_2: Yellow.normal().bold(); "hi" => "\x1B[1;33mhi\x1B[0m"); + test!(blue_underline: Blue.underline(); "hi" => "\x1B[4;34mhi\x1B[0m"); + test!(green_bold_ul: Green.bold().underline(); "hi" => "\x1B[1;4;32mhi\x1B[0m"); + test!(green_bold_ul_2: Green.underline().bold(); "hi" => "\x1B[1;4;32mhi\x1B[0m"); + test!(purple_on_white: Purple.on(White); "hi" => "\x1B[47;35mhi\x1B[0m"); + test!(purple_on_white_2: Purple.normal().on(White); "hi" => "\x1B[47;35mhi\x1B[0m"); + test!(yellow_on_blue: Style::new().on(Blue).fg(Yellow); "hi" => "\x1B[44;33mhi\x1B[0m"); + test!(yellow_on_blue_2: Cyan.on(Blue).fg(Yellow); "hi" => "\x1B[44;33mhi\x1B[0m"); + test!(cyan_bold_on_white: Cyan.bold().on(White); "hi" => "\x1B[1;47;36mhi\x1B[0m"); + test!(cyan_ul_on_white: Cyan.underline().on(White); "hi" => "\x1B[4;47;36mhi\x1B[0m"); + test!(cyan_bold_ul_on_white: Cyan.bold().underline().on(White); "hi" => "\x1B[1;4;47;36mhi\x1B[0m"); + test!(cyan_ul_bold_on_white: Cyan.underline().bold().on(White); "hi" => "\x1B[1;4;47;36mhi\x1B[0m"); + test!(fixed: Fixed(100); "hi" => "\x1B[38;5;100mhi\x1B[0m"); + test!(fixed_on_purple: Fixed(100).on(Purple); "hi" => "\x1B[45;38;5;100mhi\x1B[0m"); + test!(fixed_on_fixed: Fixed(100).on(Fixed(200)); "hi" => "\x1B[48;5;200;38;5;100mhi\x1B[0m"); + test!(rgb: RGB(70,130,180); "hi" => "\x1B[38;2;70;130;180mhi\x1B[0m"); + test!(rgb_on_blue: RGB(70,130,180).on(Blue); "hi" => "\x1B[44;38;2;70;130;180mhi\x1B[0m"); + test!(blue_on_rgb: Blue.on(RGB(70,130,180)); "hi" => "\x1B[48;2;70;130;180;34mhi\x1B[0m"); + test!(rgb_on_rgb: RGB(70,130,180).on(RGB(5,10,15)); "hi" => "\x1B[48;2;5;10;15;38;2;70;130;180mhi\x1B[0m"); + test!(bold: Style::new().bold(); "hi" => "\x1B[1mhi\x1B[0m"); + test!(underline: Style::new().underline(); "hi" => "\x1B[4mhi\x1B[0m"); + test!(bunderline: Style::new().bold().underline(); "hi" => "\x1B[1;4mhi\x1B[0m"); + test!(dimmed: Style::new().dimmed(); "hi" => "\x1B[2mhi\x1B[0m"); + test!(italic: Style::new().italic(); "hi" => "\x1B[3mhi\x1B[0m"); + test!(blink: Style::new().blink(); "hi" => "\x1B[5mhi\x1B[0m"); + test!(reverse: Style::new().reverse(); "hi" => "\x1B[7mhi\x1B[0m"); + test!(hidden: Style::new().hidden(); "hi" => "\x1B[8mhi\x1B[0m"); + test!(stricken: Style::new().strikethrough(); "hi" => "\x1B[9mhi\x1B[0m"); + + #[test] + fn test_infix() { + assert_eq!(Style::new().dimmed().infix(Style::new()).to_string(), "\x1B[0m"); + assert_eq!(White.dimmed().infix(White.normal()).to_string(), "\x1B[0m\x1B[37m"); + assert_eq!(White.normal().infix(White.bold()).to_string(), "\x1B[1m"); + assert_eq!(White.normal().infix(Blue.normal()).to_string(), "\x1B[34m"); + assert_eq!(Blue.bold().infix(Blue.bold()).to_string(), ""); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/ansi_term/src/debug.rs cargo-0.58.0/vendor/ansi_term/src/debug.rs --- cargo-0.57.0+ubuntu/vendor/ansi_term/src/debug.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ansi_term/src/debug.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,122 +1,134 @@ -use std::fmt; - -use style::Style; - - -/// Styles have a special `Debug` implementation that only shows the fields that -/// are set. Fields that haven’t been touched aren’t included in the output. -/// -/// This behaviour gets bypassed when using the alternate formatting mode -/// `format!("{:#?}")`. -/// -/// use ansi_term::Colour::{Red, Blue}; -/// assert_eq!("Style { fg(Red), on(Blue), bold, italic }", -/// format!("{:?}", Red.on(Blue).bold().italic())); -impl fmt::Debug for Style { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - if fmt.alternate() { - fmt.debug_struct("Style") - .field("foreground", &self.foreground) - .field("background", &self.background) - .field("blink", &self.is_blink) - .field("bold", &self.is_bold) - .field("dimmed", &self.is_dimmed) - .field("hidden", &self.is_hidden) - .field("italic", &self.is_italic) - .field("reverse", &self.is_reverse) - .field("strikethrough", &self.is_strikethrough) - .field("underline", &self.is_underline) - .finish() - } - else if self.is_plain() { - fmt.write_str("Style {}") - } - else { - fmt.write_str("Style { ")?; - - let mut written_anything = false; - - if let Some(fg) = self.foreground { - if written_anything { fmt.write_str(", ")? } - written_anything = true; - write!(fmt, "fg({:?})", fg)? - } - - if let Some(bg) = self.background { - if written_anything { fmt.write_str(", ")? } - written_anything = true; - write!(fmt, "on({:?})", bg)? - } - - { - let mut write_flag = |name| { - if written_anything { fmt.write_str(", ")? } - written_anything = true; - fmt.write_str(name) - }; - - if self.is_blink { write_flag("blink")? } - if self.is_bold { write_flag("bold")? } - if self.is_dimmed { write_flag("dimmed")? } - if self.is_hidden { write_flag("hidden")? } - if self.is_italic { write_flag("italic")? } - if self.is_reverse { write_flag("reverse")? } - if self.is_strikethrough { write_flag("strikethrough")? } - if self.is_underline { write_flag("underline")? } - } - - write!(fmt, " }}") - } - } -} - - -#[cfg(test)] -mod test { - use style::Colour::*; - use style::Style; - - fn style() -> Style { - Style::new() - } - - macro_rules! test { - ($name: ident: $obj: expr => $result: expr) => { - #[test] - fn $name() { - assert_eq!($result, format!("{:?}", $obj)); - } - }; - } - - test!(empty: style() => "Style {}"); - test!(bold: style().bold() => "Style { bold }"); - test!(italic: style().italic() => "Style { italic }"); - test!(both: style().bold().italic() => "Style { bold, italic }"); - - test!(red: Red.normal() => "Style { fg(Red) }"); - test!(redblue: Red.normal().on(RGB(3, 2, 4)) => "Style { fg(Red), on(RGB(3, 2, 4)) }"); - - test!(everything: - Red.on(Blue).blink().bold().dimmed().hidden().italic().reverse().strikethrough().underline() => - "Style { fg(Red), on(Blue), blink, bold, dimmed, hidden, italic, reverse, strikethrough, underline }"); - - #[test] - fn long_and_detailed() { - let debug = r##"Style { - foreground: Some( - Blue - ), - background: None, - blink: false, - bold: true, - dimmed: false, - hidden: false, - italic: false, - reverse: false, - strikethrough: false, - underline: false -}"##; - assert_eq!(debug, format!("{:#?}", Blue.bold())); - } -} +use std::fmt; + +use style::Style; + +/// Styles have a special `Debug` implementation that only shows the fields that +/// are set. Fields that haven’t been touched aren’t included in the output. +/// +/// This behaviour gets bypassed when using the alternate formatting mode +/// `format!("{:#?}")`. +/// +/// use ansi_term::Colour::{Red, Blue}; +/// assert_eq!("Style { fg(Red), on(Blue), bold, italic }", +/// format!("{:?}", Red.on(Blue).bold().italic())); +impl fmt::Debug for Style { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + if fmt.alternate() { + fmt.debug_struct("Style") + .field("foreground", &self.foreground) + .field("background", &self.background) + .field("blink", &self.is_blink) + .field("bold", &self.is_bold) + .field("dimmed", &self.is_dimmed) + .field("hidden", &self.is_hidden) + .field("italic", &self.is_italic) + .field("reverse", &self.is_reverse) + .field("strikethrough", &self.is_strikethrough) + .field("underline", &self.is_underline) + .finish() + } + else if self.is_plain() { + fmt.write_str("Style {}") + } + else { + fmt.write_str("Style { ")?; + + let mut written_anything = false; + + if let Some(fg) = self.foreground { + if written_anything { fmt.write_str(", ")? } + written_anything = true; + write!(fmt, "fg({:?})", fg)? + } + + if let Some(bg) = self.background { + if written_anything { fmt.write_str(", ")? } + written_anything = true; + write!(fmt, "on({:?})", bg)? + } + + { + let mut write_flag = |name| { + if written_anything { fmt.write_str(", ")? } + written_anything = true; + fmt.write_str(name) + }; + + if self.is_blink { write_flag("blink")? } + if self.is_bold { write_flag("bold")? } + if self.is_dimmed { write_flag("dimmed")? } + if self.is_hidden { write_flag("hidden")? } + if self.is_italic { write_flag("italic")? } + if self.is_reverse { write_flag("reverse")? } + if self.is_strikethrough { write_flag("strikethrough")? } + if self.is_underline { write_flag("underline")? } + } + + write!(fmt, " }}") + } + } +} + + +#[cfg(test)] +mod test { + use style::Colour::*; + use style::Style; + + fn style() -> Style { + Style::new() + } + + macro_rules! test { + ($name: ident: $obj: expr => $result: expr) => { + #[test] + fn $name() { + assert_eq!($result, format!("{:?}", $obj)); + } + }; + } + + test!(empty: style() => "Style {}"); + test!(bold: style().bold() => "Style { bold }"); + test!(italic: style().italic() => "Style { italic }"); + test!(both: style().bold().italic() => "Style { bold, italic }"); + + test!(red: Red.normal() => "Style { fg(Red) }"); + test!(redblue: Red.normal().on(RGB(3, 2, 4)) => "Style { fg(Red), on(RGB(3, 2, 4)) }"); + + test!(everything: + Red.on(Blue).blink().bold().dimmed().hidden().italic().reverse().strikethrough().underline() => + "Style { fg(Red), on(Blue), blink, bold, dimmed, hidden, italic, reverse, strikethrough, underline }"); + + #[test] + fn long_and_detailed() { + extern crate regex; + let expected_debug = "Style { fg(Blue), bold }"; + let expected_pretty_repat = r##"(?x) + Style\s+\{\s+ + foreground:\s+Some\(\s+ + Blue,?\s+ + \),\s+ + background:\s+None,\s+ + blink:\s+false,\s+ + bold:\s+true,\s+ + dimmed:\s+false,\s+ + hidden:\s+false,\s+ + italic:\s+false,\s+ + reverse:\s+false,\s+ + strikethrough:\s+ + false,\s+ + underline:\s+false,?\s+ + \}"##; + let re = regex::Regex::new(expected_pretty_repat).unwrap(); + + let style = Blue.bold(); + let style_fmt_debug = format!("{:?}", style); + let style_fmt_pretty = format!("{:#?}", style); + println!("style_fmt_debug:\n{}", style_fmt_debug); + println!("style_fmt_pretty:\n{}", style_fmt_pretty); + + assert_eq!(expected_debug, style_fmt_debug); + assert!(re.is_match(&style_fmt_pretty)); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/ansi_term/src/difference.rs cargo-0.58.0/vendor/ansi_term/src/difference.rs --- cargo-0.57.0+ubuntu/vendor/ansi_term/src/difference.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ansi_term/src/difference.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,179 +1,179 @@ -use super::Style; - - -/// When printing out one coloured string followed by another, use one of -/// these rules to figure out which *extra* control codes need to be sent. -#[derive(PartialEq, Clone, Copy, Debug)] -pub enum Difference { - - /// Print out the control codes specified by this style to end up looking - /// like the second string's styles. - ExtraStyles(Style), - - /// Converting between these two is impossible, so just send a reset - /// command and then the second string's styles. - Reset, - - /// The before style is exactly the same as the after style, so no further - /// control codes need to be printed. - NoDifference, -} - - -impl Difference { - - /// Compute the 'style difference' required to turn an existing style into - /// the given, second style. - /// - /// For example, to turn green text into green bold text, it's redundant - /// to write a reset command then a second green+bold command, instead of - /// just writing one bold command. This method should see that both styles - /// use the foreground colour green, and reduce it to a single command. - /// - /// This method returns an enum value because it's not actually always - /// possible to turn one style into another: for example, text could be - /// made bold and underlined, but you can't remove the bold property - /// without also removing the underline property. So when this has to - /// happen, this function returns None, meaning that the entire set of - /// styles should be reset and begun again. - pub fn between(first: &Style, next: &Style) -> Difference { - use self::Difference::*; - - // XXX(Havvy): This algorithm is kind of hard to replicate without - // having the Plain/Foreground enum variants, so I'm just leaving - // it commented out for now, and defaulting to Reset. - - if first == next { - return NoDifference; - } - - // Cannot un-bold, so must Reset. - if first.is_bold && !next.is_bold { - return Reset; - } - - if first.is_dimmed && !next.is_dimmed { - return Reset; - } - - if first.is_italic && !next.is_italic { - return Reset; - } - - // Cannot un-underline, so must Reset. - if first.is_underline && !next.is_underline { - return Reset; - } - - if first.is_blink && !next.is_blink { - return Reset; - } - - if first.is_reverse && !next.is_reverse { - return Reset; - } - - if first.is_hidden && !next.is_hidden { - return Reset; - } - - if first.is_strikethrough && !next.is_strikethrough { - return Reset; - } - - // Cannot go from foreground to no foreground, so must Reset. - if first.foreground.is_some() && next.foreground.is_none() { - return Reset; - } - - // Cannot go from background to no background, so must Reset. - if first.background.is_some() && next.background.is_none() { - return Reset; - } - - let mut extra_styles = Style::default(); - - if first.is_bold != next.is_bold { - extra_styles.is_bold = true; - } - - if first.is_dimmed != next.is_dimmed { - extra_styles.is_dimmed = true; - } - - if first.is_italic != next.is_italic { - extra_styles.is_italic = true; - } - - if first.is_underline != next.is_underline { - extra_styles.is_underline = true; - } - - if first.is_blink != next.is_blink { - extra_styles.is_blink = true; - } - - if first.is_reverse != next.is_reverse { - extra_styles.is_reverse = true; - } - - if first.is_hidden != next.is_hidden { - extra_styles.is_hidden = true; - } - - if first.is_strikethrough != next.is_strikethrough { - extra_styles.is_strikethrough = true; - } - - if first.foreground != next.foreground { - extra_styles.foreground = next.foreground; - } - - if first.background != next.background { - extra_styles.background = next.background; - } - - ExtraStyles(extra_styles) - } -} - - -#[cfg(test)] -mod test { - use super::*; - use super::Difference::*; - use style::Colour::*; - use style::Style; - - fn style() -> Style { - Style::new() - } - - macro_rules! test { - ($name: ident: $first: expr; $next: expr => $result: expr) => { - #[test] - fn $name() { - assert_eq!($result, Difference::between(&$first, &$next)); - } - }; - } - - test!(nothing: Green.normal(); Green.normal() => NoDifference); - test!(uppercase: Green.normal(); Green.bold() => ExtraStyles(style().bold())); - test!(lowercase: Green.bold(); Green.normal() => Reset); - test!(nothing2: Green.bold(); Green.bold() => NoDifference); - - test!(colour_change: Red.normal(); Blue.normal() => ExtraStyles(Blue.normal())); - - test!(addition_of_blink: style(); style().blink() => ExtraStyles(style().blink())); - test!(addition_of_dimmed: style(); style().dimmed() => ExtraStyles(style().dimmed())); - test!(addition_of_hidden: style(); style().hidden() => ExtraStyles(style().hidden())); - test!(addition_of_reverse: style(); style().reverse() => ExtraStyles(style().reverse())); - test!(addition_of_strikethrough: style(); style().strikethrough() => ExtraStyles(style().strikethrough())); - - test!(removal_of_strikethrough: style().strikethrough(); style() => Reset); - test!(removal_of_reverse: style().reverse(); style() => Reset); - test!(removal_of_hidden: style().hidden(); style() => Reset); - test!(removal_of_dimmed: style().dimmed(); style() => Reset); - test!(removal_of_blink: style().blink(); style() => Reset); -} +use super::Style; + + +/// When printing out one coloured string followed by another, use one of +/// these rules to figure out which *extra* control codes need to be sent. +#[derive(PartialEq, Clone, Copy, Debug)] +pub enum Difference { + + /// Print out the control codes specified by this style to end up looking + /// like the second string's styles. + ExtraStyles(Style), + + /// Converting between these two is impossible, so just send a reset + /// command and then the second string's styles. + Reset, + + /// The before style is exactly the same as the after style, so no further + /// control codes need to be printed. + NoDifference, +} + + +impl Difference { + + /// Compute the 'style difference' required to turn an existing style into + /// the given, second style. + /// + /// For example, to turn green text into green bold text, it's redundant + /// to write a reset command then a second green+bold command, instead of + /// just writing one bold command. This method should see that both styles + /// use the foreground colour green, and reduce it to a single command. + /// + /// This method returns an enum value because it's not actually always + /// possible to turn one style into another: for example, text could be + /// made bold and underlined, but you can't remove the bold property + /// without also removing the underline property. So when this has to + /// happen, this function returns None, meaning that the entire set of + /// styles should be reset and begun again. + pub fn between(first: &Style, next: &Style) -> Difference { + use self::Difference::*; + + // XXX(Havvy): This algorithm is kind of hard to replicate without + // having the Plain/Foreground enum variants, so I'm just leaving + // it commented out for now, and defaulting to Reset. + + if first == next { + return NoDifference; + } + + // Cannot un-bold, so must Reset. + if first.is_bold && !next.is_bold { + return Reset; + } + + if first.is_dimmed && !next.is_dimmed { + return Reset; + } + + if first.is_italic && !next.is_italic { + return Reset; + } + + // Cannot un-underline, so must Reset. + if first.is_underline && !next.is_underline { + return Reset; + } + + if first.is_blink && !next.is_blink { + return Reset; + } + + if first.is_reverse && !next.is_reverse { + return Reset; + } + + if first.is_hidden && !next.is_hidden { + return Reset; + } + + if first.is_strikethrough && !next.is_strikethrough { + return Reset; + } + + // Cannot go from foreground to no foreground, so must Reset. + if first.foreground.is_some() && next.foreground.is_none() { + return Reset; + } + + // Cannot go from background to no background, so must Reset. + if first.background.is_some() && next.background.is_none() { + return Reset; + } + + let mut extra_styles = Style::default(); + + if first.is_bold != next.is_bold { + extra_styles.is_bold = true; + } + + if first.is_dimmed != next.is_dimmed { + extra_styles.is_dimmed = true; + } + + if first.is_italic != next.is_italic { + extra_styles.is_italic = true; + } + + if first.is_underline != next.is_underline { + extra_styles.is_underline = true; + } + + if first.is_blink != next.is_blink { + extra_styles.is_blink = true; + } + + if first.is_reverse != next.is_reverse { + extra_styles.is_reverse = true; + } + + if first.is_hidden != next.is_hidden { + extra_styles.is_hidden = true; + } + + if first.is_strikethrough != next.is_strikethrough { + extra_styles.is_strikethrough = true; + } + + if first.foreground != next.foreground { + extra_styles.foreground = next.foreground; + } + + if first.background != next.background { + extra_styles.background = next.background; + } + + ExtraStyles(extra_styles) + } +} + + +#[cfg(test)] +mod test { + use super::*; + use super::Difference::*; + use style::Colour::*; + use style::Style; + + fn style() -> Style { + Style::new() + } + + macro_rules! test { + ($name: ident: $first: expr; $next: expr => $result: expr) => { + #[test] + fn $name() { + assert_eq!($result, Difference::between(&$first, &$next)); + } + }; + } + + test!(nothing: Green.normal(); Green.normal() => NoDifference); + test!(uppercase: Green.normal(); Green.bold() => ExtraStyles(style().bold())); + test!(lowercase: Green.bold(); Green.normal() => Reset); + test!(nothing2: Green.bold(); Green.bold() => NoDifference); + + test!(colour_change: Red.normal(); Blue.normal() => ExtraStyles(Blue.normal())); + + test!(addition_of_blink: style(); style().blink() => ExtraStyles(style().blink())); + test!(addition_of_dimmed: style(); style().dimmed() => ExtraStyles(style().dimmed())); + test!(addition_of_hidden: style(); style().hidden() => ExtraStyles(style().hidden())); + test!(addition_of_reverse: style(); style().reverse() => ExtraStyles(style().reverse())); + test!(addition_of_strikethrough: style(); style().strikethrough() => ExtraStyles(style().strikethrough())); + + test!(removal_of_strikethrough: style().strikethrough(); style() => Reset); + test!(removal_of_reverse: style().reverse(); style() => Reset); + test!(removal_of_hidden: style().hidden(); style() => Reset); + test!(removal_of_dimmed: style().dimmed(); style() => Reset); + test!(removal_of_blink: style().blink(); style() => Reset); +} diff -Nru cargo-0.57.0+ubuntu/vendor/ansi_term/src/display.rs cargo-0.58.0/vendor/ansi_term/src/display.rs --- cargo-0.57.0+ubuntu/vendor/ansi_term/src/display.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ansi_term/src/display.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,279 +1,296 @@ -use std::borrow::Cow; -use std::fmt; -use std::io; -use std::ops::Deref; - -use ansi::RESET; -use difference::Difference; -use style::{Style, Colour}; -use write::AnyWrite; - - -/// An `ANSIGenericString` includes a generic string type and a `Style` to -/// display that string. `ANSIString` and `ANSIByteString` are aliases for -/// this type on `str` and `[u8]`, respectively. -#[derive(PartialEq, Debug)] -pub struct ANSIGenericString<'a, S: 'a + ToOwned + ?Sized> -where ::Owned: fmt::Debug { - style: Style, - string: Cow<'a, S>, -} - - -/// Cloning an `ANSIGenericString` will clone its underlying string. -/// -/// ### Examples -/// -/// ``` -/// use ansi_term::ANSIString; -/// -/// let plain_string = ANSIString::from("a plain string"); -/// let clone_string = plain_string.clone(); -/// assert_eq!(clone_string, plain_string); -/// ``` -impl<'a, S: 'a + ToOwned + ?Sized> Clone for ANSIGenericString<'a, S> -where ::Owned: fmt::Debug { - fn clone(&self) -> ANSIGenericString<'a, S> { - ANSIGenericString { - style: self.style, - string: self.string.clone(), - } - } -} - -// You might think that the hand-written Clone impl above is the same as the -// one that gets generated with #[derive]. But it’s not *quite* the same! -// -// `str` is not Clone, and the derived Clone implementation puts a Clone -// constraint on the S type parameter (generated using --pretty=expanded): -// -// ↓_________________↓ -// impl <'a, S: ::std::clone::Clone + 'a + ToOwned + ?Sized> ::std::clone::Clone -// for ANSIGenericString<'a, S> where -// ::Owned: fmt::Debug { ... } -// -// This resulted in compile errors when you tried to derive Clone on a type -// that used it: -// -// #[derive(PartialEq, Debug, Clone, Default)] -// pub struct TextCellContents(Vec>); -// ^^^^^^^^^^^^^^^^^^^^^^^^^ -// error[E0277]: the trait `std::clone::Clone` is not implemented for `str` -// -// The hand-written impl above can ignore that constraint and still compile. - - - -/// An ANSI String is a string coupled with the `Style` to display it -/// in a terminal. -/// -/// Although not technically a string itself, it can be turned into -/// one with the `to_string` method. -/// -/// ### Examples -/// -/// ```no_run -/// use ansi_term::ANSIString; -/// use ansi_term::Colour::Red; -/// -/// let red_string = Red.paint("a red string"); -/// println!("{}", red_string); -/// ``` -/// -/// ``` -/// use ansi_term::ANSIString; -/// -/// let plain_string = ANSIString::from("a plain string"); -/// assert_eq!(&*plain_string, "a plain string"); -/// ``` -pub type ANSIString<'a> = ANSIGenericString<'a, str>; - -/// An `ANSIByteString` represents a formatted series of bytes. Use -/// `ANSIByteString` when styling text with an unknown encoding. -pub type ANSIByteString<'a> = ANSIGenericString<'a, [u8]>; - -impl<'a, I, S: 'a + ToOwned + ?Sized> From for ANSIGenericString<'a, S> -where I: Into>, - ::Owned: fmt::Debug { - fn from(input: I) -> ANSIGenericString<'a, S> { - ANSIGenericString { - string: input.into(), - style: Style::default(), - } - } -} - -impl<'a, S: 'a + ToOwned + ?Sized> Deref for ANSIGenericString<'a, S> -where ::Owned: fmt::Debug { - type Target = S; - - fn deref(&self) -> &S { - self.string.deref() - } -} - - -/// A set of `ANSIGenericString`s collected together, in order to be -/// written with a minimum of control characters. -pub struct ANSIGenericStrings<'a, S: 'a + ToOwned + ?Sized> - (pub &'a [ANSIGenericString<'a, S>]) - where ::Owned: fmt::Debug; - -/// A set of `ANSIString`s collected together, in order to be written with a -/// minimum of control characters. -pub type ANSIStrings<'a> = ANSIGenericStrings<'a, str>; - -/// A function to construct an `ANSIStrings` instance. -#[allow(non_snake_case)] -pub fn ANSIStrings<'a>(arg: &'a [ANSIString<'a>]) -> ANSIStrings<'a> { - ANSIGenericStrings(arg) -} - -/// A set of `ANSIByteString`s collected together, in order to be -/// written with a minimum of control characters. -pub type ANSIByteStrings<'a> = ANSIGenericStrings<'a, [u8]>; - -/// A function to construct an `ANSIByteStrings` instance. -#[allow(non_snake_case)] -pub fn ANSIByteStrings<'a>(arg: &'a [ANSIByteString<'a>]) -> ANSIByteStrings<'a> { - ANSIGenericStrings(arg) -} - - -// ---- paint functions ---- - -impl Style { - - /// Paints the given text with this colour, returning an ANSI string. - pub fn paint<'a, I, S: 'a + ToOwned + ?Sized>(self, input: I) -> ANSIGenericString<'a, S> - where I: Into>, - ::Owned: fmt::Debug { - ANSIGenericString { - string: input.into(), - style: self, - } - } -} - - -impl Colour { - - /// Paints the given text with this colour, returning an ANSI string. - /// This is a short-cut so you don’t have to use `Blue.normal()` just - /// to get blue text. - /// - /// ``` - /// use ansi_term::Colour::Blue; - /// println!("{}", Blue.paint("da ba dee")); - /// ``` - pub fn paint<'a, I, S: 'a + ToOwned + ?Sized>(self, input: I) -> ANSIGenericString<'a, S> - where I: Into>, - ::Owned: fmt::Debug { - ANSIGenericString { - string: input.into(), - style: self.normal(), - } - } -} - - -// ---- writers for individual ANSI strings ---- - -impl<'a> fmt::Display for ANSIString<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let w: &mut fmt::Write = f; - self.write_to_any(w) - } -} - -impl<'a> ANSIByteString<'a> { - /// Write an `ANSIByteString` to an `io::Write`. This writes the escape - /// sequences for the associated `Style` around the bytes. - pub fn write_to(&self, w: &mut W) -> io::Result<()> { - let w: &mut io::Write = w; - self.write_to_any(w) - } -} - -impl<'a, S: 'a + ToOwned + ?Sized> ANSIGenericString<'a, S> -where ::Owned: fmt::Debug, &'a S: AsRef<[u8]> { - fn write_to_any + ?Sized>(&self, w: &mut W) -> Result<(), W::Error> { - write!(w, "{}", self.style.prefix())?; - w.write_str(self.string.as_ref())?; - write!(w, "{}", self.style.suffix()) - } -} - - -// ---- writers for combined ANSI strings ---- - -impl<'a> fmt::Display for ANSIStrings<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let f: &mut fmt::Write = f; - self.write_to_any(f) - } -} - -impl<'a> ANSIByteStrings<'a> { - /// Write `ANSIByteStrings` to an `io::Write`. This writes the minimal - /// escape sequences for the associated `Style`s around each set of - /// bytes. - pub fn write_to(&self, w: &mut W) -> io::Result<()> { - let w: &mut io::Write = w; - self.write_to_any(w) - } -} - -impl<'a, S: 'a + ToOwned + ?Sized> ANSIGenericStrings<'a, S> -where ::Owned: fmt::Debug, &'a S: AsRef<[u8]> { - fn write_to_any + ?Sized>(&self, w: &mut W) -> Result<(), W::Error> { - use self::Difference::*; - - let first = match self.0.first() { - None => return Ok(()), - Some(f) => f, - }; - - write!(w, "{}", first.style.prefix())?; - w.write_str(first.string.as_ref())?; - - for window in self.0.windows(2) { - match Difference::between(&window[0].style, &window[1].style) { - ExtraStyles(style) => write!(w, "{}", style.prefix())?, - Reset => write!(w, "{}{}", RESET, window[1].style.prefix())?, - NoDifference => {/* Do nothing! */}, - } - - w.write_str(&window[1].string)?; - } - - // Write the final reset string after all of the ANSIStrings have been - // written, *except* if the last one has no styles, because it would - // have already been written by this point. - if let Some(last) = self.0.last() { - if !last.style.is_plain() { - write!(w, "{}", RESET)?; - } - } - - Ok(()) - } -} - - -// ---- tests ---- - -#[cfg(test)] -mod tests { - pub use super::super::ANSIStrings; - pub use style::Style; - pub use style::Colour::*; - - #[test] - fn no_control_codes_for_plain() { - let one = Style::default().paint("one"); - let two = Style::default().paint("two"); - let output = format!("{}", ANSIStrings( &[ one, two ] )); - assert_eq!(&*output, "onetwo"); - } -} +use std::borrow::Cow; +use std::fmt; +use std::io; +use std::ops::Deref; + +use ansi::RESET; +use difference::Difference; +use style::{Style, Colour}; +use write::AnyWrite; + + +/// An `ANSIGenericString` includes a generic string type and a `Style` to +/// display that string. `ANSIString` and `ANSIByteString` are aliases for +/// this type on `str` and `\[u8]`, respectively. +#[derive(PartialEq, Debug)] +pub struct ANSIGenericString<'a, S: 'a + ToOwned + ?Sized> +where ::Owned: fmt::Debug { + style: Style, + string: Cow<'a, S>, +} + + +/// Cloning an `ANSIGenericString` will clone its underlying string. +/// +/// # Examples +/// +/// ``` +/// use ansi_term::ANSIString; +/// +/// let plain_string = ANSIString::from("a plain string"); +/// let clone_string = plain_string.clone(); +/// assert_eq!(clone_string, plain_string); +/// ``` +impl<'a, S: 'a + ToOwned + ?Sized> Clone for ANSIGenericString<'a, S> +where ::Owned: fmt::Debug { + fn clone(&self) -> ANSIGenericString<'a, S> { + ANSIGenericString { + style: self.style, + string: self.string.clone(), + } + } +} + +// You might think that the hand-written Clone impl above is the same as the +// one that gets generated with #[derive]. But it’s not *quite* the same! +// +// `str` is not Clone, and the derived Clone implementation puts a Clone +// constraint on the S type parameter (generated using --pretty=expanded): +// +// ↓_________________↓ +// impl <'a, S: ::std::clone::Clone + 'a + ToOwned + ?Sized> ::std::clone::Clone +// for ANSIGenericString<'a, S> where +// ::Owned: fmt::Debug { ... } +// +// This resulted in compile errors when you tried to derive Clone on a type +// that used it: +// +// #[derive(PartialEq, Debug, Clone, Default)] +// pub struct TextCellContents(Vec>); +// ^^^^^^^^^^^^^^^^^^^^^^^^^ +// error[E0277]: the trait `std::clone::Clone` is not implemented for `str` +// +// The hand-written impl above can ignore that constraint and still compile. + + + +/// An ANSI String is a string coupled with the `Style` to display it +/// in a terminal. +/// +/// Although not technically a string itself, it can be turned into +/// one with the `to_string` method. +/// +/// # Examples +/// +/// ``` +/// use ansi_term::ANSIString; +/// use ansi_term::Colour::Red; +/// +/// let red_string = Red.paint("a red string"); +/// println!("{}", red_string); +/// ``` +/// +/// ``` +/// use ansi_term::ANSIString; +/// +/// let plain_string = ANSIString::from("a plain string"); +/// assert_eq!(&*plain_string, "a plain string"); +/// ``` +pub type ANSIString<'a> = ANSIGenericString<'a, str>; + +/// An `ANSIByteString` represents a formatted series of bytes. Use +/// `ANSIByteString` when styling text with an unknown encoding. +pub type ANSIByteString<'a> = ANSIGenericString<'a, [u8]>; + +impl<'a, I, S: 'a + ToOwned + ?Sized> From for ANSIGenericString<'a, S> +where I: Into>, + ::Owned: fmt::Debug { + fn from(input: I) -> ANSIGenericString<'a, S> { + ANSIGenericString { + string: input.into(), + style: Style::default(), + } + } +} + +impl<'a, S: 'a + ToOwned + ?Sized> ANSIGenericString<'a, S> + where ::Owned: fmt::Debug { + + /// Directly access the style + pub fn style_ref(&self) -> &Style { + &self.style + } + + /// Directly access the style mutably + pub fn style_ref_mut(&mut self) -> &mut Style { + &mut self.style + } +} + +impl<'a, S: 'a + ToOwned + ?Sized> Deref for ANSIGenericString<'a, S> +where ::Owned: fmt::Debug { + type Target = S; + + fn deref(&self) -> &S { + self.string.deref() + } +} + + +/// A set of `ANSIGenericString`s collected together, in order to be +/// written with a minimum of control characters. +#[derive(Debug, PartialEq)] +pub struct ANSIGenericStrings<'a, S: 'a + ToOwned + ?Sized> + (pub &'a [ANSIGenericString<'a, S>]) + where ::Owned: fmt::Debug, S: PartialEq; + +/// A set of `ANSIString`s collected together, in order to be written with a +/// minimum of control characters. +pub type ANSIStrings<'a> = ANSIGenericStrings<'a, str>; + +/// A function to construct an `ANSIStrings` instance. +#[allow(non_snake_case)] +pub fn ANSIStrings<'a>(arg: &'a [ANSIString<'a>]) -> ANSIStrings<'a> { + ANSIGenericStrings(arg) +} + +/// A set of `ANSIByteString`s collected together, in order to be +/// written with a minimum of control characters. +pub type ANSIByteStrings<'a> = ANSIGenericStrings<'a, [u8]>; + +/// A function to construct an `ANSIByteStrings` instance. +#[allow(non_snake_case)] +pub fn ANSIByteStrings<'a>(arg: &'a [ANSIByteString<'a>]) -> ANSIByteStrings<'a> { + ANSIGenericStrings(arg) +} + + +// ---- paint functions ---- + +impl Style { + + /// Paints the given text with this colour, returning an ANSI string. + #[must_use] + pub fn paint<'a, I, S: 'a + ToOwned + ?Sized>(self, input: I) -> ANSIGenericString<'a, S> + where I: Into>, + ::Owned: fmt::Debug { + ANSIGenericString { + string: input.into(), + style: self, + } + } +} + + +impl Colour { + + /// Paints the given text with this colour, returning an ANSI string. + /// This is a short-cut so you don’t have to use `Blue.normal()` just + /// to get blue text. + /// + /// ``` + /// use ansi_term::Colour::Blue; + /// println!("{}", Blue.paint("da ba dee")); + /// ``` + #[must_use] + pub fn paint<'a, I, S: 'a + ToOwned + ?Sized>(self, input: I) -> ANSIGenericString<'a, S> + where I: Into>, + ::Owned: fmt::Debug { + ANSIGenericString { + string: input.into(), + style: self.normal(), + } + } +} + + +// ---- writers for individual ANSI strings ---- + +impl<'a> fmt::Display for ANSIString<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let w: &mut fmt::Write = f; + self.write_to_any(w) + } +} + +impl<'a> ANSIByteString<'a> { + /// Write an `ANSIByteString` to an `io::Write`. This writes the escape + /// sequences for the associated `Style` around the bytes. + pub fn write_to(&self, w: &mut W) -> io::Result<()> { + let w: &mut io::Write = w; + self.write_to_any(w) + } +} + +impl<'a, S: 'a + ToOwned + ?Sized> ANSIGenericString<'a, S> +where ::Owned: fmt::Debug, &'a S: AsRef<[u8]> { + fn write_to_any + ?Sized>(&self, w: &mut W) -> Result<(), W::Error> { + write!(w, "{}", self.style.prefix())?; + w.write_str(self.string.as_ref())?; + write!(w, "{}", self.style.suffix()) + } +} + + +// ---- writers for combined ANSI strings ---- + +impl<'a> fmt::Display for ANSIStrings<'a> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let f: &mut fmt::Write = f; + self.write_to_any(f) + } +} + +impl<'a> ANSIByteStrings<'a> { + /// Write `ANSIByteStrings` to an `io::Write`. This writes the minimal + /// escape sequences for the associated `Style`s around each set of + /// bytes. + pub fn write_to(&self, w: &mut W) -> io::Result<()> { + let w: &mut io::Write = w; + self.write_to_any(w) + } +} + +impl<'a, S: 'a + ToOwned + ?Sized + PartialEq> ANSIGenericStrings<'a, S> +where ::Owned: fmt::Debug, &'a S: AsRef<[u8]> { + fn write_to_any + ?Sized>(&self, w: &mut W) -> Result<(), W::Error> { + use self::Difference::*; + + let first = match self.0.first() { + None => return Ok(()), + Some(f) => f, + }; + + write!(w, "{}", first.style.prefix())?; + w.write_str(first.string.as_ref())?; + + for window in self.0.windows(2) { + match Difference::between(&window[0].style, &window[1].style) { + ExtraStyles(style) => write!(w, "{}", style.prefix())?, + Reset => write!(w, "{}{}", RESET, window[1].style.prefix())?, + NoDifference => {/* Do nothing! */}, + } + + w.write_str(&window[1].string)?; + } + + // Write the final reset string after all of the ANSIStrings have been + // written, *except* if the last one has no styles, because it would + // have already been written by this point. + if let Some(last) = self.0.last() { + if !last.style.is_plain() { + write!(w, "{}", RESET)?; + } + } + + Ok(()) + } +} + + +// ---- tests ---- + +#[cfg(test)] +mod tests { + pub use super::super::ANSIStrings; + pub use style::Style; + pub use style::Colour::*; + + #[test] + fn no_control_codes_for_plain() { + let one = Style::default().paint("one"); + let two = Style::default().paint("two"); + let output = format!("{}", ANSIStrings( &[ one, two ] )); + assert_eq!(&*output, "onetwo"); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/ansi_term/src/lib.rs cargo-0.58.0/vendor/ansi_term/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/ansi_term/src/lib.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ansi_term/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,205 +1,271 @@ -//! This is a library for controlling colours and formatting, such as -//! red bold text or blue underlined text, on ANSI terminals. -//! -//! -//! ## Basic usage -//! -//! There are two main data structures in this crate that you need to be -//! concerned with: `ANSIString` and `Style`. A `Style` holds stylistic -//! information: colours, whether the text should be bold, or blinking, or -//! whatever. There are also `Colour` variants that represent simple foreground -//! colour styles. An `ANSIString` is a string paired with a `Style`. -//! -//! (Yes, it’s British English, but you won’t have to write “colour” very often. -//! `Style` is used the majority of the time.) -//! -//! To format a string, call the `paint` method on a `Style` or a `Colour`, -//! passing in the string you want to format as the argument. For example, -//! here’s how to get some red text: -//! -//! use ansi_term::Colour::Red; -//! println!("This is in red: {}", Red.paint("a red string")); -//! -//! It’s important to note that the `paint` method does *not* actually return a -//! string with the ANSI control characters surrounding it. Instead, it returns -//! an `ANSIString` value that has a `Display` implementation that, when -//! formatted, returns the characters. This allows strings to be printed with a -//! minimum of `String` allocations being performed behind the scenes. -//! -//! If you *do* want to get at the escape codes, then you can convert the -//! `ANSIString` to a string as you would any other `Display` value: -//! -//! use ansi_term::Colour::Red; -//! use std::string::ToString; -//! let red_string = Red.paint("a red string").to_string(); -//! -//! -//! ## Bold, underline, background, and other styles -//! -//! For anything more complex than plain foreground colour changes, you need to -//! construct `Style` objects themselves, rather than beginning with a `Colour`. -//! You can do this by chaining methods based on a new `Style`, created with -//! `Style::new()`. Each method creates a new style that has that specific -//! property set. For example: -//! -//! use ansi_term::Style; -//! println!("How about some {} and {}?", -//! Style::new().bold().paint("bold"), -//! Style::new().underline().paint("underline")); -//! -//! For brevity, these methods have also been implemented for `Colour` values, -//! so you can give your styles a foreground colour without having to begin with -//! an empty `Style` value: -//! -//! use ansi_term::Colour::{Blue, Yellow}; -//! println!("Demonstrating {} and {}!", -//! Blue.bold().paint("blue bold"), -//! Yellow.underline().paint("yellow underline")); -//! println!("Yellow on blue: {}", Yellow.on(Blue).paint("wow!")); -//! -//! The complete list of styles you can use are: `bold`, `dimmed`, `italic`, -//! `underline`, `blink`, `reverse`, `hidden`, `strikethrough`, and `on` for -//! background colours. -//! -//! In some cases, you may find it easier to change the foreground on an -//! existing `Style` rather than starting from the appropriate `Colour`. -//! You can do this using the `fg` method: -//! -//! use ansi_term::Style; -//! use ansi_term::Colour::{Blue, Cyan, Yellow}; -//! println!("Yellow on blue: {}", Style::new().on(Blue).fg(Yellow).paint("yow!")); -//! println!("Also yellow on blue: {}", Cyan.on(Blue).fg(Yellow).paint("zow!")); -//! -//! Finally, you can turn a `Colour` into a `Style` with the `normal` method. -//! This will produce the exact same `ANSIString` as if you just used the -//! `paint` method on the `Colour` directly, but it’s useful in certain cases: -//! for example, you may have a method that returns `Styles`, and need to -//! represent both the “red bold” and “red, but not bold” styles with values of -//! the same type. The `Style` struct also has a `Default` implementation if you -//! want to have a style with *nothing* set. -//! -//! use ansi_term::Style; -//! use ansi_term::Colour::Red; -//! Red.normal().paint("yet another red string"); -//! Style::default().paint("a completely regular string"); -//! -//! -//! ## Extended colours -//! -//! You can access the extended range of 256 colours by using the `Fixed` colour -//! variant, which takes an argument of the colour number to use. This can be -//! included wherever you would use a `Colour`: -//! -//! use ansi_term::Colour::Fixed; -//! Fixed(134).paint("A sort of light purple"); -//! Fixed(221).on(Fixed(124)).paint("Mustard in the ketchup"); -//! -//! The first sixteen of these values are the same as the normal and bold -//! standard colour variants. There’s nothing stopping you from using these as -//! `Fixed` colours instead, but there’s nothing to be gained by doing so -//! either. -//! -//! You can also access full 24-bit color by using the `RGB` colour variant, -//! which takes separate `u8` arguments for red, green, and blue: -//! -//! use ansi_term::Colour::RGB; -//! RGB(70, 130, 180).paint("Steel blue"); -//! -//! ## Combining successive coloured strings -//! -//! The benefit of writing ANSI escape codes to the terminal is that they -//! *stack*: you do not need to end every coloured string with a reset code if -//! the text that follows it is of a similar style. For example, if you want to -//! have some blue text followed by some blue bold text, it’s possible to send -//! the ANSI code for blue, followed by the ANSI code for bold, and finishing -//! with a reset code without having to have an extra one between the two -//! strings. -//! -//! This crate can optimise the ANSI codes that get printed in situations like -//! this, making life easier for your terminal renderer. The `ANSIStrings` -//! struct takes a slice of several `ANSIString` values, and will iterate over -//! each of them, printing only the codes for the styles that need to be updated -//! as part of its formatting routine. -//! -//! The following code snippet uses this to enclose a binary number displayed in -//! red bold text inside some red, but not bold, brackets: -//! -//! use ansi_term::Colour::Red; -//! use ansi_term::{ANSIString, ANSIStrings}; -//! let some_value = format!("{:b}", 42); -//! let strings: &[ANSIString<'static>] = &[ -//! Red.paint("["), -//! Red.bold().paint(some_value), -//! Red.paint("]"), -//! ]; -//! println!("Value: {}", ANSIStrings(strings)); -//! -//! There are several things to note here. Firstly, the `paint` method can take -//! *either* an owned `String` or a borrowed `&str`. Internally, an `ANSIString` -//! holds a copy-on-write (`Cow`) string value to deal with both owned and -//! borrowed strings at the same time. This is used here to display a `String`, -//! the result of the `format!` call, using the same mechanism as some -//! statically-available `&str` slices. Secondly, that the `ANSIStrings` value -//! works in the same way as its singular counterpart, with a `Display` -//! implementation that only performs the formatting when required. -//! -//! ## Byte strings -//! -//! This library also supports formatting `[u8]` byte strings; this supports -//! applications working with text in an unknown encoding. `Style` and -//! `Color` support painting `[u8]` values, resulting in an `ANSIByteString`. -//! This type does not implement `Display`, as it may not contain UTF-8, but -//! it does provide a method `write_to` to write the result to any -//! `io::Write`: -//! -//! use ansi_term::Colour::Green; -//! Green.paint("user data".as_bytes()).write_to(&mut std::io::stdout()).unwrap(); -//! -//! Similarly, the type `ANSIByteStrings` supports writing a list of -//! `ANSIByteString` values with minimal escape sequences: -//! -//! use ansi_term::Colour::Green; -//! use ansi_term::ANSIByteStrings; -//! ANSIByteStrings(&[ -//! Green.paint("user data 1\n".as_bytes()), -//! Green.bold().paint("user data 2\n".as_bytes()), -//! ]).write_to(&mut std::io::stdout()).unwrap(); - - -#![crate_name = "ansi_term"] -#![crate_type = "rlib"] -#![crate_type = "dylib"] - -#![warn(missing_copy_implementations)] -#![warn(missing_docs)] -#![warn(trivial_casts, trivial_numeric_casts)] -#![warn(unused_extern_crates, unused_qualifications)] - -#[cfg(target_os="windows")] -extern crate winapi; - -mod ansi; -pub use ansi::{Prefix, Infix, Suffix}; - -mod style; -pub use style::{Colour, Style}; - -/// Color is a type alias for Colour for those who can't be bothered. -pub use Colour as Color; - -// I'm not beyond calling Colour Colour, rather than Color, but I did -// purposefully name this crate 'ansi-term' so people wouldn't get -// confused when they tried to install it. -// -// Only *after* they'd installed it. - -mod difference; -mod display; -pub use display::*; - -mod write; - -mod windows; -pub use windows::*; - -mod debug; +//! This is a library for controlling colours and formatting, such as +//! red bold text or blue underlined text, on ANSI terminals. +//! +//! +//! ## Basic usage +//! +//! There are three main types in this crate that you need to be +//! concerned with: [`ANSIString`], [`Style`], and [`Colour`]. +//! +//! A `Style` holds stylistic information: foreground and background colours, +//! whether the text should be bold, or blinking, or other properties. The +//! [`Colour`] enum represents the available colours. And an [`ANSIString`] is a +//! string paired with a [`Style`]. +//! +//! [`Color`] is also available as an alias to `Colour`. +//! +//! To format a string, call the `paint` method on a `Style` or a `Colour`, +//! passing in the string you want to format as the argument. For example, +//! here’s how to get some red text: +//! +//! ``` +//! use ansi_term::Colour::Red; +//! +//! println!("This is in red: {}", Red.paint("a red string")); +//! ``` +//! +//! It’s important to note that the `paint` method does *not* actually return a +//! string with the ANSI control characters surrounding it. Instead, it returns +//! an [`ANSIString`] value that has a [`Display`] implementation that, when +//! formatted, returns the characters. This allows strings to be printed with a +//! minimum of [`String`] allocations being performed behind the scenes. +//! +//! If you *do* want to get at the escape codes, then you can convert the +//! [`ANSIString`] to a string as you would any other `Display` value: +//! +//! ``` +//! use ansi_term::Colour::Red; +//! +//! let red_string = Red.paint("a red string").to_string(); +//! ``` +//! +//! +//! ## Bold, underline, background, and other styles +//! +//! For anything more complex than plain foreground colour changes, you need to +//! construct `Style` values themselves, rather than beginning with a `Colour`. +//! You can do this by chaining methods based on a new `Style`, created with +//! [`Style::new()`]. Each method creates a new style that has that specific +//! property set. For example: +//! +//! ``` +//! use ansi_term::Style; +//! +//! println!("How about some {} and {}?", +//! Style::new().bold().paint("bold"), +//! Style::new().underline().paint("underline")); +//! ``` +//! +//! For brevity, these methods have also been implemented for `Colour` values, +//! so you can give your styles a foreground colour without having to begin with +//! an empty `Style` value: +//! +//! ``` +//! use ansi_term::Colour::{Blue, Yellow}; +//! +//! println!("Demonstrating {} and {}!", +//! Blue.bold().paint("blue bold"), +//! Yellow.underline().paint("yellow underline")); +//! +//! println!("Yellow on blue: {}", Yellow.on(Blue).paint("wow!")); +//! ``` +//! +//! The complete list of styles you can use are: [`bold`], [`dimmed`], [`italic`], +//! [`underline`], [`blink`], [`reverse`], [`hidden`], [`strikethrough`], and [`on`] for +//! background colours. +//! +//! In some cases, you may find it easier to change the foreground on an +//! existing `Style` rather than starting from the appropriate `Colour`. +//! You can do this using the [`fg`] method: +//! +//! ``` +//! use ansi_term::Style; +//! use ansi_term::Colour::{Blue, Cyan, Yellow}; +//! +//! println!("Yellow on blue: {}", Style::new().on(Blue).fg(Yellow).paint("yow!")); +//! println!("Also yellow on blue: {}", Cyan.on(Blue).fg(Yellow).paint("zow!")); +//! ``` +//! +//! You can turn a `Colour` into a `Style` with the [`normal`] method. +//! This will produce the exact same `ANSIString` as if you just used the +//! `paint` method on the `Colour` directly, but it’s useful in certain cases: +//! for example, you may have a method that returns `Styles`, and need to +//! represent both the “red bold” and “red, but not bold” styles with values of +//! the same type. The `Style` struct also has a [`Default`] implementation if you +//! want to have a style with *nothing* set. +//! +//! ``` +//! use ansi_term::Style; +//! use ansi_term::Colour::Red; +//! +//! Red.normal().paint("yet another red string"); +//! Style::default().paint("a completely regular string"); +//! ``` +//! +//! +//! ## Extended colours +//! +//! You can access the extended range of 256 colours by using the `Colour::Fixed` +//! variant, which takes an argument of the colour number to use. This can be +//! included wherever you would use a `Colour`: +//! +//! ``` +//! use ansi_term::Colour::Fixed; +//! +//! Fixed(134).paint("A sort of light purple"); +//! Fixed(221).on(Fixed(124)).paint("Mustard in the ketchup"); +//! ``` +//! +//! The first sixteen of these values are the same as the normal and bold +//! standard colour variants. There’s nothing stopping you from using these as +//! `Fixed` colours instead, but there’s nothing to be gained by doing so +//! either. +//! +//! You can also access full 24-bit colour by using the `Colour::RGB` variant, +//! which takes separate `u8` arguments for red, green, and blue: +//! +//! ``` +//! use ansi_term::Colour::RGB; +//! +//! RGB(70, 130, 180).paint("Steel blue"); +//! ``` +//! +//! ## Combining successive coloured strings +//! +//! The benefit of writing ANSI escape codes to the terminal is that they +//! *stack*: you do not need to end every coloured string with a reset code if +//! the text that follows it is of a similar style. For example, if you want to +//! have some blue text followed by some blue bold text, it’s possible to send +//! the ANSI code for blue, followed by the ANSI code for bold, and finishing +//! with a reset code without having to have an extra one between the two +//! strings. +//! +//! This crate can optimise the ANSI codes that get printed in situations like +//! this, making life easier for your terminal renderer. The [`ANSIStrings`] +//! type takes a slice of several [`ANSIString`] values, and will iterate over +//! each of them, printing only the codes for the styles that need to be updated +//! as part of its formatting routine. +//! +//! The following code snippet uses this to enclose a binary number displayed in +//! red bold text inside some red, but not bold, brackets: +//! +//! ``` +//! use ansi_term::Colour::Red; +//! use ansi_term::{ANSIString, ANSIStrings}; +//! +//! let some_value = format!("{:b}", 42); +//! let strings: &[ANSIString<'static>] = &[ +//! Red.paint("["), +//! Red.bold().paint(some_value), +//! Red.paint("]"), +//! ]; +//! +//! println!("Value: {}", ANSIStrings(strings)); +//! ``` +//! +//! There are several things to note here. Firstly, the [`paint`] method can take +//! *either* an owned [`String`] or a borrowed [`&str`]. Internally, an [`ANSIString`] +//! holds a copy-on-write ([`Cow`]) string value to deal with both owned and +//! borrowed strings at the same time. This is used here to display a `String`, +//! the result of the `format!` call, using the same mechanism as some +//! statically-available `&str` slices. Secondly, that the [`ANSIStrings`] value +//! works in the same way as its singular counterpart, with a [`Display`] +//! implementation that only performs the formatting when required. +//! +//! ## Byte strings +//! +//! This library also supports formatting `\[u8]` byte strings; this supports +//! applications working with text in an unknown encoding. [`Style`] and +//! [`Colour`] support painting `\[u8]` values, resulting in an [`ANSIByteString`]. +//! This type does not implement [`Display`], as it may not contain UTF-8, but +//! it does provide a method [`write_to`] to write the result to any value that +//! implements [`Write`]: +//! +//! ``` +//! use ansi_term::Colour::Green; +//! +//! Green.paint("user data".as_bytes()).write_to(&mut std::io::stdout()).unwrap(); +//! ``` +//! +//! Similarly, the type [`ANSIByteStrings`] supports writing a list of +//! [`ANSIByteString`] values with minimal escape sequences: +//! +//! ``` +//! use ansi_term::Colour::Green; +//! use ansi_term::ANSIByteStrings; +//! +//! ANSIByteStrings(&[ +//! Green.paint("user data 1\n".as_bytes()), +//! Green.bold().paint("user data 2\n".as_bytes()), +//! ]).write_to(&mut std::io::stdout()).unwrap(); +//! ``` +//! +//! [`Cow`]: https://doc.rust-lang.org/std/borrow/enum.Cow.html +//! [`Display`]: https://doc.rust-lang.org/std/fmt/trait.Display.html +//! [`Default`]: https://doc.rust-lang.org/std/default/trait.Default.html +//! [`String`]: https://doc.rust-lang.org/std/string/struct.String.html +//! [`&str`]: https://doc.rust-lang.org/std/primitive.str.html +//! [`Write`]: https://doc.rust-lang.org/std/io/trait.Write.html +//! [`Style`]: struct.Style.html +//! [`Style::new()`]: struct.Style.html#method.new +//! [`Color`]: enum.Color.html +//! [`Colour`]: enum.Colour.html +//! [`ANSIString`]: type.ANSIString.html +//! [`ANSIStrings`]: type.ANSIStrings.html +//! [`ANSIByteString`]: type.ANSIByteString.html +//! [`ANSIByteStrings`]: type.ANSIByteStrings.html +//! [`write_to`]: type.ANSIByteString.html#method.write_to +//! [`paint`]: type.ANSIByteString.html#method.write_to +//! [`normal`]: enum.Colour.html#method.normal +//! +//! [`bold`]: struct.Style.html#method.bold +//! [`dimmed`]: struct.Style.html#method.dimmed +//! [`italic`]: struct.Style.html#method.italic +//! [`underline`]: struct.Style.html#method.underline +//! [`blink`]: struct.Style.html#method.blink +//! [`reverse`]: struct.Style.html#method.reverse +//! [`hidden`]: struct.Style.html#method.hidden +//! [`strikethrough`]: struct.Style.html#method.strikethrough +//! [`fg`]: struct.Style.html#method.fg +//! [`on`]: struct.Style.html#method.on + +#![crate_name = "ansi_term"] +#![crate_type = "rlib"] +#![crate_type = "dylib"] + +#![warn(missing_copy_implementations)] +#![warn(missing_docs)] +#![warn(trivial_casts, trivial_numeric_casts)] +#![warn(unused_extern_crates, unused_qualifications)] + +#[cfg(target_os="windows")] +extern crate winapi; +#[cfg(test)] +#[macro_use] +extern crate doc_comment; + +#[cfg(test)] +doctest!("../README.md"); + +mod ansi; +pub use ansi::{Prefix, Infix, Suffix}; + +mod style; +pub use style::{Colour, Style}; + +/// Color is a type alias for `Colour`. +pub use Colour as Color; + +mod difference; +mod display; +pub use display::*; + +mod write; + +mod windows; +pub use windows::*; + +mod util; +pub use util::*; + +mod debug; diff -Nru cargo-0.57.0+ubuntu/vendor/ansi_term/src/style.rs cargo-0.58.0/vendor/ansi_term/src/style.rs --- cargo-0.57.0+ubuntu/vendor/ansi_term/src/style.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ansi_term/src/style.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,259 +1,521 @@ -/// A style is a collection of properties that can format a string -/// using ANSI escape codes. -#[derive(PartialEq, Clone, Copy)] -pub struct Style { - - /// The style's foreground colour, if it has one. - pub foreground: Option, - - /// The style's background colour, if it has one. - pub background: Option, - - /// Whether this style is bold. - pub is_bold: bool, - - /// Whether this style is dimmed. - pub is_dimmed: bool, - - /// Whether this style is italic. - pub is_italic: bool, - - /// Whether this style is underlined. - pub is_underline: bool, - - /// Whether this style is blinking. - pub is_blink: bool, - - /// Whether this style has reverse colours. - pub is_reverse: bool, - - /// Whether this style is hidden. - pub is_hidden: bool, - - /// Whether this style is struckthrough. - pub is_strikethrough: bool -} - -impl Style { - /// Creates a new Style with no differences. - pub fn new() -> Style { - Style::default() - } - - /// Returns a `Style` with the bold property set. - pub fn bold(&self) -> Style { - Style { is_bold: true, .. *self } - } - - /// Returns a `Style` with the dimmed property set. - pub fn dimmed(&self) -> Style { - Style { is_dimmed: true, .. *self } - } - - /// Returns a `Style` with the italic property set. - pub fn italic(&self) -> Style { - Style { is_italic: true, .. *self } - } - - /// Returns a `Style` with the underline property set. - pub fn underline(&self) -> Style { - Style { is_underline: true, .. *self } - } - - /// Returns a `Style` with the blink property set. - pub fn blink(&self) -> Style { - Style { is_blink: true, .. *self } - } - - /// Returns a `Style` with the reverse property set. - pub fn reverse(&self) -> Style { - Style { is_reverse: true, .. *self } - } - - /// Returns a `Style` with the hidden property set. - pub fn hidden(&self) -> Style { - Style { is_hidden: true, .. *self } - } - - /// Returns a `Style` with the hidden property set. - pub fn strikethrough(&self) -> Style { - Style { is_strikethrough: true, .. *self } - } - - /// Returns a `Style` with the foreground colour property set. - pub fn fg(&self, foreground: Colour) -> Style { - Style { foreground: Some(foreground), .. *self } - } - - /// Returns a `Style` with the background colour property set. - pub fn on(&self, background: Colour) -> Style { - Style { background: Some(background), .. *self } - } - - /// Return true if this `Style` has no actual styles, and can be written - /// without any control characters. - pub fn is_plain(self) -> bool { - self == Style::default() - } -} - -impl Default for Style { - - /// Returns a style with *no* properties set. Formatting text using this - /// style returns the exact same text. - /// - /// ``` - /// use ansi_term::Style; - /// assert_eq!(None, Style::default().foreground); - /// assert_eq!(None, Style::default().background); - /// assert_eq!(false, Style::default().is_bold); - /// assert_eq!("txt", Style::default().paint("txt").to_string()); - /// ``` - fn default() -> Style { - Style { - foreground: None, - background: None, - is_bold: false, - is_dimmed: false, - is_italic: false, - is_underline: false, - is_blink: false, - is_reverse: false, - is_hidden: false, - is_strikethrough: false, - } - } -} - - -// ---- colours ---- - -/// A colour is one specific type of ANSI escape code, and can refer -/// to either the foreground or background colour. -/// -/// These use the standard numeric sequences. -/// See -#[derive(PartialEq, Clone, Copy, Debug)] -pub enum Colour { - - /// Colour #0 (foreground code `30`, background code `40`). - /// - /// This is not necessarily the background colour, and using it as one may - /// render the text hard to read on terminals with dark backgrounds. - Black, - - /// Colour #1 (foreground code `31`, background code `41`). - Red, - - /// Colour #2 (foreground code `32`, background code `42`). - Green, - - /// Colour #3 (foreground code `33`, background code `43`). - Yellow, - - /// Colour #4 (foreground code `34`, background code `44`). - Blue, - - /// Colour #5 (foreground code `35`, background code `45`). - Purple, - - /// Colour #6 (foreground code `36`, background code `46`). - Cyan, - - /// Colour #7 (foreground code `37`, background code `47`). - /// - /// As above, this is not necessarily the foreground colour, and may be - /// hard to read on terminals with light backgrounds. - White, - - /// A colour number from 0 to 255, for use in 256-colour terminal - /// environments. - /// - /// - Colours 0 to 7 are the `Black` to `White` variants respectively. - /// These colours can usually be changed in the terminal emulator. - /// - Colours 8 to 15 are brighter versions of the eight colours above. - /// These can also usually be changed in the terminal emulator, or it - /// could be configured to use the original colours and show the text in - /// bold instead. It varies depending on the program. - /// - Colours 16 to 231 contain several palettes of bright colours, - /// arranged in six squares measuring six by six each. - /// - Colours 232 to 255 are shades of grey from black to white. - /// - /// It might make more sense to look at a [colour chart][cc]. - /// - /// [cc]: https://upload.wikimedia.org/wikipedia/en/1/15/Xterm_256color_chart.svg - Fixed(u8), - - /// A 24-bit RGB color, as specified by ISO-8613-3. - RGB(u8, u8, u8), -} - - -impl Colour { - /// Return a `Style` with the foreground colour set to this colour. - pub fn normal(self) -> Style { - Style { foreground: Some(self), .. Style::default() } - } - - /// Returns a `Style` with the bold property set. - pub fn bold(self) -> Style { - Style { foreground: Some(self), is_bold: true, .. Style::default() } - } - - /// Returns a `Style` with the dimmed property set. - pub fn dimmed(self) -> Style { - Style { foreground: Some(self), is_dimmed: true, .. Style::default() } - } - - /// Returns a `Style` with the italic property set. - pub fn italic(self) -> Style { - Style { foreground: Some(self), is_italic: true, .. Style::default() } - } - - /// Returns a `Style` with the underline property set. - pub fn underline(self) -> Style { - Style { foreground: Some(self), is_underline: true, .. Style::default() } - } - - /// Returns a `Style` with the blink property set. - pub fn blink(self) -> Style { - Style { foreground: Some(self), is_blink: true, .. Style::default() } - } - - /// Returns a `Style` with the reverse property set. - pub fn reverse(self) -> Style { - Style { foreground: Some(self), is_reverse: true, .. Style::default() } - } - - /// Returns a `Style` with the hidden property set. - pub fn hidden(self) -> Style { - Style { foreground: Some(self), is_hidden: true, .. Style::default() } - } - - /// Returns a `Style` with the strikethrough property set. - pub fn strikethrough(self) -> Style { - Style { foreground: Some(self), is_strikethrough: true, .. Style::default() } - } - - /// Returns a `Style` with the background colour property set. - pub fn on(self, background: Colour) -> Style { - Style { foreground: Some(self), background: Some(background), .. Style::default() } - } -} - -impl From for Style { - - /// You can turn a `Colour` into a `Style` with the foreground colour set - /// with the `From` trait. - /// - /// ``` - /// use ansi_term::{Style, Colour}; - /// let green_foreground = Style::default().fg(Colour::Green); - /// assert_eq!(green_foreground, Colour::Green.normal()); - /// assert_eq!(green_foreground, Colour::Green.into()); - /// assert_eq!(green_foreground, Style::from(Colour::Green)); - /// ``` - fn from(colour: Colour) -> Style { - colour.normal() - } -} +/// A style is a collection of properties that can format a string +/// using ANSI escape codes. +/// +/// # Examples +/// +/// ``` +/// use ansi_term::{Style, Colour}; +/// +/// let style = Style::new().bold().on(Colour::Black); +/// println!("{}", style.paint("Bold on black")); +/// ``` +#[derive(PartialEq, Clone, Copy)] +#[cfg_attr(feature = "derive_serde_style", derive(serde::Deserialize, serde::Serialize))] +pub struct Style { + + /// The style's foreground colour, if it has one. + pub foreground: Option, + + /// The style's background colour, if it has one. + pub background: Option, + + /// Whether this style is bold. + pub is_bold: bool, + + /// Whether this style is dimmed. + pub is_dimmed: bool, + + /// Whether this style is italic. + pub is_italic: bool, + + /// Whether this style is underlined. + pub is_underline: bool, + + /// Whether this style is blinking. + pub is_blink: bool, + + /// Whether this style has reverse colours. + pub is_reverse: bool, + + /// Whether this style is hidden. + pub is_hidden: bool, + + /// Whether this style is struckthrough. + pub is_strikethrough: bool +} + +impl Style { + + /// Creates a new Style with no properties set. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Style; + /// + /// let style = Style::new(); + /// println!("{}", style.paint("hi")); + /// ``` + pub fn new() -> Style { + Style::default() + } + + /// Returns a `Style` with the bold property set. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Style; + /// + /// let style = Style::new().bold(); + /// println!("{}", style.paint("hey")); + /// ``` + pub fn bold(&self) -> Style { + Style { is_bold: true, .. *self } + } + + /// Returns a `Style` with the dimmed property set. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Style; + /// + /// let style = Style::new().dimmed(); + /// println!("{}", style.paint("sup")); + /// ``` + pub fn dimmed(&self) -> Style { + Style { is_dimmed: true, .. *self } + } + + /// Returns a `Style` with the italic property set. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Style; + /// + /// let style = Style::new().italic(); + /// println!("{}", style.paint("greetings")); + /// ``` + pub fn italic(&self) -> Style { + Style { is_italic: true, .. *self } + } + + /// Returns a `Style` with the underline property set. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Style; + /// + /// let style = Style::new().underline(); + /// println!("{}", style.paint("salutations")); + /// ``` + pub fn underline(&self) -> Style { + Style { is_underline: true, .. *self } + } + + /// Returns a `Style` with the blink property set. + /// # Examples + /// + /// ``` + /// use ansi_term::Style; + /// + /// let style = Style::new().blink(); + /// println!("{}", style.paint("wazzup")); + /// ``` + pub fn blink(&self) -> Style { + Style { is_blink: true, .. *self } + } + + /// Returns a `Style` with the reverse property set. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Style; + /// + /// let style = Style::new().reverse(); + /// println!("{}", style.paint("aloha")); + /// ``` + pub fn reverse(&self) -> Style { + Style { is_reverse: true, .. *self } + } + + /// Returns a `Style` with the hidden property set. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Style; + /// + /// let style = Style::new().hidden(); + /// println!("{}", style.paint("ahoy")); + /// ``` + pub fn hidden(&self) -> Style { + Style { is_hidden: true, .. *self } + } + + /// Returns a `Style` with the strikethrough property set. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Style; + /// + /// let style = Style::new().strikethrough(); + /// println!("{}", style.paint("yo")); + /// ``` + pub fn strikethrough(&self) -> Style { + Style { is_strikethrough: true, .. *self } + } + + /// Returns a `Style` with the foreground colour property set. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::{Style, Colour}; + /// + /// let style = Style::new().fg(Colour::Yellow); + /// println!("{}", style.paint("hi")); + /// ``` + pub fn fg(&self, foreground: Colour) -> Style { + Style { foreground: Some(foreground), .. *self } + } + + /// Returns a `Style` with the background colour property set. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::{Style, Colour}; + /// + /// let style = Style::new().on(Colour::Blue); + /// println!("{}", style.paint("eyyyy")); + /// ``` + pub fn on(&self, background: Colour) -> Style { + Style { background: Some(background), .. *self } + } + + /// Return true if this `Style` has no actual styles, and can be written + /// without any control characters. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Style; + /// + /// assert_eq!(true, Style::default().is_plain()); + /// assert_eq!(false, Style::default().bold().is_plain()); + /// ``` + pub fn is_plain(self) -> bool { + self == Style::default() + } +} + +impl Default for Style { + + /// Returns a style with *no* properties set. Formatting text using this + /// style returns the exact same text. + /// + /// ``` + /// use ansi_term::Style; + /// assert_eq!(None, Style::default().foreground); + /// assert_eq!(None, Style::default().background); + /// assert_eq!(false, Style::default().is_bold); + /// assert_eq!("txt", Style::default().paint("txt").to_string()); + /// ``` + fn default() -> Style { + Style { + foreground: None, + background: None, + is_bold: false, + is_dimmed: false, + is_italic: false, + is_underline: false, + is_blink: false, + is_reverse: false, + is_hidden: false, + is_strikethrough: false, + } + } +} + + +// ---- colours ---- + +/// A colour is one specific type of ANSI escape code, and can refer +/// to either the foreground or background colour. +/// +/// These use the standard numeric sequences. +/// See +#[derive(PartialEq, Clone, Copy, Debug)] +#[cfg_attr(feature = "derive_serde_style", derive(serde::Deserialize, serde::Serialize))] +pub enum Colour { + + /// Colour #0 (foreground code `30`, background code `40`). + /// + /// This is not necessarily the background colour, and using it as one may + /// render the text hard to read on terminals with dark backgrounds. + Black, + + /// Colour #1 (foreground code `31`, background code `41`). + Red, + + /// Colour #2 (foreground code `32`, background code `42`). + Green, + + /// Colour #3 (foreground code `33`, background code `43`). + Yellow, + + /// Colour #4 (foreground code `34`, background code `44`). + Blue, + + /// Colour #5 (foreground code `35`, background code `45`). + Purple, + + /// Colour #6 (foreground code `36`, background code `46`). + Cyan, + + /// Colour #7 (foreground code `37`, background code `47`). + /// + /// As above, this is not necessarily the foreground colour, and may be + /// hard to read on terminals with light backgrounds. + White, + + /// A colour number from 0 to 255, for use in 256-colour terminal + /// environments. + /// + /// - Colours 0 to 7 are the `Black` to `White` variants respectively. + /// These colours can usually be changed in the terminal emulator. + /// - Colours 8 to 15 are brighter versions of the eight colours above. + /// These can also usually be changed in the terminal emulator, or it + /// could be configured to use the original colours and show the text in + /// bold instead. It varies depending on the program. + /// - Colours 16 to 231 contain several palettes of bright colours, + /// arranged in six squares measuring six by six each. + /// - Colours 232 to 255 are shades of grey from black to white. + /// + /// It might make more sense to look at a [colour chart][cc]. + /// + /// [cc]: https://upload.wikimedia.org/wikipedia/commons/1/15/Xterm_256color_chart.svg + Fixed(u8), + + /// A 24-bit RGB color, as specified by ISO-8613-3. + RGB(u8, u8, u8), +} + + +impl Colour { + + /// Returns a `Style` with the foreground colour set to this colour. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Colour; + /// + /// let style = Colour::Red.normal(); + /// println!("{}", style.paint("hi")); + /// ``` + pub fn normal(self) -> Style { + Style { foreground: Some(self), .. Style::default() } + } + + /// Returns a `Style` with the foreground colour set to this colour and the + /// bold property set. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Colour; + /// + /// let style = Colour::Green.bold(); + /// println!("{}", style.paint("hey")); + /// ``` + pub fn bold(self) -> Style { + Style { foreground: Some(self), is_bold: true, .. Style::default() } + } + + /// Returns a `Style` with the foreground colour set to this colour and the + /// dimmed property set. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Colour; + /// + /// let style = Colour::Yellow.dimmed(); + /// println!("{}", style.paint("sup")); + /// ``` + pub fn dimmed(self) -> Style { + Style { foreground: Some(self), is_dimmed: true, .. Style::default() } + } + + /// Returns a `Style` with the foreground colour set to this colour and the + /// italic property set. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Colour; + /// + /// let style = Colour::Blue.italic(); + /// println!("{}", style.paint("greetings")); + /// ``` + pub fn italic(self) -> Style { + Style { foreground: Some(self), is_italic: true, .. Style::default() } + } + + /// Returns a `Style` with the foreground colour set to this colour and the + /// underline property set. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Colour; + /// + /// let style = Colour::Purple.underline(); + /// println!("{}", style.paint("salutations")); + /// ``` + pub fn underline(self) -> Style { + Style { foreground: Some(self), is_underline: true, .. Style::default() } + } + + /// Returns a `Style` with the foreground colour set to this colour and the + /// blink property set. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Colour; + /// + /// let style = Colour::Cyan.blink(); + /// println!("{}", style.paint("wazzup")); + /// ``` + pub fn blink(self) -> Style { + Style { foreground: Some(self), is_blink: true, .. Style::default() } + } + + /// Returns a `Style` with the foreground colour set to this colour and the + /// reverse property set. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Colour; + /// + /// let style = Colour::Black.reverse(); + /// println!("{}", style.paint("aloha")); + /// ``` + pub fn reverse(self) -> Style { + Style { foreground: Some(self), is_reverse: true, .. Style::default() } + } + + /// Returns a `Style` with the foreground colour set to this colour and the + /// hidden property set. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Colour; + /// + /// let style = Colour::White.hidden(); + /// println!("{}", style.paint("ahoy")); + /// ``` + pub fn hidden(self) -> Style { + Style { foreground: Some(self), is_hidden: true, .. Style::default() } + } + + /// Returns a `Style` with the foreground colour set to this colour and the + /// strikethrough property set. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Colour; + /// + /// let style = Colour::Fixed(244).strikethrough(); + /// println!("{}", style.paint("yo")); + /// ``` + pub fn strikethrough(self) -> Style { + Style { foreground: Some(self), is_strikethrough: true, .. Style::default() } + } + + /// Returns a `Style` with the foreground colour set to this colour and the + /// background colour property set to the given colour. + /// + /// # Examples + /// + /// ``` + /// use ansi_term::Colour; + /// + /// let style = Colour::RGB(31, 31, 31).on(Colour::White); + /// println!("{}", style.paint("eyyyy")); + /// ``` + pub fn on(self, background: Colour) -> Style { + Style { foreground: Some(self), background: Some(background), .. Style::default() } + } +} + +impl From for Style { + + /// You can turn a `Colour` into a `Style` with the foreground colour set + /// with the `From` trait. + /// + /// ``` + /// use ansi_term::{Style, Colour}; + /// let green_foreground = Style::default().fg(Colour::Green); + /// assert_eq!(green_foreground, Colour::Green.normal()); + /// assert_eq!(green_foreground, Colour::Green.into()); + /// assert_eq!(green_foreground, Style::from(Colour::Green)); + /// ``` + fn from(colour: Colour) -> Style { + colour.normal() + } +} + +#[cfg(test)] +#[cfg(feature = "derive_serde_style")] +mod serde_json_tests { + use super::{Style, Colour}; + + #[test] + fn colour_serialization() { + + let colours = &[ + Colour::Red, + Colour::Blue, + Colour::RGB(123, 123, 123), + Colour::Fixed(255), + ]; + + assert_eq!(serde_json::to_string(&colours).unwrap(), String::from("[\"Red\",\"Blue\",{\"RGB\":[123,123,123]},{\"Fixed\":255}]")); + } + + #[test] + fn colour_deserialization() { + let colours = &[ + Colour::Red, + Colour::Blue, + Colour::RGB(123, 123, 123), + Colour::Fixed(255), + ]; + + for colour in colours.into_iter() { + let serialized = serde_json::to_string(&colour).unwrap(); + let deserialized: Colour = serde_json::from_str(&serialized).unwrap(); + + assert_eq!(colour, &deserialized); + } + } + + #[test] + fn style_serialization() { + let style = Style::default(); + + assert_eq!(serde_json::to_string(&style).unwrap(), "{\"foreground\":null,\"background\":null,\"is_bold\":false,\"is_dimmed\":false,\"is_italic\":false,\"is_underline\":false,\"is_blink\":false,\"is_reverse\":false,\"is_hidden\":false,\"is_strikethrough\":false}".to_string()); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/ansi_term/src/util.rs cargo-0.58.0/vendor/ansi_term/src/util.rs --- cargo-0.57.0+ubuntu/vendor/ansi_term/src/util.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/ansi_term/src/util.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,81 @@ +use display::*; +use std::ops::Deref; + +/// Return a substring of the given ANSIStrings sequence, while keeping the formatting. +pub fn sub_string<'a>(start: usize, len: usize, strs: &ANSIStrings<'a>) -> Vec> { + let mut vec = Vec::new(); + let mut pos = start; + let mut len_rem = len; + + for i in strs.0.iter() { + let fragment = i.deref(); + let frag_len = fragment.len(); + if pos >= frag_len { + pos -= frag_len; + continue; + } + if len_rem <= 0 { + break; + } + + let end = pos + len_rem; + let pos_end = if end >= frag_len { frag_len } else { end }; + + vec.push(i.style_ref().paint(String::from(&fragment[pos..pos_end]))); + + if end <= frag_len { + break; + } + + len_rem -= pos_end - pos; + pos = 0; + } + + vec +} + +/// Return a concatenated copy of `strs` without the formatting, as an allocated `String`. +pub fn unstyle(strs: &ANSIStrings) -> String { + let mut s = String::new(); + + for i in strs.0.iter() { + s += &i.deref(); + } + + s +} + +/// Return the unstyled length of ANSIStrings. This is equaivalent to `unstyle(strs).len()`. +pub fn unstyled_len(strs: &ANSIStrings) -> usize { + let mut l = 0; + for i in strs.0.iter() { + l += i.deref().len(); + } + l +} + +#[cfg(test)] +mod test { + use Colour::*; + use display::*; + use super::*; + + #[test] + fn test() { + let l = [ + Black.paint("first"), + Red.paint("-second"), + White.paint("-third"), + ]; + let a = ANSIStrings(&l); + assert_eq!(unstyle(&a), "first-second-third"); + assert_eq!(unstyled_len(&a), 18); + + let l2 = [ + Black.paint("st"), + Red.paint("-second"), + White.paint("-t"), + ]; + assert_eq!(sub_string(3, 11, &a).as_slice(), &l2); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/ansi_term/src/windows.rs cargo-0.58.0/vendor/ansi_term/src/windows.rs --- cargo-0.57.0+ubuntu/vendor/ansi_term/src/windows.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ansi_term/src/windows.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,40 +1,61 @@ -/// Enables ANSI code support on Windows 10. -/// -/// This uses Windows API calls to alter the properties of the console that -/// the program is running in. -/// -/// https://msdn.microsoft.com/en-us/library/windows/desktop/mt638032(v=vs.85).aspx -/// -/// Returns a `Result` with the Windows error code if unsuccessful. -#[cfg(windows)] -pub fn enable_ansi_support() -> Result<(), u32> { - use winapi::um::processenv::GetStdHandle; - use winapi::um::errhandlingapi::GetLastError; - use winapi::um::consoleapi::{GetConsoleMode, SetConsoleMode}; - - const STD_OUT_HANDLE: u32 = -11i32 as u32; - const ENABLE_VIRTUAL_TERMINAL_PROCESSING: u32 = 0x0004; - - unsafe { - // https://docs.microsoft.com/en-us/windows/console/getstdhandle - let std_out_handle = GetStdHandle(STD_OUT_HANDLE); - let error_code = GetLastError(); - if error_code != 0 { return Err(error_code); } - - // https://docs.microsoft.com/en-us/windows/console/getconsolemode - let mut console_mode: u32 = 0; - GetConsoleMode(std_out_handle, &mut console_mode); - let error_code = GetLastError(); - if error_code != 0 { return Err(error_code); } - - // VT processing not already enabled? - if console_mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING == 0 { - // https://docs.microsoft.com/en-us/windows/console/setconsolemode - SetConsoleMode(std_out_handle, console_mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING); - let error_code = GetLastError(); - if error_code != 0 { return Err(error_code); } - } - } - - return Ok(()); -} +/// Enables ANSI code support on Windows 10. +/// +/// This uses Windows API calls to alter the properties of the console that +/// the program is running in. +/// +/// https://msdn.microsoft.com/en-us/library/windows/desktop/mt638032(v=vs.85).aspx +/// +/// Returns a `Result` with the Windows error code if unsuccessful. +#[cfg(windows)] +pub fn enable_ansi_support() -> Result<(), u32> { + // ref: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#EXAMPLE_OF_ENABLING_VIRTUAL_TERMINAL_PROCESSING @@ https://archive.is/L7wRJ#76% + + use std::ffi::OsStr; + use std::iter::once; + use std::os::windows::ffi::OsStrExt; + use std::ptr::null_mut; + use winapi::um::consoleapi::{GetConsoleMode, SetConsoleMode}; + use winapi::um::errhandlingapi::GetLastError; + use winapi::um::fileapi::{CreateFileW, OPEN_EXISTING}; + use winapi::um::handleapi::INVALID_HANDLE_VALUE; + use winapi::um::winnt::{FILE_SHARE_WRITE, GENERIC_READ, GENERIC_WRITE}; + + const ENABLE_VIRTUAL_TERMINAL_PROCESSING: u32 = 0x0004; + + unsafe { + // ref: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilew + // Using `CreateFileW("CONOUT$", ...)` to retrieve the console handle works correctly even if STDOUT and/or STDERR are redirected + let console_out_name: Vec = OsStr::new("CONOUT$").encode_wide().chain(once(0)).collect(); + let console_handle = CreateFileW( + console_out_name.as_ptr(), + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_WRITE, + null_mut(), + OPEN_EXISTING, + 0, + null_mut(), + ); + if console_handle == INVALID_HANDLE_VALUE + { + return Err(GetLastError()); + } + + // ref: https://docs.microsoft.com/en-us/windows/console/getconsolemode + let mut console_mode: u32 = 0; + if 0 == GetConsoleMode(console_handle, &mut console_mode) + { + return Err(GetLastError()); + } + + // VT processing not already enabled? + if console_mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING == 0 { + // https://docs.microsoft.com/en-us/windows/console/setconsolemode + if 0 == SetConsoleMode(console_handle, console_mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING) + { + return Err(GetLastError()); + } + } + } + + return Ok(()); +} diff -Nru cargo-0.57.0+ubuntu/vendor/ansi_term/src/write.rs cargo-0.58.0/vendor/ansi_term/src/write.rs --- cargo-0.57.0+ubuntu/vendor/ansi_term/src/write.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ansi_term/src/write.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,40 +1,40 @@ -use std::fmt; -use std::io; - - -pub trait AnyWrite { - type wstr: ?Sized; - type Error; - - fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<(), Self::Error>; - - fn write_str(&mut self, s: &Self::wstr) -> Result<(), Self::Error>; -} - - -impl<'a> AnyWrite for fmt::Write + 'a { - type wstr = str; - type Error = fmt::Error; - - fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<(), Self::Error> { - fmt::Write::write_fmt(self, fmt) - } - - fn write_str(&mut self, s: &Self::wstr) -> Result<(), Self::Error> { - fmt::Write::write_str(self, s) - } -} - - -impl<'a> AnyWrite for io::Write + 'a { - type wstr = [u8]; - type Error = io::Error; - - fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<(), Self::Error> { - io::Write::write_fmt(self, fmt) - } - - fn write_str(&mut self, s: &Self::wstr) -> Result<(), Self::Error> { - io::Write::write_all(self, s) - } -} +use std::fmt; +use std::io; + + +pub trait AnyWrite { + type wstr: ?Sized; + type Error; + + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<(), Self::Error>; + + fn write_str(&mut self, s: &Self::wstr) -> Result<(), Self::Error>; +} + + +impl<'a> AnyWrite for fmt::Write + 'a { + type wstr = str; + type Error = fmt::Error; + + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<(), Self::Error> { + fmt::Write::write_fmt(self, fmt) + } + + fn write_str(&mut self, s: &Self::wstr) -> Result<(), Self::Error> { + fmt::Write::write_str(self, s) + } +} + + +impl<'a> AnyWrite for io::Write + 'a { + type wstr = [u8]; + type Error = io::Error; + + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<(), Self::Error> { + io::Write::write_fmt(self, fmt) + } + + fn write_str(&mut self, s: &Self::wstr) -> Result<(), Self::Error> { + io::Write::write_all(self, s) + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/build.rs cargo-0.58.0/vendor/anyhow/build.rs --- cargo-0.57.0+ubuntu/vendor/anyhow/build.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/build.rs 2022-01-21 02:47:39.000000000 +0000 @@ -55,13 +55,13 @@ None => return, }; - if rustc < 38 { - println!("cargo:rustc-cfg=anyhow_no_macro_reexport"); - } - if rustc < 51 { println!("cargo:rustc-cfg=anyhow_no_ptr_addr_of"); } + + if rustc < 52 { + println!("cargo:rustc-cfg=anyhow_no_fmt_arguments_as_str"); + } } fn compile_probe() -> Option { diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/.cargo-checksum.json cargo-0.58.0/vendor/anyhow/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/anyhow/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1"} \ No newline at end of file +{"files":{},"package":"84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/Cargo.toml cargo-0.58.0/vendor/anyhow/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/anyhow/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -11,8 +11,9 @@ [package] edition = "2018" +rust-version = "1.38" name = "anyhow" -version = "1.0.44" +version = "1.0.52" authors = ["David Tolnay "] description = "Flexible concrete Error type built on std::error::Error" documentation = "https://docs.rs/anyhow" @@ -31,7 +32,7 @@ default-features = false [dev-dependencies.rustversion] -version = "1.0" +version = "1.0.6" [dev-dependencies.syn] version = "1.0" @@ -41,7 +42,7 @@ version = "1.0" [dev-dependencies.trybuild] -version = "1.0.19" +version = "1.0.49" features = ["diff"] [features] diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/README.md cargo-0.58.0/vendor/anyhow/README.md --- cargo-0.57.0+ubuntu/vendor/anyhow/README.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/README.md 2022-01-21 02:47:39.000000000 +0000 @@ -16,7 +16,7 @@ anyhow = "1.0" ``` -*Compiler support: requires rustc 1.34+* +*Compiler support: requires rustc 1.38+*
@@ -76,9 +76,9 @@ ``` - If using the nightly channel, or stable with `features = ["backtrace"]`, a - a backtrace is captured and printed with the error if the underlying error - type does not already provide its own. In order to see backtraces, they must - be enabled through the environment variables described in [`std::backtrace`]: + backtrace is captured and printed with the error if the underlying error type + does not already provide its own. In order to see backtraces, they must be + enabled through the environment variables described in [`std::backtrace`]: - If you want panics and errors to both have backtraces, set `RUST_BACKTRACE=1`; diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/rust-toolchain.toml cargo-0.58.0/vendor/anyhow/rust-toolchain.toml --- cargo-0.57.0+ubuntu/vendor/anyhow/rust-toolchain.toml 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/rust-toolchain.toml 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,2 @@ +[toolchain] +components = ["rust-src"] diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/src/backtrace.rs cargo-0.58.0/vendor/anyhow/src/backtrace.rs --- cargo-0.57.0+ubuntu/vendor/anyhow/src/backtrace.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/src/backtrace.rs 2022-01-21 02:47:39.000000000 +0000 @@ -182,7 +182,7 @@ 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 @@ None => false, }, }; - ENABLED.store(enabled as usize + 1, Ordering::SeqCst); + ENABLED.store(enabled as usize + 1, Ordering::Relaxed); enabled } diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/src/ensure.rs cargo-0.58.0/vendor/anyhow/src/ensure.rs --- cargo-0.57.0+ubuntu/vendor/anyhow/src/ensure.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/src/ensure.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,818 @@ +use crate::Error; +use alloc::string::String; +use core::fmt::{self, Debug, Write}; +use core::mem::MaybeUninit; +use core::ptr; +use core::slice; +use core::str; + +#[doc(hidden)] +pub trait BothDebug { + fn __dispatch_ensure(self, msg: &'static str) -> Error; +} + +impl BothDebug for (A, B) +where + A: Debug, + B: Debug, +{ + fn __dispatch_ensure(self, msg: &'static str) -> Error { + render(msg, &self.0, &self.1) + } +} + +#[doc(hidden)] +pub trait NotBothDebug { + fn __dispatch_ensure(self, msg: &'static str) -> Error; +} + +impl NotBothDebug for &(A, B) { + fn __dispatch_ensure(self, msg: &'static str) -> Error { + Error::msg(msg) + } +} + +struct Buf { + bytes: [MaybeUninit; 40], + written: usize, +} + +impl Buf { + fn new() -> Self { + Buf { + bytes: [MaybeUninit::uninit(); 40], + written: 0, + } + } + + fn as_str(&self) -> &str { + unsafe { + str::from_utf8_unchecked(slice::from_raw_parts( + self.bytes.as_ptr().cast::(), + self.written, + )) + } + } +} + +impl Write for Buf { + fn write_str(&mut self, s: &str) -> fmt::Result { + if s.bytes().any(|b| b == b' ' || b == b'\n') { + return Err(fmt::Error); + } + + let remaining = self.bytes.len() - self.written; + if s.len() > remaining { + return Err(fmt::Error); + } + + unsafe { + ptr::copy_nonoverlapping( + s.as_ptr(), + self.bytes.as_mut_ptr().add(self.written).cast::(), + s.len(), + ); + } + self.written += s.len(); + Ok(()) + } +} + +fn render(msg: &'static str, lhs: &dyn Debug, rhs: &dyn Debug) -> Error { + let mut lhs_buf = Buf::new(); + if fmt::write(&mut lhs_buf, format_args!("{:?}", lhs)).is_ok() { + let mut rhs_buf = Buf::new(); + if fmt::write(&mut rhs_buf, format_args!("{:?}", rhs)).is_ok() { + let lhs_str = lhs_buf.as_str(); + let rhs_str = rhs_buf.as_str(); + // "{msg} ({lhs} vs {rhs})" + let len = msg.len() + 2 + lhs_str.len() + 4 + rhs_str.len() + 1; + let mut string = String::with_capacity(len); + string.push_str(msg); + string.push_str(" ("); + string.push_str(lhs_str); + string.push_str(" vs "); + string.push_str(rhs_str); + string.push(')'); + return Error::msg(string); + } + } + Error::msg(msg) +} + +#[doc(hidden)] +#[macro_export] +macro_rules! __parse_ensure { + (atom () $bail:tt $fuel:tt {($($rhs:tt)+) ($($lhs:tt)+) $op:tt} $dup:tt $(,)?) => { + $crate::__fancy_ensure!($($lhs)+, $op, $($rhs)+) + }; + + // low precedence control flow constructs + + (0 $stack:tt ($($bail:tt)*) $fuel:tt $parse:tt $dup:tt return $($rest:tt)*) => { + $crate::__fallback_ensure!($($bail)*) + }; + + (0 $stack:tt ($($bail:tt)*) $fuel:tt $parse:tt $dup:tt break $($rest:tt)*) => { + $crate::__fallback_ensure!($($bail)*) + }; + + (0 $stack:tt ($($bail:tt)*) $fuel:tt $parse:tt $dup:tt continue $($rest:tt)*) => { + $crate::__fallback_ensure!($($bail)*) + }; + + (0 $stack:tt ($($bail:tt)*) $fuel:tt $parse:tt $dup:tt yield $($rest:tt)*) => { + $crate::__fallback_ensure!($($bail)*) + }; + + (0 $stack:tt ($($bail:tt)*) $fuel:tt $parse:tt $dup:tt move $($rest:tt)*) => { + $crate::__fallback_ensure!($($bail)*) + }; + + // unary operators + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($deref:tt $($dup:tt)*) * $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $deref) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($not:tt $($dup:tt)*) ! $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $not) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($neg:tt $($dup:tt)*) - $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $neg) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($let:tt $($dup:tt)*) let $($rest:tt)*) => { + $crate::__parse_ensure!(pat $stack $bail ($($fuel)*) {($($buf)* $let) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($life:tt $colon:tt $($dup:tt)*) $label:lifetime : $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $life $colon) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($and:tt $mut:tt $($dup:tt)*) &mut $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $and $mut) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($and:tt $($dup:tt)*) & $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $and) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($andand:tt $mut:tt $($dup:tt)*) &&mut $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $andand $mut) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($andand:tt $($dup:tt)*) && $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $andand) $($parse)*} ($($rest)*) $($rest)*) + }; + + // control flow constructs + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($if:tt $($dup:tt)*) if $($rest:tt)*) => { + $crate::__parse_ensure!(0 (cond $stack) $bail ($($fuel)*) {($($buf)* $if) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($match:tt $($dup:tt)*) match $($rest:tt)*) => { + $crate::__parse_ensure!(0 (cond $stack) $bail ($($fuel)*) {($($buf)* $match) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($while:tt $($dup:tt)*) while $($rest:tt)*) => { + $crate::__parse_ensure!(0 (cond $stack) $bail ($($fuel)*) {($($buf)* $while) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($for:tt $($dup:tt)*) for $($rest:tt)*) => { + $crate::__parse_ensure!(pat (cond $stack) $bail ($($fuel)*) {($($buf)* $for) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom (cond $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($brace:tt $($dup:tt)*) {$($block:tt)*} $($rest:tt)*) => { + $crate::__parse_ensure!(cond $stack $bail ($($fuel)*) {($($buf)* $brace) $($parse)*} ($($rest)*) $($rest)*) + }; + + (cond $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($else:tt $if:tt $($dup:tt)*) else if $($rest:tt)*) => { + $crate::__parse_ensure!(0 (cond $stack) $bail ($($fuel)*) {($($buf)* $else $if) $($parse)*} ($($rest)*) $($rest)*) + }; + + (cond $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($else:tt $brace:tt $($dup:tt)*) else {$($block:tt)*} $($rest:tt)*) => { + $crate::__parse_ensure!(atom $stack $bail ($($fuel)*) {($($buf)* $else $brace) $($parse)*} ($($rest)*) $($rest)*) + }; + + (cond $stack:tt $bail:tt (~$($fuel:tt)*) $parse:tt $dup:tt $($rest:tt)*) => { + $crate::__parse_ensure!(atom $stack $bail ($($fuel)*) $parse $dup $($rest)*) + }; + + // atomic expressions + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($paren:tt $($dup:tt)*) ($($content:tt)*) $($rest:tt)*) => { + $crate::__parse_ensure!(atom $stack $bail ($($fuel)*) {($($buf)* $paren) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($bracket:tt $($dup:tt)*) [$($array:tt)*] $($rest:tt)*) => { + $crate::__parse_ensure!(atom $stack $bail ($($fuel)*) {($($buf)* $bracket) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($brace:tt $($dup:tt)*) {$($block:tt)*} $($rest:tt)*) => { + $crate::__parse_ensure!(atom $stack $bail ($($fuel)*) {($($buf)* $brace) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($loop:tt $block:tt $($dup:tt)*) loop {$($body:tt)*} $($rest:tt)*) => { + $crate::__parse_ensure!(atom $stack $bail ($($fuel)*) {($($buf)* $loop $block) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($async:tt $block:tt $($dup:tt)*) async {$($body:tt)*} $($rest:tt)*) => { + $crate::__parse_ensure!(atom $stack $bail ($($fuel)*) {($($buf)* $async $block) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($async:tt $move:tt $block:tt $($dup:tt)*) async move {$($body:tt)*} $($rest:tt)*) => { + $crate::__parse_ensure!(atom $stack $bail ($($fuel)*) {($($buf)* $async $move $block) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($unsafe:tt $block:tt $($dup:tt)*) unsafe {$($body:tt)*} $($rest:tt)*) => { + $crate::__parse_ensure!(atom $stack $bail ($($fuel)*) {($($buf)* $unsafe $block) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} $dup:tt $lit:literal $($rest:tt)*) => { + $crate::__parse_ensure!(atom $stack $bail ($($fuel)*) {($($buf)* $lit) $($parse)*} ($($rest)*) $($rest)*) + }; + + // path expressions + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($colons:tt $($dup:tt)*) :: $ident:ident $($rest:tt)*) => { + $crate::__parse_ensure!(epath (atom $stack) $bail ($($fuel)*) {($($buf)* $colons $ident) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} $dup:tt $ident:ident $($rest:tt)*) => { + $crate::__parse_ensure!(epath (atom $stack) $bail ($($fuel)*) {($($buf)* $ident) $($parse)*} ($($rest)*) $($rest)*) + }; + + (0 $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($langle:tt $($dup:tt)*) < $($rest:tt)*) => { + $crate::__parse_ensure!(type (qpath (epath (atom $stack))) $bail ($($fuel)*) {($($buf)* $langle) $($parse)*} ($($rest)*) $($rest)*) + }; + + (epath $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($colons:tt $langle:tt $($dup:tt)*) :: < $($rest:tt)*) => { + $crate::__parse_ensure!(generic (epath $stack) $bail ($($fuel)*) {($($buf)* $colons $langle) $($parse)*} ($($rest)*) $($rest)*) + }; + + (epath $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($colons:tt $($dup:tt)*) :: << $($rest:tt)*) => { + $crate::__parse_ensure!(generic (epath $stack) $bail ($($fuel)*) {($($buf)* $colons <) $($parse)*} (< $($rest)*) < $($rest)*) + }; + + (epath $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($colons:tt $($dup:tt)*) :: $ident:ident $($rest:tt)*) => { + $crate::__parse_ensure!(epath $stack $bail ($($fuel)*) {($($buf)* $colons $ident) $($parse)*} ($($rest)*) $($rest)*) + }; + + (epath ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($bang:tt $args:tt $($dup:tt)*) ! ($($mac:tt)*) $($rest:tt)*) => { + $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* $bang $args) $($parse)*} ($($rest)*) $($rest)*) + }; + + (epath ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($bang:tt $args:tt $($dup:tt)*) ! [$($mac:tt)*] $($rest:tt)*) => { + $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* $bang $args) $($parse)*} ($($rest)*) $($rest)*) + }; + + (epath ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($bang:tt $args:tt $($dup:tt)*) ! {$($mac:tt)*} $($rest:tt)*) => { + $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* $bang $args) $($parse)*} ($($rest)*) $($rest)*) + }; + + (epath ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) $parse:tt $dup:tt $($rest:tt)*) => { + $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) $parse $dup $($rest)*) + }; + + // trailer expressions + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($paren:tt $($dup:tt)*) ($($call:tt)*) $($rest:tt)*) => { + $crate::__parse_ensure!(atom $stack $bail ($($fuel)*) {($($buf)* $paren) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($bracket:tt $($dup:tt)*) [$($index:tt)*] $($rest:tt)*) => { + $crate::__parse_ensure!(atom $stack $bail ($($fuel)*) {($($buf)* $bracket) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($brace:tt $($dup:tt)*) {$($init:tt)*} $($rest:tt)*) => { + $crate::__parse_ensure!(atom $stack $bail ($($fuel)*) {($($buf)* $brace) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($question:tt $($dup:tt)*) ? $($rest:tt)*) => { + $crate::__parse_ensure!(atom $stack $bail ($($fuel)*) {($($buf)* $question) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($dot:tt $ident:tt $colons:tt $langle:tt $($dup:tt)*) . $i:ident :: < $($rest:tt)*) => { + $crate::__parse_ensure!(generic (atom $stack) $bail ($($fuel)*) {($($buf)* $dot $ident $colons $langle) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($dot:tt $ident:tt $colons:tt $($dup:tt)*) . $i:ident :: << $($rest:tt)*) => { + $crate::__parse_ensure!(generic (atom $stack) $bail ($($fuel)*) {($($buf)* $dot $ident $colons <) $($parse)*} (< $($rest)*) < $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($dot:tt $($dup:tt)*) . $field:ident $($rest:tt)*) => { + $crate::__parse_ensure!(atom $stack $bail ($($fuel)*) {($($buf)* $dot $field) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($dot:tt $index:tt $($dup:tt)*) . $lit:literal $($rest:tt)*) => { + $crate::__parse_ensure!(atom $stack $bail ($($fuel)*) {($($buf)* $dot $index) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($as:tt $($dup:tt)*) as $($rest:tt)*) => { + $crate::__parse_ensure!(type (atom $stack) $bail ($($fuel)*) {($($buf)* $as) $($parse)*} ($($rest)*) $($rest)*) + }; + + // types + + (type ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($bracket:tt $($dup:tt)*) [$($content:tt)*] $($rest:tt)*) => { + $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* $bracket) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($paren:tt $($dup:tt)*) ($($content:tt)*) $($rest:tt)*) => { + $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* $paren) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($star:tt $const:tt $($dup:tt)*) *const $($rest:tt)*) => { + $crate::__parse_ensure!(type $stack $bail ($($fuel)*) {($($buf)* $star $const) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($star:tt $mut:tt $($dup:tt)*) *mut $($rest:tt)*) => { + $crate::__parse_ensure!(type $stack $bail ($($fuel)*) {($($buf)* $star $mut) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($and:tt $life:lifetime $mut:tt $($dup:tt)*) & $l:lifetime mut $($rest:tt)*) => { + $crate::__parse_ensure!(type $stack $bail ($($fuel)*) {($($buf)* $and $life $mut) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($and:tt $mut:tt $($dup:tt)*) & mut $($rest:tt)*) => { + $crate::__parse_ensure!(type $stack $bail ($($fuel)*) {($($buf)* $and $mut) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($and:tt $life:lifetime $($dup:tt)*) & $l:lifetime $($rest:tt)*) => { + $crate::__parse_ensure!(type $stack $bail ($($fuel)*) {($($buf)* $and $life) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($and:tt $($dup:tt)*) & $($rest:tt)*) => { + $crate::__parse_ensure!(type $stack $bail ($($fuel)*) {($($buf)* $and) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($and:tt $life:lifetime $mut:tt $($dup:tt)*) && $l:lifetime mut $($rest:tt)*) => { + $crate::__parse_ensure!(type $stack $bail ($($fuel)*) {($($buf)* $and $life $mut) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($and:tt $mut:tt $($dup:tt)*) && mut $($rest:tt)*) => { + $crate::__parse_ensure!(type $stack $bail ($($fuel)*) {($($buf)* $and $mut) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($and:tt $life:lifetime $($dup:tt)*) && $l:lifetime $($rest:tt)*) => { + $crate::__parse_ensure!(type $stack $bail ($($fuel)*) {($($buf)* $and $life) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($and:tt $($dup:tt)*) && $($rest:tt)*) => { + $crate::__parse_ensure!(type $stack $bail ($($fuel)*) {($($buf)* $and) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($unsafe:tt $(extern $($abi:literal)?)? fn $($dup:tt)*) unsafe $($rest:tt)*) => { + $crate::__parse_ensure!(type $stack $bail ($($fuel)*) {($($buf)* $unsafe) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($extern:tt $abi:literal fn $($dup:tt)*) extern $lit:literal $($rest:tt)*) => { + $crate::__parse_ensure!(type $stack $bail ($($fuel)*) {($($buf)* $extern $abi) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($extern:tt fn $($dup:tt)*) extern $($rest:tt)*) => { + $crate::__parse_ensure!(type $stack $bail ($($fuel)*) {($($buf)* $extern) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($fn:tt $paren:tt $arrow:tt $($dup:tt)*) fn ($($args:tt)*) -> $($rest:tt)*) => { + $crate::__parse_ensure!(type $stack $bail ($($fuel)*) {($($buf)* $fn $paren $arrow) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($fn:tt $paren:tt $($dup:tt)*) fn ($($args:tt)*) $($rest:tt)*) => { + $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* $fn $paren) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($impl:tt $($dup:tt)*) impl $($rest:tt)*) => { + $crate::__parse_ensure!(type $stack $bail ($($fuel)*) {($($buf)* $impl) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($dyn:tt $($dup:tt)*) dyn $($rest:tt)*) => { + $crate::__parse_ensure!(type $stack $bail ($($fuel)*) {($($buf)* $dyn) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($wild:tt $($dup:tt)*) _ $($rest:tt)*) => { + $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* $wild) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($never:tt $($dup:tt)*) ! $($rest:tt)*) => { + $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* $never) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($for:tt $langle:tt $($dup:tt)*) for < $($rest:tt)*) => { + $crate::__parse_ensure!(generic (type $stack) $bail ($($fuel)*) {($($buf)* $for $langle) $($parse)*} ($($rest)*) $($rest)*) + }; + + // path types + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($colons:tt $($dup:tt)*) :: $ident:ident $($rest:tt)*) => { + $crate::__parse_ensure!(tpath $stack $bail ($($fuel)*) {($($buf)* $colons $ident) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} $dup:tt $ident:ident $($rest:tt)*) => { + $crate::__parse_ensure!(tpath $stack $bail ($($fuel)*) {($($buf)* $ident) $($parse)*} ($($rest)*) $($rest)*) + }; + + (type $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($langle:tt $($dup:tt)*) < $($rest:tt)*) => { + $crate::__parse_ensure!(type (qpath (tpath $stack)) $bail ($($fuel)*) {($($buf)* $langle) $($parse)*} ($($rest)*) $($rest)*) + }; + + (tpath $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($langle:tt $($dup:tt)*) < $($rest:tt)*) => { + $crate::__parse_ensure!(generic (tpath $stack) $bail ($($fuel)*) {($($buf)* $langle) $($parse)*} ($($rest)*) $($rest)*) + }; + + (tpath $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} $dup:tt << $($rest:tt)*) => { + $crate::__parse_ensure!(generic (tpath $stack) $bail ($($fuel)*) {($($buf)* <) $($parse)*} (< $($rest)*) < $($rest)*) + }; + + (tpath $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($colons:tt $langle:tt $($dup:tt)*) :: < $($rest:tt)*) => { + $crate::__parse_ensure!(generic (tpath $stack) $bail ($($fuel)*) {($($buf)* $colons $langle) $($parse)*} ($($rest)*) $($rest)*) + }; + + (tpath $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($colons:tt $($dup:tt)*) :: << $($rest:tt)*) => { + $crate::__parse_ensure!(generic (tpath $stack) $bail ($($fuel)*) {($($buf)* $colons <) $($parse)*} (< $($rest)*) < $($rest)*) + }; + + (tpath $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($colons:tt $($dup:tt)*) :: $ident:ident $($rest:tt)*) => { + $crate::__parse_ensure!(tpath $stack $bail ($($fuel)*) {($($buf)* $colons $ident) $($parse)*} ($($rest)*) $($rest)*) + }; + + (tpath $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($paren:tt $arrow:tt $($dup:tt)*) ($($args:tt)*) -> $($rest:tt)*) => { + $crate::__parse_ensure!(type $stack $bail ($($fuel)*) {($($buf)* $paren $arrow) $($parse)*} ($($rest)*) $($rest)*) + }; + + (tpath $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($paren:tt $($dup:tt)*) ($($args:tt)*) $($rest:tt)*) => { + $crate::__parse_ensure!(object $stack $bail ($($fuel)*) {($($buf)* $paren) $($parse)*} ($($rest)*) $($rest)*) + }; + + (tpath $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($colons:tt $paren:tt $arrow:tt $($dup:tt)*) :: ($($args:tt)*) -> $($rest:tt)*) => { + $crate::__parse_ensure!(type $stack $bail ($($fuel)*) {($($buf)* $colons $paren $arrow) $($parse)*} ($($rest)*) $($rest)*) + }; + + (tpath $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($colons:tt $paren:tt $($dup:tt)*) :: ($($args:tt)*) $($rest:tt)*) => { + $crate::__parse_ensure!(object $stack $bail ($($fuel)*) {($($buf)* $colons $paren) $($parse)*} ($($rest)*) $($rest)*) + }; + + (tpath ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($bang:tt $args:tt $($dup:tt)*) ! ($($mac:tt)*) $($rest:tt)*) => { + $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* $bang $args) $($parse)*} ($($rest)*) $($rest)*) + }; + + (tpath ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($bang:tt $args:tt $($dup:tt)*) ! [$($mac:tt)*] $($rest:tt)*) => { + $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* $bang $args) $($parse)*} ($($rest)*) $($rest)*) + }; + + (tpath ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($bang:tt $args:tt $($dup:tt)*) ! {$($mac:tt)*} $($rest:tt)*) => { + $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* $bang $args) $($parse)*} ($($rest)*) $($rest)*) + }; + + (tpath $stack:tt $bail:tt (~$($fuel:tt)*) $parse:tt $dup:tt $($rest:tt)*) => { + $crate::__parse_ensure!(object $stack $bail ($($fuel)*) $parse $dup $($rest)*) + }; + + // qualified paths + + (qpath ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($rangle:tt $colons:tt $($dup:tt)*) > :: $ident:ident $($rest:tt)*) => { + $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* $rangle $colons $ident) $($parse)*} ($($rest)*) $($rest)*) + }; + + (qpath $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($as:tt $($dup:tt)*) as $($rest:tt)*) => { + $crate::__parse_ensure!(type (qpath $stack) $bail ($($fuel)*) {($($buf)* $as) $($parse)*} ($($rest)*) $($rest)*) + }; + + // trait objects + + (object (arglist $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($plus:tt $colons:tt $($dup:tt)*) + :: $ident:ident $($rest:tt)*) => { + $crate::__parse_ensure!(tpath (arglist $stack) $bail ($($fuel)*) {($($buf)* $plus $colons $ident) $($parse)*} ($($rest)*) $($rest)*) + }; + + (object (arglist $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($plus:tt $($dup:tt)*) + $ident:ident $($rest:tt)*) => { + $crate::__parse_ensure!(tpath (arglist $stack) $bail ($($fuel)*) {($($buf)* $plus $ident) $($parse)*} ($($rest)*) $($rest)*) + }; + + (object ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) $parse:tt $dup:tt $($rest:tt)*) => { + $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) $parse $dup $($rest)*) + }; + + // angle bracketed generic arguments + + (generic ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($rangle:tt $($dup:tt)*) > $($rest:tt)*) => { + $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* $rangle) $($parse)*} ($($rest)*) $($rest)*) + }; + + (generic ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} $dup:tt >> $($rest:tt)*) => { + $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* >) $($parse)*} (> $($rest)*) > $($rest)*) + }; + + (generic $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} $dup:tt $lit:literal $($rest:tt)*) => { + $crate::__parse_ensure!(arglist $stack $bail ($($fuel)*) {($($buf)* $lit) $($parse)*} ($($rest)*) $($rest)*) + }; + + (generic $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($brace:tt $($dup:tt)*) {$($block:tt)*} $($rest:tt)*) => { + $crate::__parse_ensure!(arglist $stack $bail ($($fuel)*) {($($buf)* $brace) $($parse)*} ($($rest)*) $($rest)*) + }; + + (generic $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} $dup:tt $life:lifetime $($rest:tt)*) => { + $crate::__parse_ensure!(arglist $stack $bail ($($fuel)*) {($($buf)* $life) $($parse)*} ($($rest)*) $($rest)*) + }; + + (generic $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($assoc:ident $eq:tt $($dup:tt)*) $ident:ident = $($rest:tt)*) => { + $crate::__parse_ensure!(type (arglist $stack) $bail ($($fuel)*) {($($buf)* $assoc $eq) $($parse)*} ($($rest)*) $($rest)*) + }; + + (generic $stack:tt $bail:tt (~$($fuel:tt)*) $parse:tt $dup:tt $($rest:tt)*) => { + $crate::__parse_ensure!(type (arglist $stack) $bail ($($fuel)*) $parse $dup $($rest)*) + }; + + (arglist $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($comma:tt $($dup:tt)*) , $($rest:tt)*) => { + $crate::__parse_ensure!(generic $stack $bail ($($fuel)*) {($($buf)* $comma) $($parse)*} ($($rest)*) $($rest)*) + }; + + (arglist ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($rangle:tt $($dup:tt)*) > $($rest:tt)*) => { + $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* $rangle) $($parse)*} ($($rest)*) $($rest)*) + }; + + (arglist ($pop:ident $stack:tt) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} $dup:tt >> $($rest:tt)*) => { + $crate::__parse_ensure!($pop $stack $bail ($($fuel)*) {($($buf)* >) $($parse)*} (> $($rest)*) > $($rest)*) + }; + + // patterns + + (pat $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($pipe:tt $($dup:tt)*) | $($rest:tt)*) => { + $crate::__parse_ensure!(pat $stack $bail ($($fuel)*) {($($buf)* $pipe) $($parse)*} ($($rest)*) $($rest)*) + }; + + (pat $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($eq:tt $($dup:tt)*) = $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $eq) $($parse)*} ($($rest)*) $($rest)*) + }; + + (pat $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($in:tt $($dup:tt)*) in $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $in) $($parse)*} ($($rest)*) $($rest)*) + }; + + (pat $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($ref:tt $($dup:tt)*) ref $($rest:tt)*) => { + $crate::__parse_ensure!(pat $stack $bail ($($fuel)*) {($($buf)* $ref) $($parse)*} ($($rest)*) $($rest)*) + }; + + (pat $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($mut:tt $($dup:tt)*) mut $($rest:tt)*) => { + $crate::__parse_ensure!(pat $stack $bail ($($fuel)*) {($($buf)* $mut) $($parse)*} ($($rest)*) $($rest)*) + }; + + (pat $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($at:tt $($dup:tt)*) @ $($rest:tt)*) => { + $crate::__parse_ensure!(pat $stack $bail ($($fuel)*) {($($buf)* $at) $($parse)*} ($($rest)*) $($rest)*) + }; + + (pat $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} $dup:tt $lit:literal $($rest:tt)*) => { + $crate::__parse_ensure!(pat $stack $bail ($($fuel)*) {($($buf)* $lit) $($parse)*} ($($rest)*) $($rest)*) + }; + + (pat $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($range:tt $($dup:tt)*) .. $($rest:tt)*) => { + $crate::__parse_ensure!(pat $stack $bail ($($fuel)*) {($($buf)* $range) $($parse)*} ($($rest)*) $($rest)*) + }; + + (pat $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($range:tt $($dup:tt)*) ..= $($rest:tt)*) => { + $crate::__parse_ensure!(pat $stack $bail ($($fuel)*) {($($buf)* $range) $($parse)*} ($($rest)*) $($rest)*) + }; + + (pat $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($and:tt $($dup:tt)*) & $($rest:tt)*) => { + $crate::__parse_ensure!(pat $stack $bail ($($fuel)*) {($($buf)* $and) $($parse)*} ($($rest)*) $($rest)*) + }; + + (pat $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($andand:tt $($dup:tt)*) && $($rest:tt)*) => { + $crate::__parse_ensure!(pat $stack $bail ($($fuel)*) {($($buf)* $andand) $($parse)*} ($($rest)*) $($rest)*) + }; + + (pat $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($paren:tt $($dup:tt)*) ($($content:tt)*) $($rest:tt)*) => { + $crate::__parse_ensure!(pat $stack $bail ($($fuel)*) {($($buf)* $paren) $($parse)*} ($($rest)*) $($rest)*) + }; + + (pat $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($bracket:tt $($dup:tt)*) [$($content:tt)*] $($rest:tt)*) => { + $crate::__parse_ensure!(pat $stack $bail ($($fuel)*) {($($buf)* $bracket) $($parse)*} ($($rest)*) $($rest)*) + }; + + (pat $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($brace:tt $($dup:tt)*) {$($content:tt)*} $($rest:tt)*) => { + $crate::__parse_ensure!(pat $stack $bail ($($fuel)*) {($($buf)* $brace) $($parse)*} ($($rest)*) $($rest)*) + }; + + (pat $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($wild:tt $($dup:tt)*) _ $($rest:tt)*) => { + $crate::__parse_ensure!(pat $stack $bail ($($fuel)*) {($($buf)* $wild) $($parse)*} ($($rest)*) $($rest)*) + }; + + (pat $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($colons:tt $($dup:tt)*) :: $ident:ident $($rest:tt)*) => { + $crate::__parse_ensure!(epath (pat $stack) $bail ($($fuel)*) {($($buf)* $colons $ident) $($parse)*} ($($rest)*) $($rest)*) + }; + + (pat $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} $dup:tt $ident:ident $($rest:tt)*) => { + $crate::__parse_ensure!(epath (pat $stack) $bail ($($fuel)*) {($($buf)* $ident) $($parse)*} ($($rest)*) $($rest)*) + }; + + (pat $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($langle:tt $($dup:tt)*) < $($rest:tt)*) => { + $crate::__parse_ensure!(type (qpath (epath (pat $stack))) $bail ($($fuel)*) {($($buf)* $langle) $($parse)*} ($($rest)*) $($rest)*) + }; + + // high precedence binary operators + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($add:tt $($dup:tt)*) + $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $add) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($sub:tt $($dup:tt)*) - $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $sub) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($mul:tt $($dup:tt)*) * $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $mul) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($div:tt $($dup:tt)*) / $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $div) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($rem:tt $($dup:tt)*) % $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $rem) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($bitxor:tt $($dup:tt)*) ^ $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $bitxor) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($bitand:tt $($dup:tt)*) & $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $bitand) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($bitor:tt $($dup:tt)*) | $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $bitor) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($shl:tt $($dup:tt)*) << $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $shl) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($shr:tt $($dup:tt)*) >> $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $shr) $($parse)*} ($($rest)*) $($rest)*) + }; + + // comparison binary operators + + (atom () $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($eq:tt $($dup:tt)*) == $($rest:tt)*) => { + $crate::__parse_ensure!(0 () $bail ($($fuel)*) {() $($parse)* ($($buf)*) $eq} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)+) $($parse:tt)*} ($eq:tt $($dup:tt)*) == $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $eq) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom () $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($le:tt $($dup:tt)*) <= $($rest:tt)*) => { + $crate::__parse_ensure!(0 () $bail ($($fuel)*) {() $($parse)* ($($buf)*) $le} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)+) $($parse:tt)*} ($le:tt $($dup:tt)*) <= $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $le) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom () $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($lt:tt $($dup:tt)*) < $($rest:tt)*) => { + $crate::__parse_ensure!(0 () $bail ($($fuel)*) {() $($parse)* ($($buf)*) $lt} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)+) $($parse:tt)*} ($lt:tt $($dup:tt)*) < $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $lt) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom () $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($ne:tt $($dup:tt)*) != $($rest:tt)*) => { + $crate::__parse_ensure!(0 () $bail ($($fuel)*) {() $($parse)* ($($buf)*) $ne} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)+) $($parse:tt)*} ($ne:tt $($dup:tt)*) != $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $ne) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom () $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($ge:tt $($dup:tt)*) >= $($rest:tt)*) => { + $crate::__parse_ensure!(0 () $bail ($($fuel)*) {() $($parse)* ($($buf)*) $ge} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)+) $($parse:tt)*} ($ge:tt $($dup:tt)*) >= $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $ge) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom () $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($gt:tt $($dup:tt)*) > $($rest:tt)*) => { + $crate::__parse_ensure!(0 () $bail ($($fuel)*) {() $($parse)* ($($buf)*) $gt} ($($rest)*) $($rest)*) + }; + + (atom $stack:tt $bail:tt (~$($fuel:tt)*) {($($buf:tt)+) $($parse:tt)*} ($gt:tt $($dup:tt)*) > $($rest:tt)*) => { + $crate::__parse_ensure!(0 $stack $bail ($($fuel)*) {($($buf)* $gt) $($parse)*} ($($rest)*) $($rest)*) + }; + + // low precedence binary operators + + (atom ($($stack:tt)+) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($and:tt $($dup:tt)*) && $($rest:tt)*) => { + $crate::__parse_ensure!(0 ($($stack)*) $bail ($($fuel)*) {($($buf)* $and) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom ($($stack:tt)+) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($or:tt $($dup:tt)*) || $($rest:tt)*) => { + $crate::__parse_ensure!(0 ($($stack)*) $bail ($($fuel)*) {($($buf)* $or) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom ($($stack:tt)+) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($assign:tt $($dup:tt)*) = $($rest:tt)*) => { + $crate::__parse_ensure!(0 ($($stack)*) $bail ($($fuel)*) {($($buf)* $assign) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom ($($stack:tt)+) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($addeq:tt $($dup:tt)*) += $($rest:tt)*) => { + $crate::__parse_ensure!(0 ($($stack)*) $bail ($($fuel)*) {($($buf)* $addeq) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom ($($stack:tt)+) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($subeq:tt $($dup:tt)*) -= $($rest:tt)*) => { + $crate::__parse_ensure!(0 ($($stack)*) $bail ($($fuel)*) {($($buf)* $subeq) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom ($($stack:tt)+) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($muleq:tt $($dup:tt)*) *= $($rest:tt)*) => { + $crate::__parse_ensure!(0 ($($stack)*) $bail ($($fuel)*) {($($buf)* $muleq) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom ($($stack:tt)+) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($diveq:tt $($dup:tt)*) /= $($rest:tt)*) => { + $crate::__parse_ensure!(0 ($($stack)*) $bail ($($fuel)*) {($($buf)* $diveq) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom ($($stack:tt)+) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($remeq:tt $($dup:tt)*) %= $($rest:tt)*) => { + $crate::__parse_ensure!(0 ($($stack)*) $bail ($($fuel)*) {($($buf)* $remeq) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom ($($stack:tt)+) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($bitxoreq:tt $($dup:tt)*) ^= $($rest:tt)*) => { + $crate::__parse_ensure!(0 ($($stack)*) $bail ($($fuel)*) {($($buf)* $bitxoreq) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom ($($stack:tt)+) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($bitandeq:tt $($dup:tt)*) &= $($rest:tt)*) => { + $crate::__parse_ensure!(0 ($($stack)*) $bail ($($fuel)*) {($($buf)* $bitandeq) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom ($($stack:tt)+) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($bitoreq:tt $($dup:tt)*) |= $($rest:tt)*) => { + $crate::__parse_ensure!(0 ($($stack)*) $bail ($($fuel)*) {($($buf)* $bitoreq) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom ($($stack:tt)+) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($shleq:tt $($dup:tt)*) <<= $($rest:tt)*) => { + $crate::__parse_ensure!(0 ($($stack)*) $bail ($($fuel)*) {($($buf)* $shleq) $($parse)*} ($($rest)*) $($rest)*) + }; + + (atom ($($stack:tt)+) $bail:tt (~$($fuel:tt)*) {($($buf:tt)*) $($parse:tt)*} ($shreq:tt $($dup:tt)*) >>= $($rest:tt)*) => { + $crate::__parse_ensure!(0 ($($stack)*) $bail ($($fuel)*) {($($buf)* $shreq) $($parse)*} ($($rest)*) $($rest)*) + }; + + // unrecognized expression + + ($state:tt $stack:tt ($($bail:tt)*) $($rest:tt)*) => { + $crate::__fallback_ensure!($($bail)*) + }; +} + +#[doc(hidden)] +#[macro_export] +macro_rules! __fancy_ensure { + ($lhs:expr, $op:tt, $rhs:expr) => { + match (&$lhs, &$rhs) { + (lhs, rhs) => { + if !(lhs $op rhs) { + #[allow(unused_imports)] + use $crate::private::{BothDebug, NotBothDebug}; + return Err((lhs, rhs).__dispatch_ensure( + $crate::private::concat!( + "Condition failed: `", + $crate::private::stringify!($lhs), + " ", + $crate::private::stringify!($op), + " ", + $crate::private::stringify!($rhs), + "`", + ), + )); + } + } + } + }; +} + +#[doc(hidden)] +#[macro_export] +macro_rules! __fallback_ensure { + ($cond:expr $(,)?) => { + if !$cond { + return $crate::private::Err($crate::Error::msg( + $crate::private::concat!("Condition failed: `", $crate::private::stringify!($cond), "`") + )); + } + }; + ($cond:expr, $msg:literal $(,)?) => { + if !$cond { + return $crate::private::Err($crate::anyhow!($msg)); + } + }; + ($cond:expr, $err:expr $(,)?) => { + if !$cond { + return $crate::private::Err($crate::anyhow!($err)); + } + }; + ($cond:expr, $fmt:expr, $($arg:tt)*) => { + if !$cond { + return $crate::private::Err($crate::anyhow!($fmt, $($arg)*)); + } + }; +} diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/src/error.rs cargo-0.58.0/vendor/anyhow/src/error.rs --- cargo-0.57.0+ubuntu/vendor/anyhow/src/error.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/src/error.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,10 +1,10 @@ -use crate::alloc::Box; use crate::backtrace::Backtrace; use crate::chain::Chain; #[cfg(any(feature = "std", anyhow_no_ptr_addr_of))] use crate::ptr::Mut; use crate::ptr::{Own, Ref}; use crate::{Error, StdError}; +use alloc::boxed::Box; use core::any::TypeId; use core::fmt::{self, Debug, Display}; use core::mem::ManuallyDrop; diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/src/lib.rs cargo-0.58.0/vendor/anyhow/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/anyhow/src/lib.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -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.44")] +#![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,27 +225,20 @@ 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, clippy::wrong_self_convention )] -mod alloc { - #[cfg(not(feature = "std"))] - extern crate alloc; - - #[cfg(not(feature = "std"))] - pub use alloc::boxed::Box; - - #[cfg(feature = "std")] - pub use std::boxed::Box; -} +extern crate alloc; #[macro_use] mod backtrace; mod chain; mod context; +mod ensure; mod error; mod fmt; mod kind; @@ -610,13 +603,40 @@ F: FnOnce() -> C; } +/// Equivalent to Ok::<_, anyhow::Error>(value). +/// +/// This simplifies creation of an anyhow::Result in places where type inference +/// cannot deduce the `E` type of the result — without needing to write +/// `Ok::<_, anyhow::Error>(value)`. +/// +/// One might think that `anyhow::Result::Ok(value)` would work in such cases +/// but it does not. +/// +/// ```console +/// error[E0282]: type annotations needed for `std::result::Result` +/// --> src/main.rs:11:13 +/// | +/// 11 | let _ = anyhow::Result::Ok(1); +/// | - ^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `E` declared on the enum `Result` +/// | | +/// | consider giving this pattern the explicit type `std::result::Result`, where the type parameter `E` is specified +/// ``` +#[allow(non_snake_case)] +pub fn Ok(t: T) -> Result { + Result::Ok(t) +} + // Not public API. Referenced by macro-generated code. #[doc(hidden)] pub mod private { use crate::Error; - use core::fmt::{Debug, Display}; + use alloc::fmt; + use core::fmt::Arguments; + pub use crate::ensure::{BothDebug, NotBothDebug}; + pub use alloc::format; pub use core::result::Result::Err; + pub use core::{concat, format_args, stringify}; #[doc(hidden)] pub mod kind { @@ -626,34 +646,21 @@ pub use crate::kind::BoxedKind; } - #[cold] - pub fn new_adhoc(message: M) -> Error - where - M: Display + Debug + Send + Sync + 'static, - { - Error::from_adhoc(message, backtrace!()) - } - - #[cfg(anyhow_no_macro_reexport)] - pub use crate::{__anyhow_concat as concat, __anyhow_stringify as stringify}; - #[cfg(not(anyhow_no_macro_reexport))] - pub use core::{concat, stringify}; - - #[cfg(anyhow_no_macro_reexport)] #[doc(hidden)] - #[macro_export] - macro_rules! __anyhow_concat { - ($($tt:tt)*) => { - concat!($($tt)*) - }; - } - - #[cfg(anyhow_no_macro_reexport)] - #[doc(hidden)] - #[macro_export] - macro_rules! __anyhow_stringify { - ($($tt:tt)*) => { - stringify!($($tt)*) - }; + #[inline] + #[cold] + pub fn format_err(args: Arguments) -> Error { + #[cfg(anyhow_no_fmt_arguments_as_str)] + let fmt_arguments_as_str = None::<&str>; + #[cfg(not(anyhow_no_fmt_arguments_as_str))] + let fmt_arguments_as_str = args.as_str(); + + if let Some(message) = fmt_arguments_as_str { + // anyhow!("literal"), can downcast to &'static str + Error::msg(message) + } else { + // anyhow!("interpolate {var}"), can downcast to String + Error::msg(fmt::format(args)) + } } } diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/src/macros.rs cargo-0.58.0/vendor/anyhow/src/macros.rs --- cargo-0.57.0+ubuntu/vendor/anyhow/src/macros.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/src/macros.rs 2022-01-21 02:47:39.000000000 +0000 @@ -50,6 +50,7 @@ /// # Ok(()) /// # } /// ``` +#[cfg(doc)] #[macro_export] macro_rules! bail { ($msg:literal $(,)?) => { @@ -63,6 +64,27 @@ }; } +// Workaround for crates that intentionally contained `{}` in an error message +// prior to https://github.com/dtolnay/anyhow/issues/55 catching the missing +// format args. +#[cfg(not(doc))] +#[macro_export] +macro_rules! bail { + // https://github.com/estk/log4rs/blob/afa0351af56b3bfd1780389700051d7e4d8bbdc9/src/append/rolling_file/policy/compound/roll/fixed_window.rs#L261 + ("pattern does not contain `{}`") => { + return $crate::private::Err($crate::Error::msg("pattern does not contain `{}`")) + }; + ($msg:literal $(,)?) => { + return $crate::private::Err($crate::anyhow!($msg)) + }; + ($err:expr $(,)?) => { + return $crate::private::Err($crate::anyhow!($err)) + }; + ($fmt:expr, $($arg:tt)*) => { + return $crate::private::Err($crate::anyhow!($fmt, $($arg)*)) + }; +} + /// Return early with an error if a condition is not satisfied. /// /// This macro is equivalent to `if !$cond { return @@ -111,13 +133,15 @@ /// # Ok(()) /// # } /// ``` +#[cfg(doc)] #[macro_export] macro_rules! ensure { ($cond:expr $(,)?) => { - $crate::ensure!( - $cond, - $crate::private::concat!("Condition failed: `", $crate::private::stringify!($cond), "`"), - ) + if !$cond { + return $crate::private::Err($crate::Error::msg( + $crate::private::concat!("Condition failed: `", $crate::private::stringify!($cond), "`") + )); + } }; ($cond:expr, $msg:literal $(,)?) => { if !$cond { @@ -136,6 +160,22 @@ }; } +#[cfg(not(doc))] +#[macro_export] +macro_rules! ensure { + ($($tt:tt)*) => { + $crate::__parse_ensure!( + /* state */ 0 + /* stack */ () + /* bail */ ($($tt)*) + /* fuel */ (~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~ ~~~~~~~~~~) + /* parse */ {()} + /* dup */ ($($tt)*) + /* rest */ $($tt)* + ) + }; +} + /// Construct an ad-hoc error from a string or existing non-`anyhow` error /// value. /// @@ -166,18 +206,18 @@ /// ``` #[macro_export] macro_rules! anyhow { - ($msg:literal $(,)?) => { - // Handle $:literal as a special case to make cargo-expanded code more - // concise in the common case. - $crate::private::new_adhoc($msg) - }; + ($msg:literal $(,)?) => ({ + let error = $crate::private::format_err($crate::private::format_args!($msg)); + error + }); ($err:expr $(,)?) => ({ use $crate::private::kind::*; - match $err { + let error = match $err { error => (&error).anyhow_kind().new(error), - } + }; + error }); ($fmt:expr, $($arg:tt)*) => { - $crate::private::new_adhoc(format!($fmt, $($arg)*)) + $crate::Error::msg($crate::private::format!($fmt, $($arg)*)) }; } diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/src/ptr.rs cargo-0.58.0/vendor/anyhow/src/ptr.rs --- cargo-0.57.0+ubuntu/vendor/anyhow/src/ptr.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/src/ptr.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,4 +1,4 @@ -use crate::alloc::Box; +use alloc::boxed::Box; use core::marker::PhantomData; use core::ptr::NonNull; diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/tests/drop/mod.rs cargo-0.58.0/vendor/anyhow/tests/drop/mod.rs --- cargo-0.57.0+ubuntu/vendor/anyhow/tests/drop/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/tests/drop/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -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 @@ } pub fn get(&self) -> bool { - self.atomic.load(SeqCst) + self.atomic.load(Ordering::Relaxed) } } @@ -48,7 +47,7 @@ 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); } } diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/tests/test_chain.rs cargo-0.58.0/vendor/anyhow/tests/test_chain.rs --- cargo-0.57.0+ubuntu/vendor/anyhow/tests/test_chain.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/tests/test_chain.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,7 +1,7 @@ use anyhow::{anyhow, Chain, Error}; fn error() -> Error { - anyhow!(0).context(1).context(2).context(3) + anyhow!({ 0 }).context(1).context(2).context(3) } #[test] diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/tests/test_context.rs cargo-0.58.0/vendor/anyhow/tests/test_context.rs --- cargo-0.57.0+ubuntu/vendor/anyhow/tests/test_context.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/tests/test_context.rs 2022-01-21 02:47:39.000000000 +0000 @@ -24,6 +24,7 @@ #[derive(Debug)] struct $name { message: &'static str, + #[allow(dead_code)] drop: DetectDrop, } diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/tests/test_ensure.rs cargo-0.58.0/vendor/anyhow/tests/test_ensure.rs --- cargo-0.57.0+ubuntu/vendor/anyhow/tests/test_ensure.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/tests/test_ensure.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,685 @@ +#![allow( + clippy::diverging_sub_expression, + clippy::if_same_then_else, + clippy::ifs_same_cond, + 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, + clippy::redundant_pattern_matching, + clippy::too_many_lines, + clippy::unit_arg, + clippy::while_immutable_condition, + clippy::zero_ptr +)] + +use anyhow::{anyhow, ensure, Chain, Error, Result}; +use std::fmt::Debug; +use std::iter; +use std::marker::{PhantomData, PhantomData as P}; +use std::ops::Add; +use std::ptr; + +struct S; + +impl Add for S { + type Output = bool; + fn add(self, rhs: T) -> Self::Output { + let _ = rhs; + false + } +} + +trait Trait: Sized { + const V: usize = 0; + fn t(self, i: i32) -> i32 { + i + } +} + +impl Trait for T {} + +#[track_caller] +fn assert_err(result: impl FnOnce() -> Result, expected: &'static str) { + let actual = result().unwrap_err().to_string(); + + // 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 ")); + } +} + +#[test] +fn test_recursion() { + // Must not blow the default #[recursion_limit], which is 128. + #[rustfmt::skip] + let test = || Ok(ensure!( + false | false | false | false | false | false | false | false | false | + false | false | false | false | false | false | false | false | false | + false | false | false | false | false | false | false | false | false | + false | false | false | false | false | false | false | false | false | + false | false | false | false | false | false | false | false | false | + false | false | false | false | false | false | false | false | false | + false | false | false | false | false | false | false | false | false + )); + + test().unwrap_err(); +} + +#[test] +fn test_low_precedence_control_flow() { + #[allow(unreachable_code)] + let test = || { + let val = loop { + // Break has lower precedence than the comparison operators so the + // expression here is `S + (break (1 == 1))`. It would be bad if the + // ensure macro partitioned this input into `(S + break 1) == (1)` + // because that means a different thing than what was written. + ensure!(S + break 1 == 1); + }; + Ok(val) + }; + + assert!(test().unwrap()); +} + +#[test] +fn test_low_precedence_binary_operator() { + // Must not partition as `false == (true && false)`. + let test = || Ok(ensure!(false == true && false)); + assert_err(test, "Condition failed: `false == true && false`"); + + // But outside the root level, it is fine. + let test = || Ok(ensure!(while false == true && false {} < ())); + assert_err( + test, + "Condition failed: `while false == true && false {} < ()` (() vs ())", + ); +} + +#[test] +fn test_closure() { + // Must not partition as `(S + move) || (1 == 1)` by treating move as an + // identifier, nor as `(S + move || 1) == (1)` by misinterpreting the + // closure precedence. + let test = || Ok(ensure!(S + move || 1 == 1)); + assert_err(test, "Condition failed: `S + (move || 1 == 1)`"); + + let test = || Ok(ensure!(S + || 1 == 1)); + assert_err(test, "Condition failed: `S + (|| 1 == 1)`"); + + // Must not partition as `S + ((move | ()) | 1) == 1` by treating those + // pipes as bitwise-or. + let test = || Ok(ensure!(S + move |()| 1 == 1)); + assert_err(test, "Condition failed: `S + (move |()| 1 == 1)`"); + + let test = || Ok(ensure!(S + |()| 1 == 1)); + assert_err(test, "Condition failed: `S + (|()| 1 == 1)`"); +} + +#[test] +fn test_unary() { + let mut x = &1; + let test = || Ok(ensure!(*x == 2)); + assert_err(test, "Condition failed: `*x == 2` (1 vs 2)"); + + let test = || Ok(ensure!(!x == 1)); + assert_err(test, "Condition failed: `!x == 1` (-2 vs 1)"); + + let test = || Ok(ensure!(-x == 1)); + assert_err(test, "Condition failed: `-x == 1` (-1 vs 1)"); + + let test = || Ok(ensure!(&x == &&2)); + assert_err(test, "Condition failed: `&x == &&2` (1 vs 2)"); + + let test = || Ok(ensure!(&mut x == *&&mut &2)); + assert_err(test, "Condition failed: `&mut x == *&&mut &2` (1 vs 2)"); +} + +#[test] +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)"); + + #[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)", + ); + + #[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)", + ); + + #[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)", + ); + + #[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)", + ); + + #[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)", + ); +} + +#[test] +fn test_loop() { + #[rustfmt::skip] + let test = || Ok(ensure!(1 + loop { break 1 } == 1)); + assert_err( + test, + "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, + "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)", + ); + + #[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)", + ); + + #[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)", + ); + + #[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)", + ); + + #[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)", + ); +} + +#[test] +fn test_match() { + #[rustfmt::skip] + let test = || Ok(ensure!(match 1 == 1 { true => 1, false => 0 } == 2)); + assert_err( + test, + "Condition failed: `match 1 == 1 { true => 1, false => 0, } == 2` (1 vs 2)", + ); +} + +#[test] +fn test_atom() { + let test = || Ok(ensure!([false, false].len() > 3)); + assert_err( + test, + "Condition failed: `[false, false].len() > 3` (2 vs 3)", + ); + + #[rustfmt::skip] + let test = || Ok(ensure!({ let x = 1; x } >= 3)); + assert_err(test, "Condition failed: `{ let x = 1; x } >= 3` (1 vs 3)"); + + let test = || Ok(ensure!(S + async { 1 } == true)); + assert_err( + test, + "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)", + ); + + let x = &1; + let test = || Ok(ensure!(S + unsafe { ptr::read(x) } == true)); + assert_err( + test, + "Condition failed: `S + unsafe { ptr::read(x) } == true` (false vs true)", + ); +} + +#[test] +fn test_path() { + let test = || Ok(ensure!(crate::S.t(1) == 2)); + assert_err(test, "Condition failed: `crate::S.t(1) == 2` (1 vs 2)"); + + let test = || Ok(ensure!(::anyhow::Error::root_cause.t(1) == 2)); + assert_err( + test, + "Condition failed: `::anyhow::Error::root_cause.t(1) == 2` (1 vs 2)", + ); + + let test = || Ok(ensure!(Error::msg::<&str>.t(1) == 2)); + assert_err( + test, + "Condition failed: `Error::msg::<&str>.t(1) == 2` (1 vs 2)", + ); + + #[rustfmt::skip] + let test = || Ok(ensure!(Error::msg::<&str,>.t(1) == 2)); + assert_err( + test, + "Condition failed: `Error::msg::<&str>.t(1) == 2` (1 vs 2)", + ); + + let test = || Ok(ensure!(Error::msg::<::Owned>.t(1) == 2)); + assert_err( + test, + "Condition failed: `Error::msg::<::Owned>.t(1) == 2` (1 vs 2)", + ); + + let test = || Ok(ensure!(Chain::<'static>::new.t(1) == 2)); + assert_err( + test, + "Condition failed: `Chain::<'static>::new.t(1) == 2` (1 vs 2)", + ); + + #[rustfmt::skip] + let test = || Ok(ensure!(Chain::<'static,>::new.t(1) == 2)); + assert_err( + test, + "Condition failed: `Chain::<'static>::new.t(1) == 2` (1 vs 2)", + ); + + #[derive(PartialOrd, PartialEq, Debug)] + enum E<'a, T> { + #[allow(dead_code)] + T(&'a T), + U, + } + + #[rustfmt::skip] + let test = || Ok(ensure!(E::U::<>>E::U::)); + assert_err(test, "Condition failed: `E::U::<> > E::U::` (U vs U)"); + + #[rustfmt::skip] + let test = || Ok(ensure!(E::U::>E::U)); + assert_err(test, "Condition failed: `E::U:: > E::U` (U vs U)"); + + #[rustfmt::skip] + let test = || Ok(ensure!(E::U::>E::U)); + assert_err(test, "Condition failed: `E::U:: > E::U` (U vs U)"); + + let test = || Ok(ensure!(PhantomData:: != PhantomData)); + assert_err( + test, + "Condition failed: `PhantomData:: != PhantomData` (PhantomData vs PhantomData)", + ); + + let test = || Ok(ensure!(PhantomData:: != PhantomData)); + assert_err( + test, + "Condition failed: `PhantomData:: != PhantomData` (PhantomData vs PhantomData)", + ); + + #[rustfmt::skip] + let test = || { + Ok(ensure!( + PhantomData:: != PhantomData + )) + }; + assert_err( + test, + "Condition failed: `PhantomData:: != PhantomData` (PhantomData vs PhantomData)", + ); +} + +#[test] +fn test_macro() { + let test = || Ok(ensure!(anyhow!("...").to_string().len() <= 1)); + assert_err( + test, + "Condition failed: `anyhow!(\"...\").to_string().len() <= 1` (3 vs 1)", + ); + + let test = || Ok(ensure!(vec![1].len() < 1)); + assert_err(test, "Condition failed: `vec![1].len() < 1` (1 vs 1)"); + + let test = || Ok(ensure!(stringify! {} != "")); + assert_err( + test, + "Condition failed: `stringify! {} != \"\"` (\"\" vs \"\")", + ); +} + +#[test] +fn test_trailer() { + let test = || Ok(ensure!((|| 1)() == 2)); + assert_err(test, "Condition failed: `(|| 1)() == 2` (1 vs 2)"); + + let test = || Ok(ensure!(b"hmm"[1] == b'c')); + assert_err(test, "Condition failed: `b\"hmm\"[1] == b'c'` (109 vs 99)"); + + let test = || Ok(ensure!(PhantomData:: {} != PhantomData)); + assert_err( + test, + "Condition failed: `PhantomData::{} != PhantomData` (PhantomData vs PhantomData)", + ); + + let result = Ok::<_, Error>(1); + let test = || Ok(ensure!(result? == 2)); + assert_err(test, "Condition failed: `result? == 2` (1 vs 2)"); + + let test = || Ok(ensure!((2, 3).1 == 2)); + assert_err(test, "Condition failed: `(2, 3).1 == 2` (3 vs 2)"); + + #[rustfmt::skip] + let test = || Ok(ensure!((2, (3, 4)). 1.1 == 2)); + assert_err(test, "Condition failed: `(2, (3, 4)).1.1 == 2` (4 vs 2)"); + + let err = anyhow!(""); + let test = || Ok(ensure!(err.is::<&str>() == false)); + assert_err( + test, + "Condition failed: `err.is::<&str>() == false` (true vs false)", + ); + + let test = || Ok(ensure!(err.is::<::Owned>() == true)); + assert_err( + test, + "Condition failed: `err.is::<::Owned>() == true` (false vs true)", + ); +} + +#[test] +fn test_whitespace() { + #[derive(Debug)] + pub struct Point { + pub x: i32, + pub y: i32, + } + + let point = Point { x: 0, y: 0 }; + let test = || Ok(ensure!("" == format!("{:#?}", point))); + assert_err( + test, + "Condition failed: `\"\" == format!(\"{:#?}\", point)`", + ); +} + +#[test] +fn test_too_long() { + let test = || Ok(ensure!("" == "x".repeat(10))); + assert_err( + test, + "Condition failed: `\"\" == \"x\".repeat(10)` (\"\" vs \"xxxxxxxxxx\")", + ); + + let test = || Ok(ensure!("" == "x".repeat(80))); + assert_err(test, "Condition failed: `\"\" == \"x\".repeat(80)`"); +} + +#[test] +fn test_as() { + let test = || Ok(ensure!('\0' as u8 > 1)); + assert_err(test, "Condition failed: `'\\0' as u8 > 1` (0 vs 1)"); + + let test = || Ok(ensure!('\0' as ::std::primitive::u8 > 1)); + assert_err( + test, + "Condition failed: `'\\0' as ::std::primitive::u8 > 1` (0 vs 1)", + ); + + let test = || Ok(ensure!(&[0] as &[i32] == [1])); + assert_err( + test, + "Condition failed: `&[0] as &[i32] == [1]` ([0] vs [1])", + ); + + let test = || Ok(ensure!(0 as *const () as *mut _ == 1 as *mut ())); + assert_err( + test, + "Condition failed: `0 as *const () as *mut _ == 1 as *mut ()` (0x0 vs 0x1)", + ); + + let s = ""; + let test = || Ok(ensure!(s as &str != s)); + assert_err(test, "Condition failed: `s as &str != s` (\"\" vs \"\")"); + + let test = || Ok(ensure!(&s as &&str != &s)); + assert_err(test, "Condition failed: `&s as &&str != &s` (\"\" vs \"\")"); + + let test = || Ok(ensure!(s as &'static str != s)); + assert_err( + test, + "Condition failed: `s as &'static str != s` (\"\" vs \"\")", + ); + + let test = || Ok(ensure!(&s as &&'static str != &s)); + assert_err( + test, + "Condition failed: `&s as &&'static str != &s` (\"\" vs \"\")", + ); + + let m: &mut str = Default::default(); + let test = || Ok(ensure!(m as &mut str != s)); + assert_err( + test, + "Condition failed: `m as &mut str != s` (\"\" vs \"\")", + ); + + let test = || Ok(ensure!(&m as &&mut str != &s)); + assert_err( + test, + "Condition failed: `&m as &&mut str != &s` (\"\" vs \"\")", + ); + + let test = || Ok(ensure!(&m as &&'static mut str != &s)); + assert_err( + test, + "Condition failed: `&m as &&'static mut str != &s` (\"\" vs \"\")", + ); + + let f = || {}; + let test = || Ok(ensure!(f as fn() as usize * 0 != 0)); + assert_err( + test, + "Condition failed: `f as fn() as usize * 0 != 0` (0 vs 0)", + ); + + let test = || Ok(ensure!(f as fn() -> () as usize * 0 != 0)); + assert_err( + test, + "Condition failed: `f as fn() -> () as usize * 0 != 0` (0 vs 0)", + ); + + 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)", // FIXME + ); + + let test = || Ok(ensure!(f as unsafe fn() as usize * 0 != 0)); + assert_err( + test, + "Condition failed: `f as unsafe fn() as usize * 0 != 0` (0 vs 0)", + ); + + #[rustfmt::skip] + let test = || Ok(ensure!(f as extern "Rust" fn() as usize * 0 != 0)); + assert_err( + test, + "Condition failed: `f as extern \"Rust\" fn() as usize * 0 != 0` (0 vs 0)", + ); + + extern "C" fn extern_fn() {} + #[rustfmt::skip] + let test = || Ok(ensure!(extern_fn as extern fn() as usize * 0 != 0)); + assert_err( + test, + "Condition failed: `extern_fn as extern fn() as usize * 0 != 0` (0 vs 0)", + ); + + let f = || -> ! { panic!() }; + let test = || Ok(ensure!(f as fn() -> ! as usize * 0 != 0)); + assert_err( + test, + "Condition failed: `f as fn() -> ! as usize * 0 != 0` (0 vs 0)", + ); + + trait EqDebug: PartialEq + Debug { + type Assoc; + } + + impl EqDebug for S + where + S: PartialEq + Debug, + { + type Assoc = bool; + } + + let test = || Ok(ensure!(&0 as &dyn EqDebug != &0)); + assert_err( + test, + "Condition failed: `&0 as &dyn EqDebug != &0` (0 vs 0)", + ); + + let test = || { + Ok(ensure!( + PhantomData as PhantomData<::Owned> != PhantomData + )) + }; + assert_err( + test, + "Condition failed: `PhantomData as PhantomData<::Owned> != PhantomData` (PhantomData vs PhantomData)", + ); + + macro_rules! int { + (...) => { + u8 + }; + } + + let test = || Ok(ensure!(0 as int!(...) != 0)); + assert_err(test, "Condition failed: `0 as int!(...) != 0` (0 vs 0)"); + + let test = || Ok(ensure!(0 as int![...] != 0)); + assert_err(test, "Condition failed: `0 as int![...] != 0` (0 vs 0)"); + + let test = || Ok(ensure!(0 as int! {...} != 0)); + assert_err(test, "Condition failed: `0 as int! { ... } != 0` (0 vs 0)"); +} + +#[test] +fn test_pat() { + let test = || Ok(ensure!(if let ref mut _x @ 0 = 0 { 0 } else { 1 } == 1)); + assert_err( + test, + "Condition failed: `if let ref mut _x @ 0 = 0 { 0 } else { 1 } == 1` (0 vs 1)", + ); + + 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)", // FIXME + ); + + let test = || Ok(ensure!(if let &0 = &0 { 0 } else { 1 } == 1)); + assert_err( + test, + "Condition failed: `if let &0 = &0 { 0 } else { 1 } == 1` (0 vs 1)", + ); + + let test = || Ok(ensure!(if let &&0 = &&0 { 0 } else { 1 } == 1)); + assert_err( + test, + "Condition failed: `if let &&0 = &&0 { 0 } else { 1 } == 1` (0 vs 1)", + ); + + let test = || Ok(ensure!(if let &mut 0 = &mut 0 { 0 } else { 1 } == 1)); + assert_err( + test, + "Condition failed: `if let &mut 0 = &mut 0 { 0 } else { 1 } == 1` (0 vs 1)", + ); + + let test = || Ok(ensure!(if let &&mut 0 = &&mut 0 { 0 } else { 1 } == 1)); + assert_err( + test, + "Condition failed: `if let &&mut 0 = &&mut 0 { 0 } else { 1 } == 1` (0 vs 1)", + ); + + let test = || Ok(ensure!(if let (0, 1) = (0, 1) { 0 } else { 1 } == 1)); + assert_err( + test, + "Condition failed: `if let (0, 1) = (0, 1) { 0 } else { 1 } == 1` (0 vs 1)", + ); + + let test = || Ok(ensure!(if let [0] = b"\0" { 0 } else { 1 } == 1)); + assert_err( + test, + "Condition failed: `if let [0] = b\"\\0\" { 0 } else { 1 } == 1` (0 vs 1)", + ); + + let p = PhantomData::; + let test = || Ok(ensure!(if let P:: {} = p { 0 } else { 1 } == 1)); + assert_err( + test, + "Condition failed: `if let P:: { } = 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 ())", + ); + + let test = || Ok(ensure!(if let ::V = 0 { 0 } else { 1 } == 1)); + assert_err( + test, + "Condition failed: `if let ::V = 0 { 0 } else { 1 } == 1` (0 vs 1)", + ); + + let test = || Ok(ensure!(for _ in iter::once(()) {} != ())); + assert_err( + test, + "Condition failed: `for _ in iter::once(()) {} != ()` (() vs ())", + ); + + let test = || Ok(ensure!(if let stringify!(x) = "x" { 0 } else { 1 } == 1)); + assert_err( + test, + "Condition failed: `if let stringify!(x) = \"x\" { 0 } else { 1 } == 1` (0 vs 1)", + ); +} diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/tests/test_macros.rs cargo-0.58.0/vendor/anyhow/tests/test_macros.rs --- cargo-0.57.0+ubuntu/vendor/anyhow/tests/test_macros.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/tests/test_macros.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,9 +1,17 @@ -#![allow(clippy::eq_op, clippy::shadow_unrelated, clippy::wildcard_imports)] +#![allow( + clippy::eq_op, + clippy::items_after_statements, + clippy::needless_pass_by_value, + clippy::shadow_unrelated, + clippy::wildcard_imports +)] mod common; use self::common::*; -use anyhow::ensure; +use anyhow::{anyhow, ensure}; +use std::cell::Cell; +use std::future; #[test] fn test_messages() { @@ -39,6 +47,33 @@ }; assert_eq!( f().unwrap_err().to_string(), - "Condition failed: `v + v == 1`", + "Condition failed: `v + v == 1` (2 vs 1)", ); } + +#[test] +fn test_temporaries() { + fn require_send_sync(_: impl Send + Sync) {} + + require_send_sync(async { + // If anyhow hasn't dropped any temporary format_args it creates by the + // time it's done evaluating, those will stick around until the + // semicolon, which is on the other side of the await point, making the + // enclosing future non-Send. + future::ready(anyhow!("...")).await; + }); + + fn message(cell: Cell<&str>) -> &str { + cell.get() + } + + require_send_sync(async { + future::ready(anyhow!(message(Cell::new("...")))).await; + }); +} + +#[test] +fn test_brace_escape() { + let err = anyhow!("unterminated ${{..}} expression"); + assert_eq!("unterminated ${..} expression", err.to_string()); +} diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/tests/ui/chained-comparison.rs cargo-0.58.0/vendor/anyhow/tests/ui/chained-comparison.rs --- cargo-0.57.0+ubuntu/vendor/anyhow/tests/ui/chained-comparison.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/tests/ui/chained-comparison.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,8 @@ +use anyhow::{ensure, Result}; + +fn main() -> Result<()> { + // `ensure!` must not partition this into `(false) == (false == true)` + // because Rust doesn't ordinarily allow this form of expression. + ensure!(false == false == true); + Ok(()) +} diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/tests/ui/chained-comparison.stderr cargo-0.58.0/vendor/anyhow/tests/ui/chained-comparison.stderr --- cargo-0.57.0+ubuntu/vendor/anyhow/tests/ui/chained-comparison.stderr 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/tests/ui/chained-comparison.stderr 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,10 @@ +error: comparison operators cannot be chained + --> tests/ui/chained-comparison.rs:6:19 + | +6 | ensure!(false == false == true); + | ^^ ^^ + | +help: split the comparison into two + | +6 | ensure!(false == false && false == true); + | ++++++++ diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/tests/ui/empty-ensure.rs cargo-0.58.0/vendor/anyhow/tests/ui/empty-ensure.rs --- cargo-0.57.0+ubuntu/vendor/anyhow/tests/ui/empty-ensure.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/tests/ui/empty-ensure.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,6 @@ +use anyhow::{ensure, Result}; + +fn main() -> Result<()> { + ensure!(); + Ok(()) +} diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/tests/ui/empty-ensure.stderr cargo-0.58.0/vendor/anyhow/tests/ui/empty-ensure.stderr --- cargo-0.57.0+ubuntu/vendor/anyhow/tests/ui/empty-ensure.stderr 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/tests/ui/empty-ensure.stderr 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,7 @@ +error: unexpected end of macro invocation + --> tests/ui/empty-ensure.rs:4:5 + | +4 | ensure!(); + | ^^^^^^^^^ missing tokens in macro arguments + | + = note: this error originates in the macro `$crate::__parse_ensure` (in Nightly builds, run with -Z macro-backtrace for more info) diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/tests/ui/no-impl.stderr cargo-0.58.0/vendor/anyhow/tests/ui/no-impl.stderr --- cargo-0.57.0+ubuntu/vendor/anyhow/tests/ui/no-impl.stderr 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/tests/ui/no-impl.stderr 2022-01-21 02:47:39.000000000 +0000 @@ -1,21 +1,42 @@ error[E0599]: the method `anyhow_kind` exists for reference `&Error`, but its trait bounds were not satisfied - --> $DIR/no-impl.rs:7:13 - | -4 | struct Error; - | ------------- - | | - | doesn't satisfy `Error: Into` - | doesn't satisfy `Error: anyhow::private::kind::TraitKind` - | doesn't satisfy `Error: std::fmt::Display` + --> tests/ui/no-impl.rs:7:13 + | +4 | struct Error; + | ------------- + | | + | doesn't satisfy `Error: Into` + | doesn't satisfy `Error: anyhow::private::kind::TraitKind` + | doesn't satisfy `Error: std::fmt::Display` ... -7 | let _ = anyhow!(Error); - | ^^^^^^^^^^^^^^ method cannot be called on `&Error` due to unsatisfied trait bounds - | - = note: the following trait bounds were not satisfied: - `Error: Into` - which is required by `Error: anyhow::private::kind::TraitKind` - `Error: std::fmt::Display` - which is required by `&Error: anyhow::private::kind::AdhocKind` - `&Error: Into` - which is required by `&Error: anyhow::private::kind::TraitKind` - = note: this error originates in the macro `anyhow` (in Nightly builds, run with -Z macro-backtrace for more info) +7 | let _ = anyhow!(Error); + | ^^^^^^^^^^^^^^ method cannot be called on `&Error` due to unsatisfied trait bounds + | + = note: the following trait bounds were not satisfied: + `Error: Into` + which is required by `Error: anyhow::private::kind::TraitKind` + `Error: std::fmt::Display` + which is required by `&Error: anyhow::private::kind::AdhocKind` + `&Error: Into` + which is required by `&Error: anyhow::private::kind::TraitKind` +note: the following traits must be implemented + --> $RUST/core/src/convert/mod.rs + | + | / pub trait Into: Sized { + | | /// Performs the conversion. + | | #[must_use] + | | #[stable(feature = "rust1", since = "1.0.0")] + | | fn into(self) -> T; + | | } + | |_^ + | + ::: $RUST/core/src/fmt/mod.rs + | + | / pub trait Display { + | | /// Formats the value using the given formatter. + | | /// + | | /// # Examples +... | + | | fn fmt(&self, f: &mut Formatter<'_>) -> Result; + | | } + | |_^ + = note: this error originates in the macro `anyhow` (in Nightly builds, run with -Z macro-backtrace for more info) diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/tests/ui/temporary-value.stderr cargo-0.58.0/vendor/anyhow/tests/ui/temporary-value.stderr --- cargo-0.57.0+ubuntu/vendor/anyhow/tests/ui/temporary-value.stderr 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/tests/ui/temporary-value.stderr 2022-01-21 02:47:39.000000000 +0000 @@ -1,8 +1,9 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/temporary-value.rs:4:22 + --> tests/ui/temporary-value.rs:4:22 | 4 | let _ = anyhow!(&String::new()); - | ---------^^^^^^^^^^^^^-- temporary value is freed at the end of this statement + | ---------^^^^^^^^^^^^^- | | | | | creates a temporary which is freed while still in use + | temporary value is freed at the end of this statement | argument requires that borrow lasts for `'static` diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/tests/ui/wrong-interpolation.rs cargo-0.58.0/vendor/anyhow/tests/ui/wrong-interpolation.rs --- cargo-0.57.0+ubuntu/vendor/anyhow/tests/ui/wrong-interpolation.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/tests/ui/wrong-interpolation.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,5 @@ +use anyhow::{bail, Result}; + +fn main() -> Result<()> { + bail!("{} not found"); +} diff -Nru cargo-0.57.0+ubuntu/vendor/anyhow/tests/ui/wrong-interpolation.stderr cargo-0.58.0/vendor/anyhow/tests/ui/wrong-interpolation.stderr --- cargo-0.57.0+ubuntu/vendor/anyhow/tests/ui/wrong-interpolation.stderr 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/anyhow/tests/ui/wrong-interpolation.stderr 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,5 @@ +error: 1 positional argument in format string, but no arguments were given + --> tests/ui/wrong-interpolation.rs:4:12 + | +4 | bail!("{} not found"); + | ^^ diff -Nru cargo-0.57.0+ubuntu/vendor/cc/.cargo-checksum.json cargo-0.58.0/vendor/cc/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/cc/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/cc/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd"} \ No newline at end of file +{"files":{},"package":"22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/cc/Cargo.lock cargo-0.58.0/vendor/cc/Cargo.lock --- cargo-0.57.0+ubuntu/vendor/cc/Cargo.lock 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/cc/Cargo.lock 2022-01-21 02:47:39.000000000 +0000 @@ -10,7 +10,7 @@ [[package]] name = "cc" -version = "1.0.71" +version = "1.0.72" dependencies = [ "jobserver", "tempfile", @@ -44,15 +44,15 @@ [[package]] name = "libc" -version = "0.2.103" +version = "0.2.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" +checksum = "fbe5e23404da5b4f555ef85ebed98fb4083e55a00c317800bc2a50ede9f3d219" [[package]] name = "ppv-lite86" -version = "0.2.10" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" [[package]] name = "rand" diff -Nru cargo-0.57.0+ubuntu/vendor/cc/Cargo.toml cargo-0.58.0/vendor/cc/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/cc/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/cc/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -12,7 +12,7 @@ [package] edition = "2018" name = "cc" -version = "1.0.71" +version = "1.0.72" authors = ["Alex Crichton "] exclude = ["/.github", "/.travis.yml", "/appveyor.yml"] description = "A build-time dependency for Cargo build scripts to assist in invoking the native\nC compiler to compile native C code into a static archive to be linked into Rust\ncode.\n" diff -Nru cargo-0.57.0+ubuntu/vendor/cc/src/lib.rs cargo-0.58.0/vendor/cc/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/cc/src/lib.rs 2021-12-13 01:03:07.000000000 +0000 +++ cargo-0.58.0/vendor/cc/src/lib.rs 2022-01-21 02:49:13.000000000 +0000 @@ -1557,6 +1557,10 @@ cmd.args.push( format!("--target={}", target.replace("riscv64gc", "riscv64")).into(), ); + } else if target.starts_with("riscv32gc-") { + cmd.args.push( + format!("--target={}", target.replace("riscv32gc", "riscv32")).into(), + ); } else if target.contains("uefi") { if target.contains("x86_64") { cmd.args.push("--target=x86_64-unknown-windows-gnu".into()); @@ -1638,6 +1642,11 @@ && (target.contains("-linux-") || target.contains("-kmc-solid_")) { cmd.args.push("-march=armv7-a".into()); + + if target.ends_with("eabihf") { + // lowest common denominator FPU + cmd.args.push("-mfpu=vfpv3-d16".into()); + } } // (x86 Android doesn't say "eabi") diff -Nru cargo-0.57.0+ubuntu/vendor/cc/src/windows_registry.rs cargo-0.58.0/vendor/cc/src/windows_registry.rs --- cargo-0.57.0+ubuntu/vendor/cc/src/windows_registry.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/cc/src/windows_registry.rs 2022-01-21 02:47:39.000000000 +0000 @@ -89,6 +89,8 @@ Vs15, /// Visual Studio 16 (2019) Vs16, + /// Visual Studio 17 (2022) + Vs17, /// Hidden variant that should not be matched on. Callers that want to /// handle an enumeration of `VsVers` instances should always have a default @@ -114,6 +116,7 @@ match env::var("VisualStudioVersion") { Ok(version) => match &version[..] { + "17.0" => Ok(VsVers::Vs17), "16.0" => Ok(VsVers::Vs16), "15.0" => Ok(VsVers::Vs15), "14.0" => Ok(VsVers::Vs14), @@ -223,7 +226,7 @@ } /// Attempt to find the tool using environment variables set by vcvars. - pub fn find_msvc_environment(target: &str, tool: &str) -> Option { + pub fn find_msvc_environment(tool: &str, target: &str) -> Option { // Early return if the environment doesn't contain a VC install. if env::var_os("VCINSTALLDIR").is_none() { return None; diff -Nru cargo-0.57.0+ubuntu/vendor/clap/.cargo-checksum.json cargo-0.58.0/vendor/clap/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/clap/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002"} \ No newline at end of file +{"files":{},"package":"a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/clap/Cargo.toml cargo-0.58.0/vendor/clap/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/clap/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -11,8 +11,9 @@ # will likely look very different (and much more reasonable) [package] +edition = "2018" name = "clap" -version = "2.33.3" +version = "2.34.0" authors = ["Kevin K. "] exclude = ["examples/*", "clap-test/*", "tests/*", "benches/*", "*.png", "clap-perf/*", "*.dot"] description = "A simple to use, efficient, and full-featured Command Line Argument Parser\n" @@ -98,7 +99,6 @@ debug = [] default = ["suggestions", "color", "vec_map"] doc = ["yaml"] -lints = [] nightly = [] no_cargo = [] suggestions = ["strsim"] diff -Nru cargo-0.57.0+ubuntu/vendor/clap/CHANGELOG.md cargo-0.58.0/vendor/clap/CHANGELOG.md --- cargo-0.57.0+ubuntu/vendor/clap/CHANGELOG.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 @@ -1,3 +1,15 @@ + +## v2.34.0 (2021-11-30) + +- Updates to Rust 2018 edition and bumps the MSRV to Rust 1.46 + + +### v2.33.4 (2021-11-29) + +#### Bug Fixes + +* **prevents `panic`:** swallows broken pipe errors on error output ([7a729bc4](https://github.com/kbknapp/clap-rs/commit/7a729bc4df2646b05f6bf15f001124cd39d076ce)) + ### v2.33.3 (2020-08-13) diff -Nru cargo-0.57.0+ubuntu/vendor/clap/debian/patches/no-clippy.patch cargo-0.58.0/vendor/clap/debian/patches/no-clippy.patch --- cargo-0.57.0+ubuntu/vendor/clap/debian/patches/no-clippy.patch 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/debian/patches/no-clippy.patch 2022-01-21 02:47:39.000000000 +0000 @@ -1,6 +1,6 @@ --- a/Cargo.toml +++ b/Cargo.toml -@@ -63,10 +63,6 @@ +@@ -64,10 +64,6 @@ [dependencies.bitflags] version = "1.0" @@ -11,12 +11,3 @@ [dependencies.strsim] version = "0.8" optional = true -@@ -102,7 +98,7 @@ - debug = [] - default = ["suggestions", "color", "vec_map"] - doc = ["yaml"] --lints = ["clippy"] -+lints = [] - nightly = [] - no_cargo = [] - suggestions = ["strsim"] diff -Nru cargo-0.57.0+ubuntu/vendor/clap/debian/patches/relax-dep-versions.patch cargo-0.58.0/vendor/clap/debian/patches/relax-dep-versions.patch --- cargo-0.57.0+ubuntu/vendor/clap/debian/patches/relax-dep-versions.patch 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/debian/patches/relax-dep-versions.patch 2022-01-21 02:47:39.000000000 +0000 @@ -1,6 +1,6 @@ --- a/Cargo.toml +++ b/Cargo.toml -@@ -64,7 +64,7 @@ +@@ -65,7 +65,7 @@ version = "1.0" [dependencies.strsim] @@ -9,7 +9,7 @@ optional = true [dependencies.term_size] -@@ -82,7 +82,7 @@ +@@ -83,7 +83,7 @@ optional = true [dependencies.yaml-rust] @@ -18,11 +18,11 @@ optional = true [dev-dependencies.lazy_static] version = "1.3" -@@ -105,7 +105,7 @@ +@@ -106,7 +106,7 @@ wrap_help = ["term_size", "textwrap/term_size"] yaml = ["yaml-rust"] [target."cfg(not(windows))".dependencies.ansi_term] --version = "0.11" +-version = "0.12" +version = ">= 0.11, < 0.13" optional = true [badges.appveyor] diff -Nru cargo-0.57.0+ubuntu/vendor/clap/README.md cargo-0.58.0/vendor/clap/README.md --- cargo-0.57.0+ubuntu/vendor/clap/README.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/README.md 2022-01-21 02:47:39.000000000 +0000 @@ -246,7 +246,7 @@ Since this feature requires additional dependencies that not everyone may want, it is *not* compiled in by default and we need to enable a feature flag in Cargo.toml: -Simply change your `clap = "2.33"` to `clap = {version = "2.33", features = ["yaml"]}`. +Simply change your `clap = "2.34"` to `clap = {version = "2.34", features = ["yaml"]}`. Finally we create our `main.rs` file just like we would have with the previous two examples: @@ -347,7 +347,7 @@ ```toml [dependencies] -clap = "~2.33" +clap = "~2.34" ``` (**note**: If you are concerned with supporting a minimum version of Rust that is *older* than the current stable Rust minus 2 stable releases, it's recommended to use the `~major.minor.patch` style versions in your `Cargo.toml` which will only update the patch version automatically. For more information see the [Compatibility Policy](#compatibility-policy)) @@ -370,7 +370,7 @@ ```toml [dependencies.clap] -version = "2.33" +version = "2.34" default-features = false ``` @@ -378,7 +378,7 @@ ```toml [dependencies.clap] -version = "2.33" +version = "2.34" default-features = false # Cherry-pick the features you'd like to use @@ -427,7 +427,7 @@ ```toml [dependencies] -clap = "~2.33" +clap = "~2.34" ``` This will cause *only* the patch version to be updated upon a `cargo update` call, and therefore cannot break due to new features, or bumped minimum versions of Rust. @@ -444,11 +444,11 @@ # In one Cargo.toml [dependencies] -clap = "~2.33.0" +clap = "~2.34.0" # In another Cargo.toml [dependencies] -clap = "2.33.0" +clap = "2.34.0" ``` This is inherently an unresolvable crate graph in Cargo right now. Cargo requires there's only one major version of a crate, and being in the same workspace these two crates must share a version. This is impossible in this location, though, as these version constraints cannot be met. diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/app/help.rs cargo-0.58.0/vendor/clap/src/app/help.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/app/help.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/app/help.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,27 +1,30 @@ // Std -use std::borrow::Cow; -use std::cmp; -use std::collections::BTreeMap; -use std::fmt::Display; -use std::io::{self, Cursor, Read, Write}; -use std::usize; - -// Internal -use app::parser::Parser; -use app::usage; -use app::{App, AppSettings}; -use args::{AnyArg, ArgSettings, DispOrder}; -use errors::{Error, Result as ClapResult}; -use fmt::{Colorizer, ColorizerOption, Format}; -use map::VecMap; -use INTERNAL_ERROR_MSG; +use std::{ + borrow::Cow, + cmp, + collections::BTreeMap, + fmt::Display, + io::{self, Cursor, Read, Write}, + usize, +}; // Third Party #[cfg(feature = "wrap_help")] use term_size; +#[cfg(feature = "wrap_help")] use textwrap; use unicode_width::UnicodeWidthStr; +// Internal +use crate::{ + app::{parser::Parser, usage, App, AppSettings}, + args::{AnyArg, ArgSettings, DispOrder}, + errors::{Error, Result as ClapResult}, + fmt::{Colorizer, ColorizerOption, Format}, + map::VecMap, + INTERNAL_ERROR_MSG, +}; + #[cfg(not(feature = "wrap_help"))] mod term_size { pub fn dimensions() -> Option<(usize, usize)> { @@ -33,7 +36,7 @@ UnicodeWidthStr::width(s) } -const TAB: &'static str = " "; +const TAB: &str = " "; // These are just convenient traits to make the code easier to read. trait ArgWithDisplay<'b, 'c>: AnyArg<'b, 'c> + Display {} @@ -96,7 +99,7 @@ // Public Functions impl<'a> Help<'a> { /// Create a new `Help` instance. - #[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] + #[cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))] pub fn new( w: &'a mut Write, next_line_help: bool, @@ -110,8 +113,8 @@ debugln!("Help::new;"); Help { writer: w, - next_line_help: next_line_help, - hide_pv: hide_pv, + next_line_help, + hide_pv, term_w: match term_w { Some(width) => { if width == 0 { @@ -128,11 +131,11 @@ }, ), }, - color: color, - cizer: cizer, + color, + cizer, longest: 0, force_next_line: false, - use_long: use_long, + use_long, } } @@ -492,7 +495,7 @@ write!(self.writer, "{}", part)?; } for part in help.lines().skip(1) { - write!(self.writer, "\n")?; + writeln!(self.writer)?; if nlh || self.force_next_line { write!(self.writer, "{}{}{}", TAB, TAB, TAB)?; } else if arg.has_switch() { @@ -503,7 +506,7 @@ write!(self.writer, "{}", part)?; } if !help.contains('\n') && (nlh || self.force_next_line) { - write!(self.writer, "\n")?; + writeln!(self.writer)?; } Ok(()) } @@ -590,8 +593,6 @@ impl<'a> Help<'a> { /// Writes help for all arguments (options, flags, args, subcommands) /// including titles of a Parser Object to the wrapped stream. - #[cfg_attr(feature = "lints", allow(useless_let_if_seq))] - #[cfg_attr(feature = "cargo-clippy", allow(useless_let_if_seq))] pub fn write_all_args(&mut self, parser: &Parser) -> ClapResult<()> { debugln!("Help::write_all_args;"); let flags = parser.has_flags(); diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/app/mod.rs cargo-0.58.0/vendor/clap/src/app/mod.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/app/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/app/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -6,27 +6,30 @@ mod validator; // Std -use std::env; -use std::ffi::{OsStr, OsString}; -use std::fmt; -use std::io::{self, BufRead, BufWriter, Write}; -use std::path::Path; -use std::process; -use std::rc::Rc; use std::result::Result as StdResult; +use std::{ + env, + ffi::{OsStr, OsString}, + fmt, + io::{self, BufRead, BufWriter, Write}, + path::Path, + process, + rc::Rc, +}; // Third Party #[cfg(feature = "yaml")] use yaml_rust::Yaml; // Internal -pub use self::settings::AppSettings; -use app::help::Help; -use app::parser::Parser; -use args::{AnyArg, Arg, ArgGroup, ArgMatcher, ArgMatches, ArgSettings}; -use completions::Shell; -use errors::Result as ClapResult; -use map::{self, VecMap}; +use crate::errors::Result as ClapResult; +use crate::{ + app::{help::Help, parser::Parser}, + args::{AnyArg, Arg, ArgGroup, ArgMatcher, ArgMatches, ArgSettings}, + completions::Shell, + map::{self, VecMap}, +}; +pub use settings::AppSettings; /// Used to create a representation of a command line program and all possible command line /// arguments. Application settings are set using the "builder pattern" with the @@ -90,7 +93,7 @@ /// Get the name of the binary pub fn get_bin_name(&self) -> Option<&str> { - self.p.meta.bin_name.as_ref().map(|s| s.as_str()) + self.p.meta.bin_name.as_deref() } /// Creates a new instance of an application requiring a name, but uses the [`crate_authors!`] @@ -1640,7 +1643,7 @@ return Err(e); } - let global_arg_vec: Vec<&str> = (&self).p.global_args.iter().map(|ga| ga.b.name).collect(); + let global_arg_vec: Vec<&str> = self.p.global_args.iter().map(|ga| ga.b.name).collect(); matcher.propagate_globals(&global_arg_vec); Ok(matcher.into()) @@ -1650,7 +1653,7 @@ #[cfg(feature = "yaml")] impl<'a> From<&'a Yaml> for App<'a, 'a> { fn from(mut yaml: &'a Yaml) -> Self { - use args::SubCommand; + use crate::args::SubCommand; // We WANT this to panic on error...so expect() is good. let mut is_sc = None; let mut a = if let Some(name) = yaml["name"].as_str() { @@ -1841,9 +1844,11 @@ fn possible_vals(&self) -> Option<&[&'e str]> { None } + #[cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] fn validator(&self) -> Option<&Rc StdResult<(), String>>> { None } + #[cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] fn validator_os(&self) -> Option<&Rc StdResult<(), OsString>>> { None } diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/app/parser.rs cargo-0.58.0/vendor/clap/src/app/parser.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/app/parser.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/app/parser.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,43 +1,39 @@ // Std -#[cfg(all(feature = "debug", any(target_os = "windows", target_arch = "wasm32")))] -use osstringext::OsStrExt3; -use std::cell::Cell; -use std::ffi::{OsStr, OsString}; -use std::fmt::Display; -use std::fs::File; -use std::io::{self, BufWriter, Write}; -use std::iter::Peekable; -#[cfg(all( - feature = "debug", - not(any(target_os = "windows", target_arch = "wasm32")) -))] +#[cfg(not(any(target_os = "windows", target_arch = "wasm32")))] use std::os::unix::ffi::OsStrExt; -use std::path::PathBuf; -use std::slice::Iter; +use std::{ + cell::Cell, + ffi::{OsStr, OsString}, + fmt::Display, + fs::File, + io::{self, BufWriter, Write}, + iter::Peekable, + path::PathBuf, + slice::Iter, +}; // Internal -use app::help::Help; -use app::meta::AppMeta; -use app::settings::AppFlags; -use app::settings::AppSettings as AS; -use app::usage; -use app::validator::Validator; -use app::App; -use args::settings::ArgSettings; -use args::{ - AnyArg, Arg, ArgGroup, ArgMatcher, Base, FlagBuilder, OptBuilder, PosBuilder, Switched, +#[cfg(all(feature = "debug", any(target_os = "windows", target_arch = "wasm32")))] +use crate::osstringext::OsStrExt3; +#[cfg(any(target_os = "windows", target_arch = "wasm32"))] +use crate::osstringext::OsStrExt3; +use crate::{ + app::{ + help::Help, meta::AppMeta, settings::AppFlags, settings::AppSettings as AS, usage, + validator::Validator, App, + }, + args::{ + settings::ArgSettings, AnyArg, Arg, ArgGroup, ArgMatcher, Base, FlagBuilder, OptBuilder, + PosBuilder, Switched, + }, + completions::{ComplGen, Shell}, + errors::Result as ClapResult, + errors::{Error, ErrorKind}, + fmt::ColorWhen, + map::{self, VecMap}, + osstringext::OsStrExt2, + suggestions, SubCommand, INTERNAL_ERROR_MSG, INVALID_UTF8, }; -use completions::ComplGen; -use completions::Shell; -use errors::Result as ClapResult; -use errors::{Error, ErrorKind}; -use fmt::ColorWhen; -use map::{self, VecMap}; -use osstringext::OsStrExt2; -use suggestions; -use SubCommand; -use INTERNAL_ERROR_MSG; -use INVALID_UTF8; #[derive(Debug, PartialEq, Copy, Clone)] #[doc(hidden)] @@ -95,7 +91,7 @@ let c = s .trim_left_matches(|c| c == '-') .chars() - .nth(0) + .next() .unwrap_or('h'); self.help_short = Some(c); } @@ -104,7 +100,7 @@ let c = s .trim_left_matches(|c| c == '-') .chars() - .nth(0) + .next() .unwrap_or('V'); self.version_short = Some(c); } @@ -146,10 +142,10 @@ assert!(self.verify_positionals()); let should_err = self.groups.iter().all(|g| { g.args.iter().all(|arg| { - (self.flags.iter().any(|f| &f.b.name == arg) + self.flags.iter().any(|f| &f.b.name == arg) || self.opts.iter().any(|o| &o.b.name == arg) || self.positionals.values().any(|p| &p.b.name == arg) - || self.groups.iter().any(|g| &g.name == arg)) + || self.groups.iter().any(|g| &g.name == arg) }) }); let g = self.groups.iter().find(|g| { @@ -180,7 +176,8 @@ fn debug_asserts(&self, a: &Arg) -> bool { assert!( !arg_names!(self).any(|name| name == a.b.name), - format!("Non-unique argument name: {} is already in use", a.b.name) + "Non-unique argument name: {} is already in use", + a.b.name ); if let Some(l) = a.s.long { assert!( @@ -197,7 +194,7 @@ ); } let i = if a.index.is_none() { - (self.positionals.len() + 1) + self.positionals.len() + 1 } else { a.index.unwrap() as usize }; @@ -306,7 +303,7 @@ self.implied_settings(&a); if a.index.is_some() || (a.s.short.is_none() && a.s.long.is_none()) { let i = if a.index.is_none() { - (self.positionals.len() + 1) + self.positionals.len() + 1 } else { a.index.unwrap() as usize }; @@ -331,7 +328,7 @@ self.implied_settings(a); if a.index.is_some() || (a.s.short.is_none() && a.s.long.is_none()) { let i = if a.index.is_none() { - (self.positionals.len() + 1) + self.positionals.len() + 1 } else { a.index.unwrap() as usize }; @@ -425,7 +422,6 @@ } } - #[cfg_attr(feature = "lints", allow(needless_borrow))] pub fn derive_display_order(&mut self) { if self.is_set(AS::DeriveDisplayOrder) { let unified = self.is_set(AS::UnifiedHelpMessage); @@ -463,7 +459,6 @@ self.required.iter() } - #[cfg_attr(feature = "lints", allow(needless_borrow))] #[inline] pub fn has_args(&self) -> bool { !(self.flags.is_empty() && self.opts.is_empty() && self.positionals.is_empty()) @@ -540,7 +535,6 @@ self.settings.unset(s) } - #[cfg_attr(feature = "lints", allow(block_in_if_condition_stmt))] pub fn verify_positionals(&self) -> bool { // Because you must wait until all arguments have been supplied, this is the first chance // to make assertions on positional argument indexes @@ -602,10 +596,10 @@ ); } + let mut found = false; if self.is_set(AS::AllowMissingPositional) { // Check that if a required positional argument is found, all positions with a lower // index are also required. - let mut found = false; let mut foundx2 = false; for p in self.positionals.values().rev() { if foundx2 && !p.b.settings.is_set(ArgSettings::Required) { @@ -637,7 +631,6 @@ } else { // Check that if a required positional argument is found, all positions with a lower // index are also required - let mut found = false; for p in self.positionals.values().rev() { if found { assert!( @@ -690,10 +683,6 @@ // Checks if the arg matches a subcommand name, or any of it's aliases (if defined) fn possible_subcommand(&self, arg_os: &OsStr) -> (bool, Option<&str>) { - #[cfg(any(target_os = "windows", target_arch = "wasm32"))] - use osstringext::OsStrExt3; - #[cfg(not(any(target_os = "windows", target_arch = "wasm32")))] - use std::os::unix::ffi::OsStrExt; debugln!("Parser::possible_subcommand: arg={:?}", arg_os); fn starts(h: &str, n: &OsStr) -> bool { let n_bytes = n.as_bytes(); @@ -839,7 +828,7 @@ .iter() .find(|o| o.b.name == name) .expect(INTERNAL_ERROR_MSG); - (o.is_set(ArgSettings::AllowLeadingHyphen) || app_wide_settings) + o.is_set(ArgSettings::AllowLeadingHyphen) || app_wide_settings } ParseResult::Pos(name) => { let p = self @@ -847,7 +836,7 @@ .values() .find(|p| p.b.name == name) .expect(INTERNAL_ERROR_MSG); - (p.is_set(ArgSettings::AllowLeadingHyphen) || app_wide_settings) + p.is_set(ArgSettings::AllowLeadingHyphen) || app_wide_settings } ParseResult::ValuesDone => return true, _ => false, @@ -866,7 +855,7 @@ } else if arg_os.starts_with(b"-") { debugln!("Parser::is_new_arg: - found"); // a singe '-' by itself is a value and typically means "stdin" on unix systems - !(arg_os.len() == 1) + arg_os.len() != 1 } else { debugln!("Parser::is_new_arg: probably value"); false @@ -879,7 +868,10 @@ } // The actual parsing function - #[cfg_attr(feature = "lints", allow(while_let_on_iterator, collapsible_if))] + #[cfg_attr( + feature = "cargo-clippy", + allow(clippy::while_let_on_iterator, clippy::nonminimal_bool) + )] pub fn get_matches_with( &mut self, matcher: &mut ArgMatcher<'a>, @@ -1011,19 +1003,17 @@ _ => (), } } - } else { - if let ParseResult::Opt(name) = needs_val_of { - // Check to see if parsing a value from a previous arg - let arg = self - .opts - .iter() - .find(|o| o.b.name == name) - .expect(INTERNAL_ERROR_MSG); - // get the OptBuilder so we can check the settings - needs_val_of = self.add_val_to_arg(arg, &arg_os, matcher)?; - // get the next value from the iterator - continue; - } + } else if let ParseResult::Opt(name) = needs_val_of { + // Check to see if parsing a value from a previous arg + let arg = self + .opts + .iter() + .find(|o| o.b.name == name) + .expect(INTERNAL_ERROR_MSG); + // get the OptBuilder so we can check the settings + needs_val_of = self.add_val_to_arg(arg, &arg_os, matcher)?; + // get the next value from the iterator + continue; } } @@ -1122,7 +1112,7 @@ matcher.inc_occurrence_of(p.b.name); let _ = self .groups_for_arg(p.b.name) - .and_then(|vec| Some(matcher.inc_occurrences_of(&*vec))); + .map(|vec| matcher.inc_occurrences_of(&*vec)); self.settings.set(AS::ValidArgFound); // Only increment the positional counter if it doesn't allow multiples @@ -1147,6 +1137,8 @@ // Collect the external subcommand args let mut sc_m = ArgMatcher::new(); + // Due to borrow rules, this has to be a while let... + #[cfg_attr(feature = "cargo-clippy", allow(clippy::while_let_on_iterator))] while let Some(v) = it.next() { let a = v.into(); if a.to_str().is_none() && !self.is_set(AS::StrictUtf8) { @@ -1345,7 +1337,7 @@ write!(&mut mid_string, " {}", s).expect(INTERNAL_ERROR_MSG); } } - mid_string.push_str(" "); + mid_string.push(' '); if let Some(ref mut sc) = self .subcommands .iter_mut() @@ -1462,7 +1454,7 @@ } } - args.iter().map(|s| *s).collect() + args.iter().copied().collect() } pub fn create_help_and_version(&mut self) { @@ -1677,7 +1669,7 @@ debugln!("Parser::parse_long_arg: Didn't match anything"); - let args_rest: Vec<_> = it.map(|x| x.clone().into()).collect(); + let args_rest: Vec<_> = it.map(|x| x.into()).collect(); let args_rest2: Vec<_> = args_rest .iter() .map(|x| x.to_str().expect(INVALID_UTF8)) @@ -1686,7 +1678,6 @@ .map(|_| ParseResult::NotFound) } - #[cfg_attr(feature = "lints", allow(len_zero))] fn parse_short_arg( &mut self, matcher: &mut ArgMatcher<'a>, @@ -1736,7 +1727,7 @@ p[1].as_bytes() ); let i = p[0].as_bytes().len() + 1; - let val = if p[1].as_bytes().len() > 0 { + let val = if !p[1].as_bytes().is_empty() { debugln!( "Parser::parse_short_arg:iter:{}: val={:?} (bytes), val={:?} (ascii)", c, @@ -1800,7 +1791,7 @@ if let Some(fv) = val { has_eq = fv.starts_with(&[b'=']) || had_eq; let v = fv.trim_left_matches(b'='); - if !empty_vals && (v.len() == 0 || (needs_eq && !has_eq)) { + if !empty_vals && (v.is_empty() || (needs_eq && !has_eq)) { sdebugln!("Found Empty - Error"); return Err(Error::empty_value( opt, @@ -1828,8 +1819,9 @@ matcher.inc_occurrence_of(opt.b.name); // Increment or create the group "args" - self.groups_for_arg(opt.b.name) - .and_then(|vec| Some(matcher.inc_occurrences_of(&*vec))); + if let Some(vec) = self.groups_for_arg(opt.b.name) { + matcher.inc_occurrences_of(&*vec); + } let needs_delim = opt.is_set(ArgSettings::RequireDelimiter); let mult = opt.is_set(ArgSettings::Multiple); @@ -1934,8 +1926,9 @@ matcher.add_index_to(flag.b.name, self.cur_idx.get()); // Increment or create the group "args" - self.groups_for_arg(flag.b.name) - .and_then(|vec| Some(matcher.inc_occurrences_of(&*vec))); + if let Some(vec) = self.groups_for_arg(flag.b.name) { + matcher.inc_occurrences_of(&*vec); + } Ok(ParseResult::Flag) } @@ -1948,17 +1941,19 @@ ) -> ClapResult<()> { // Didn't match a flag or option let suffix = - suggestions::did_you_mean_flag_suffix(arg, &args_rest, longs!(self), &self.subcommands); + suggestions::did_you_mean_flag_suffix(arg, args_rest, longs!(self), &self.subcommands); // Add the arg to the matches to build a proper usage string if let Some(name) = suffix.1 { if let Some(opt) = find_opt_by_long!(self, name) { - self.groups_for_arg(&*opt.b.name) - .and_then(|grps| Some(matcher.inc_occurrences_of(&*grps))); + if let Some(grps) = self.groups_for_arg(&*opt.b.name) { + matcher.inc_occurrences_of(&*grps); + } matcher.insert(&*opt.b.name); } else if let Some(flg) = find_flag_by_long!(self, name) { - self.groups_for_arg(&*flg.b.name) - .and_then(|grps| Some(matcher.inc_occurrences_of(&*grps))); + if let Some(grps) = self.groups_for_arg(&*flg.b.name) { + matcher.inc_occurrences_of(&*grps); + } matcher.insert(&*flg.b.name); } } @@ -2183,7 +2178,7 @@ self.meta .bin_name .as_ref() - .and_then(|name| Some(value == name)) + .map(|name| value == name) .unwrap_or(false) } @@ -2192,13 +2187,13 @@ self.meta .aliases .as_ref() - .and_then(|aliases| { + .map(|aliases| { for alias in aliases { if alias.0 == value { - return Some(true); + return true; } } - Some(false) + false }) .unwrap_or(false) } diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/app/usage.rs cargo-0.58.0/vendor/clap/src/app/usage.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/app/usage.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/app/usage.rs 2022-01-21 02:47:39.000000000 +0000 @@ -2,11 +2,11 @@ use std::collections::{BTreeMap, VecDeque}; // Internal -use app::parser::Parser; -use app::settings::AppSettings as AS; -use args::settings::ArgSettings; -use args::{AnyArg, ArgMatcher, PosBuilder}; -use INTERNAL_ERROR_MSG; +use crate::{ + app::{parser::Parser, settings::AppSettings as AS}, + args::{settings::ArgSettings, AnyArg, ArgMatcher, PosBuilder}, + INTERNAL_ERROR_MSG, +}; // Creates a usage string for display. This happens just after all arguments were parsed, but before // any subcommands have been parsed (so as to give subcommands their own usage recursively) @@ -36,7 +36,7 @@ true // flags can't be required, so they're always true } }) - .map(|&n| n) + .copied() .collect(); if let Some(r) = extra { args.push(r); @@ -67,7 +67,7 @@ usage.push_str(&*name); let req_string = if incl_reqs { let mut reqs: Vec<&str> = p.required().map(|r| &**r).collect(); - reqs.sort(); + reqs.sort_unstable(); reqs.dedup(); get_required_usage_from(p, &reqs, None, None, false) .iter() @@ -134,10 +134,10 @@ usage.push_str(" [-- <"); } usage.push_str(&*pos.name_no_brackets()); - usage.push_str(">"); + usage.push('>'); usage.push_str(pos.multiple_str()); if !req { - usage.push_str("]"); + usage.push(']'); } } } @@ -145,15 +145,13 @@ // incl_reqs is only false when this function is called recursively if p.has_visible_subcommands() && incl_reqs || p.is_set(AS::AllowExternalSubcommands) { if p.is_set(AS::SubcommandsNegateReqs) || p.is_set(AS::ArgsNegateSubcommands) { + usage.push_str("\n "); if !p.is_set(AS::ArgsNegateSubcommands) { - usage.push_str("\n "); usage.push_str(&*create_help_usage(p, false)); - usage.push_str(" "); } else { - usage.push_str("\n "); usage.push_str(&*name); - usage.push_str(" "); } + usage.push_str(" "); } else if p.is_set(AS::SubcommandRequired) || p.is_set(AS::SubcommandRequiredElseHelp) { usage.push_str(" "); } else { @@ -415,7 +413,7 @@ } } desc_reqs.extend_from_slice(reqs); - desc_reqs.sort(); + desc_reqs.sort_unstable(); desc_reqs.dedup(); debugln!( "usage::get_required_usage_from: final desc_reqs={:?}", diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/app/validator.rs cargo-0.58.0/vendor/clap/src/app/validator.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/app/validator.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/app/validator.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,19 +1,19 @@ // std #[allow(deprecated, unused_imports)] -use std::ascii::AsciiExt; -use std::fmt::Display; +use std::{ascii::AsciiExt, fmt::Display}; // Internal -use app::parser::{ParseResult, Parser}; -use app::settings::AppSettings as AS; -use app::usage; -use args::settings::ArgSettings; -use args::{AnyArg, ArgMatcher, MatchedArg}; -use errors::Result as ClapResult; -use errors::{Error, ErrorKind}; -use fmt::{Colorizer, ColorizerOption}; -use INTERNAL_ERROR_MSG; -use INVALID_UTF8; +use crate::{ + app::{ + parser::{ParseResult, Parser}, + settings::AppSettings as AS, + usage, + }, + args::{settings::ArgSettings, AnyArg, ArgMatcher, MatchedArg}, + errors::{Error, ErrorKind, Result as ClapResult}, + fmt::{Colorizer, ColorizerOption}, + INTERNAL_ERROR_MSG, INVALID_UTF8, +}; pub struct Validator<'a, 'b, 'z>(&'z mut Parser<'a, 'b>) where @@ -74,7 +74,7 @@ }); } self.validate_blacklist(matcher)?; - if !(self.0.is_set(AS::SubcommandsNegateReqs) && subcmd_name.is_some()) && !reqs_validated { + if !(reqs_validated || self.0.is_set(AS::SubcommandsNegateReqs) && subcmd_name.is_some()) { self.validate_required(matcher)?; } self.validate_matched_args(matcher)?; @@ -162,13 +162,14 @@ fn build_err(&self, name: &str, matcher: &ArgMatcher) -> ClapResult<()> { debugln!("build_err!: name={}", name); let mut c_with = find_from!(self.0, &name, blacklist, matcher); - c_with = c_with.or(self - .0 - .find_any_arg(name) - .map_or(None, |aa| aa.blacklist()) - .map_or(None, |bl| bl.iter().find(|arg| matcher.contains(arg))) - .map_or(None, |an| self.0.find_any_arg(an)) - .map_or(None, |aa| Some(format!("{}", aa)))); + c_with = c_with.or_else(|| { + self.0 + .find_any_arg(name) + .and_then(|aa| aa.blacklist()) + .and_then(|bl| bl.iter().find(|arg| matcher.contains(arg))) + .and_then(|an| self.0.find_any_arg(an)) + .map(|aa| format!("{}", aa)) + }); debugln!("build_err!: '{:?}' conflicts with '{}'", c_with, &name); // matcher.remove(&name); let usg = usage::create_error_usage(self.0, matcher, None); @@ -184,7 +185,7 @@ debugln!("build_err!: It was a positional..."); Err(Error::argument_conflict(p, c_with, &*usg, self.0.color())) } - None => panic!(INTERNAL_ERROR_MSG), + None => panic!("{}", INTERNAL_ERROR_MSG), } } } @@ -361,7 +362,7 @@ a, num, if a.is_set(ArgSettings::Multiple) { - (ma.vals.len() % num as usize) + ma.vals.len() % num as usize } else { ma.vals.len() }, diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/args/any_arg.rs cargo-0.58.0/vendor/clap/src/args/any_arg.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/args/any_arg.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/args/any_arg.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,12 +1,16 @@ // Std -use std::ffi::{OsStr, OsString}; -use std::fmt as std_fmt; -use std::rc::Rc; +use std::{ + ffi::{OsStr, OsString}, + fmt as std_fmt, + rc::Rc, +}; // Internal -use args::settings::ArgSettings; -use map::{self, VecMap}; -use INTERNAL_ERROR_MSG; +use crate::{ + args::settings::ArgSettings, + map::{self, VecMap}, + INTERNAL_ERROR_MSG, +}; #[doc(hidden)] pub trait AnyArg<'n, 'e>: std_fmt::Display { @@ -16,14 +20,16 @@ fn requires(&self) -> Option<&[(Option<&'e str>, &'n str)]>; fn blacklist(&self) -> Option<&[&'e str]>; fn required_unless(&self) -> Option<&[&'e str]>; - fn is_set(&self, ArgSettings) -> bool; - fn set(&mut self, ArgSettings); + fn is_set(&self, setting: ArgSettings) -> bool; + fn set(&mut self, setting: ArgSettings); fn has_switch(&self) -> bool; fn max_vals(&self) -> Option; fn min_vals(&self) -> Option; fn num_vals(&self) -> Option; fn possible_vals(&self) -> Option<&[&'e str]>; + #[cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] fn validator(&self) -> Option<&Rc Result<(), String>>>; + #[cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] fn validator_os(&self) -> Option<&Rc Result<(), OsString>>>; fn short(&self) -> Option; fn long(&self) -> Option<&'e str>; @@ -69,7 +75,7 @@ (*self).is_set(a) } fn set(&mut self, _: ArgSettings) { - panic!(INTERNAL_ERROR_MSG) + panic!("{}", INTERNAL_ERROR_MSG) } fn has_switch(&self) -> bool { (*self).has_switch() @@ -86,9 +92,11 @@ fn possible_vals(&self) -> Option<&[&'e str]> { (*self).possible_vals() } + #[cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] fn validator(&self) -> Option<&Rc Result<(), String>>> { (*self).validator() } + #[cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] fn validator_os(&self) -> Option<&Rc Result<(), OsString>>> { (*self).validator_os() } diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/args/arg_builder/base.rs cargo-0.58.0/vendor/clap/src/args/arg_builder/base.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/args/arg_builder/base.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/args/arg_builder/base.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,4 +1,4 @@ -use args::{Arg, ArgFlags, ArgSettings}; +use crate::args::{Arg, ArgFlags, ArgSettings}; #[derive(Debug, Clone, Default)] pub struct Base<'a, 'b> @@ -19,7 +19,7 @@ impl<'n, 'e> Base<'n, 'e> { pub fn new(name: &'n str) -> Self { Base { - name: name, + name, ..Default::default() } } diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/args/arg_builder/flag.rs cargo-0.58.0/vendor/clap/src/args/arg_builder/flag.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/args/arg_builder/flag.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/args/arg_builder/flag.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,15 +1,18 @@ // Std -use std::convert::From; -use std::ffi::{OsStr, OsString}; -use std::fmt::{Display, Formatter, Result}; -use std::mem; -use std::rc::Rc; -use std::result::Result as StdResult; +use std::{ + convert::From, + ffi::{OsStr, OsString}, + fmt::{Display, Formatter, Result}, + mem, + rc::Rc, + result::Result as StdResult, +}; // Internal -use args::{AnyArg, ArgSettings, Base, DispOrder, Switched}; -use map::{self, VecMap}; -use Arg; +use crate::{ + args::{AnyArg, Arg, ArgSettings, Base, DispOrder, Switched}, + map::{self, VecMap}, +}; #[derive(Default, Clone, Debug)] #[doc(hidden)] @@ -42,8 +45,8 @@ impl<'a, 'b> From> for FlagBuilder<'a, 'b> { fn from(mut a: Arg<'a, 'b>) -> Self { FlagBuilder { - b: mem::replace(&mut a.b, Base::default()), - s: mem::replace(&mut a.s, Switched::default()), + b: mem::take(&mut a.b), + s: mem::take(&mut a.s), } } } @@ -100,9 +103,11 @@ fn possible_vals(&self) -> Option<&[&'e str]> { None } + #[cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] fn validator(&self) -> Option<&Rc StdResult<(), String>>> { None } + #[cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] fn validator_os(&self) -> Option<&Rc StdResult<(), OsString>>> { None } @@ -171,7 +176,7 @@ #[cfg(test)] mod test { use super::FlagBuilder; - use args::settings::ArgSettings; + use crate::args::settings::ArgSettings; #[test] fn flagbuilder_display() { diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/args/arg_builder/option.rs cargo-0.58.0/vendor/clap/src/args/arg_builder/option.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/args/arg_builder/option.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/args/arg_builder/option.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,14 +1,18 @@ // Std -use std::ffi::{OsStr, OsString}; -use std::fmt::{Display, Formatter, Result}; -use std::mem; -use std::rc::Rc; -use std::result::Result as StdResult; +use std::{ + ffi::{OsStr, OsString}, + fmt::{Display, Formatter, Result}, + mem, + rc::Rc, + result::Result as StdResult, +}; // Internal -use args::{AnyArg, Arg, ArgSettings, Base, DispOrder, Switched, Valued}; -use map::{self, VecMap}; -use INTERNAL_ERROR_MSG; +use crate::{ + args::{AnyArg, Arg, ArgSettings, Base, DispOrder, Switched, Valued}, + map::{self, VecMap}, + INTERNAL_ERROR_MSG, +}; #[allow(missing_debug_implementations)] #[doc(hidden)] @@ -45,9 +49,9 @@ fn from(mut a: Arg<'n, 'e>) -> Self { a.v.fill_in(); OptBuilder { - b: mem::replace(&mut a.b, Base::default()), - s: mem::replace(&mut a.s, Switched::default()), - v: mem::replace(&mut a.v, Valued::default()), + b: mem::take(&mut a.b), + s: mem::take(&mut a.s), + v: mem::take(&mut a.v), } } } @@ -153,9 +157,11 @@ fn possible_vals(&self) -> Option<&[&'e str]> { self.v.possible_vals.as_ref().map(|o| &o[..]) } + #[cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] fn validator(&self) -> Option<&Rc StdResult<(), String>>> { self.v.validator.as_ref() } + #[cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] fn validator_os(&self) -> Option<&Rc StdResult<(), OsString>>> { self.v.validator_os.as_ref() } @@ -227,8 +233,7 @@ #[cfg(test)] mod test { use super::OptBuilder; - use args::settings::ArgSettings; - use map::VecMap; + use crate::{args::settings::ArgSettings, map::VecMap}; #[test] fn optbuilder_display1() { diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/args/arg_builder/positional.rs cargo-0.58.0/vendor/clap/src/args/arg_builder/positional.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/args/arg_builder/positional.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/args/arg_builder/positional.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,16 +1,19 @@ // Std -use std::borrow::Cow; -use std::ffi::{OsStr, OsString}; -use std::fmt::{Display, Formatter, Result}; -use std::mem; -use std::rc::Rc; -use std::result::Result as StdResult; +use std::{ + borrow::Cow, + ffi::{OsStr, OsString}, + fmt::{Display, Formatter, Result}, + mem, + rc::Rc, + result::Result as StdResult, +}; // Internal -use args::{AnyArg, ArgSettings, Base, DispOrder, Valued}; -use map::{self, VecMap}; -use Arg; -use INTERNAL_ERROR_MSG; +use crate::{ + args::{AnyArg, Arg, ArgSettings, Base, DispOrder, Valued}, + map::{self, VecMap}, + INTERNAL_ERROR_MSG, +}; #[allow(missing_debug_implementations)] #[doc(hidden)] @@ -56,8 +59,8 @@ a.b.settings.set(ArgSettings::Multiple); } PosBuilder { - b: mem::replace(&mut a.b, Base::default()), - v: mem::replace(&mut a.v, Valued::default()), + b: mem::take(&mut a.b), + v: mem::take(&mut a.v), index: idx, } } @@ -174,9 +177,11 @@ fn possible_vals(&self) -> Option<&[&'e str]> { self.v.possible_vals.as_ref().map(|o| &o[..]) } + #[cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] fn validator(&self) -> Option<&Rc StdResult<(), String>>> { self.v.validator.as_ref() } + #[cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] fn validator_os(&self) -> Option<&Rc StdResult<(), OsString>>> { self.v.validator_os.as_ref() } @@ -236,8 +241,7 @@ #[cfg(test)] mod test { use super::PosBuilder; - use args::settings::ArgSettings; - use map::VecMap; + use crate::{args::settings::ArgSettings, map::VecMap}; #[test] fn display_mult() { diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/args/arg_builder/switched.rs cargo-0.58.0/vendor/clap/src/args/arg_builder/switched.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/args/arg_builder/switched.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/args/arg_builder/switched.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,4 +1,4 @@ -use Arg; +use crate::Arg; #[derive(Debug)] pub struct Switched<'b> { diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/args/arg_builder/valued.rs cargo-0.58.0/vendor/clap/src/args/arg_builder/valued.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/args/arg_builder/valued.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/args/arg_builder/valued.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,9 +1,9 @@ -use std::ffi::{OsStr, OsString}; -use std::rc::Rc; +use std::{ + ffi::{OsStr, OsString}, + rc::Rc, +}; -use map::VecMap; - -use Arg; +use crate::{map::VecMap, Arg}; #[allow(missing_debug_implementations)] #[derive(Clone)] @@ -16,10 +16,13 @@ pub num_vals: Option, pub max_vals: Option, pub min_vals: Option, + #[cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] pub validator: Option Result<(), String>>>, + #[cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] pub validator_os: Option Result<(), OsString>>>, pub val_delim: Option, pub default_val: Option<&'b OsStr>, + #[cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] pub default_vals_ifs: Option, &'b OsStr)>>, pub env: Option<(&'a OsStr, Option)>, pub terminator: Option<&'b str>, diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/args/arg_matcher.rs cargo-0.58.0/vendor/clap/src/args/arg_matcher.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/args/arg_matcher.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/args/arg_matcher.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,14 +1,16 @@ // Std -use std::collections::hash_map::{Entry, Iter}; -use std::collections::HashMap; -use std::ffi::OsStr; -use std::mem; -use std::ops::Deref; +use std::{ + collections::{ + hash_map::{Entry, Iter}, + HashMap, + }, + ffi::OsStr, + mem, + ops::Deref, +}; // Internal -use args::settings::ArgSettings; -use args::AnyArg; -use args::{ArgMatches, MatchedArg, SubCommand}; +use crate::args::{settings::ArgSettings, AnyArg, ArgMatches, MatchedArg, SubCommand}; #[doc(hidden)] #[allow(missing_debug_implementations)] @@ -142,7 +144,7 @@ mem::swap(&mut am.0, &mut sc.matches); } - for (name, matched_arg) in vals_map.into_iter() { + for (name, matched_arg) in vals_map.iter_mut() { self.0.args.insert(name, matched_arg.clone()); } } @@ -251,7 +253,7 @@ }; } else if let Some(num) = o.max_vals() { debugln!("ArgMatcher::needs_more_vals: max_vals...{}", num); - return !((ma.vals.len() as u64) > num); + return (ma.vals.len() as u64) <= num; } else if o.min_vals().is_some() { debugln!("ArgMatcher::needs_more_vals: min_vals...true"); return true; @@ -262,6 +264,9 @@ } } +// Not changing to From just to not deal with possible breaking changes on v2 since v3 is coming +// in the future anyways +#[cfg_attr(feature = "cargo-clippy", allow(clippy::from_over_into))] impl<'a> Into> for ArgMatcher<'a> { fn into(self) -> ArgMatches<'a> { self.0 diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/args/arg_matches.rs cargo-0.58.0/vendor/clap/src/args/arg_matches.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/args/arg_matches.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/args/arg_matches.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,14 +1,17 @@ // Std -use std::borrow::Cow; -use std::collections::HashMap; -use std::ffi::{OsStr, OsString}; -use std::iter::Map; -use std::slice::Iter; +use std::{ + borrow::Cow, + collections::HashMap, + ffi::{OsStr, OsString}, + iter::Map, + slice::Iter, +}; // Internal -use args::MatchedArg; -use args::SubCommand; -use INVALID_UTF8; +use crate::{ + args::{MatchedArg, SubCommand}, + INVALID_UTF8, +}; /// Used to get information about the arguments that were supplied to the program at runtime by /// the user. New instances of this struct are obtained by using the [`App::get_matches`] family of @@ -827,7 +830,7 @@ // This is never called because the iterator is empty: fn to_str_slice(_: &OsString) -> &str { unreachable!() - }; + } Values { iter: EMPTY[..].iter().map(to_str_slice), } @@ -886,7 +889,7 @@ // This is never called because the iterator is empty: fn to_str_slice(_: &OsString) -> &OsStr { unreachable!() - }; + } OsValues { iter: EMPTY[..].iter().map(to_str_slice), } @@ -946,7 +949,7 @@ // This is never called because the iterator is empty: fn to_usize(_: &usize) -> usize { unreachable!() - }; + } Indices { iter: EMPTY[..].iter().map(to_usize), } diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/args/arg.rs cargo-0.58.0/vendor/clap/src/args/arg.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/args/arg.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/args/arg.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,20 +1,26 @@ -#[cfg(any(target_os = "windows", target_arch = "wasm32"))] -use osstringext::OsStrExt3; #[cfg(feature = "yaml")] use std::collections::BTreeMap; -use std::env; -use std::ffi::{OsStr, OsString}; #[cfg(not(any(target_os = "windows", target_arch = "wasm32")))] use std::os::unix::ffi::OsStrExt; -use std::rc::Rc; +use std::{ + env, + ffi::{OsStr, OsString}, + rc::Rc, +}; -use map::VecMap; #[cfg(feature = "yaml")] use yaml_rust::Yaml; -use args::arg_builder::{Base, Switched, Valued}; -use args::settings::ArgSettings; -use usage_parser::UsageParser; +#[cfg(any(target_os = "windows", target_arch = "wasm32"))] +use crate::osstringext::OsStrExt3; +use crate::{ + args::{ + arg_builder::{Base, Switched, Valued}, + settings::ArgSettings, + }, + map::VecMap, + usage_parser::UsageParser, +}; /// The abstract representation of a command line argument. Used to set all the options and /// relationships that define a valid argument for the program. @@ -334,7 +340,7 @@ /// ``` /// [`short`]: ./struct.Arg.html#method.short pub fn short>(mut self, s: S) -> Self { - self.s.short = s.as_ref().trim_left_matches(|c| c == '-').chars().nth(0); + self.s.short = s.as_ref().trim_left_matches(|c| c == '-').chars().next(); self } @@ -1023,7 +1029,7 @@ vec.push(s); } } else { - self.b.r_unless = Some(names.iter().map(|s| *s).collect::>()); + self.b.r_unless = Some(names.iter().copied().collect()); } self.setb(ArgSettings::RequiredUnlessAll); self.required(true) @@ -1099,7 +1105,7 @@ vec.push(s); } } else { - self.b.r_unless = Some(names.iter().map(|s| *s).collect::>()); + self.b.r_unless = Some(names.iter().copied().collect()); } self.required(true) } @@ -1197,7 +1203,7 @@ vec.push(s); } } else { - self.b.blacklist = Some(names.iter().map(|s| *s).collect::>()); + self.b.blacklist = Some(names.iter().copied().collect()); } self } @@ -1342,7 +1348,7 @@ vec.push(s); } } else { - self.b.overrides = Some(names.iter().map(|s| *s).collect::>()); + self.b.overrides = Some(names.iter().copied().collect()); } self } @@ -1406,9 +1412,7 @@ if let Some(ref mut vec) = self.b.requires { vec.push((None, name)); } else { - let mut vec = vec![]; - vec.push((None, name)); - self.b.requires = Some(vec); + self.b.requires = Some(vec![(None, name)]); } self } @@ -2407,7 +2411,7 @@ vec.push(s); } } else { - self.v.possible_vals = Some(names.iter().map(|s| *s).collect::>()); + self.v.possible_vals = Some(names.iter().copied().collect()); } self } @@ -2603,7 +2607,7 @@ vec.push(s); } } else { - self.b.groups = Some(names.into_iter().map(|s| *s).collect::>()); + self.b.groups = Some(names.iter().copied().collect()); } self } @@ -2909,12 +2913,11 @@ } self.setb(ArgSettings::TakesValue); self.setb(ArgSettings::UseValueDelimiter); - self.unset(ArgSettings::ValueDelimiterNotSet) } else { self.v.val_delim = None; self.unsetb(ArgSettings::UseValueDelimiter); - self.unset(ArgSettings::ValueDelimiterNotSet) } + self.unset(ArgSettings::ValueDelimiterNotSet) } /// Specifies that *multiple values* may only be set using the delimiter. This means if an @@ -3031,7 +3034,7 @@ self.setb(ArgSettings::UseValueDelimiter); self.v.val_delim = Some( d.chars() - .nth(0) + .next() .expect("Failed to get value_delimiter from arg"), ); self @@ -3479,7 +3482,6 @@ /// [`Arg::default_value_ifs`] only using [`OsStr`]s instead. /// [`Arg::default_value_ifs`]: ./struct.Arg.html#method.default_value_ifs /// [`OsStr`]: https://doc.rust-lang.org/std/ffi/struct.OsStr.html - #[cfg_attr(feature = "lints", allow(explicit_counter_loop))] pub fn default_value_ifs_os(mut self, ifs: &[(&'a str, Option<&'b OsStr>, &'b OsStr)]) -> Self { for &(arg, val, default) in ifs { self = self.default_value_if_os(arg, val, default); diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/args/group.rs cargo-0.58.0/vendor/clap/src/args/group.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/args/group.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/args/group.rs 2022-01-21 02:47:39.000000000 +0000 @@ -154,7 +154,6 @@ /// assert!(m.is_present("flag")); /// ``` /// [argument]: ./struct.Arg.html - #[cfg_attr(feature = "lints", allow(should_assert_eq))] pub fn arg(mut self, n: &'a str) -> Self { assert!( self.name != n, diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/args/subcommand.rs cargo-0.58.0/vendor/clap/src/args/subcommand.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/args/subcommand.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/args/subcommand.rs 2022-01-21 02:47:39.000000000 +0000 @@ -3,8 +3,7 @@ use yaml_rust::Yaml; // Internal -use App; -use ArgMatches; +use crate::{App, ArgMatches}; /// The abstract representation of a command line subcommand. /// diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/completions/bash.rs cargo-0.58.0/vendor/clap/src/completions/bash.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/completions/bash.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/completions/bash.rs 2022-01-21 02:47:39.000000000 +0000 @@ -2,9 +2,11 @@ use std::io::Write; // Internal -use app::parser::Parser; -use args::OptBuilder; -use completions; +use crate::{ + app::parser::Parser, + args::{AnyArg, OptBuilder}, + completions, +}; pub struct BashGen<'a, 'b> where @@ -15,7 +17,7 @@ impl<'a, 'b> BashGen<'a, 'b> { pub fn new(p: &'b Parser<'a, 'b>) -> Self { - BashGen { p: p } + BashGen { p } } pub fn generate_to(&self, buf: &mut W) { @@ -123,7 +125,7 @@ subcmd_dets, subcmd = sc.replace("-", "__"), sc_opts = self.all_options_for_path(&*sc), - level = sc.split("__").map(|_| 1).fold(0, |acc, n| acc + n), + level = sc.split("__").count(), opts_details = self.option_details_for_path(&*sc) ); } @@ -170,7 +172,6 @@ fn vals_for(&self, o: &OptBuilder) -> String { debugln!("BashGen::vals_for: o={}", o.b.name); - use args::AnyArg; if let Some(vals) = o.possible_vals() { format!(r#"$(compgen -W "{}" -- "${{cur}}")"#, vals.join(" ")) } else { diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/completions/elvish.rs cargo-0.58.0/vendor/clap/src/completions/elvish.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/completions/elvish.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/completions/elvish.rs 2022-01-21 02:47:39.000000000 +0000 @@ -2,8 +2,7 @@ use std::io::Write; // Internal -use app::parser::Parser; -use INTERNAL_ERROR_MSG; +use crate::{app::parser::Parser, INTERNAL_ERROR_MSG}; pub struct ElvishGen<'a, 'b> where @@ -14,7 +13,7 @@ impl<'a, 'b> ElvishGen<'a, 'b> { pub fn new(p: &'b Parser<'a, 'b>) -> Self { - ElvishGen { p: p } + ElvishGen { p } } pub fn generate_to(&self, buf: &mut W) { diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/completions/fish.rs cargo-0.58.0/vendor/clap/src/completions/fish.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/completions/fish.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/completions/fish.rs 2022-01-21 02:47:39.000000000 +0000 @@ -2,7 +2,7 @@ use std::io::Write; // Internal -use app::parser::Parser; +use crate::app::parser::Parser; pub struct FishGen<'a, 'b> where @@ -13,7 +13,7 @@ impl<'a, 'b> FishGen<'a, 'b> { pub fn new(p: &'b Parser<'a, 'b>) -> Self { - FishGen { p: p } + FishGen { p } } pub fn generate_to(&self, buf: &mut W) { @@ -66,7 +66,7 @@ template.push_str(format!(" -r -f -a \"{}\"", data.join(" ")).as_str()); } buffer.push_str(template.as_str()); - buffer.push_str("\n"); + buffer.push('\n'); } for flag in comp_gen.p.flags() { @@ -81,7 +81,7 @@ template.push_str(format!(" -d '{}'", escape_string(data)).as_str()); } buffer.push_str(template.as_str()); - buffer.push_str("\n"); + buffer.push('\n'); } for subcommand in &comp_gen.p.subcommands { @@ -92,7 +92,7 @@ template.push_str(format!(" -d '{}'", escape_string(data)).as_str()) } buffer.push_str(template.as_str()); - buffer.push_str("\n"); + buffer.push('\n'); } // generate options of subcommands diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/completions/mod.rs cargo-0.58.0/vendor/clap/src/completions/mod.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/completions/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/completions/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -11,13 +11,13 @@ use std::io::Write; // Internal -use self::bash::BashGen; -use self::elvish::ElvishGen; -use self::fish::FishGen; -use self::powershell::PowerShellGen; -pub use self::shell::Shell; -use self::zsh::ZshGen; -use app::parser::Parser; +pub use crate::completions::shell::Shell; +use crate::{ + app::parser::Parser, + completions::{ + bash::BashGen, elvish::ElvishGen, fish::FishGen, powershell::PowerShellGen, zsh::ZshGen, + }, +}; pub struct ComplGen<'a, 'b> where @@ -28,7 +28,7 @@ impl<'a, 'b> ComplGen<'a, 'b> { pub fn new(p: &'b Parser<'a, 'b>) -> Self { - ComplGen { p: p } + ComplGen { p } } pub fn generate(&self, for_shell: Shell, buf: &mut W) { diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/completions/powershell.rs cargo-0.58.0/vendor/clap/src/completions/powershell.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/completions/powershell.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/completions/powershell.rs 2022-01-21 02:47:39.000000000 +0000 @@ -2,8 +2,7 @@ use std::io::Write; // Internal -use app::parser::Parser; -use INTERNAL_ERROR_MSG; +use crate::{app::parser::Parser, INTERNAL_ERROR_MSG}; pub struct PowerShellGen<'a, 'b> where @@ -14,7 +13,7 @@ impl<'a, 'b> PowerShellGen<'a, 'b> { pub fn new(p: &'b Parser<'a, 'b>) -> Self { - PowerShellGen { p: p } + PowerShellGen { p } } pub fn generate_to(&self, buf: &mut W) { diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/completions/shell.rs cargo-0.58.0/vendor/clap/src/completions/shell.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/completions/shell.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/completions/shell.rs 2022-01-21 02:47:39.000000000 +0000 @@ -4,7 +4,6 @@ use std::str::FromStr; /// Describes which shell to produce a completions file for -#[cfg_attr(feature = "lints", allow(enum_variant_names))] #[derive(Debug, Copy, Clone)] pub enum Shell { /// Generates a .bash completion file for the Bourne Again SHell (BASH) @@ -29,6 +28,7 @@ impl FromStr for Shell { type Err = String; + #[cfg_attr(feature = "cargo-clippy", allow(clippy::wildcard_in_or_patterns))] fn from_str(s: &str) -> Result { match s { "ZSH" | _ if s.eq_ignore_ascii_case("zsh") => Ok(Shell::Zsh), diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/completions/zsh.rs cargo-0.58.0/vendor/clap/src/completions/zsh.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/completions/zsh.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/completions/zsh.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,14 +1,13 @@ // Std #[allow(deprecated, unused_imports)] -use std::ascii::AsciiExt; -use std::io::Write; +use std::{ascii::AsciiExt, io::Write}; // Internal -use app::parser::Parser; -use app::App; -use args::{AnyArg, ArgSettings}; -use completions; -use INTERNAL_ERROR_MSG; +use crate::{ + app::{parser::Parser, App}, + args::{AnyArg, ArgSettings}, + completions, INTERNAL_ERROR_MSG, +}; pub struct ZshGen<'a, 'b> where @@ -20,7 +19,7 @@ impl<'a, 'b> ZshGen<'a, 'b> { pub fn new(p: &'b Parser<'a, 'b>) -> Self { debugln!("ZshGen::new;"); - ZshGen { p: p } + ZshGen { p } } pub fn generate_to(&self, buf: &mut W) { diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/errors.rs cargo-0.58.0/vendor/clap/src/errors.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/errors.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/errors.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,16 +1,20 @@ // Std -use std::convert::From; -use std::error::Error as StdError; -use std::fmt as std_fmt; -use std::fmt::Display; -use std::io::{self, Write}; -use std::process; -use std::result::Result as StdResult; +use std::{ + convert::From, + error::Error as StdError, + fmt as std_fmt, + fmt::Display, + io::{self, Write}, + process, + result::Result as StdResult, +}; // Internal -use args::AnyArg; -use fmt::{ColorWhen, Colorizer, ColorizerOption}; -use suggestions; +use crate::{ + args::AnyArg, + fmt::{ColorWhen, Colorizer, ColorizerOption}, + suggestions, +}; /// Short hand for [`Result`] type /// @@ -385,20 +389,35 @@ impl Error { /// Should the message be written to `stdout` or not pub fn use_stderr(&self) -> bool { - match self.kind { - ErrorKind::HelpDisplayed | ErrorKind::VersionDisplayed => false, - _ => true, - } + !matches!( + self.kind, + ErrorKind::HelpDisplayed | ErrorKind::VersionDisplayed + ) } - /// Prints the error to `stderr` and exits with a status of `1` + /// Prints the error message and exits. If `Error::use_stderr` evaluates to `true`, the message + /// will be written to `stderr` and exits with a status of `1`. Otherwise, `stdout` is used + /// with a status of `0`. pub fn exit(&self) -> ! { if self.use_stderr() { - wlnerr!("{}", self.message); + wlnerr!(@nopanic "{}", self.message); process::exit(1); } - let out = io::stdout(); - writeln!(&mut out.lock(), "{}", self.message).expect("Error writing Error to stdout"); + // We are deliberately dropping errors here. We could match on the error kind, and only + // drop things such as `std::io::ErrorKind::BrokenPipe`, however nothing is being bubbled + // up or reported back to the caller and we will be exit'ing the process anyways. + // Additionally, changing this API to bubble up the result would be a breaking change. + // + // Another approach could be to try and write to stdout, if that fails due to a broken pipe + // then use stderr. However, that would change the semantics in what could be argued is a + // breaking change. Simply dropping the error, can always be changed to this "use stderr if + // stdout is closed" approach later if desired. + // + // A good explanation of the types of errors are SIGPIPE where the read side of the pipe + // closes before the write side. See the README in `calm_io` for a good explanation: + // + // https://github.com/myrrlyn/calm_io/blob/a42845575a04cd8b65e92c19d104627f5fcad3d7/README.md + let _ = writeln!(&mut io::stdout().lock(), "{}", self.message); process::exit(0); } @@ -866,11 +885,7 @@ when: ColorWhen::Auto, }); Error { - message: format!( - "{} The argument '{}' wasn't found", - c.error("error:"), - a.clone() - ), + message: format!("{} The argument '{}' wasn't found", c.error("error:"), a), kind: ErrorKind::ArgumentNotFound, info: Some(vec![a]), } @@ -887,7 +902,7 @@ }); Error { message: format!("{} {}", c.error("error:"), description), - kind: kind, + kind, info: None, } } diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/fmt.rs cargo-0.58.0/vendor/clap/src/fmt.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/fmt.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/fmt.rs 2022-01-21 02:47:39.000000000 +0000 @@ -4,8 +4,6 @@ #[cfg(all(feature = "color", not(target_os = "windows")))] use ansi_term::Colour::{Green, Red, Yellow}; -#[cfg(feature = "color")] -use atty; use std::env; use std::fmt; @@ -142,7 +140,7 @@ } #[cfg(any(not(feature = "color"), target_os = "windows"))] -#[cfg_attr(feature = "lints", allow(match_same_arms))] +#[cfg_attr(feature = "cargo-clippy", allow(clippy::match_same_arms))] impl Format { fn format(&self) -> &T { match *self { diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/lib.rs cargo-0.58.0/vendor/clap/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/lib.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -366,7 +366,7 @@ //! * **Red** Color: **NOT** included by default (must use cargo `features` to enable) //! * **Blue** Color: Dev dependency, only used while developing. //! -//! ![clap dependencies](https://github.com/clap-rs/clap/blob/v2.33.1/clap_dep_graph.png) +//! ![clap dependencies](https://github.com/clap-rs/clap/blob/v2.34.0/clap_dep_graph.png) //! //! ### More Information //! @@ -391,7 +391,7 @@ //! `clap`. You can either add it to the [examples/] directory, or file an issue and tell //! me. I'm all about giving credit where credit is due :) //! -//! Please read [CONTRIBUTING.md](https://github.com/clap-rs/clap/blob/v2.33.1/.github/CONTRIBUTING.md) before you start contributing. +//! Please read [CONTRIBUTING.md](https://github.com/clap-rs/clap/blob/v2.34.0/.github/CONTRIBUTING.md) before you start contributing. //! //! //! ### Testing Code @@ -512,12 +512,12 @@ //! `clap` is licensed under the MIT license. Please read the [LICENSE-MIT][license] file in //! this repository for more information. //! -//! [examples/]: https://github.com/clap-rs/clap/tree/v2.33.1/examples +//! [examples/]: https://github.com/clap-rs/clap/tree/v2.34.0/examples //! [video tutorials]: https://www.youtube.com/playlist?list=PLza5oFLQGTl2Z5T8g1pRkIynR3E0_pc7U -//! [license]: https://github.com/clap-rs/clap/blob/v2.33.1/LICENSE-MIT +//! [license]: https://github.com/clap-rs/clap/blob/v2.34.0/LICENSE-MIT #![crate_type = "lib"] -#![doc(html_root_url = "https://docs.rs/clap/2.33.3")] +#![doc(html_root_url = "https://docs.rs/clap/2.34.0")] #![deny( missing_docs, missing_debug_implementations, @@ -530,16 +530,15 @@ // unused_qualifications (bitflags, clippy) // trivial_numeric_casts (bitflags) #![cfg_attr( - not(any(feature = "lints", feature = "nightly")), + not(any(feature = "cargo-clippy", feature = "nightly")), forbid(unstable_features) )] -#![cfg_attr(feature = "lints", feature(plugin))] -#![cfg_attr(feature = "lints", plugin(clippy))] +//#![cfg_attr(feature = "lints", feature(plugin))] +//#![cfg_attr(feature = "lints", plugin(clippy))] // Need to disable deny(warnings) while deprecations are active -// #![cfg_attr(feature = "lints", deny(warnings))] -#![cfg_attr(feature = "lints", allow(cyclomatic_complexity))] -#![cfg_attr(feature = "lints", allow(doc_markdown))] -#![cfg_attr(feature = "lints", allow(explicit_iter_loop))] +//#![cfg_attr(feature = "cargo-clippy", deny(warnings))] +// Due to our "MSRV for 2.x will remain unchanged" policy, we can't fix these warnings +#![allow(bare_trait_objects, deprecated)] #[cfg(all(feature = "color", not(target_os = "windows")))] extern crate ansi_term; @@ -579,9 +578,9 @@ mod suggestions; mod usage_parser; -const INTERNAL_ERROR_MSG: &'static str = "Fatal internal error. Please consider filing a bug \ +const INTERNAL_ERROR_MSG: &str = "Fatal internal error. Please consider filing a bug \ report at https://github.com/clap-rs/clap/issues"; -const INVALID_UTF8: &'static str = "unexpected invalid UTF-8 code point"; +const INVALID_UTF8: &str = "unexpected invalid UTF-8 code point"; #[cfg(unstable)] pub use derive::{ArgEnum, ClapApp, FromArgMatches, IntoApp}; diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/macros.rs cargo-0.58.0/vendor/clap/src/macros.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/macros.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/macros.rs 2022-01-21 02:47:39.000000000 +0000 @@ -839,6 +839,10 @@ // Convenience for writing to stderr thanks to https://github.com/BurntSushi macro_rules! wlnerr( + (@nopanic $($arg:tt)*) => ({ + use std::io::{Write, stderr}; + let _ = writeln!(&mut stderr().lock(), $($arg)*); + }); ($($arg:tt)*) => ({ use std::io::{Write, stderr}; writeln!(&mut stderr(), $($arg)*).ok(); diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/osstringext.rs cargo-0.58.0/vendor/clap/src/osstringext.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/osstringext.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/osstringext.rs 2022-01-21 02:47:39.000000000 +0000 @@ -2,7 +2,7 @@ #[cfg(not(any(target_os = "windows", target_arch = "wasm32")))] use std::os::unix::ffi::OsStrExt; #[cfg(any(target_os = "windows", target_arch = "wasm32"))] -use INVALID_UTF8; +use crate::INVALID_UTF8; #[cfg(any(target_os = "windows", target_arch = "wasm32"))] pub trait OsStrExt3 { @@ -77,7 +77,7 @@ // UTF-16 surrogate characters are only valid in pairs. Including one on // the end by itself makes this invalid UTF-16. let surrogate_char: u16 = 0xDC00; - let mut invalid_unicode = + let invalid_unicode = OsString::from_wide(&['a' as u16, 'b' as u16, 'c' as u16, surrogate_char]); assert!( invalid_unicode.to_str().is_none(), @@ -112,9 +112,12 @@ // `clap.exe --arg=[invalid]`. Note that this entire module is // replaced in Clap 3.x, so this workaround is specific to the 2.x // branch. - return windows_osstr_starts_with(self, s); + windows_osstr_starts_with(self, s) + } + #[cfg(not(target_os = "windows"))] + { + self.as_bytes().starts_with(s) } - self.as_bytes().starts_with(s) } fn contains_byte(&self, byte: u8) -> bool { diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/strext.rs cargo-0.58.0/vendor/clap/src/strext.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/strext.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/strext.rs 2022-01-21 02:47:39.000000000 +0000 @@ -10,7 +10,7 @@ } match self.as_bytes().get(index) { None => false, - Some(&b) => b < 128 || b >= 192, + Some(&b) => !(128..192).contains(&b), } } } diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/suggestions.rs cargo-0.58.0/vendor/clap/src/suggestions.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/suggestions.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/suggestions.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,17 +1,12 @@ -use app::App; -// Third Party -#[cfg(feature = "suggestions")] -use strsim; - // Internal -use fmt::Format; +use crate::{app::App, fmt::Format}; /// Produces a string from a given list of possible values which is similar to /// the passed in value `v` with a certain confidence. /// Thus in a list of possible values like ["foo", "bar"], the value "fop" will yield /// `Some("foo")`, whereas "blark" would yield `None`. #[cfg(feature = "suggestions")] -#[cfg_attr(feature = "lints", allow(needless_lifetimes))] +#[cfg_attr(feature = "cargo-clippy", allow(clippy::needless_lifetimes))] pub fn did_you_mean<'a, T: ?Sized, I>(v: &str, possible_values: I) -> Option<&'a str> where T: AsRef + 'a, @@ -41,7 +36,6 @@ } /// Returns a suffix that can be empty, or is the standard 'did you mean' phrase -#[cfg_attr(feature = "lints", allow(needless_lifetimes))] pub fn did_you_mean_flag_suffix<'z, T, I>( arg: &str, args_rest: &'z [&str], @@ -62,7 +56,7 @@ } subcommands - .into_iter() + .iter() .filter_map(|subcommand| { let opts = subcommand .p diff -Nru cargo-0.57.0+ubuntu/vendor/clap/src/usage_parser.rs cargo-0.58.0/vendor/clap/src/usage_parser.rs --- cargo-0.57.0+ubuntu/vendor/clap/src/usage_parser.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/clap/src/usage_parser.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,8 +1,9 @@ // Internal -use args::settings::ArgSettings; -use args::Arg; -use map::VecMap; -use INTERNAL_ERROR_MSG; +use crate::{ + args::{settings::ArgSettings, Arg}, + map::VecMap, + INTERNAL_ERROR_MSG, +}; #[derive(PartialEq, Debug)] enum UsageToken { @@ -29,7 +30,7 @@ fn new(usage: &'a str) -> Self { debugln!("UsageParser::new: usage={:?}", usage); UsageParser { - usage: usage, + usage, pos: 0, start: 0, prev: UsageToken::Unknown, @@ -61,10 +62,8 @@ } debug_assert!( !arg.b.name.is_empty(), - format!( - "No name found for Arg when parsing usage string: {}", - self.usage - ) + "No name found for Arg when parsing usage string: {}", + self.usage ); arg.v.num_vals = match arg.v.val_names { Some(ref v) if v.len() >= 2 => Some(v.len() as u64), @@ -157,7 +156,7 @@ fn short(&mut self, arg: &mut Arg<'a, 'a>) { debugln!("UsageParser::short;"); let start = &self.usage[self.pos..]; - let short = start.chars().nth(0).expect(INTERNAL_ERROR_MSG); + let short = start.chars().next().expect(INTERNAL_ERROR_MSG); debugln!("UsageParser::short: setting short...{}", short); arg.s.short = Some(short); if arg.b.name.is_empty() { @@ -232,8 +231,7 @@ #[cfg(test)] mod test { - use args::Arg; - use args::ArgSettings; + use crate::args::{Arg, ArgSettings}; #[test] fn create_flag_usage() { diff -Nru cargo-0.57.0+ubuntu/vendor/crc32fast/benches/bench.rs cargo-0.58.0/vendor/crc32fast/benches/bench.rs --- cargo-0.57.0+ubuntu/vendor/crc32fast/benches/bench.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/crc32fast/benches/bench.rs 2022-01-21 02:47:39.000000000 +0000 @@ -21,19 +21,23 @@ } fn bench_kilobyte_baseline(b: &mut Bencher) { - bench(b, 1024, Hasher::internal_new_baseline(0)) + bench(b, 1024, Hasher::internal_new_baseline(0, 0)) } fn bench_kilobyte_specialized(b: &mut Bencher) { - bench(b, 1024, Hasher::internal_new_specialized(0).unwrap()) + bench(b, 1024, Hasher::internal_new_specialized(0, 0).unwrap()) } fn bench_megabyte_baseline(b: &mut Bencher) { - bench(b, 1024 * 1024, Hasher::internal_new_baseline(0)) + bench(b, 1024 * 1024, Hasher::internal_new_baseline(0, 0)) } fn bench_megabyte_specialized(b: &mut Bencher) { - bench(b, 1024 * 1024, Hasher::internal_new_specialized(0).unwrap()) + bench( + b, + 1024 * 1024, + Hasher::internal_new_specialized(0, 0).unwrap(), + ) } benchmark_group!( diff -Nru cargo-0.57.0+ubuntu/vendor/crc32fast/.cargo-checksum.json cargo-0.58.0/vendor/crc32fast/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/crc32fast/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/crc32fast/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a"} \ No newline at end of file +{"files":{},"package":"738c290dfaea84fc1ca15ad9c168d083b05a714e1efddd8edaab678dc28d2836"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/crc32fast/Cargo.toml cargo-0.58.0/vendor/crc32fast/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/crc32fast/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/crc32fast/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -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 = "crc32fast" -version = "1.2.1" +version = "1.3.0" authors = ["Sam Rijs ", "Alex Crichton "] description = "Fast, SIMD-accelerated CRC32 (IEEE) checksum computation" readme = "README.md" @@ -29,11 +28,11 @@ version = "0.1" [dev-dependencies.quickcheck] -version = "0.9" +version = "1.0" default-features = false [dev-dependencies.rand] -version = "0.7" +version = "0.8" [features] default = ["std"] diff -Nru cargo-0.57.0+ubuntu/vendor/crc32fast/README.md cargo-0.58.0/vendor/crc32fast/README.md --- cargo-0.57.0+ubuntu/vendor/crc32fast/README.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/crc32fast/README.md 2022-01-21 02:47:39.000000000 +0000 @@ -1,19 +1,31 @@ # crc32fast [![Build Status][travis-img]][travis] [![Crates.io][crates-img]][crates] [![Documentation][docs-img]][docs] -[travis-img]: https://travis-ci.com/srijs/rust-crc32fast.svg?branch=master -[travis]: https://travis-ci.com/srijs/rust-crc32fast -[crates-img]: https://img.shields.io/crates/v/crc32fast.svg -[crates]: https://crates.io/crates/crc32fast -[docs-img]: https://docs.rs/crc32fast/badge.svg -[docs]: https://docs.rs/crc32fast +[travis-img]: https://travis-ci.com/srijs/rust-crc32fast.svg?branch=master +[travis]: https://travis-ci.com/srijs/rust-crc32fast +[crates-img]: https://img.shields.io/crates/v/crc32fast.svg +[crates]: https://crates.io/crates/crc32fast +[docs-img]: https://docs.rs/crc32fast/badge.svg +[docs]: https://docs.rs/crc32fast _Fast, SIMD-accelerated CRC32 (IEEE) checksum computation_ ## Usage +### Simple usage + +For simple use-cases, you can call the `hash` convenience function to +directly compute the CRC32 checksum for a given byte slice: + ```rust -extern crate crc32fast; +let checksum = crc32fast::hash(b"foo bar baz"); +``` +### Advanced usage + +For use-cases that require more flexibility or performance, for example when +processing large amounts of data, you can create and manipulate a `Hasher`: + +```rust use crc32fast::Hasher; let mut hasher = Hasher::new(); @@ -33,10 +45,10 @@ optimal implementation for the current CPU feature set. | crate | version | variant | ns/iter | MB/s | -|-------------------------------------|---------|-----------|---------|------| -| [crc](https://crates.io/crates/crc) | 1.8.1 | n/a | 4,926 | 207 | -| crc32fast (this crate) | 1.0.0 | baseline | 683 | 1499 | -| crc32fast (this crate) | 1.0.0 | pclmulqdq | 140 | 7314 | +| ----------------------------------- | ------- | --------- | ------- | ---- | +| [crc](https://crates.io/crates/crc) | 1.8.1 | n/a | 4,926 | 207 | +| crc32fast (this crate) | 1.0.0 | baseline | 683 | 1499 | +| crc32fast (this crate) | 1.0.0 | pclmulqdq | 140 | 7314 | ## Memory Safety @@ -67,10 +79,10 @@ This project is licensed under either of - * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or - http://www.apache.org/licenses/LICENSE-2.0) - * MIT license ([LICENSE-MIT](LICENSE-MIT) or - http://opensource.org/licenses/MIT) +- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or + http://www.apache.org/licenses/LICENSE-2.0) +- MIT license ([LICENSE-MIT](LICENSE-MIT) or + http://opensource.org/licenses/MIT) at your option. diff -Nru cargo-0.57.0+ubuntu/vendor/crc32fast/src/lib.rs cargo-0.58.0/vendor/crc32fast/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/crc32fast/src/lib.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/crc32fast/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,4 +1,20 @@ -//! ## Example +//! Fast, SIMD-accelerated CRC32 (IEEE) checksum computation. +//! +//! ## Usage +//! +//! ### Simple usage +//! +//! For simple use-cases, you can call the [`hash()`] convenience function to +//! directly compute the CRC32 checksum for a given byte slice: +//! +//! ```rust +//! let checksum = crc32fast::hash(b"foo bar baz"); +//! ``` +//! +//! ### Advanced usage +//! +//! For use-cases that require more flexibility or performance, for example when +//! processing large amounts of data, you can create and manipulate a [`Hasher`]: //! //! ```rust //! use crc32fast::Hasher; @@ -15,7 +31,7 @@ //! - A fast baseline implementation which processes up to 16 bytes per iteration //! - An optimized implementation for modern `x86` using `sse` and `pclmulqdq` instructions //! -//! Calling the `Hasher::new` constructor at runtime will perform a feature detection to select the most +//! Calling the [`Hasher::new`] constructor at runtime will perform a feature detection to select the most //! optimal implementation for the current CPU feature set. #![cfg_attr(not(feature = "std"), no_std)] @@ -43,6 +59,15 @@ mod specialized; mod table; +/// Computes the CRC32 hash of a byte slice. +/// +/// Check out [`Hasher`] for more advanced use-cases. +pub fn hash(buf: &[u8]) -> u32 { + let mut h = Hasher::new(); + h.update(buf); + h.finalize() +} + #[derive(Clone)] enum State { Baseline(baseline::State), @@ -72,25 +97,35 @@ /// This works just like `Hasher::new`, except that it allows for an initial /// CRC32 state to be passed in. pub fn new_with_initial(init: u32) -> Self { - Self::internal_new_specialized(init).unwrap_or_else(|| Self::internal_new_baseline(init)) + Self::new_with_initial_len(init, 0) + } + + /// Create a new `Hasher` with an initial CRC32 state. + /// + /// As `new_with_initial`, but also accepts a length (in bytes). The + /// resulting object can then be used with `combine` to compute `crc(a || + /// b)` from `crc(a)`, `crc(b)`, and `len(b)`. + pub fn new_with_initial_len(init: u32, amount: u64) -> Self { + Self::internal_new_specialized(init, amount) + .unwrap_or_else(|| Self::internal_new_baseline(init, amount)) } #[doc(hidden)] // Internal-only API. Don't use. - pub fn internal_new_baseline(init: u32) -> Self { + pub fn internal_new_baseline(init: u32, amount: u64) -> Self { Hasher { - amount: 0, + amount, state: State::Baseline(baseline::State::new(init)), } } #[doc(hidden)] // Internal-only API. Don't use. - pub fn internal_new_specialized(init: u32) -> Option { + pub fn internal_new_specialized(init: u32, amount: u64) -> Option { { if let Some(state) = specialized::State::new(init) { return Some(Hasher { - amount: 0, + amount, state: State::Specialized(state), }); } @@ -174,5 +209,27 @@ hash_a.finalize() == hash_c.finalize() } + + fn combine_from_len(bytes_1: Vec, bytes_2: Vec) -> bool { + let mut hash_a = Hasher::new(); + hash_a.update(&bytes_1); + let a = hash_a.finalize(); + + let mut hash_b = Hasher::new(); + hash_b.update(&bytes_2); + let b = hash_b.finalize(); + + let mut hash_ab = Hasher::new(); + hash_ab.update(&bytes_1); + hash_ab.update(&bytes_2); + let ab = hash_ab.finalize(); + + let mut reconstructed = Hasher::new_with_initial_len(a, bytes_1.len() as u64); + let hash_b_reconstructed = Hasher::new_with_initial_len(b, bytes_2.len() as u64); + + reconstructed.combine(&hash_b_reconstructed); + + reconstructed.finalize() == ab + } } } diff -Nru cargo-0.57.0+ubuntu/vendor/crc32fast/src/specialized/mod.rs cargo-0.58.0/vendor/crc32fast/src/specialized/mod.rs --- cargo-0.57.0+ubuntu/vendor/crc32fast/src/specialized/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/crc32fast/src/specialized/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,6 +1,7 @@ cfg_if! { if #[cfg(all( crc32fast_stdarchx86, + target_feature = "sse2", any(target_arch = "x86", target_arch = "x86_64") ))] { mod pclmulqdq; diff -Nru cargo-0.57.0+ubuntu/vendor/crc32fast/src/specialized/pclmulqdq.rs cargo-0.58.0/vendor/crc32fast/src/specialized/pclmulqdq.rs --- cargo-0.57.0+ubuntu/vendor/crc32fast/src/specialized/pclmulqdq.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/crc32fast/src/specialized/pclmulqdq.rs 2022-01-21 02:47:39.000000000 +0000 @@ -89,7 +89,7 @@ } #[target_feature(enable = "pclmulqdq", enable = "sse2", enable = "sse4.1")] -pub unsafe fn calculate(crc: u32, mut data: &[u8]) -> u32 { +unsafe fn calculate(crc: u32, mut data: &[u8]) -> u32 { // In theory we can accelerate smaller chunks too, but for now just rely on // the fallback implementation as it's too much hassle and doesn't seem too // beneficial. diff -Nru cargo-0.57.0+ubuntu/vendor/crossbeam-utils/build.rs cargo-0.58.0/vendor/crossbeam-utils/build.rs --- cargo-0.57.0+ubuntu/vendor/crossbeam-utils/build.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/crossbeam-utils/build.rs 2022-01-21 02:47:39.000000000 +0000 @@ -4,9 +4,31 @@ 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, diff -Nru cargo-0.57.0+ubuntu/vendor/crossbeam-utils/.cargo-checksum.json cargo-0.58.0/vendor/crossbeam-utils/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/crossbeam-utils/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/crossbeam-utils/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db"} \ No newline at end of file +{"files":{},"package":"cfcae03edb34f947e64acdb1c33ec169824e20657e9ecb61cef6c8c74dcb8120"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/crossbeam-utils/Cargo.toml cargo-0.58.0/vendor/crossbeam-utils/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/crossbeam-utils/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/crossbeam-utils/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -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 @@ [dev-dependencies.rand] version = ">= 0.7, < 0.9" +[dev-dependencies.rustversion] +version = "1" + [features] default = ["std"] nightly = [] diff -Nru cargo-0.57.0+ubuntu/vendor/crossbeam-utils/CHANGELOG.md cargo-0.58.0/vendor/crossbeam-utils/CHANGELOG.md --- cargo-0.57.0+ubuntu/vendor/crossbeam-utils/CHANGELOG.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/crossbeam-utils/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 @@ -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 diff -Nru cargo-0.57.0+ubuntu/vendor/crossbeam-utils/no_atomic.rs cargo-0.58.0/vendor/crossbeam-utils/no_atomic.rs --- cargo-0.57.0+ubuntu/vendor/crossbeam-utils/no_atomic.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/crossbeam-utils/no_atomic.rs 2022-01-21 02:47:39.000000000 +0000 @@ -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 @@ "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 @@ "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 @@ "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", diff -Nru cargo-0.57.0+ubuntu/vendor/crossbeam-utils/src/atomic/atomic_cell.rs cargo-0.58.0/vendor/crossbeam-utils/src/atomic/atomic_cell.rs --- cargo-0.57.0+ubuntu/vendor/crossbeam-utils/src/atomic/atomic_cell.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/crossbeam-utils/src/atomic/atomic_cell.rs 2022-01-21 02:47:39.000000000 +0000 @@ -295,7 +295,7 @@ } 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 @@ /// ``` #[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 @@ /// ``` #[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 @@ /// ``` #[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 @@ /// ``` #[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 @@ /// ``` #[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!(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 @@ // 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 @@ ($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 @@ const fn atomic_is_lock_free() -> 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::() - | can_transmute::() | can_transmute::() | can_transmute::() | can_transmute::(); diff -Nru cargo-0.57.0+ubuntu/vendor/crossbeam-utils/src/sync/parker.rs cargo-0.58.0/vendor/crossbeam-utils/src/sync/parker.rs --- cargo-0.57.0+ubuntu/vendor/crossbeam-utils/src/sync/parker.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/crossbeam-utils/src/sync/parker.rs 2022-01-21 02:47:39.000000000 +0000 @@ -175,6 +175,7 @@ /// /// 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 @@ /// 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 () diff -Nru cargo-0.57.0+ubuntu/vendor/crossbeam-utils/src/thread.rs cargo-0.58.0/vendor/crossbeam-utils/src/thread.rs --- cargo-0.57.0+ubuntu/vendor/crossbeam-utils/src/thread.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/crossbeam-utils/src/thread.rs 2022-01-21 02:47:39.000000000 +0000 @@ -446,7 +446,7 @@ unsafe { mem::transmute(closure) }; // Finally, spawn the closure. - self.builder.spawn(move || closure())? + self.builder.spawn(closure)? }; let thread = handle.thread().clone(); diff -Nru cargo-0.57.0+ubuntu/vendor/crossbeam-utils/tests/atomic_cell.rs cargo-0.58.0/vendor/crossbeam-utils/tests/atomic_cell.rs --- cargo-0.57.0+ubuntu/vendor/crossbeam-utils/tests/atomic_cell.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/crossbeam-utils/tests/atomic_cell.rs 2022-01-21 02:47:39.000000000 +0000 @@ -264,3 +264,22 @@ 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::(), 8); + assert!(AtomicCell::::is_lock_free()); + let x = AtomicCell::new(Test::FieldLess); + assert_eq!(x.load(), Test::FieldLess); +} diff -Nru cargo-0.57.0+ubuntu/vendor/crossbeam-utils/tests/sharded_lock.rs cargo-0.58.0/vendor/crossbeam-utils/tests/sharded_lock.rs --- cargo-0.57.0+ubuntu/vendor/crossbeam-utils/tests/sharded_lock.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/crossbeam-utils/tests/sharded_lock.rs 2022-01-21 02:47:39.000000000 +0000 @@ -21,6 +21,9 @@ #[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(())); diff -Nru cargo-0.57.0+ubuntu/vendor/filetime/.cargo-checksum.json cargo-0.58.0/vendor/filetime/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/filetime/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/filetime/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"3ed85775dcc68644b5c950ac06a2b23768d3bc9390464151aaf27136998dcf9e"} \ No newline at end of file +{"files":{},"package":"975ccf83d8d9d0d84682850a38c8169027be83368805971cc4f238c2b245bc98"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/filetime/Cargo.toml cargo-0.58.0/vendor/filetime/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/filetime/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/filetime/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -13,7 +13,7 @@ [package] edition = "2018" name = "filetime" -version = "0.2.12" +version = "0.2.15" authors = ["Alex Crichton "] description = "Platform-agnostic accessors of timestamps in File metadata\n" homepage = "https://github.com/alexcrichton/filetime" @@ -23,11 +23,11 @@ license = "MIT/Apache-2.0" repository = "https://github.com/alexcrichton/filetime" [dependencies.cfg-if] -version = "0.1.6" +version = "1.0.0" [dev-dependencies.tempfile] version = "3" [target."cfg(target_os = \"redox\")".dependencies.redox_syscall] -version = "0.1" +version = "0.2.9" [target."cfg(unix)".dependencies.libc] version = "0.2.27" [target."cfg(windows)".dependencies.winapi] diff -Nru cargo-0.57.0+ubuntu/vendor/filetime/src/redox.rs cargo-0.58.0/vendor/filetime/src/redox.rs --- cargo-0.57.0+ubuntu/vendor/filetime/src/redox.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/filetime/src/redox.rs 2022-01-21 02:47:39.000000000 +0000 @@ -5,16 +5,14 @@ use std::path::Path; pub fn set_file_times(p: &Path, atime: FileTime, mtime: FileTime) -> io::Result<()> { - let fd = syscall::open(p.as_os_str().as_bytes(), 0) - .map_err(|err| io::Error::from_raw_os_error(err.errno))?; + let fd = open_redox(p, 0).map_err(|err| io::Error::from_raw_os_error(err.errno))?; let res = set_file_times_redox(fd, atime, mtime); let _ = syscall::close(fd); res } pub fn set_file_mtime(p: &Path, mtime: FileTime) -> io::Result<()> { - let fd = syscall::open(p.as_os_str().as_bytes(), 0) - .map_err(|err| io::Error::from_raw_os_error(err.errno))?; + let fd = open_redox(p, 0).map_err(|err| io::Error::from_raw_os_error(err.errno))?; let mut st = syscall::Stat::default(); let res = match syscall::fstat(fd, &mut st) { Err(err) => Err(io::Error::from_raw_os_error(err.errno)), @@ -32,8 +30,7 @@ } pub fn set_file_atime(p: &Path, atime: FileTime) -> io::Result<()> { - let fd = syscall::open(p.as_os_str().as_bytes(), 0) - .map_err(|err| io::Error::from_raw_os_error(err.errno))?; + let fd = open_redox(p, 0).map_err(|err| io::Error::from_raw_os_error(err.errno))?; let mut st = syscall::Stat::default(); let res = match syscall::fstat(fd, &mut st) { Err(err) => Err(io::Error::from_raw_os_error(err.errno)), @@ -51,7 +48,7 @@ } pub fn set_symlink_file_times(p: &Path, atime: FileTime, mtime: FileTime) -> io::Result<()> { - let fd = syscall::open(p.as_os_str().as_bytes(), syscall::O_NOFOLLOW) + let fd = open_redox(p, syscall::O_NOFOLLOW) .map_err(|err| io::Error::from_raw_os_error(err.errno))?; let res = set_file_times_redox(fd, atime, mtime); let _ = syscall::close(fd); @@ -78,6 +75,13 @@ set_file_times_redox(f.as_raw_fd() as usize, atime1, mtime1) } +fn open_redox(path: &Path, flags: usize) -> syscall::Result { + match path.to_str() { + Some(string) => syscall::open(string, flags), + None => Err(syscall::Error::new(syscall::EINVAL)), + } +} + fn set_file_times_redox(fd: usize, atime: FileTime, mtime: FileTime) -> io::Result<()> { use syscall::TimeSpec; diff -Nru cargo-0.57.0+ubuntu/vendor/filetime/src/unix/macos.rs cargo-0.58.0/vendor/filetime/src/unix/macos.rs --- cargo-0.57.0+ubuntu/vendor/filetime/src/unix/macos.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/filetime/src/unix/macos.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,5 +1,5 @@ -//! Beginning with MacOS 10.3, `utimensat` is supported by the MacOS, so here, we check if the symbol exists -//! and if not, we fallabck to `utimes`. +//! Beginning with macOS 10.13, `utimensat` is supported by the OS, so here, we check if the symbol exists +//! and if not, we fallback to `utimes`. use crate::FileTime; use libc::{c_char, c_int, timespec}; use std::ffi::{CStr, CString}; diff -Nru cargo-0.57.0+ubuntu/vendor/filetime/src/unix/mod.rs cargo-0.58.0/vendor/filetime/src/unix/mod.rs --- cargo-0.57.0+ubuntu/vendor/filetime/src/unix/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/filetime/src/unix/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -33,13 +33,22 @@ #[allow(dead_code)] fn to_timespec(ft: &Option) -> timespec { cfg_if::cfg_if! { - if #[cfg(target_os = "macos")] { + if #[cfg(any(target_os = "macos", + target_os = "illumos", + target_os = "freebsd"))] { // https://github.com/apple/darwin-xnu/blob/a449c6a3b8014d9406c2ddbdc81795da24aa7443/bsd/sys/stat.h#L541 + // https://github.com/illumos/illumos-gate/blob/master/usr/src/boot/sys/sys/stat.h#L312 + // https://svnweb.freebsd.org/base/head/sys/sys/stat.h?view=markup#l359 const UTIME_OMIT: i64 = -2; } else if #[cfg(target_os = "openbsd")] { // https://github.com/openbsd/src/blob/master/sys/sys/stat.h#L189 const UTIME_OMIT: i64 = -1; + } else if #[cfg(target_os = "haiku")] { + // https://git.haiku-os.org/haiku/tree/headers/posix/sys/stat.h?#n106 + const UTIME_OMIT: i64 = 1000000001; } else { + // http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/stat.h?annotate=1.68.30.1 + // https://github.com/emscripten-core/emscripten/blob/master/system/include/libc/sys/stat.h#L71 const UTIME_OMIT: i64 = 1_073_741_822; } } diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/benches/mod.rs cargo-0.58.0/vendor/getrandom/benches/mod.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/benches/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/benches/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,5 +1,4 @@ #![feature(test)] -extern crate getrandom; extern crate test; #[bench] diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/build.rs cargo-0.58.0/vendor/getrandom/build.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/build.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/build.rs 2022-01-21 02:47:39.000000000 +0000 @@ -7,8 +7,6 @@ if target.contains("-uwp-windows-") { // for BCryptGenRandom println!("cargo:rustc-link-lib=bcrypt"); - // to work around unavailability of `target_vendor` on Rust 1.33 - println!("cargo:rustc-cfg=getrandom_uwp"); } else if target.contains("windows") { // for RtlGenRandom (aka SystemFunction036) println!("cargo:rustc-link-lib=advapi32"); diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/.cargo-checksum.json cargo-0.58.0/vendor/getrandom/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/getrandom/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"} \ No newline at end of file +{"files":{},"package":"ee8025cf36f917e6a52cce185b7c7177689b838b7ec138364e50cc2277a56cf4"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/Cargo.toml cargo-0.58.0/vendor/getrandom/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/getrandom/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -13,7 +13,7 @@ [package] edition = "2018" name = "getrandom" -version = "0.1.16" +version = "0.2.0" authors = ["The Rand Project Developers"] exclude = ["utils/*", ".*", "appveyor.yml"] description = "A small cross-platform library for retrieving random data from system source" @@ -21,8 +21,10 @@ categories = ["os", "no-std"] license = "MIT OR Apache-2.0" repository = "https://github.com/rust-random/getrandom" +[package.metadata.docs.rs] +features = ["std", "custom"] [dependencies.cfg-if] -version = "1" +version = "0.1.2" [dependencies.compiler_builtins] version = "0.1" @@ -33,33 +35,26 @@ optional = true package = "rustc-std-workspace-core" -[dependencies.log] -version = "0.4" -optional = true - [features] -dummy = [] +custom = [] +js = ["stdweb", "wasm-bindgen"] +rdrand = [] rustc-dep-of-std = ["compiler_builtins", "core"] std = [] -test-in-browser = ["wasm-bindgen"] -wasm-bindgen = ["bindgen", "js-sys"] +test-in-browser = [] +[target."cfg(all(target_arch = \"wasm32\", target_os = \"unknown\", cargo_web))".dependencies.stdweb] +version = "0.4.18" +optional = true +default-features = false +[target."cfg(all(target_arch = \"wasm32\", target_os = \"unknown\", not(cargo_web)))".dependencies.wasm-bindgen] +version = "0.2.62" +optional = true +default-features = false +[target."cfg(all(target_arch = \"wasm32\", target_os = \"unknown\", not(cargo_web)))".dev-dependencies.wasm-bindgen-test] +version = "0.3.18" [target."cfg(unix)".dependencies.libc] version = "0.2.64" default-features = false -[target.wasm32-unknown-unknown.dependencies.bindgen] -version = "0.2.29" -optional = true -package = "wasm-bindgen" - -[target.wasm32-unknown-unknown.dependencies.js-sys] -version = "0.3" -optional = true - -[target.wasm32-unknown-unknown.dependencies.stdweb] -version = "0.4.18" -optional = true -[target.wasm32-unknown-unknown.dev-dependencies.wasm-bindgen-test] -version = "0.2" [badges.appveyor] repository = "rust-random/getrandom" diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/CHANGELOG.md cargo-0.58.0/vendor/getrandom/CHANGELOG.md --- cargo-0.57.0+ubuntu/vendor/getrandom/CHANGELOG.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 @@ -4,17 +4,33 @@ 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.1.16] - 2020-12-31 -### Changed -- Update `cfg-if` to v1.0. [#173] -- Implement `std::error::Error` for the `Error` type on additional targets. [#169] +## [0.2.0] - 2020-09-10 +### Features for using getrandom on unsupported targets + +The following (off by default) Cargo features have been added: +- `"rdrand"` - use the RDRAND instruction on `no_std` `x86`/`x86_64` targets [#133] +- `"js"` - use JavaScript calls on `wasm32-unknown-unknown` [#149] + - Replaces the `stdweb` and `wasm-bindgen` features (which are removed) +- `"custom"` - allows a user to specify a custom implementation [#109] -### Fixed -- Multithreaded WASM support. [#171] +### Breaking Changes +- Unsupported targets no longer compile [#107] +- Change/Add `Error` constants [#120] +- Only impl `std` traits when the `"std"` Cargo feature is specified [#106] +- Remove offical support for Hermit, L4Re, and UEFI [#133] +- Remove optional `"log"` dependancy [#131] +- Update minimum supported Linux kernel to 2.6.32 [#153] +- Update MSRV to 1.34 [#159] -[#173]: https://github.com/rust-random/getrandom/pull/173 -[#171]: https://github.com/rust-random/getrandom/pull/171 -[#169]: https://github.com/rust-random/getrandom/pull/169 +[#106]: https://github.com/rust-random/getrandom/pull/106 +[#107]: https://github.com/rust-random/getrandom/pull/107 +[#109]: https://github.com/rust-random/getrandom/pull/109 +[#120]: https://github.com/rust-random/getrandom/pull/120 +[#131]: https://github.com/rust-random/getrandom/pull/131 +[#133]: https://github.com/rust-random/getrandom/pull/133 +[#149]: https://github.com/rust-random/getrandom/pull/149 +[#153]: https://github.com/rust-random/getrandom/pull/153 +[#159]: https://github.com/rust-random/getrandom/pull/159 ## [0.1.15] - 2020-09-10 ### Changed diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/debian/patches/drop-wasi.patch cargo-0.58.0/vendor/getrandom/debian/patches/drop-wasi.patch --- cargo-0.57.0+ubuntu/vendor/getrandom/debian/patches/drop-wasi.patch 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/debian/patches/drop-wasi.patch 2022-01-21 02:47:39.000000000 +0000 @@ -1,9 +1,9 @@ --- a/Cargo.toml +++ b/Cargo.toml -@@ -43,8 +43,6 @@ - std = [] - test-in-browser = ["wasm-bindgen"] - wasm-bindgen = ["bindgen", "js-sys"] +@@ -52,8 +52,6 @@ + default-features = false + [target."cfg(all(target_arch = \"wasm32\", target_os = \"unknown\", not(cargo_web)))".dev-dependencies.wasm-bindgen-test] + version = "0.3.18" -[target."cfg(target_os = \"wasi\")".dependencies.wasi] -version = "0.9" [target."cfg(unix)".dependencies.libc] diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/README.md cargo-0.58.0/vendor/getrandom/README.md --- cargo-0.57.0+ubuntu/vendor/getrandom/README.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/README.md 2022-01-21 02:47:39.000000000 +0000 @@ -24,7 +24,7 @@ ```toml [dependencies] -getrandom = "0.1" +getrandom = "0.2" ``` Then invoke the `getrandom` function: @@ -37,36 +37,14 @@ } ``` -## Features - -This library is `no_std` for every supported target. However, getting randomness -usually requires calling some external system API. This means most platforms -will require linking against system libraries (i.e. `libc` for Unix, -`Advapi32.dll` for Windows, Security framework on iOS, etc...). - -The `log` library is supported as an optional dependency. If enabled, error -reporting will be improved on some platforms. - -For the `wasm32-unknown-unknown` target, one of the following features should be -enabled: - -- [`wasm-bindgen`](https://crates.io/crates/wasm_bindgen) -- [`stdweb`](https://crates.io/crates/stdweb) - -By default, compiling `getrandom` for an unsupported target will result in -a compilation error. If you want to build an application which uses `getrandom` -for such target, you can either: -- Use [`[replace]`][replace] or [`[patch]`][patch] section in your `Cargo.toml` -to switch to a custom implementation with a support of your target. -- Enable the `dummy` feature to have getrandom use an implementation that always -fails at run-time on unsupported targets. - -[replace]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-replace-section -[patch]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-patch-section +For more information about supported targets, entropy sources, `no_std` targets, +crate features, WASM support and Custom RNGs see the +[`getrandom` documentation](https://docs.rs/getrandom/latest) and +[`getrandom::Error` documentation](https://docs.rs/getrandom/latest/getrandom/struct.Error.html). ## Minimum Supported Rust Version -This crate requires Rust 1.32.0 or later. +This crate requires Rust 1.34.0 or later. # License diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/bsd_arandom.rs cargo-0.58.0/vendor/getrandom/src/bsd_arandom.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/bsd_arandom.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/bsd_arandom.rs 2022-01-21 02:47:39.000000000 +0000 @@ -7,8 +7,7 @@ // except according to those terms. //! Implementation for FreeBSD and NetBSD -use crate::util_libc::sys_fill_exact; -use crate::Error; +use crate::{util_libc::sys_fill_exact, Error}; use core::ptr; fn kern_arnd(buf: &mut [u8]) -> libc::ssize_t { @@ -25,7 +24,6 @@ ) }; if ret == -1 { - error!("sysctl kern.arandom: syscall failed"); -1 } else { len as libc::ssize_t @@ -45,5 +43,10 @@ return sys_fill_exact(dest, |buf| unsafe { func(buf.as_mut_ptr(), buf.len(), 0) }); } } - sys_fill_exact(dest, kern_arnd) + // Both FreeBSD and NetBSD will only return up to 256 bytes at a time, and + // older NetBSD kernels will fail on longer buffers. + for chunk in dest.chunks_mut(256) { + sys_fill_exact(chunk, kern_arnd)? + } + Ok(()) } diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/cloudabi.rs cargo-0.58.0/vendor/getrandom/src/cloudabi.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/cloudabi.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/cloudabi.rs 2022-01-21 02:47:39.000000000 +0000 @@ -17,7 +17,6 @@ pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { let errno = unsafe { cloudabi_sys_random_get(dest.as_mut_ptr(), dest.len()) }; if let Some(code) = NonZeroU32::new(errno as u32) { - error!("cloudabi_sys_random_get: failed with {}", errno); Err(Error::from(code)) } else { Ok(()) // Zero means success for CloudABI diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/custom.rs cargo-0.58.0/vendor/getrandom/src/custom.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/custom.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/custom.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,103 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! An implementation which calls out to an externally defined function. +use crate::Error; +use core::num::NonZeroU32; + +/// Register a function to be invoked by `getrandom` on unsupported targets. +/// +/// *This API requires the `"custom"` Cargo feature to be activated*. +/// +/// ## Writing a custom `getrandom` implementation +/// +/// The function to register must have the same signature as +/// [`getrandom::getrandom`](crate::getrandom). The function can be defined +/// wherever you want, either in root crate or a dependant crate. +/// +/// For example, if we wanted a `failure-getrandom` crate containing an +/// implementation that always fails, we would first depend on `getrandom` +/// (for the [`Error`] type) in `failure-getrandom/Cargo.toml`: +/// ```toml +/// [dependencies] +/// getrandom = "0.2" +/// ``` +/// Note that the crate containing this function does **not** need to enable the +/// `"custom"` Cargo feature. +/// +/// Next, in `failure-getrandom/src/lib.rs`, we define our function: +/// ```rust +/// use core::num::NonZeroU32; +/// use getrandom::Error; +/// +/// // Some application-specific error code +/// const MY_CUSTOM_ERROR_CODE: u32 = Error::CUSTOM_START + 42; +/// pub fn always_fail(buf: &mut [u8]) -> Result<(), Error> { +/// let code = NonZeroU32::new(MY_CUSTOM_ERROR_CODE).unwrap(); +/// Err(Error::from(code)) +/// } +/// ``` +/// +/// ## Registering a custom `getrandom` implementation +/// +/// Functions can only be registered in the root binary crate. Attempting to +/// register a function in a non-root crate will result in a linker error. +/// This is similar to +/// [`#[panic_handler]`](https://doc.rust-lang.org/nomicon/panic-handler.html) or +/// [`#[global_allocator]`](https://doc.rust-lang.org/edition-guide/rust-2018/platform-and-target-support/global-allocators.html), +/// where helper crates define handlers/allocators but only the binary crate +/// actually _uses_ the functionality. +/// +/// To register the function, we first depend on `failure-getrandom` _and_ +/// `getrandom` in `Cargo.toml`: +/// ```toml +/// [dependencies] +/// failure-getrandom = "0.1" +/// getrandom = { version = "0.2", features = ["custom"] } +/// ``` +/// +/// Then, we register the function in `src/main.rs`: +/// ```rust +/// # mod failure_getrandom { pub fn always_fail(_: &mut [u8]) -> Result<(), getrandom::Error> { unimplemented!() } } +/// use failure_getrandom::always_fail; +/// use getrandom::register_custom_getrandom; +/// +/// register_custom_getrandom!(always_fail); +/// ``` +/// +/// Now any user of `getrandom` (direct or indirect) on this target will use the +/// registered function. As noted in the +/// [top-level documentation](index.html#use-a-custom-implementation) this +/// registration only has an effect on unsupported targets. +#[macro_export] +macro_rules! register_custom_getrandom { + ($path:path) => { + // We use an extern "C" function to get the guarantees of a stable ABI. + #[no_mangle] + extern "C" fn __getrandom_custom(dest: *mut u8, len: usize) -> u32 { + let f: fn(&mut [u8]) -> Result<(), ::getrandom::Error> = $path; + let slice = unsafe { ::core::slice::from_raw_parts_mut(dest, len) }; + match f(slice) { + Ok(()) => 0, + Err(e) => e.code().get(), + } + } + }; +} + +#[allow(dead_code)] +pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { + extern "C" { + fn __getrandom_custom(dest: *mut u8, len: usize) -> u32; + } + let ret = unsafe { __getrandom_custom(dest.as_mut_ptr(), dest.len()) }; + match NonZeroU32::new(ret) { + None => Ok(()), + Some(code) => Err(Error::from(code)), + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/dummy.rs cargo-0.58.0/vendor/getrandom/src/dummy.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/dummy.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/dummy.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! A dummy implementation for unsupported targets which always fails -use crate::{error::UNSUPPORTED, Error}; - -pub fn getrandom_inner(_: &mut [u8]) -> Result<(), Error> { - Err(UNSUPPORTED) -} diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/error_impls.rs cargo-0.58.0/vendor/getrandom/src/error_impls.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/error_impls.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/error_impls.rs 2022-01-21 02:47:39.000000000 +0000 @@ -7,22 +7,10 @@ // except according to those terms. extern crate std; -use crate::{error::UNKNOWN_IO_ERROR, Error}; +use crate::Error; use core::convert::From; -use core::num::NonZeroU32; use std::io; -impl From for Error { - fn from(err: io::Error) -> Self { - if let Some(errno) = err.raw_os_error() { - if let Some(code) = NonZeroU32::new(errno as u32) { - return Error::from(code); - } - } - UNKNOWN_IO_ERROR - } -} - impl From for io::Error { fn from(err: Error) -> Self { match err.raw_os_error() { diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/error.rs cargo-0.58.0/vendor/getrandom/src/error.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/error.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/error.rs 2022-01-21 02:47:39.000000000 +0000 @@ -5,10 +5,9 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. -use core::fmt; -use core::num::NonZeroU32; +use core::{fmt, num::NonZeroU32}; -/// A small and `no_std` compatible error type. +/// A small and `no_std` compatible error type /// /// The [`Error::raw_os_error()`] will indicate if the error is from the OS, and /// if so, which error code the OS gave the application. If such an error is @@ -16,16 +15,44 @@ /// /// Internally this type is a NonZeroU32, with certain values reserved for /// certain purposes, see [`Error::INTERNAL_START`] and [`Error::CUSTOM_START`]. +/// +/// *If this crate's `"std"` Cargo feature is enabled*, then: +/// - [`getrandom::Error`][Error] implements +/// [`std::error::Error`](https://doc.rust-lang.org/std/error/trait.Error.html) +/// - [`std::io::Error`](https://doc.rust-lang.org/std/io/struct.Error.html) implements +/// [`From`](https://doc.rust-lang.org/std/convert/trait.From.html). #[derive(Copy, Clone, Eq, PartialEq)] pub struct Error(NonZeroU32); +const fn internal_error(n: u16) -> Error { + // SAFETY: code > 0 as INTERNAL_START > 0 and adding n won't overflow a u32. + let code = Error::INTERNAL_START + (n as u32); + Error(unsafe { NonZeroU32::new_unchecked(code) }) +} + impl Error { - #[deprecated(since = "0.1.7")] - /// Unknown error. - pub const UNKNOWN: Error = UNSUPPORTED; - #[deprecated(since = "0.1.7")] - /// System entropy source is unavailable. - pub const UNAVAILABLE: Error = UNSUPPORTED; + /// This target/platform is not supported by `getrandom`. + pub const UNSUPPORTED: Error = internal_error(0); + /// The platform-specific `errno` returned a non-positive value. + pub const ERRNO_NOT_POSITIVE: Error = internal_error(1); + /// Call to iOS [`SecRandomCopyBytes`](https://developer.apple.com/documentation/security/1399291-secrandomcopybytes) failed. + pub const IOS_SEC_RANDOM: Error = internal_error(3); + /// Call to Windows [`RtlGenRandom`](https://docs.microsoft.com/en-us/windows/win32/api/ntsecapi/nf-ntsecapi-rtlgenrandom) failed. + pub const WINDOWS_RTL_GEN_RANDOM: Error = internal_error(4); + /// RDRAND instruction failed due to a hardware issue. + pub const FAILED_RDRAND: Error = internal_error(5); + /// RDRAND instruction unsupported on this target. + pub const NO_RDRAND: Error = internal_error(6); + /// The browser does not have support for `self.crypto`. + pub const WEB_CRYPTO: Error = internal_error(7); + /// The browser does not have support for `crypto.getRandomValues`. + pub const WEB_GET_RANDOM_VALUES: Error = internal_error(8); + /// On VxWorks, call to `randSecure` failed (random number generator is not yet initialized). + pub const VXWORKS_RAND_SECURE: Error = internal_error(11); + /// NodeJS does not have support for the `crypto` module. + pub const NODE_CRYPTO: Error = internal_error(12); + /// NodeJS does not have support for `crypto.randomFillSync`. + pub const NODE_RANDOM_FILL_SYNC: Error = internal_error(13); /// Codes below this point represent OS Errors (i.e. positive i32 values). /// Codes at or above this point, but below [`Error::CUSTOM_START`] are @@ -38,9 +65,11 @@ /// Extract the raw OS error code (if this error came from the OS) /// - /// This method is identical to `std::io::Error::raw_os_error()`, except + /// This method is identical to [`std::io::Error::raw_os_error()`][1], except /// that it works in `no_std` contexts. If this method returns `None`, the /// error value can still be formatted via the `Display` implementation. + /// + /// [1]: https://doc.rust-lang.org/std/io/struct.Error.html#method.raw_os_error #[inline] pub fn raw_os_error(self) -> Option { if self.0.get() < Self::INTERNAL_START { @@ -55,7 +84,7 @@ /// This code can either come from the underlying OS, or be a custom error. /// Use [`Error::raw_os_error()`] to disambiguate. #[inline] - pub fn code(self) -> NonZeroU32 { + pub const fn code(self) -> NonZeroU32 { self.0 } } @@ -125,41 +154,19 @@ } } -// TODO: Convert to a function when min_version >= 1.33 -macro_rules! internal_error { - ($n:expr) => { - Error(unsafe { NonZeroU32::new_unchecked(Error::INTERNAL_START + $n as u16 as u32) }) - }; -} - -/// Internal Error constants -pub(crate) const UNSUPPORTED: Error = internal_error!(0); -pub(crate) const ERRNO_NOT_POSITIVE: Error = internal_error!(1); -pub(crate) const UNKNOWN_IO_ERROR: Error = internal_error!(2); -pub(crate) const SEC_RANDOM_FAILED: Error = internal_error!(3); -pub(crate) const RTL_GEN_RANDOM_FAILED: Error = internal_error!(4); -pub(crate) const FAILED_RDRAND: Error = internal_error!(5); -pub(crate) const NO_RDRAND: Error = internal_error!(6); -pub(crate) const BINDGEN_CRYPTO_UNDEF: Error = internal_error!(7); -pub(crate) const BINDGEN_GRV_UNDEF: Error = internal_error!(8); -pub(crate) const STDWEB_NO_RNG: Error = internal_error!(9); -pub(crate) const STDWEB_RNG_FAILED: Error = internal_error!(10); -pub(crate) const RAND_SECURE_FATAL: Error = internal_error!(11); - fn internal_desc(error: Error) -> Option<&'static str> { match error { - UNSUPPORTED => Some("getrandom: this target is not supported"), - ERRNO_NOT_POSITIVE => Some("errno: did not return a positive value"), - UNKNOWN_IO_ERROR => Some("Unknown std::io::Error"), - SEC_RANDOM_FAILED => Some("SecRandomCopyBytes: call failed"), - RTL_GEN_RANDOM_FAILED => Some("RtlGenRandom: call failed"), - FAILED_RDRAND => Some("RDRAND: failed multiple times: CPU issue likely"), - NO_RDRAND => Some("RDRAND: instruction not supported"), - BINDGEN_CRYPTO_UNDEF => Some("wasm-bindgen: self.crypto is undefined"), - BINDGEN_GRV_UNDEF => Some("wasm-bindgen: crypto.getRandomValues is undefined"), - STDWEB_NO_RNG => Some("stdweb: no randomness source available"), - STDWEB_RNG_FAILED => Some("stdweb: failed to get randomness"), - RAND_SECURE_FATAL => Some("randSecure: random number generator module is not initialized"), + Error::UNSUPPORTED => Some("getrandom: this target is not supported"), + Error::ERRNO_NOT_POSITIVE => Some("errno: did not return a positive value"), + Error::IOS_SEC_RANDOM => Some("SecRandomCopyBytes: iOS Security framework failure"), + Error::WINDOWS_RTL_GEN_RANDOM => Some("RtlGenRandom: Windows system function failure"), + Error::FAILED_RDRAND => Some("RDRAND: failed multiple times: CPU issue likely"), + Error::NO_RDRAND => Some("RDRAND: instruction not supported"), + Error::WEB_CRYPTO => Some("Web API self.crypto is unavailable"), + Error::WEB_GET_RANDOM_VALUES => Some("Web API crypto.getRandomValues is unavailable"), + Error::VXWORKS_RAND_SECURE => Some("randSecure: VxWorks RNG module is not initialized"), + Error::NODE_CRYPTO => Some("Node.js crypto module is unavailable"), + Error::NODE_RANDOM_FILL_SYNC => Some("Node.js API crypto.randomFillSync is unavailable"), _ => None, } } diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/ios.rs cargo-0.58.0/vendor/getrandom/src/ios.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/ios.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/ios.rs 2022-01-21 02:47:39.000000000 +0000 @@ -7,24 +7,19 @@ // except according to those terms. //! Implementation for iOS -use crate::{error::SEC_RANDOM_FAILED, Error}; - -// TODO: Make extern once extern_types feature is stabilized. See: -// https://github.com/rust-lang/rust/issues/43467 -#[repr(C)] -struct SecRandom([u8; 0]); +use crate::Error; +use core::{ffi::c_void, ptr::null}; #[link(name = "Security", kind = "framework")] extern "C" { - static kSecRandomDefault: *const SecRandom; - - fn SecRandomCopyBytes(rnd: *const SecRandom, count: usize, bytes: *mut u8) -> i32; + fn SecRandomCopyBytes(rnd: *const c_void, count: usize, bytes: *mut u8) -> i32; } pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { - let ret = unsafe { SecRandomCopyBytes(kSecRandomDefault, dest.len(), dest.as_mut_ptr()) }; + // Apple's documentation guarantees kSecRandomDefault is a synonym for NULL. + let ret = unsafe { SecRandomCopyBytes(null(), dest.len(), dest.as_mut_ptr()) }; if ret == -1 { - Err(SEC_RANDOM_FAILED) + Err(Error::IOS_SEC_RANDOM) } else { Ok(()) } diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/lib.rs cargo-0.58.0/vendor/getrandom/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/lib.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -6,89 +6,114 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Interface to the random number generator of the operating system. +//! Interface to the operating system's random number generator. //! -//! # Platform sources +//! # Supported targets //! -//! | OS | interface -//! |------------------|--------------------------------------------------------- -//! | Linux, Android | [`getrandom`][1] system call if available, otherwise [`/dev/urandom`][2] after successfully polling `/dev/random` -//! | Windows | [`RtlGenRandom`][3] -//! | macOS | [`getentropy()`][19] if available, otherwise [`/dev/random`][20] (identical to `/dev/urandom`) -//! | iOS | [`SecRandomCopyBytes`][4] -//! | FreeBSD | [`getrandom()`][21] if available, otherwise [`kern.arandom`][5] -//! | OpenBSD | [`getentropy`][6] -//! | NetBSD | [`kern.arandom`][7] -//! | Dragonfly BSD | [`/dev/random`][8] -//! | Solaris, illumos | [`getrandom`][9] system call if available, otherwise [`/dev/random`][10] -//! | Fuchsia OS | [`cprng_draw`][11] -//! | Redox | [`rand:`][12] -//! | CloudABI | [`cloudabi_sys_random_get`][13] -//! | Haiku | `/dev/random` (identical to `/dev/urandom`) -//! | L4RE, SGX, UEFI | [RDRAND][18] -//! | Hermit | [RDRAND][18] as [`sys_rand`][22] is currently broken. -//! | VxWorks | `randABytes` after checking entropy pool initialization with `randSecure` -//! | Web browsers | [`Crypto.getRandomValues`][14] (see [Support for WebAssembly and asm.js][16]) -//! | Node.js | [`crypto.randomBytes`][15] (see [Support for WebAssembly and asm.js][16]) -//! | WASI | [`__wasi_random_get`][17] -//! -//! Getrandom doesn't have a blanket implementation for all Unix-like operating -//! systems that reads from `/dev/urandom`. This ensures all supported operating -//! systems are using the recommended interface and respect maximum buffer -//! sizes. +//! | Target | Target Triple | Implementation +//! | ----------------- | ------------------ | -------------- +//! | Linux, Android | `*‑linux‑*` | [`getrandom`][1] system call if available, otherwise [`/dev/urandom`][2] after successfully polling `/dev/random` | +//! | Windows | `*‑pc‑windows‑*` | [`RtlGenRandom`][3] | +//! | [Windows UWP][22] | `*‑uwp‑windows‑*` | [`BCryptGenRandom`][23] | +//! | macOS | `*‑apple‑darwin` | [`getentropy()`][19] if available, otherwise [`/dev/random`][20] (identical to `/dev/urandom`) +//! | iOS | `*‑apple‑ios` | [`SecRandomCopyBytes`][4] +//! | FreeBSD | `*‑freebsd` | [`getrandom()`][21] if available, otherwise [`kern.arandom`][5] +//! | OpenBSD | `*‑openbsd` | [`getentropy`][6] +//! | NetBSD | `*‑netbsd` | [`kern.arandom`][7] +//! | Dragonfly BSD | `*‑dragonfly` | [`/dev/random`][8] +//! | Solaris, illumos | `*‑solaris`, `*‑illumos` | [`getrandom()`][9] if available, otherwise [`/dev/random`][10] +//! | Fuchsia OS | `*‑fuchsia` | [`cprng_draw`][11] +//! | Redox | `*‑cloudabi` | [`rand:`][12] +//! | CloudABI | `*‑redox` | [`cloudabi_sys_random_get`][13] +//! | Haiku | `*‑haiku` | `/dev/random` (identical to `/dev/urandom`) +//! | SGX | `x86_64‑*‑sgx` | [RDRAND][18] +//! | VxWorks | `*‑wrs‑vxworks‑*` | `randABytes` after checking entropy pool initialization with `randSecure` +//! | Emscripten | `*‑emscripten` | `/dev/random` (identical to `/dev/urandom`) +//! | WASI | `wasm32‑wasi` | [`__wasi_random_get`][17] +//! | Web Browser | `wasm32‑*‑unknown` | [`Crypto.getRandomValues()`][14], see [WebAssembly support][16] +//! | Node.js | `wasm32‑*‑unknown` | [`crypto.randomBytes`][15], see [WebAssembly support][16] +//! +//! There is no blanket implementation on `unix` targets that reads from +//! `/dev/urandom`. This ensures all supported targets are using the recommended +//! interface and respect maximum buffer sizes. //! -//! ## Unsupported targets +//! Pull Requests that add support for new targets to `getrandom` are always welcome. //! -//! By default, compiling `getrandom` for an unsupported target will result in -//! a compilation error. If you want to build an application which uses `getrandom` -//! for such target, you can either: -//! - Use [`[replace]`][replace] or [`[patch]`][patch] section in your `Cargo.toml` -//! to switch to a custom implementation with a support of your target. -//! - Enable the `dummy` feature to have getrandom use an implementation that always -//! fails at run-time on unsupported targets. -//! -//! [replace]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-replace-section -//! [patch]: https://doc.rust-lang.org/cargo/reference/manifest.html#the-patch-section -//! -//! ## Support for WebAssembly and asm.js -//! -//! Getrandom supports all of Rust's current `wasm32` targets, and it works with -//! both Node.js and web browsers. The three Emscripten targets -//! `asmjs-unknown-emscripten`, `wasm32-unknown-emscripten`, and -//! `wasm32-experimental-emscripten` use Emscripten's `/dev/random` emulation. -//! The WASI target `wasm32-wasi` uses the [`__wasi_random_get`][17] function -//! defined by the WASI standard. -//! -//! Getrandom also supports `wasm32-unknown-unknown` by directly calling -//! JavaScript methods. Rust currently has two ways to do this: [bindgen] and -//! [stdweb]. Getrandom supports using either one by enabling the -//! `wasm-bindgen` or `stdweb` crate features. Note that if both features are -//! enabled, `wasm-bindgen` will be used. If neither feature is enabled, calls -//! to `getrandom` will always fail at runtime. +//! ## Unsupported targets //! -//! [bindgen]: https://github.com/rust-lang/rust-bindgen -//! [stdweb]: https://github.com/koute/stdweb +//! By default, `getrandom` will not compile on unsupported targets, but certain +//! features allow a user to select a "fallback" implementation if no supported +//! implementation exists. +//! +//! All of the below mechanisms only affect unsupported +//! targets. Supported targets will _always_ use their supported implementations. +//! This prevents a crate from overriding a secure source of randomness +//! (either accidentally or intentionally). +//! +//! ### RDRAND on x86 +//! +//! *If the `"rdrand"` Cargo feature is enabled*, `getrandom` will fallback to using +//! the [`RDRAND`][18] instruction to get randomness on `no_std` `x86`/`x86_64` +//! targets. This feature has no effect on other CPU architectures. +//! +//! ### WebAssembly support +//! +//! This crate fully supports the +//! [`wasm32-wasi`](https://github.com/CraneStation/wasi) and +//! [`wasm32-unknown-emscripten`](https://www.hellorust.com/setup/emscripten/) +//! targets. However, the `wasm32-unknown-unknown` target is not automatically +//! supported since, from the target name alone, we cannot deduce which +//! JavaScript interface is in use (or if JavaScript is available at all). +//! +//! Instead, *if the `"js"` Cargo feature is enabled*, this crate will assume +//! that you are building for an environment containing JavaScript, and will +//! call the appropriate methods. Both web browser (main window and Web Workers) +//! and Node.js environments are supported, invoking the methods +//! [described above](#supported-targets). This crate can be built with either +//! the [wasm-bindgen](https://github.com/rust-lang/rust-bindgen) or +//! [cargo-web](https://github.com/koute/cargo-web) toolchains. +//! +//! This feature has no effect on targets other than `wasm32-unknown-unknown`. +//! +//! ### Custom implementations +//! +//! The [`register_custom_getrandom!`] macro allows a user to mark their own +//! function as the backing implementation for [`getrandom`]. See the macro's +//! documentation for more information about writing and registering your own +//! custom implementations. +//! +//! Note that registering a custom implementation only has an effect on targets +//! that would otherwise not compile. Any supported targets (including those +//! using `"rdrand"` and `"js"` Cargo features) continue using their normal +//! implementations even if a function is registered. +//! +//! ### Indirect Dependencies +//! +//! If `getrandom` is not a direct dependency of your crate, you can still +//! enable any of the above fallback behaviors by enabling the relevant +//! feature in your root crate's `Cargo.toml`: +//! ```toml +//! [dependencies] +//! getrandom = { version = "0.2", features = ["js"] } +//! ``` //! //! ## Early boot //! -//! It is possible that early in the boot process the OS hasn't had enough time -//! yet to collect entropy to securely seed its RNG, especially on virtual -//! machines. +//! Sometimes, early in the boot process, the OS has not collected enough +//! entropy to securely seed its RNG. This is especially common on virtual +//! machines, where standard "random" events are hard to come by. //! -//! Some operating systems always block the thread until the RNG is securely +//! Some operating system interfaces always block until the RNG is securely //! seeded. This can take anywhere from a few seconds to more than a minute. -//! Others make a best effort to use a seed from before the shutdown and don't -//! document much. -//! -//! A few, Linux, NetBSD and Solaris, offer a choice between blocking and -//! getting an error; in these cases we always choose to block. +//! A few (Linux, NetBSD and Solaris) offer a choice between blocking and +//! getting an error; in these cases, we always choose to block. //! -//! On Linux (when the `getrandom` system call is not available) and on NetBSD -//! reading from `/dev/urandom` never blocks, even when the OS hasn't collected -//! enough entropy yet. To avoid returning low-entropy bytes, we first read from +//! On Linux (when the `getrandom` system call is not available), reading from +//! `/dev/urandom` never blocks, even when the OS hasn't collected enough +//! entropy yet. To avoid returning low-entropy bytes, we first poll //! `/dev/random` and only switch to `/dev/urandom` once this has succeeded. //! -//! # Error handling +//! ## Error handling //! //! We always choose failure over returning insecure "random" bytes. In general, //! on supported platforms, failure is highly unlikely, though not impossible. @@ -96,9 +121,6 @@ //! `getrandom`, hence after the first successful call one can be reasonably //! confident that no errors will occur. //! -//! On unsupported platforms, `getrandom` always fails. See the [`Error`] type -//! for more information on what data is returned on failure. -//! //! [1]: http://man7.org/linux/man-pages/man2/getrandom.2.html //! [2]: http://man7.org/linux/man-pages/man4/urandom.4.html //! [3]: https://docs.microsoft.com/en-us/windows/desktop/api/ntsecapi/nf-ntsecapi-rtlgenrandom @@ -114,13 +136,14 @@ //! [13]: https://github.com/nuxinl/cloudabi#random_get //! [14]: https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues //! [15]: https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback -//! [16]: #support-for-webassembly-and-asmjs +//! [16]: #webassembly-support //! [17]: https://github.com/WebAssembly/WASI/blob/master/design/WASI-core.md#__wasi_random_get //! [18]: https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide //! [19]: https://www.unix.com/man-page/mojave/2/getentropy/ //! [20]: https://www.unix.com/man-page/mojave/4/random/ //! [21]: https://www.freebsd.org/cgi/man.cgi?query=getrandom&manpath=FreeBSD+12.0-stable -//! [22]: https://github.com/hermitcore/libhermit-rs/blob/09c38b0371cee6f56a541400ba453e319e43db53/src/syscalls/random.rs#L21 +//! [22]: https://docs.microsoft.com/en-us/windows/uwp/ +//! [23]: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom #![doc( html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", @@ -128,146 +151,78 @@ html_root_url = "https://rust-random.github.io/rand/" )] #![no_std] -#![cfg_attr(feature = "stdweb", recursion_limit = "128")] #![warn(rust_2018_idioms, unused_lifetimes, missing_docs)] #[macro_use] extern crate cfg_if; -cfg_if! { - if #[cfg(feature = "log")] { - #[allow(unused)] - #[macro_use] - extern crate log; - } else { - #[allow(unused)] - macro_rules! error { - ($($x:tt)*) => {}; - } - #[allow(unused)] - macro_rules! warn { - ($($x:tt)*) => {}; - } - #[allow(unused)] - macro_rules! info { - ($($x:tt)*) => {}; - } - } -} - mod error; -pub use crate::error::Error; - mod util; - -// For backwards compatibility, we provide the std-only trait implementations -// for some platforms, even if they don't enable the "std" feature. -#[cfg(any( - feature = "std", - all(windows, not(getrandom_uwp)), - target_os = "android", - target_os = "dragonfly", - target_os = "emscripten", - target_os = "freebsd", - target_os = "fuchsia", - target_os = "haiku", - target_os = "illumos", - target_os = "ios", - target_os = "linux", - target_os = "macos", - target_os = "netbsd", - target_os = "openbsd", - target_os = "redox", - target_os = "solaris", -))] +// To prevent a breaking change when targets are added, we always export the +// register_custom_getrandom macro, so old Custom RNG crates continue to build. +#[cfg(feature = "custom")] +mod custom; +#[cfg(feature = "std")] mod error_impls; +pub use crate::error::Error; + // System-specific implementations. // // These should all provide getrandom_inner with the same signature as getrandom. cfg_if! { - if #[cfg(target_os = "android")] { + if #[cfg(any(target_os = "dragonfly", target_os = "emscripten", + target_os = "haiku", target_os = "redox"))] { + mod util_libc; + #[path = "use_file.rs"] mod imp; + } else if #[cfg(any(target_os = "android", target_os = "linux"))] { mod util_libc; mod use_file; #[path = "linux_android.rs"] mod imp; - } else if #[cfg(target_os = "cloudabi")] { - #[path = "cloudabi.rs"] mod imp; - } else if #[cfg(target_os = "dragonfly")] { + } else if #[cfg(any(target_os = "illumos", target_os = "solaris"))] { mod util_libc; - #[path = "use_file.rs"] mod imp; - } else if #[cfg(target_os = "emscripten")] { - mod util_libc; - #[path = "use_file.rs"] mod imp; - } else if #[cfg(target_os = "freebsd")] { + mod use_file; + #[path = "solaris_illumos.rs"] mod imp; + } else if #[cfg(any(target_os = "freebsd", target_os = "netbsd"))] { mod util_libc; #[path = "bsd_arandom.rs"] mod imp; + } else if #[cfg(target_os = "cloudabi")] { + #[path = "cloudabi.rs"] mod imp; } else if #[cfg(target_os = "fuchsia")] { #[path = "fuchsia.rs"] mod imp; - } else if #[cfg(target_os = "haiku")] { - mod util_libc; - #[path = "use_file.rs"] mod imp; - } else if #[cfg(target_os = "illumos")] { - mod util_libc; - mod use_file; - #[path = "solaris_illumos.rs"] mod imp; } else if #[cfg(target_os = "ios")] { #[path = "ios.rs"] mod imp; - } else if #[cfg(target_os = "linux")] { - mod util_libc; - mod use_file; - #[path = "linux_android.rs"] mod imp; } else if #[cfg(target_os = "macos")] { mod util_libc; mod use_file; #[path = "macos.rs"] mod imp; - } else if #[cfg(target_os = "netbsd")] { - mod util_libc; - #[path = "bsd_arandom.rs"] mod imp; } else if #[cfg(target_os = "openbsd")] { mod util_libc; #[path = "openbsd.rs"] mod imp; - } else if #[cfg(target_os = "redox")] { - mod util_libc; - #[path = "use_file.rs"] mod imp; - } else if #[cfg(target_os = "solaris")] { - mod util_libc; - mod use_file; - #[path = "solaris_illumos.rs"] mod imp; } else if #[cfg(target_os = "wasi")] { #[path = "wasi.rs"] mod imp; } else if #[cfg(target_os = "vxworks")] { mod util_libc; #[path = "vxworks.rs"] mod imp; - } else if #[cfg(all(windows, getrandom_uwp))] { + } else if #[cfg(all(windows, target_vendor = "uwp"))] { #[path = "windows_uwp.rs"] mod imp; } else if #[cfg(windows)] { #[path = "windows.rs"] mod imp; - } else if #[cfg(all(target_arch = "x86_64", any( - target_os = "hermit", - target_os = "l4re", - target_os = "uefi", - target_env = "sgx", - )))] { + } else if #[cfg(all(target_arch = "x86_64", target_env = "sgx"))] { #[path = "rdrand.rs"] mod imp; - } else if #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] { - cfg_if! { - if #[cfg(feature = "wasm-bindgen")] { - #[path = "wasm32_bindgen.rs"] mod imp; - } else if #[cfg(feature = "stdweb")] { - #[path = "wasm32_stdweb.rs"] mod imp; - } else { - // Always have an implementation for wasm32-unknown-unknown. - // See https://github.com/rust-random/getrandom/issues/87 - #[path = "dummy.rs"] mod imp; - } - } - } else if #[cfg(feature = "dummy")] { - #[path = "dummy.rs"] mod imp; + } else if #[cfg(all(feature = "rdrand", + any(target_arch = "x86_64", target_arch = "x86")))] { + #[path = "rdrand.rs"] mod imp; + } else if #[cfg(all(feature = "js", + target_arch = "wasm32", target_os = "unknown"))] { + #[cfg_attr(cargo_web, path = "stdweb.rs")] + #[cfg_attr(not(cargo_web), path = "wasm-bindgen.rs")] + mod imp; + } else if #[cfg(feature = "custom")] { + use custom as imp; } else { - compile_error!("\ - target is not supported, for more information see: \ - https://docs.rs/getrandom/#unsupported-targets\ - "); + compile_error!("target is not supported, for more information see: \ + https://docs.rs/getrandom/#unsupported-targets"); } } @@ -284,9 +239,14 @@ /// In general, `getrandom` will be fast enough for interactive usage, though /// significantly slower than a user-space CSPRNG; for the latter consider /// [`rand::thread_rng`](https://docs.rs/rand/*/rand/fn.thread_rng.html). -pub fn getrandom(dest: &mut [u8]) -> Result<(), error::Error> { +pub fn getrandom(dest: &mut [u8]) -> Result<(), Error> { if dest.is_empty() { return Ok(()); } imp::getrandom_inner(dest) } + +#[cfg(test)] +mod test_common; +#[cfg(test)] +mod test_rdrand; diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/linux_android.rs cargo-0.58.0/vendor/getrandom/src/linux_android.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/linux_android.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/linux_android.rs 2022-01-21 02:47:39.000000000 +0000 @@ -7,9 +7,11 @@ // except according to those terms. //! Implementation for Linux / Android -use crate::util::LazyBool; -use crate::util_libc::{last_os_error, sys_fill_exact}; -use crate::{use_file, Error}; +use crate::{ + util::LazyBool, + util_libc::{last_os_error, sys_fill_exact}, + {use_file, Error}, +}; pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { static HAS_GETRANDOM: LazyBool = LazyBool::new(); diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/macos.rs cargo-0.58.0/vendor/getrandom/src/macos.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/macos.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/macos.rs 2022-01-21 02:47:39.000000000 +0000 @@ -7,8 +7,11 @@ // except according to those terms. //! Implementation for macOS -use crate::util_libc::{last_os_error, Weak}; -use crate::{use_file, Error}; +use crate::{ + use_file, + util_libc::{last_os_error, Weak}, + Error, +}; use core::mem; type GetEntropyFn = unsafe extern "C" fn(*mut u8, libc::size_t) -> libc::c_int; @@ -20,9 +23,7 @@ for chunk in dest.chunks_mut(256) { let ret = unsafe { func(chunk.as_mut_ptr(), chunk.len()) }; if ret != 0 { - let err = last_os_error(); - error!("getentropy syscall failed"); - return Err(err); + return Err(last_os_error()); } } Ok(()) diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/openbsd.rs cargo-0.58.0/vendor/getrandom/src/openbsd.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/openbsd.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/openbsd.rs 2022-01-21 02:47:39.000000000 +0000 @@ -7,16 +7,13 @@ // except according to those terms. //! Implementation for OpenBSD -use crate::util_libc::last_os_error; -use crate::Error; +use crate::{util_libc::last_os_error, Error}; pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { for chunk in dest.chunks_mut(256) { let ret = unsafe { libc::getentropy(chunk.as_mut_ptr() as *mut libc::c_void, chunk.len()) }; if ret == -1 { - let err = last_os_error(); - error!("libc::getentropy call failed"); - return Err(err); + return Err(last_os_error()); } } Ok(()) diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/rdrand.rs cargo-0.58.0/vendor/getrandom/src/rdrand.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/rdrand.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/rdrand.rs 2022-01-21 02:47:39.000000000 +0000 @@ -7,24 +7,30 @@ // except according to those terms. //! Implementation for SGX using RDRAND instruction -use crate::error::{FAILED_RDRAND, NO_RDRAND}; -#[cfg(not(target_feature = "rdrand"))] -use crate::util::LazyBool; use crate::Error; -use core::arch::x86_64::_rdrand64_step; use core::mem; +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + use core::arch::x86_64 as arch; + use arch::_rdrand64_step as rdrand_step; + } else if #[cfg(target_arch = "x86")] { + use core::arch::x86 as arch; + use arch::_rdrand32_step as rdrand_step; + } +} + // Recommendation from "Intel® Digital Random Number Generator (DRNG) Software // Implementation Guide" - Section 5.2.1 and "Intel® 64 and IA-32 Architectures // Software Developer’s Manual" - Volume 1 - Section 7.3.17.1. const RETRY_LIMIT: usize = 10; -const WORD_SIZE: usize = mem::size_of::(); +const WORD_SIZE: usize = mem::size_of::(); #[target_feature(enable = "rdrand")] unsafe fn rdrand() -> Result<[u8; WORD_SIZE], Error> { for _ in 0..RETRY_LIMIT { let mut el = mem::zeroed(); - if _rdrand64_step(&mut el) == 1 { + if rdrand_step(&mut el) == 1 { // AMD CPUs from families 14h to 16h (pre Ryzen) sometimes fail to // set CF on bogus random data, so we check these values explicitly. // See https://github.com/systemd/systemd/issues/11810#issuecomment-489727505 @@ -33,11 +39,10 @@ if el != 0 && el != !0 { return Ok(el.to_ne_bytes()); } - error!("RDRAND returned {:X}, CPU RNG may be broken", el); // Keep looping in case this was a false positive. } } - Err(FAILED_RDRAND) + Err(Error::FAILED_RDRAND) } // "rdrand" target feature requires "+rdrnd" flag, see https://github.com/rust-lang/rust/issues/49653. @@ -55,16 +60,18 @@ // https://github.com/rust-lang-nursery/stdsimd/issues/464 #[cfg(not(target_feature = "rdrand"))] fn is_rdrand_supported() -> bool { - use core::arch::x86_64::__cpuid; - // SAFETY: All x86_64 CPUs support CPUID leaf 1 + use crate::util::LazyBool; + + // SAFETY: All Rust x86 targets are new enough to have CPUID, and if CPUID + // is supported, CPUID leaf 1 is always supported. const FLAG: u32 = 1 << 30; static HAS_RDRAND: LazyBool = LazyBool::new(); - HAS_RDRAND.unsync_init(|| unsafe { (__cpuid(1).ecx & FLAG) != 0 }) + HAS_RDRAND.unsync_init(|| unsafe { (arch::__cpuid(1).ecx & FLAG) != 0 }) } pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { if !is_rdrand_supported() { - return Err(NO_RDRAND); + return Err(Error::NO_RDRAND); } // SAFETY: After this point, rdrand is supported, so calling the rdrand diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/solaris_illumos.rs cargo-0.58.0/vendor/getrandom/src/solaris_illumos.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/solaris_illumos.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/solaris_illumos.rs 2022-01-21 02:47:39.000000000 +0000 @@ -17,8 +17,11 @@ //! To make sure we can compile on both Solaris and its derivatives, as well as //! function, we check for the existence of getrandom(2) in libc by calling //! libc::dlsym. -use crate::util_libc::{sys_fill_exact, Weak}; -use crate::{use_file, Error}; +use crate::{ + use_file, + util_libc::{sys_fill_exact, Weak}, + Error, +}; use core::mem; #[cfg(target_os = "illumos")] diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/stdweb.rs cargo-0.58.0/vendor/getrandom/src/stdweb.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/stdweb.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/stdweb.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,86 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +use crate::Error; + +extern crate std; +use std::thread_local; + +use stdweb::js; + +#[derive(Clone, Copy, PartialEq)] +enum RngSource { + Browser, + Node, +} + +thread_local!( + static RNG_SOURCE: Result = getrandom_init(); +); + +pub(crate) fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { + RNG_SOURCE.with(|&source| getrandom_fill(source?, dest)) +} + +fn getrandom_init() -> Result { + if js! { return typeof self === "object"; } == true { + // We are in a Browser or WebWorker + let supported = js! { return typeof self.crypto === "object"; }; + if supported == true { + Ok(RngSource::Browser) + } else { + Err(Error::WEB_CRYPTO) + } + } else { + // We are in Node.js + let supported = js! { + try { + require("crypto"); + return true; + } catch(err) { + return false; + } + }; + if supported == true { + Ok(RngSource::Node) + } else { + Err(Error::NODE_CRYPTO) + } + } +} + +fn getrandom_fill(source: RngSource, dest: &mut [u8]) -> Result<(), Error> { + for chunk in dest.chunks_mut(65536) { + let len = chunk.len() as u32; + let ptr = chunk.as_mut_ptr() as i32; + + let success = js! { + try { + let array = new Uint8Array(@{ len }); + + if @{ source == RngSource::Browser } { + self.crypto.getRandomValues(array); + } else { + require("crypto").randomFillSync(array); + } + + HEAPU8.set(array, @{ ptr }); + return true; + } catch(err) { + return false; + } + }; + + if success != true { + return match source { + RngSource::Browser => Err(Error::WEB_GET_RANDOM_VALUES), + RngSource::Node => Err(Error::NODE_RANDOM_FILL_SYNC), + }; + } + } + Ok(()) +} diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/test_common.rs cargo-0.58.0/vendor/getrandom/src/test_common.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/test_common.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/test_common.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,67 @@ +// Allow getrandom to be renamed by the parent module. +use super::getrandom; + +#[cfg(all(target_arch = "wasm32", target_os = "unknown", not(cargo_web)))] +use wasm_bindgen_test::wasm_bindgen_test as test; + +#[cfg(feature = "test-in-browser")] +wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); + +#[test] +fn test_zero() { + // Test that APIs are happy with zero-length requests + getrandom(&mut [0u8; 0]).unwrap(); +} + +#[test] +fn test_diff() { + let mut v1 = [0u8; 1000]; + getrandom(&mut v1).unwrap(); + + let mut v2 = [0u8; 1000]; + getrandom(&mut v2).unwrap(); + + let mut n_diff_bits = 0; + for i in 0..v1.len() { + n_diff_bits += (v1[i] ^ v2[i]).count_ones(); + } + + // Check at least 1 bit per byte differs. p(failure) < 1e-1000 with random input. + assert!(n_diff_bits >= v1.len() as u32); +} + +#[test] +fn test_huge() { + let mut huge = [0u8; 100_000]; + getrandom(&mut huge).unwrap(); +} + +// On WASM, the thread API always fails/panics +#[cfg(not(target_arch = "wasm32"))] +#[test] +fn test_multithreading() { + extern crate std; + use std::{sync::mpsc::channel, thread, vec}; + + let mut txs = vec![]; + for _ in 0..20 { + let (tx, rx) = channel(); + txs.push(tx); + + thread::spawn(move || { + // wait until all the tasks are ready to go. + rx.recv().unwrap(); + let mut v = [0u8; 1000]; + + for _ in 0..100 { + getrandom(&mut v).unwrap(); + thread::yield_now(); + } + }); + } + + // start all the tasks + for tx in txs.iter() { + tx.send(()).unwrap(); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/test_rdrand.rs cargo-0.58.0/vendor/getrandom/src/test_rdrand.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/test_rdrand.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/test_rdrand.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,8 @@ +// We only test the RDRAND-based RNG source on supported architectures. +#![cfg(any(target_arch = "x86_64", target_arch = "x86"))] + +#[path = "rdrand.rs"] +mod rdrand; +use rdrand::getrandom_inner as getrandom; +#[path = "test_common.rs"] +mod test_common; diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/use_file.rs cargo-0.58.0/vendor/getrandom/src/use_file.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/use_file.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/use_file.rs 2022-01-21 02:47:39.000000000 +0000 @@ -7,11 +7,15 @@ // except according to those terms. //! Implementations that just need to read from a file -use crate::util::LazyUsize; -use crate::util_libc::{open_readonly, sys_fill_exact}; -use crate::Error; -use core::cell::UnsafeCell; -use core::sync::atomic::{AtomicUsize, Ordering::Relaxed}; +use crate::{ + util::LazyUsize, + util_libc::{open_readonly, sys_fill_exact}, + Error, +}; +use core::{ + cell::UnsafeCell, + sync::atomic::{AtomicUsize, Ordering::Relaxed}, +}; #[cfg(target_os = "redox")] const FILE_PATH: &str = "rand:\0"; @@ -99,7 +103,7 @@ // A negative timeout means an infinite timeout. let res = unsafe { libc::poll(&mut pfd, 1, -1) }; if res >= 0 { - assert_eq!(res, 1); // We only used one fd, and cannot timeout. + debug_assert_eq!(res, 1); // We only used one fd, and cannot timeout. return Ok(()); } let err = crate::util_libc::last_os_error(); diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/util_libc.rs cargo-0.58.0/vendor/getrandom/src/util_libc.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/util_libc.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/util_libc.rs 2022-01-21 02:47:39.000000000 +0000 @@ -6,11 +6,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. #![allow(dead_code)] -use crate::error::ERRNO_NOT_POSITIVE; -use crate::util::LazyUsize; -use crate::Error; -use core::num::NonZeroU32; -use core::ptr::NonNull; +use crate::{util::LazyUsize, Error}; +use core::{num::NonZeroU32, ptr::NonNull}; cfg_if! { if #[cfg(any(target_os = "netbsd", target_os = "openbsd", target_os = "android"))] { @@ -43,7 +40,7 @@ if errno > 0 { Error::from(NonZeroU32::new(errno as u32).unwrap()) } else { - ERRNO_NOT_POSITIVE + Error::ERRNO_NOT_POSITIVE } } @@ -109,14 +106,10 @@ // SAFETY: path must be null terminated, FD must be manually closed. pub unsafe fn open_readonly(path: &str) -> Result { - debug_assert!(path.as_bytes().last() == Some(&0)); + debug_assert_eq!(path.as_bytes().last(), Some(&0)); let fd = open(path.as_ptr() as *const _, libc::O_RDONLY | libc::O_CLOEXEC); if fd < 0 { return Err(last_os_error()); } - // O_CLOEXEC works on all Unix targets except for older Linux kernels (pre - // 2.6.23), so we also use an ioctl to make sure FD_CLOEXEC is set. - #[cfg(target_os = "linux")] - libc::ioctl(fd, libc::FIOCLEX); Ok(fd) } diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/vxworks.rs cargo-0.58.0/vendor/getrandom/src/vxworks.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/vxworks.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/vxworks.rs 2022-01-21 02:47:39.000000000 +0000 @@ -7,8 +7,7 @@ // except according to those terms. //! Implementation for VxWorks -use crate::error::{Error, RAND_SECURE_FATAL}; -use crate::util_libc::last_os_error; +use crate::{util_libc::last_os_error, Error}; use core::sync::atomic::{AtomicBool, Ordering::Relaxed}; pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { @@ -16,7 +15,7 @@ while !RNG_INIT.load(Relaxed) { let ret = unsafe { libc::randSecure() }; if ret < 0 { - return Err(RAND_SECURE_FATAL); + return Err(Error::VXWORKS_RAND_SECURE); } else if ret > 0 { RNG_INIT.store(true, Relaxed); break; diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/wasm32_bindgen.rs cargo-0.58.0/vendor/getrandom/src/wasm32_bindgen.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/wasm32_bindgen.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/wasm32_bindgen.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,128 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Implementation for WASM via wasm-bindgen -extern crate std; - -use core::cell::RefCell; -use core::mem; -use std::thread_local; - -use js_sys::Uint8Array; -// We have to rename wasm_bindgen to bindgen in the Cargo.toml for backwards -// compatibility. We have to rename it back here or else the macros will break. -extern crate bindgen as wasm_bindgen; -use wasm_bindgen::prelude::*; - -use crate::error::{BINDGEN_CRYPTO_UNDEF, BINDGEN_GRV_UNDEF}; -use crate::Error; - -const CHUNK_SIZE: usize = 256; - -#[derive(Clone, Debug)] -enum RngSource { - Node(NodeCrypto), - Browser(BrowserCrypto, Uint8Array), -} - -// JsValues are always per-thread, so we initialize RngSource for each thread. -// See: https://github.com/rustwasm/wasm-bindgen/pull/955 -thread_local!( - static RNG_SOURCE: RefCell> = RefCell::new(None); -); - -pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { - assert_eq!(mem::size_of::(), 4); - - RNG_SOURCE.with(|f| { - let mut source = f.borrow_mut(); - if source.is_none() { - *source = Some(getrandom_init()?); - } - - match source.as_ref().unwrap() { - RngSource::Node(n) => n.random_fill_sync(dest), - RngSource::Browser(crypto, buf) => { - // getRandomValues does not work with all types of WASM memory, - // so we initially write to browser memory to avoid exceptions. - for chunk in dest.chunks_mut(CHUNK_SIZE) { - // The chunk can be smaller than buf's length, so we call to - // JS to create a smaller view of buf without allocation. - let sub_buf = buf.subarray(0, chunk.len() as u32); - - crypto.get_random_values(&sub_buf); - sub_buf.copy_to(chunk); - } - } - }; - Ok(()) - }) -} - -fn getrandom_init() -> Result { - if let Ok(self_) = Global::get_self() { - // If `self` is defined then we're in a browser somehow (main window - // or web worker). We get `self.crypto` (called `msCrypto` on IE), so we - // can call `crypto.getRandomValues`. If `crypto` isn't defined, we - // assume we're in an older web browser and the OS RNG isn't available. - - let crypto: BrowserCrypto = match (self_.crypto(), self_.ms_crypto()) { - (crypto, _) if !crypto.is_undefined() => crypto.into(), - (_, crypto) if !crypto.is_undefined() => crypto.into(), - _ => return Err(BINDGEN_CRYPTO_UNDEF), - }; - - // Test if `crypto.getRandomValues` is undefined as well - if crypto.get_random_values_fn().is_undefined() { - return Err(BINDGEN_GRV_UNDEF); - } - - let buf = Uint8Array::new_with_length(CHUNK_SIZE as u32); - return Ok(RngSource::Browser(crypto, buf)); - } - - return Ok(RngSource::Node(MODULE.require("crypto"))); -} - -#[wasm_bindgen] -extern "C" { - type Global; - #[wasm_bindgen(getter, catch, static_method_of = Global, js_class = self, js_name = self)] - fn get_self() -> Result; - - type Self_; - #[wasm_bindgen(method, getter, js_name = "msCrypto", structural)] - fn ms_crypto(me: &Self_) -> JsValue; - #[wasm_bindgen(method, getter, structural)] - fn crypto(me: &Self_) -> JsValue; - - #[derive(Clone, Debug)] - type BrowserCrypto; - - // TODO: these `structural` annotations here ideally wouldn't be here to - // avoid a JS shim, but for now with feature detection they're - // unavoidable. - #[wasm_bindgen(method, js_name = getRandomValues, structural, getter)] - fn get_random_values_fn(me: &BrowserCrypto) -> JsValue; - #[wasm_bindgen(method, js_name = getRandomValues, structural)] - fn get_random_values(me: &BrowserCrypto, buf: &Uint8Array); - - #[derive(Clone, Debug)] - type NodeCrypto; - - #[wasm_bindgen(method, js_name = randomFillSync, structural)] - fn random_fill_sync(me: &NodeCrypto, buf: &mut [u8]); - - type NodeModule; - - #[wasm_bindgen(js_name = module)] - static MODULE: NodeModule; - - #[wasm_bindgen(method)] - fn require(this: &NodeModule, s: &str) -> NodeCrypto; -} diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/wasm32_stdweb.rs cargo-0.58.0/vendor/getrandom/src/wasm32_stdweb.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/wasm32_stdweb.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/wasm32_stdweb.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Implementation for WASM via stdweb -extern crate std; - -use core::mem; - -use stdweb::js; -use stdweb::unstable::TryInto; -use stdweb::web::error::Error as WebError; - -use crate::error::{STDWEB_NO_RNG, STDWEB_RNG_FAILED}; -use crate::Error; -use std::sync::Once; - -#[derive(Clone, Copy, Debug)] -enum RngSource { - Browser, - Node, -} - -pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { - assert_eq!(mem::size_of::(), 4); - static ONCE: Once = Once::new(); - static mut RNG_SOURCE: Result = Ok(RngSource::Node); - - // SAFETY: RNG_SOURCE is only written once, before being read. - ONCE.call_once(|| unsafe { - RNG_SOURCE = getrandom_init(); - }); - getrandom_fill(unsafe { RNG_SOURCE }?, dest) -} - -fn getrandom_init() -> Result { - let result = js! { - try { - if ( - typeof self === "object" && - typeof self.crypto === "object" && - typeof self.crypto.getRandomValues === "function" - ) { - return { success: true, ty: 1 }; - } - - if (typeof require("crypto").randomBytes === "function") { - return { success: true, ty: 2 }; - } - - return { success: false, error: new Error("not supported") }; - } catch(err) { - return { success: false, error: err }; - } - }; - - if js! { return @{ result.as_ref() }.success } == true { - let ty = js! { return @{ result }.ty }; - - if ty == 1 { - Ok(RngSource::Browser) - } else if ty == 2 { - Ok(RngSource::Node) - } else { - unreachable!() - } - } else { - let _err: WebError = js! { return @{ result }.error }.try_into().unwrap(); - error!("getrandom unavailable: {}", _err); - Err(STDWEB_NO_RNG) - } -} - -fn getrandom_fill(source: RngSource, dest: &mut [u8]) -> Result<(), Error> { - for chunk in dest.chunks_mut(65536) { - let len = chunk.len() as u32; - let ptr = chunk.as_mut_ptr() as i32; - - let result = match source { - RngSource::Browser => js! { - try { - let array = new Uint8Array(@{ len }); - self.crypto.getRandomValues(array); - HEAPU8.set(array, @{ ptr }); - - return { success: true }; - } catch(err) { - return { success: false, error: err }; - } - }, - RngSource::Node => js! { - try { - let bytes = require("crypto").randomBytes(@{ len }); - HEAPU8.set(new Uint8Array(bytes), @{ ptr }); - - return { success: true }; - } catch(err) { - return { success: false, error: err }; - } - }, - }; - - if js! { return @{ result.as_ref() }.success } != true { - let _err: WebError = js! { return @{ result }.error }.try_into().unwrap(); - error!("getrandom failed: {}", _err); - return Err(STDWEB_RNG_FAILED); - } - } - Ok(()) -} diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/wasm-bindgen.rs cargo-0.58.0/vendor/getrandom/src/wasm-bindgen.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/wasm-bindgen.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/wasm-bindgen.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,99 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +use crate::Error; + +extern crate std; +use std::thread_local; + +use wasm_bindgen::prelude::*; + +enum RngSource { + Node(NodeCrypto), + Browser(BrowserCrypto), +} + +// JsValues are always per-thread, so we initialize RngSource for each thread. +// See: https://github.com/rustwasm/wasm-bindgen/pull/955 +thread_local!( + static RNG_SOURCE: Result = getrandom_init(); +); + +pub(crate) fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { + RNG_SOURCE.with(|result| { + let source = result.as_ref().map_err(|&e| e)?; + + match source { + RngSource::Node(n) => { + if n.random_fill_sync(dest).is_err() { + return Err(Error::NODE_RANDOM_FILL_SYNC); + } + } + RngSource::Browser(n) => { + // see https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues + // + // where it says: + // + // > A QuotaExceededError DOMException is thrown if the + // > requested length is greater than 65536 bytes. + for chunk in dest.chunks_mut(65536) { + if n.get_random_values(chunk).is_err() { + return Err(Error::WEB_GET_RANDOM_VALUES); + } + } + } + }; + Ok(()) + }) +} + +fn getrandom_init() -> Result { + if let Ok(self_) = Global::get_self() { + // If `self` is defined then we're in a browser somehow (main window + // or web worker). We get `self.crypto` (called `msCrypto` on IE), so we + // can call `crypto.getRandomValues`. If `crypto` isn't defined, we + // assume we're in an older web browser and the OS RNG isn't available. + + let crypto: BrowserCrypto = match (self_.crypto(), self_.ms_crypto()) { + (crypto, _) if !crypto.is_undefined() => crypto, + (_, crypto) if !crypto.is_undefined() => crypto, + _ => return Err(Error::WEB_CRYPTO), + }; + return Ok(RngSource::Browser(crypto)); + } + + let crypto = MODULE.require("crypto").map_err(|_| Error::NODE_CRYPTO)?; + Ok(RngSource::Node(crypto)) +} + +#[wasm_bindgen] +extern "C" { + type Global; + #[wasm_bindgen(getter, catch, static_method_of = Global, js_class = self, js_name = self)] + fn get_self() -> Result; + + type Self_; + #[wasm_bindgen(method, getter, js_name = "msCrypto")] + fn ms_crypto(me: &Self_) -> BrowserCrypto; + #[wasm_bindgen(method, getter)] + fn crypto(me: &Self_) -> BrowserCrypto; + + type BrowserCrypto; + #[wasm_bindgen(method, js_name = getRandomValues, catch)] + fn get_random_values(me: &BrowserCrypto, buf: &mut [u8]) -> Result<(), JsValue>; + + #[wasm_bindgen(js_name = module)] + static MODULE: NodeModule; + + type NodeModule; + #[wasm_bindgen(method, catch)] + fn require(this: &NodeModule, s: &str) -> Result; + + type NodeCrypto; + #[wasm_bindgen(method, js_name = randomFillSync, catch)] + fn random_fill_sync(crypto: &NodeCrypto, buf: &mut [u8]) -> Result<(), JsValue>; +} diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/windows.rs cargo-0.58.0/vendor/getrandom/src/windows.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/windows.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/windows.rs 2022-01-21 02:47:39.000000000 +0000 @@ -7,7 +7,7 @@ // except according to those terms. //! Implementation for Windows -use crate::{error::RTL_GEN_RANDOM_FAILED, Error}; +use crate::Error; extern "system" { #[link_name = "SystemFunction036"] @@ -19,7 +19,7 @@ for chunk in dest.chunks_mut(u32::max_value() as usize) { let ret = unsafe { RtlGenRandom(chunk.as_mut_ptr(), chunk.len() as u32) }; if ret == 0 { - return Err(RTL_GEN_RANDOM_FAILED); + return Err(Error::WINDOWS_RTL_GEN_RANDOM); } } Ok(()) diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/src/windows_uwp.rs cargo-0.58.0/vendor/getrandom/src/windows_uwp.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/src/windows_uwp.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/src/windows_uwp.rs 2022-01-21 02:47:39.000000000 +0000 @@ -33,26 +33,16 @@ BCRYPT_USE_SYSTEM_PREFERRED_RNG, ) }; - // NTSTATUS codes use two highest bits for severity status - match ret >> 30 { - 0b01 => { - info!("BCryptGenRandom: information code 0x{:08X}", ret); - } - 0b10 => { - warn!("BCryptGenRandom: warning code 0x{:08X}", ret); - } - 0b11 => { - error!("BCryptGenRandom: failed with 0x{:08X}", ret); - // We zeroize the highest bit, so the error code will reside - // inside the range of designated for OS codes. - let code = ret ^ (1 << 31); - // SAFETY: the second highest bit is always equal to one, - // so it's impossible to get zero. Unfortunately compiler - // is not smart enough to figure out it yet. - let code = unsafe { NonZeroU32::new_unchecked(code) }; - return Err(Error::from(code)); - } - _ => (), + // NTSTATUS codes use the two highest bits for severity status. + if ret >> 30 == 0b11 { + // We zeroize the highest bit, so the error code will reside + // inside the range designated for OS codes. + let code = ret ^ (1 << 31); + // SAFETY: the second highest bit is always equal to one, + // so it's impossible to get zero. Unfortunately the type + // system does not have a way to express this yet. + let code = unsafe { NonZeroU32::new_unchecked(code) }; + return Err(Error::from(code)); } } Ok(()) diff -Nru cargo-0.57.0+ubuntu/vendor/getrandom/tests/common.rs cargo-0.58.0/vendor/getrandom/tests/common.rs --- cargo-0.57.0+ubuntu/vendor/getrandom/tests/common.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/getrandom/tests/common.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,68 +0,0 @@ -#[cfg(feature = "wasm-bindgen")] -use wasm_bindgen_test::*; - -use getrandom::getrandom; - -#[cfg(feature = "test-in-browser")] -wasm_bindgen_test_configure!(run_in_browser); - -#[cfg_attr(feature = "wasm-bindgen", wasm_bindgen_test)] -#[test] -fn test_zero() { - // Test that APIs are happy with zero-length requests - getrandom(&mut [0u8; 0]).unwrap(); -} - -#[cfg_attr(feature = "wasm-bindgen", wasm_bindgen_test)] -#[test] -fn test_diff() { - let mut v1 = [0u8; 1000]; - getrandom(&mut v1).unwrap(); - - let mut v2 = [0u8; 1000]; - getrandom(&mut v2).unwrap(); - - let mut n_diff_bits = 0; - for i in 0..v1.len() { - n_diff_bits += (v1[i] ^ v2[i]).count_ones(); - } - - // Check at least 1 bit per byte differs. p(failure) < 1e-1000 with random input. - assert!(n_diff_bits >= v1.len() as u32); -} - -#[cfg_attr(feature = "wasm-bindgen", wasm_bindgen_test)] -#[test] -fn test_huge() { - let mut huge = [0u8; 100_000]; - getrandom(&mut huge).unwrap(); -} - -#[cfg(not(target_arch = "wasm32"))] -#[test] -fn test_multithreading() { - use std::sync::mpsc::channel; - use std::thread; - - let mut txs = vec![]; - for _ in 0..20 { - let (tx, rx) = channel(); - txs.push(tx); - - thread::spawn(move || { - // wait until all the tasks are ready to go. - rx.recv().unwrap(); - let mut v = [0u8; 1000]; - - for _ in 0..100 { - getrandom(&mut v).unwrap(); - thread::yield_now(); - } - }); - } - - // start all the tasks - for tx in txs.iter() { - tx.send(()).unwrap(); - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/.cargo-checksum.json cargo-0.58.0/vendor/itertools/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/itertools/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf"} \ No newline at end of file +{"files":{},"package":"a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/Cargo.lock cargo-0.58.0/vendor/itertools/Cargo.lock --- cargo-0.57.0+ubuntu/vendor/itertools/Cargo.lock 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/Cargo.lock 2022-01-21 02:47:39.000000000 +0000 @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "atty" version = "0.2.14" @@ -221,7 +223,7 @@ [[package]] name = "itertools" -version = "0.10.1" +version = "0.10.3" dependencies = [ "criterion", "either", diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/Cargo.toml cargo-0.58.0/vendor/itertools/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/itertools/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -13,11 +13,12 @@ [package] edition = "2018" name = "itertools" -version = "0.10.1" +version = "0.10.3" authors = ["bluss"] exclude = ["/bors.toml"] description = "Extra iterator adaptors, iterator methods, free functions, and macros." documentation = "https://docs.rs/itertools/" +readme = "README.md" keywords = ["iterator", "data-structure", "zip", "product", "group-by"] categories = ["algorithms", "rust-patterns"] license = "MIT/Apache-2.0" diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/CHANGELOG.md cargo-0.58.0/vendor/itertools/CHANGELOG.md --- cargo-0.57.0+ubuntu/vendor/itertools/CHANGELOG.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 @@ -1,5 +1,16 @@ # Changelog +## 0.10.2 + - Add `Itertools::multiunzip` (#362, #565) + - Add `intersperse` and `intersperse_with` free functions (#555) + - Add `Itertools::sorted_by_cached_key` (#424, #575) + - Specialize `ProcessResults::fold` (#563) + - Fix subtraction overflow in `DuplicatesBy::size_hint` (#552) + - Fix specialization tests (#574) + - More `Debug` impls (#573) + - Deprecate `fold1` (use `reduce` instead) (#580) + - Documentation fixes (`HomogenousTuple`, `into_group_map`, `into_group_map_by`, `MultiPeek::peek`) (#543 et al.) + ## 0.10.1 - Add `Itertools::contains` (#514) - Add `Itertools::counts_by` (#515) diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/README.md cargo-0.58.0/vendor/itertools/README.md --- cargo-0.57.0+ubuntu/vendor/itertools/README.md 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/README.md 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,44 @@ +# Itertools + +Extra iterator adaptors, functions and macros. + +Please read the [API documentation here](https://docs.rs/itertools/). + +[![build_status](https://github.com/rust-itertools/itertools/actions/workflows/ci.yml/badge.svg)](https://github.com/rust-itertools/itertools/actions) +[![crates.io](https://img.shields.io/crates/v/itertools.svg)](https://crates.io/crates/itertools) + +How to use with Cargo: + +```toml +[dependencies] +itertools = "0.10.2" +``` + +How to use in your crate: + +```rust +use itertools::Itertools; +``` + +## How to contribute + +- Fix a bug or implement a new thing +- Include tests for your new feature, preferably a QuickCheck test +- Make a Pull Request + +For new features, please first consider filing a PR to [rust-lang/rust](https://github.com/rust-lang/rust), +adding your new feature to the `Iterator` trait of the standard library, if you believe it is reasonable. +If it isn't accepted there, proposing it for inclusion in ``itertools`` is a good idea. +The reason for doing is this is so that we avoid future breakage as with ``.flatten()``. +However, if your feature involves heap allocation, such as storing elements in a ``Vec``, +then it can't be accepted into ``libcore``, and you should propose it for ``itertools`` directly instead. + +## License + +Dual-licensed to be compatible with the Rust project. + +Licensed under the Apache License, Version 2.0 +https://www.apache.org/licenses/LICENSE-2.0 or the MIT license +https://opensource.org/licenses/MIT, at your +option. This file may not be copied, modified, or distributed +except according to those terms. diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/README.rst cargo-0.58.0/vendor/itertools/README.rst --- cargo-0.57.0+ubuntu/vendor/itertools/README.rst 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/README.rst 1970-01-01 00:00:00.000000000 +0000 @@ -1,55 +0,0 @@ - -Itertools -========= - -Extra iterator adaptors, functions and macros. - -Please read the `API documentation here`__ - -__ https://docs.rs/itertools/ - -|build_status|_ |crates|_ - -.. |build_status| image:: https://travis-ci.org/rust-itertools/itertools.svg?branch=master -.. _build_status: https://travis-ci.org/rust-itertools/itertools - -.. |crates| image:: https://meritbadge.herokuapp.com/itertools -.. _crates: https://crates.io/crates/itertools - -How to use with cargo: - -.. code:: toml - - [dependencies] - itertools = "0.10.0" - -How to use in your crate: - -.. code:: rust - - use itertools::Itertools; - -How to contribute ------------------ - -- Fix a bug or implement a new thing -- Include tests for your new feature, preferably a quickcheck test -- Make a Pull Request - -For new features, please first consider filing a PR to `rust-lang/rust `_, -adding your new feature to the `Iterator` trait of the standard library, if you believe it is reasonable. -If it isn't accepted there, proposing it for inclusion in ``itertools`` is a good idea. -The reason for doing is this is so that we avoid future breakage as with ``.flatten()``. -However, if your feature involves heap allocation, such as storing elements in a ``Vec``, -then it can't be accepted into ``libcore``, and you should propose it for ``itertools`` directly instead. - -License -------- - -Dual-licensed to be compatible with the Rust project. - -Licensed under the Apache License, Version 2.0 -https://www.apache.org/licenses/LICENSE-2.0 or the MIT license -https://opensource.org/licenses/MIT, at your -option. This file may not be copied, modified, or distributed -except according to those terms. diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/src/adaptors/coalesce.rs cargo-0.58.0/vendor/itertools/src/adaptors/coalesce.rs --- cargo-0.57.0+ubuntu/vendor/itertools/src/adaptors/coalesce.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/src/adaptors/coalesce.rs 2022-01-21 02:47:39.000000000 +0000 @@ -119,6 +119,10 @@ #[derive(Clone)] pub struct DedupPred2CoalescePred(DP); +impl fmt::Debug for DedupPred2CoalescePred { + debug_fmt_fields!(DedupPred2CoalescePred,); +} + pub trait DedupPredicate { // TODO replace by Fn(&T, &T)->bool once Rust supports it fn dedup_pair(&mut self, a: &T, b: &T) -> bool; @@ -137,7 +141,7 @@ } } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct DedupEq; impl DedupPredicate for DedupEq { @@ -186,7 +190,7 @@ pub type DedupByWithCount = CoalesceBy, (usize, ::Item)>; -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct DedupPredWithCount2CoalescePred(DP); impl CoalescePredicate for DedupPredWithCount2CoalescePred diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/src/adaptors/map.rs cargo-0.58.0/vendor/itertools/src/adaptors/map.rs --- cargo-0.57.0+ubuntu/vendor/itertools/src/adaptors/map.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/src/adaptors/map.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,7 +1,7 @@ use std::iter::FromIterator; use std::marker::PhantomData; -#[derive(Clone)] +#[derive(Clone, Debug)] #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] pub struct MapSpecialCase { iter: I, @@ -84,6 +84,10 @@ #[derive(Clone)] pub struct MapSpecialCaseFnOk(F); +impl std::fmt::Debug for MapSpecialCaseFnOk { + debug_fmt_fields!(MapSpecialCaseFnOk,); +} + /// Create a new `MapOk` iterator. pub fn map_ok(iter: I, f: F) -> MapOk where @@ -108,7 +112,7 @@ } } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct MapSpecialCaseFnInto(PhantomData); /// Create a new [`MapInto`] iterator. diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/src/adaptors/mod.rs cargo-0.58.0/vendor/itertools/src/adaptors/mod.rs --- cargo-0.57.0+ubuntu/vendor/itertools/src/adaptors/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/src/adaptors/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -477,7 +477,7 @@ fn merge_pred(&mut self, a: &T, b: &T) -> bool; } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct MergeLte; impl MergePredicate for MergeLte { @@ -849,6 +849,13 @@ f: F } +impl fmt::Debug for FilterOk +where + I: fmt::Debug, +{ + debug_fmt_fields!(FilterOk, iter); +} + /// Create a new `FilterOk` iterator. pub fn filter_ok(iter: I, f: F) -> FilterOk where I: Iterator>, @@ -917,6 +924,13 @@ f: F } +impl fmt::Debug for FilterMapOk +where + I: fmt::Debug, +{ + debug_fmt_fields!(FilterMapOk, iter); +} + fn transpose_result(result: Result, E>) -> Option> { match result { Ok(Some(v)) => Some(Ok(v)), @@ -995,6 +1009,13 @@ count: usize, } +impl fmt::Debug for Positions +where + I: fmt::Debug, +{ + debug_fmt_fields!(Positions, iter, count); +} + /// Create a new `Positions` iterator. pub fn positions(iter: I, f: F) -> Positions where I: Iterator, @@ -1058,6 +1079,13 @@ f: F, } +impl fmt::Debug for Update +where + I: fmt::Debug, +{ + debug_fmt_fields!(Update, iter); +} + /// Create a new `Update` iterator. pub fn update(iter: I, f: F) -> Update where diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/src/adaptors/multi_product.rs cargo-0.58.0/vendor/itertools/src/adaptors/multi_product.rs --- cargo-0.57.0+ubuntu/vendor/itertools/src/adaptors/multi_product.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/src/adaptors/multi_product.rs 2022-01-21 02:47:39.000000000 +0000 @@ -18,6 +18,14 @@ where I: Iterator + Clone, I::Item: Clone; +impl std::fmt::Debug for MultiProduct +where + I: Iterator + Clone + std::fmt::Debug, + I::Item: Clone + std::fmt::Debug, +{ + debug_fmt_fields!(CoalesceBy, 0); +} + /// Create a new cartesian product iterator over an arbitrary number /// of iterators of the same type. /// diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/src/duplicates_impl.rs cargo-0.58.0/vendor/itertools/src/duplicates_impl.rs --- cargo-0.57.0+ubuntu/vendor/itertools/src/duplicates_impl.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/src/duplicates_impl.rs 2022-01-21 02:47:39.000000000 +0000 @@ -84,13 +84,18 @@ #[inline] fn size_hint(&self) -> (usize, Option) { let (_, hi) = self.iter.size_hint(); - // There are `hi` number of items left in the base iterator. In the best case scenario, - // these items are exactly the same as the ones pending (i.e items seen exactly once so - // far), plus (hi - pending) / 2 pairs of never seen before items. let hi = hi.map(|hi| { - let max_pending = std::cmp::min(self.meta.pending, hi); - let max_new = std::cmp::max(hi - self.meta.pending, 0) / 2; - max_pending + max_new + if hi <= self.meta.pending { + // fewer or equally many iter-remaining elements than pending elements + // => at most, each iter-remaining element is matched + hi + } else { + // fewer pending elements than iter-remaining elements + // => at most: + // * each pending element is matched + // * the other iter-remaining elements come in pairs + self.meta.pending + (hi - self.meta.pending) / 2 + } }); // The lower bound is always 0 since we might only get unique items from now on (0, hi) @@ -117,6 +122,7 @@ } /// Apply the identity function to elements before checking them for equality. + #[derive(Debug)] pub struct ById; impl KeyMethod for ById { type Container = JustValue; @@ -128,6 +134,9 @@ /// Apply a user-supplied function to elements before checking them for equality. pub struct ByFn(pub(crate) F); + impl fmt::Debug for ByFn { + debug_fmt_fields!(ByFn,); + } impl KeyMethod for ByFn where F: FnMut(&V) -> K, @@ -147,6 +156,7 @@ fn value(self) -> V; } + #[derive(Debug)] pub struct KeyValue(K, V); impl KeyXorValue for KeyValue { fn key_ref(&self) -> &K { @@ -160,6 +170,7 @@ } } + #[derive(Debug)] pub struct JustValue(V); impl KeyXorValue for JustValue { fn key_ref(&self) -> &V { diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/src/free.rs cargo-0.58.0/vendor/itertools/src/free.rs --- cargo-0.57.0+ubuntu/vendor/itertools/src/free.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/src/free.rs 2022-01-21 02:47:39.000000000 +0000 @@ -14,8 +14,8 @@ string::String, }; -#[cfg(feature = "use_alloc")] use crate::Itertools; +use crate::intersperse::{Intersperse, IntersperseWith}; pub use crate::adaptors::{ interleave, @@ -35,6 +35,41 @@ #[cfg(feature = "use_alloc")] pub use crate::rciter_impl::rciter; +/// Iterate `iterable` with a particular value inserted between each element. +/// +/// [`IntoIterator`] enabled version of [`Iterator::intersperse`]. +/// +/// ``` +/// use itertools::intersperse; +/// +/// itertools::assert_equal(intersperse((0..3), 8), vec![0, 8, 1, 8, 2]); +/// ``` +pub fn intersperse(iterable: I, element: I::Item) -> Intersperse + where I: IntoIterator, + ::Item: Clone +{ + Itertools::intersperse(iterable.into_iter(), element) +} + +/// Iterate `iterable` with a particular value created by a function inserted +/// between each element. +/// +/// [`IntoIterator`] enabled version of [`Iterator::intersperse_with`]. +/// +/// ``` +/// use itertools::intersperse_with; +/// +/// let mut i = 10; +/// itertools::assert_equal(intersperse_with((0..3), || { i -= 1; i }), vec![0, 9, 1, 8, 2]); +/// assert_eq!(i, 8); +/// ``` +pub fn intersperse_with(iterable: I, element: F) -> IntersperseWith + where I: IntoIterator, + F: FnMut() -> I::Item +{ + Itertools::intersperse_with(iterable.into_iter(), element) +} + /// Iterate `iterable` with a running index. /// /// [`IntoIterator`] enabled version of [`Iterator::enumerate`]. diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/src/impl_macros.rs cargo-0.58.0/vendor/itertools/src/impl_macros.rs --- cargo-0.57.0+ubuntu/vendor/itertools/src/impl_macros.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/src/impl_macros.rs 2022-01-21 02:47:39.000000000 +0000 @@ -2,7 +2,7 @@ //! Implementation's internal macros macro_rules! debug_fmt_fields { - ($tyname:ident, $($($field:ident).+),*) => { + ($tyname:ident, $($($field:tt/*TODO ideally we would accept ident or tuple element here*/).+),*) => { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { f.debug_struct(stringify!($tyname)) $( diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/src/kmerge_impl.rs cargo-0.58.0/vendor/itertools/src/kmerge_impl.rs --- cargo-0.57.0+ubuntu/vendor/itertools/src/kmerge_impl.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/src/kmerge_impl.rs 2022-01-21 02:47:39.000000000 +0000 @@ -111,7 +111,7 @@ fn kmerge_pred(&mut self, a: &T, b: &T) -> bool; } -#[derive(Clone)] +#[derive(Clone, Debug)] pub struct KMergeByLt; impl KMergePredicate for KMergeByLt { diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/src/lib.rs cargo-0.58.0/vendor/itertools/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/itertools/src/lib.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -179,6 +179,7 @@ #[allow(deprecated)] pub use crate::sources::{repeat_call, unfold, iterate}; pub use crate::with_position::Position; +pub use crate::unziptuple::{multiunzip, MultiUnzip}; pub use crate::ziptuple::multizip; mod adaptors; mod either_or_both; @@ -237,6 +238,7 @@ mod duplicates_impl; #[cfg(feature = "use_std")] mod unique_impl; +mod unziptuple; mod with_position; mod zip_eq_impl; mod zip_longest; @@ -660,7 +662,7 @@ } /// Return an iterator over all contiguous windows producing tuples of - /// a specific size (up to 4). + /// a specific size (up to 12). /// /// `tuple_windows` clones the iterator elements so that they can be /// part of successive windows, this makes it most suited for iterators @@ -702,7 +704,7 @@ /// Return an iterator over all windows, wrapping back to the first /// elements when the window would otherwise exceed the length of the - /// iterator, producing tuples of a specific size (up to 4). + /// iterator, producing tuples of a specific size (up to 12). /// /// `circular_tuple_windows` clones the iterator elements so that they can be /// part of successive windows, this makes it most suited for iterators @@ -735,7 +737,7 @@ tuple_impl::circular_tuple_windows(self) } /// Return an iterator that groups the items in tuples of a specific size - /// (up to 4). + /// (up to 12). /// /// See also the method [`.next_tuple()`](Itertools::next_tuple). /// @@ -2241,6 +2243,7 @@ /// assert_eq!((0..10).fold1(|x, y| x + y).unwrap_or(0), 45); /// assert_eq!((0..0).fold1(|x, y| x * y), None); /// ``` + #[deprecated(since = "0.10.2", note = "Use `Iterator::reduce` instead")] fn fold1(mut self, f: F) -> Option where F: FnMut(Self::Item, Self::Item) -> Self::Item, Self: Sized, @@ -2665,6 +2668,43 @@ v.into_iter() } + /// Sort all iterator elements into a new iterator in ascending order. The key function is + /// called exactly once per key. + /// + /// **Note:** This consumes the entire iterator, uses the + /// [`slice::sort_by_cached_key`] method and returns the result as a new + /// iterator that owns its elements. + /// + /// The sorted iterator, if directly collected to a `Vec`, is converted + /// without any extra copying or allocation cost. + /// + /// ``` + /// use itertools::Itertools; + /// + /// // sort people in descending order by age + /// let people = vec![("Jane", 20), ("John", 18), ("Jill", 30), ("Jack", 27)]; + /// + /// let oldest_people_first = people + /// .into_iter() + /// .sorted_by_cached_key(|x| -x.1) + /// .map(|(person, _age)| person); + /// + /// itertools::assert_equal(oldest_people_first, + /// vec!["Jill", "Jack", "Jane", "John"]); + /// ``` + /// ``` + #[cfg(feature = "use_alloc")] + fn sorted_by_cached_key(self, f: F) -> VecIntoIter + where + Self: Sized, + K: Ord, + F: FnMut(&Self::Item) -> K, + { + let mut v = Vec::from_iter(self); + v.sort_by_cached_key(f); + v.into_iter() + } + /// Sort the k smallest elements into a new iterator, in ascending order. /// /// **Note:** This consumes the entire iterator, and returns the result @@ -2770,6 +2810,8 @@ /// Return a `HashMap` of keys mapped to `Vec`s of values. Keys and values /// are taken from `(Key, Value)` tuple pairs yielded by the input iterator. /// + /// Essentially a shorthand for `.into_grouping_map().collect::>()`. + /// /// ``` /// use itertools::Itertools; /// @@ -2791,8 +2833,8 @@ /// Return an `Iterator` on a `HashMap`. Keys mapped to `Vec`s of values. The key is specified /// in the closure. - /// Different to `into_group_map_by` because the key is still present. It is also more general. - /// You can also fold the `group_map`. + /// + /// Essentially a shorthand for `.into_grouping_map_by(f).collect::>()`. /// /// ``` /// use itertools::Itertools; @@ -3401,6 +3443,33 @@ { self.map(f).counts() } + + /// Converts an iterator of tuples into a tuple of containers. + /// + /// `unzip()` consumes an entire iterator of n-ary tuples, producing `n` collections, one for each + /// column. + /// + /// This function is, in some sense, the opposite of [`multizip`]. + /// + /// ``` + /// use itertools::Itertools; + /// + /// let inputs = vec![(1, 2, 3), (4, 5, 6), (7, 8, 9)]; + /// + /// let (a, b, c): (Vec<_>, Vec<_>, Vec<_>) = inputs + /// .into_iter() + /// .multiunzip(); + /// + /// assert_eq!(a, vec![1, 4, 7]); + /// assert_eq!(b, vec![2, 5, 8]); + /// assert_eq!(c, vec![3, 6, 9]); + /// ``` + fn multiunzip(self) -> FromI + where + Self: Sized + MultiUnzip, + { + MultiUnzip::multiunzip(self) + } } impl Itertools for T where T: Iterator { } diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/src/multipeek_impl.rs cargo-0.58.0/vendor/itertools/src/multipeek_impl.rs --- cargo-0.57.0+ubuntu/vendor/itertools/src/multipeek_impl.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/src/multipeek_impl.rs 2022-01-21 02:47:39.000000000 +0000 @@ -38,6 +38,7 @@ /// Works exactly like `.next()` with the only difference that it doesn't /// advance itself. `.peek()` can be called multiple times, to peek /// further ahead. + /// When `.next()` is called, reset the peeking “cursor”. pub fn peek(&mut self) -> Option<&I::Item> { let ret = if self.index < self.buf.len() { Some(&self.buf[self.index]) diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/src/pad_tail.rs cargo-0.58.0/vendor/itertools/src/pad_tail.rs --- cargo-0.57.0+ubuntu/vendor/itertools/src/pad_tail.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/src/pad_tail.rs 2022-01-21 02:47:39.000000000 +0000 @@ -16,6 +16,13 @@ filler: F, } +impl std::fmt::Debug for PadUsing +where + I: std::fmt::Debug, +{ + debug_fmt_fields!(PadUsing, iter, min, pos); +} + /// Create a new **PadUsing** iterator. pub fn pad_using(iter: I, min: usize, filler: F) -> PadUsing where I: Iterator, diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/src/peeking_take_while.rs cargo-0.58.0/vendor/itertools/src/peeking_take_while.rs --- cargo-0.57.0+ubuntu/vendor/itertools/src/peeking_take_while.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/src/peeking_take_while.rs 2022-01-21 02:47:39.000000000 +0000 @@ -83,6 +83,13 @@ f: F, } +impl<'a, I: 'a, F> std::fmt::Debug for PeekingTakeWhile<'a, I, F> +where + I: Iterator + std::fmt::Debug, +{ + debug_fmt_fields!(PeekingTakeWhile, iter); +} + /// Create a PeekingTakeWhile pub fn peeking_take_while(iter: &mut I, f: F) -> PeekingTakeWhile where I: Iterator, diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/src/process_results_impl.rs cargo-0.58.0/vendor/itertools/src/process_results_impl.rs --- cargo-0.57.0+ubuntu/vendor/itertools/src/process_results_impl.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/src/process_results_impl.rs 2022-01-21 02:47:39.000000000 +0000 @@ -30,6 +30,23 @@ fn size_hint(&self) -> (usize, Option) { (0, self.iter.size_hint().1) } + + fn fold(mut self, init: B, mut f: F) -> B + where + Self: Sized, + F: FnMut(B, Self::Item) -> B, + { + let error = self.error; + self.iter + .try_fold(init, |acc, opt| match opt { + Ok(x) => Ok(f(acc, x)), + Err(e) => { + *error = Err(e); + Err(acc) + } + }) + .unwrap_or_else(|e| e) + } } /// “Lift” a function of the values of an iterator so that it can process diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/src/tuple_impl.rs cargo-0.58.0/vendor/itertools/src/tuple_impl.rs --- cargo-0.57.0+ubuntu/vendor/itertools/src/tuple_impl.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/src/tuple_impl.rs 2022-01-21 02:47:39.000000000 +0000 @@ -11,7 +11,7 @@ // hiding the implementation details of `TupleCollect`. // See https://github.com/rust-itertools/itertools/issues/387 -/// Implemented for homogeneous tuples of size up to 4. +/// Implemented for homogeneous tuples of size up to 12. pub trait HomogeneousTuple : TupleCollect {} @@ -77,7 +77,7 @@ /// An iterator that groups the items in tuples of a specific size. /// /// See [`.tuples()`](crate::Itertools::tuples) for more information. -#[derive(Clone)] +#[derive(Clone, Debug)] #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] pub struct Tuples where I: Iterator, diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/src/unziptuple.rs cargo-0.58.0/vendor/itertools/src/unziptuple.rs --- cargo-0.57.0+ubuntu/vendor/itertools/src/unziptuple.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/src/unziptuple.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,80 @@ +/// Converts an iterator of tuples into a tuple of containers. +/// +/// `unzip()` consumes an entire iterator of n-ary tuples, producing `n` collections, one for each +/// column. +/// +/// This function is, in some sense, the opposite of [`multizip`]. +/// +/// ``` +/// use itertools::multiunzip; +/// +/// let inputs = vec![(1, 2, 3), (4, 5, 6), (7, 8, 9)]; +/// +/// let (a, b, c): (Vec<_>, Vec<_>, Vec<_>) = multiunzip(inputs); +/// +/// assert_eq!(a, vec![1, 4, 7]); +/// assert_eq!(b, vec![2, 5, 8]); +/// assert_eq!(c, vec![3, 6, 9]); +/// ``` +/// +/// [`multizip`]: crate::multizip +pub fn multiunzip(i: I) -> FromI +where + I: IntoIterator, + I::IntoIter: MultiUnzip, +{ + i.into_iter().multiunzip() +} + +/// An iterator that can be unzipped into multiple collections. +/// +/// See [`.multiunzip()`](crate::Itertools::multiunzip) for more information. +pub trait MultiUnzip: Iterator { + /// Unzip this iterator into multiple collections. + fn multiunzip(self) -> FromI; +} + +macro_rules! impl_unzip_iter { + ($($T:ident => $FromT:ident),*) => ( + #[allow(non_snake_case)] + impl, $($T, $FromT: Default + Extend<$T>),* > MultiUnzip<($($FromT,)*)> for IT { + fn multiunzip(self) -> ($($FromT,)*) { + // This implementation mirrors the logic of Iterator::unzip as close as possible. + // Unfortunately a lot of the used api there is still unstable represented by + // the commented out parts that follow. + // + // https://doc.rust-lang.org/src/core/iter/traits/iterator.rs.html#2816-2844 + + let mut res = ($($FromT::default(),)*); + let ($($FromT,)*) = &mut res; + + // Still unstable #72631 + // let (lower_bound, _) = self.size_hint(); + // if lower_bound > 0 { + // $($FromT.extend_reserve(lower_bound);)* + // } + + self.fold((), |(), ($($T,)*)| { + // Still unstable #72631 + // $( $FromT.extend_one($T); )* + $( $FromT.extend(std::iter::once($T)); )* + }); + res + } + } + ); +} + +impl_unzip_iter!(); +impl_unzip_iter!(A => FromA); +impl_unzip_iter!(A => FromA, B => FromB); +impl_unzip_iter!(A => FromA, B => FromB, C => FromC); +impl_unzip_iter!(A => FromA, B => FromB, C => FromC, D => FromD); +impl_unzip_iter!(A => FromA, B => FromB, C => FromC, D => FromD, E => FromE); +impl_unzip_iter!(A => FromA, B => FromB, C => FromC, D => FromD, E => FromE, F => FromF); +impl_unzip_iter!(A => FromA, B => FromB, C => FromC, D => FromD, E => FromE, F => FromF, G => FromG); +impl_unzip_iter!(A => FromA, B => FromB, C => FromC, D => FromD, E => FromE, F => FromF, G => FromG, H => FromH); +impl_unzip_iter!(A => FromA, B => FromB, C => FromC, D => FromD, E => FromE, F => FromF, G => FromG, H => FromH, I => FromI); +impl_unzip_iter!(A => FromA, B => FromB, C => FromC, D => FromD, E => FromE, F => FromF, G => FromG, H => FromH, I => FromI, J => FromJ); +impl_unzip_iter!(A => FromA, B => FromB, C => FromC, D => FromD, E => FromE, F => FromF, G => FromG, H => FromH, I => FromI, J => FromJ, K => FromK); +impl_unzip_iter!(A => FromA, B => FromB, C => FromC, D => FromD, E => FromE, F => FromF, G => FromG, H => FromH, I => FromI, J => FromJ, K => FromK, L => FromL); diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/tests/fold_specialization.rs cargo-0.58.0/vendor/itertools/tests/fold_specialization.rs --- cargo-0.57.0+ubuntu/vendor/itertools/tests/fold_specialization.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/tests/fold_specialization.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,13 +0,0 @@ -use itertools::Itertools; - -#[test] -fn specialization_intersperse() { - let mut iter = (1..2).intersperse(0); - iter.clone().for_each(|x| assert_eq!(Some(x), iter.next())); - - let mut iter = (1..3).intersperse(0); - iter.clone().for_each(|x| assert_eq!(Some(x), iter.next())); - - let mut iter = (1..4).intersperse(0); - iter.clone().for_each(|x| assert_eq!(Some(x), iter.next())); -} diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/tests/specializations.rs cargo-0.58.0/vendor/itertools/tests/specializations.rs --- cargo-0.57.0+ubuntu/vendor/itertools/tests/specializations.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/tests/specializations.rs 2022-01-21 02:47:39.000000000 +0000 @@ -15,16 +15,16 @@ } } -fn check_specialized<'a, V, IterItem, Iter, F>(iterator: &Iter, mapper: F) -where - V: Eq + Debug, - Iter: Iterator + Clone + 'a, - F: Fn(Box + 'a>) -> V, -{ - assert_eq!( - mapper(Box::new(Unspecialized(iterator.clone()))), - mapper(Box::new(iterator.clone())) - ) +macro_rules! check_specialized { + ($src:expr, |$it:pat| $closure:expr) => { + let $it = $src.clone(); + let v1 = $closure; + + let $it = Unspecialized($src.clone()); + let v2 = $closure; + + assert_eq!(v1, v2); + } } fn test_specializations( @@ -33,10 +33,10 @@ IterItem: Eq + Debug + Clone, Iter: Iterator + Clone, { - check_specialized(it, |i| i.count()); - check_specialized(it, |i| i.last()); - check_specialized(it, |i| i.collect::>()); - check_specialized(it, |i| { + check_specialized!(it, |i| i.count()); + check_specialized!(it, |i| i.last()); + check_specialized!(it, |i| i.collect::>()); + check_specialized!(it, |i| { let mut parameters_from_fold = vec![]; let fold_result = i.fold(vec![], |mut acc, v: IterItem| { parameters_from_fold.push((acc.clone(), v.clone())); @@ -45,7 +45,7 @@ }); (parameters_from_fold, fold_result) }); - check_specialized(it, |mut i| { + check_specialized!(it, |mut i| { let mut parameters_from_all = vec![]; let first = i.next(); let all_result = i.all(|x| { @@ -56,7 +56,7 @@ }); let size = it.clone().count(); for n in 0..size + 2 { - check_specialized(it, |mut i| i.nth(n)); + check_specialized!(it, |mut i| i.nth(n)); } // size_hint is a bit harder to check let mut it_sh = it.clone(); @@ -73,6 +73,12 @@ } quickcheck! { + fn intersperse(v: Vec) -> () { + test_specializations(&v.into_iter().intersperse(0)); + } +} + +quickcheck! { fn put_back_qc(test_vec: Vec) -> () { test_specializations(&itertools::put_back(test_vec.iter())); let mut pb = itertools::put_back(test_vec.into_iter()); @@ -98,3 +104,50 @@ test_specializations(&v.into_iter().map_ok(|u| u.checked_add(1))); } } + +quickcheck! { + fn process_results(v: Vec>) -> () { + helper(v.iter().copied()); + helper(v.iter().copied().filter(Result::is_ok)); + + fn helper(it: impl Iterator> + Clone) { + macro_rules! check_results_specialized { + ($src:expr, |$it:pat| $closure:expr) => { + assert_eq!( + itertools::process_results($src.clone(), |$it| $closure), + itertools::process_results($src.clone(), |i| { + let $it = Unspecialized(i); + $closure + }), + ) + } + } + + check_results_specialized!(it, |i| i.count()); + check_results_specialized!(it, |i| i.last()); + check_results_specialized!(it, |i| i.collect::>()); + check_results_specialized!(it, |i| { + let mut parameters_from_fold = vec![]; + let fold_result = i.fold(vec![], |mut acc, v| { + parameters_from_fold.push((acc.clone(), v.clone())); + acc.push(v); + acc + }); + (parameters_from_fold, fold_result) + }); + check_results_specialized!(it, |mut i| { + let mut parameters_from_all = vec![]; + let first = i.next(); + let all_result = i.all(|x| { + parameters_from_all.push(x.clone()); + Some(x)==first + }); + (parameters_from_all, all_result) + }); + let size = it.clone().count(); + for n in 0..size + 2 { + check_results_specialized!(it, |mut i| i.nth(n)); + } + } + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/tests/test_core.rs cargo-0.58.0/vendor/itertools/tests/test_core.rs --- cargo-0.57.0+ubuntu/vendor/itertools/tests/test_core.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/tests/test_core.rs 2022-01-21 02:47:39.000000000 +0000 @@ -9,6 +9,8 @@ use itertools as it; use crate::it::Itertools; use crate::it::interleave; +use crate::it::intersperse; +use crate::it::intersperse_with; use crate::it::multizip; use crate::it::free::put_back; use crate::it::iproduct; @@ -136,6 +138,23 @@ it::assert_equal(it, rs.iter()); } +#[test] +fn test_intersperse() { + let xs = [1u8, 2, 3]; + let ys = [1u8, 0, 2, 0, 3]; + let it = intersperse(&xs, &0); + it::assert_equal(it, ys.iter()); +} + +#[test] +fn test_intersperse_with() { + let xs = [1u8, 2, 3]; + let ys = [1u8, 10, 2, 10, 3]; + let i = 10; + let it = intersperse_with(&xs, || &i); + it::assert_equal(it, ys.iter()); +} + #[allow(deprecated)] #[test] fn foreach() { diff -Nru cargo-0.57.0+ubuntu/vendor/itertools/tests/test_std.rs cargo-0.58.0/vendor/itertools/tests/test_std.rs --- cargo-0.57.0+ubuntu/vendor/itertools/tests/test_std.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itertools/tests/test_std.rs 2022-01-21 02:47:39.000000000 +0000 @@ -84,6 +84,13 @@ it::assert_equal(ys.iter(), xs.iter().rev().duplicates().rev()); let ys_rev = [1, 0]; it::assert_equal(ys_rev.iter(), xs.iter().duplicates().rev()); + + let xs = vec![0, 1, 2, 1, 2]; + let ys = vec![1, 2]; + assert_eq!(ys, xs.iter().duplicates().cloned().collect_vec()); + assert_eq!(ys, xs.iter().rev().duplicates().rev().cloned().collect_vec()); + let ys_rev = vec![2, 1]; + assert_eq!(ys_rev, xs.iter().duplicates().rev().cloned().collect_vec()); } #[test] @@ -504,6 +511,30 @@ } #[test] +fn sorted_by_cached_key() { + // Track calls to key function + let mut ncalls = 0; + + let sorted = [3, 4, 1, 2].iter().cloned().sorted_by_cached_key(|&x| { + ncalls += 1; + x.to_string() + }); + it::assert_equal(sorted, vec![1, 2, 3, 4]); + // Check key function called once per element + assert_eq!(ncalls, 4); + + let mut ncalls = 0; + + let sorted = (0..5).sorted_by_cached_key(|&x| { + ncalls += 1; + -x + }); + it::assert_equal(sorted, vec![4, 3, 2, 1, 0]); + // Check key function called once per element + assert_eq!(ncalls, 5); +} + +#[test] fn test_multipeek() { let nums = vec![1u8,2,3,4,5]; @@ -1080,3 +1111,12 @@ [].iter().exactly_one()?; Ok(()) } + +#[test] +fn multiunzip() { + let (a, b, c): (Vec<_>, Vec<_>, Vec<_>) = [(0, 1, 2), (3, 4, 5), (6, 7, 8)].iter().cloned().multiunzip(); + assert_eq!((a, b, c), (vec![0, 3, 6], vec![1, 4, 7], vec![2, 5, 8])); + let (): () = [(), (), ()].iter().cloned().multiunzip(); + let t: (Vec<_>, Vec<_>, Vec<_>, Vec<_>, Vec<_>, Vec<_>, Vec<_>, Vec<_>, Vec<_>, Vec<_>, Vec<_>, Vec<_>) = [(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)].iter().cloned().multiunzip(); + assert_eq!(t, (vec![0], vec![1], vec![2], vec![3], vec![4], vec![5], vec![6], vec![7], vec![8], vec![9], vec![10], vec![11])); +} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/itoa/benches/bench.rs cargo-0.58.0/vendor/itoa/benches/bench.rs --- cargo-0.57.0+ubuntu/vendor/itoa/benches/bench.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itoa/benches/bench.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,66 +1,40 @@ -#![cfg_attr(feature = "cargo-clippy", allow(cast_lossless))] #![feature(test)] #![allow(non_snake_case)] +#![allow(clippy::cast_lossless)] -extern crate itoa; extern crate test; macro_rules! benches { - ( - $( - $(#[$attr:meta])* - $name:ident($value:expr) - ),* - ) => { - mod bench_itoa_write { + ($($name:ident($value:expr))*) => { + mod bench_itoa_format { use test::{Bencher, black_box}; - $( - $(#[$attr])* - #[bench] - fn $name(b: &mut Bencher) { - use itoa; - - let mut buf = Vec::with_capacity(40); - b.iter(|| { - buf.clear(); - itoa::write(&mut buf, black_box($value)).unwrap() - }); - } - )* - } - - mod bench_itoa_fmt { - use test::{Bencher, black_box}; $( - $(#[$attr])* #[bench] fn $name(b: &mut Bencher) { - use itoa; - - let mut buf = String::with_capacity(40); + let mut buffer = itoa::Buffer::new(); b.iter(|| { - buf.clear(); - itoa::fmt(&mut buf, black_box($value)).unwrap() + let printed = buffer.format(black_box($value)); + black_box(printed); }); } )* } mod bench_std_fmt { + use std::io::Write; use test::{Bencher, black_box}; + $( - $(#[$attr])* #[bench] fn $name(b: &mut Bencher) { - use std::io::Write; - let mut buf = Vec::with_capacity(40); b.iter(|| { buf.clear(); - write!(&mut buf, "{}", black_box($value)).unwrap() + write!(&mut buf, "{}", black_box($value)).unwrap(); + black_box(&buf); }); } )* @@ -69,15 +43,13 @@ } benches! { - bench_u64_0(0u64), - bench_u64_half(::max_value() as u64), - bench_u64_max(::max_value()), - - bench_i16_0(0i16), - bench_i16_min(::min_value()), - - #[cfg(feature = "i128")] - bench_u128_0(0u128), - #[cfg(feature = "i128")] - bench_u128_max(::max_value()) + bench_u64_0(0u64) + bench_u64_half(u32::max_value() as u64) + bench_u64_max(u64::max_value()) + + bench_i16_0(0i16) + bench_i16_min(i16::min_value()) + + bench_u128_0(0u128) + bench_u128_max(u128::max_value()) } diff -Nru cargo-0.57.0+ubuntu/vendor/itoa/.cargo-checksum.json cargo-0.58.0/vendor/itoa/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/itoa/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itoa/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"} \ No newline at end of file +{"files":{},"package":"1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/itoa/Cargo.toml cargo-0.58.0/vendor/itoa/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/itoa/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itoa/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -10,11 +10,13 @@ # See Cargo.toml.orig for the original contents. [package] +edition = "2018" +rust-version = "1.36" name = "itoa" -version = "0.4.8" +version = "1.0.1" authors = ["David Tolnay "] -exclude = ["performance.png"] -description = "Fast functions for printing integer primitives to an io::Write" +exclude = ["performance.png", "chart/**"] +description = "Fast integer primitive to string conversion" documentation = "https://docs.rs/itoa" readme = "README.md" categories = ["value-formatting"] @@ -22,8 +24,3 @@ repository = "https://github.com/dtolnay/itoa" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] - -[features] -default = ["std"] -i128 = [] -std = [] diff -Nru cargo-0.57.0+ubuntu/vendor/itoa/README.md cargo-0.58.0/vendor/itoa/README.md --- cargo-0.57.0+ubuntu/vendor/itoa/README.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itoa/README.md 2022-01-21 02:47:39.000000000 +0000 @@ -6,77 +6,40 @@ [docs.rs](https://docs.rs/itoa) [build status](https://github.com/dtolnay/itoa/actions?query=branch%3Amaster) -This crate provides fast functions for printing integer primitives to an -[`io::Write`] or a [`fmt::Write`]. The implementation comes straight from -[libcore] but avoids the performance penalty of going through -[`fmt::Formatter`]. +This crate provides a fast conversion of integer primitives to decimal strings. +The implementation comes straight from [libcore] but avoids the performance +penalty of going through [`core::fmt::Formatter`]. -See also [`dtoa`] for printing floating point primitives. +See also [`ryu`] for printing floating point primitives. -*Version requirement: rustc 1.0+* +*Version requirement: rustc 1.36+* -[`io::Write`]: https://doc.rust-lang.org/std/io/trait.Write.html -[`fmt::Write`]: https://doc.rust-lang.org/core/fmt/trait.Write.html [libcore]: https://github.com/rust-lang/rust/blob/b8214dc6c6fc20d0a660fb5700dca9ebf51ebe89/src/libcore/fmt/num.rs#L201-L254 -[`fmt::Formatter`]: https://doc.rust-lang.org/std/fmt/struct.Formatter.html -[`dtoa`]: https://github.com/dtolnay/dtoa +[`core::fmt::Formatter`]: https://doc.rust-lang.org/std/fmt/struct.Formatter.html +[`ryu`]: https://github.com/dtolnay/ryu ```toml [dependencies] -itoa = "0.4" +itoa = "1.0" ```
-## Performance (lower is better) - -![performance](https://raw.githubusercontent.com/dtolnay/itoa/master/performance.png) - -
- -## Examples +## Example ```rust -use std::{fmt, io}; - -fn demo_itoa_write() -> io::Result<()> { - // Write to a vector or other io::Write. - let mut buf = Vec::new(); - itoa::write(&mut buf, 128u64)?; - println!("{:?}", buf); - - // Write to a stack buffer. - let mut bytes = [0u8; 20]; - let n = itoa::write(&mut bytes[..], 128u64)?; - println!("{:?}", &bytes[..n]); - - Ok(()) -} - -fn demo_itoa_fmt() -> fmt::Result { - // Write to a string. - let mut s = String::new(); - itoa::fmt(&mut s, 128u64)?; - println!("{}", s); - - Ok(()) +fn main() { + let mut buffer = itoa::Buffer::new(); + let printed = buffer.format(128u64); + assert_eq!(printed, "128"); } ``` -The function signatures are: - -```rust -fn write(writer: W, value: V) -> io::Result; - -fn fmt(writer: W, value: V) -> fmt::Result; -``` +
-where `itoa::Integer` is implemented for i8, u8, i16, u16, i32, u32, i64, u64, -i128, u128, isize and usize. 128-bit integer support requires rustc 1.26+ and -the `i128` feature of this crate enabled. +## Performance (lower is better) -The `write` function is only available when the `std` feature is enabled -(default is enabled). The return value gives the number of bytes written. +![performance](https://raw.githubusercontent.com/dtolnay/itoa/master/performance.png)
diff -Nru cargo-0.57.0+ubuntu/vendor/itoa/src/lib.rs cargo-0.58.0/vendor/itoa/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/itoa/src/lib.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itoa/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -6,98 +6,46 @@ //! //!
//! -//! This crate provides fast functions for printing integer primitives to an -//! [`io::Write`] or a [`fmt::Write`]. The implementation comes straight from -//! [libcore] but avoids the performance penalty of going through -//! [`fmt::Formatter`]. +//! This crate provides a fast conversion of integer primitives to decimal +//! strings. The implementation comes straight from [libcore] but avoids the +//! performance penalty of going through [`core::fmt::Formatter`]. //! -//! See also [`dtoa`] for printing floating point primitives. +//! See also [`ryu`] for printing floating point primitives. //! -//! [`io::Write`]: https://doc.rust-lang.org/std/io/trait.Write.html -//! [`fmt::Write`]: https://doc.rust-lang.org/core/fmt/trait.Write.html //! [libcore]: https://github.com/rust-lang/rust/blob/b8214dc6c6fc20d0a660fb5700dca9ebf51ebe89/src/libcore/fmt/num.rs#L201-L254 -//! [`fmt::Formatter`]: https://doc.rust-lang.org/std/fmt/struct.Formatter.html -//! [`dtoa`]: https://github.com/dtolnay/dtoa +//! [`core::fmt::Formatter`]: https://doc.rust-lang.org/std/fmt/struct.Formatter.html +//! [`ryu`]: https://github.com/dtolnay/ryu //! -//!
-//! -//! # Performance (lower is better) -//! -//! ![performance](https://raw.githubusercontent.com/dtolnay/itoa/master/performance.png) -//! -//!
-//! -//! # Examples -//! -//! ```edition2018 -//! use std::{fmt, io}; -//! -//! fn demo_itoa_write() -> io::Result<()> { -//! // Write to a vector or other io::Write. -//! let mut buf = Vec::new(); -//! itoa::write(&mut buf, 128u64)?; -//! println!("{:?}", buf); -//! -//! // Write to a stack buffer. -//! let mut bytes = [0u8; 20]; -//! let n = itoa::write(&mut bytes[..], 128u64)?; -//! println!("{:?}", &bytes[..n]); +//! # Example //! -//! Ok(()) +//! ``` +//! fn main() { +//! let mut buffer = itoa::Buffer::new(); +//! let printed = buffer.format(128u64); +//! assert_eq!(printed, "128"); //! } +//! ``` //! -//! fn demo_itoa_fmt() -> fmt::Result { -//! // Write to a string. -//! let mut s = String::new(); -//! itoa::fmt(&mut s, 128u64)?; -//! println!("{}", s); +//! # Performance (lower is better) //! -//! Ok(()) -//! } -//! ``` +//! ![performance](https://raw.githubusercontent.com/dtolnay/itoa/master/performance.png) -#![doc(html_root_url = "https://docs.rs/itoa/0.4.8")] -#![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))] -#![cfg_attr( - feature = "cargo-clippy", - allow( - expl_impl_clone_on_copy, - missing_errors_doc, - must_use_candidate, - transmute_ptr_to_ptr - ) +#![doc(html_root_url = "https://docs.rs/itoa/1.0.1")] +#![no_std] +#![allow( + clippy::cast_lossless, + clippy::cast_possible_truncation, + clippy::must_use_candidate, + clippy::unreadable_literal )] -#[cfg(feature = "i128")] mod udiv128; -#[cfg(feature = "std")] -use std::{fmt, io, mem, ptr, slice, str}; - -#[cfg(not(feature = "std"))] -use core::{fmt, mem, ptr, slice, str}; - -/// Write integer to an `io::Write`. -#[cfg(feature = "std")] -#[inline] -pub fn write(mut wr: W, value: V) -> io::Result { - let mut buf = Buffer::new(); - let s = buf.format(value); - match wr.write_all(s.as_bytes()) { - Ok(()) => Ok(s.len()), - Err(e) => Err(e), - } -} - -/// Write integer to an `fmt::Write`. -#[inline] -pub fn fmt(mut wr: W, value: V) -> fmt::Result { - let mut buf = Buffer::new(); - wr.write_str(buf.format(value)) -} +use core::mem::{self, MaybeUninit}; +use core::{ptr, slice, str}; -/// A safe API for formatting integers to text. +/// A correctly sized stack allocation for the formatted integer to be written +/// into. /// /// # Example /// @@ -106,9 +54,8 @@ /// let printed = buffer.format(1234); /// assert_eq!(printed, "1234"); /// ``` -#[derive(Copy)] pub struct Buffer { - bytes: [u8; I128_MAX_LEN], + bytes: [MaybeUninit; I128_MAX_LEN], } impl Default for Buffer { @@ -129,39 +76,35 @@ /// This is a cheap operation; you don't need to worry about reusing buffers /// for efficiency. #[inline] - #[allow(deprecated)] pub fn new() -> Buffer { - Buffer { - bytes: unsafe { mem::uninitialized() }, - } + let bytes = [MaybeUninit::::uninit(); I128_MAX_LEN]; + Buffer { bytes } } - /// Print an integer into this buffer and return a reference to its string representation - /// within the buffer. + /// Print an integer into this buffer and return a reference to its string + /// representation within the buffer. pub fn format(&mut self, i: I) -> &str { - i.write(self) + i.write(unsafe { + &mut *(&mut self.bytes as *mut [MaybeUninit; I128_MAX_LEN] + as *mut ::Buffer) + }) } } -// Seal to prevent downstream implementations of the Integer trait. -mod private { - pub trait Sealed {} -} - -/// An integer that can be formatted by `itoa::write` and `itoa::fmt`. +/// An integer that can be written into an [`itoa::Buffer`][Buffer]. /// /// This trait is sealed and cannot be implemented for types outside of itoa. -pub trait Integer: private::Sealed { - // Not public API. - #[doc(hidden)] - fn write(self, buf: &mut Buffer) -> &str; -} +pub trait Integer: private::Sealed {} -trait IntegerPrivate { - fn write_to(self, buf: &mut B) -> &[u8]; +// Seal to prevent downstream implementations of the Integer trait. +mod private { + pub trait Sealed: Copy { + type Buffer: 'static; + fn write(self, buf: &mut Self::Buffer) -> &str; + } } -const DEC_DIGITS_LUT: &'static [u8] = b"\ +const DEC_DIGITS_LUT: &[u8] = b"\ 0001020304050607080910111213141516171819\ 2021222324252627282930313233343536373839\ 4041424344454647484950515253545556575859\ @@ -170,34 +113,16 @@ // Adaptation of the original implementation at // https://github.com/rust-lang/rust/blob/b8214dc6c6fc20d0a660fb5700dca9ebf51ebe89/src/libcore/fmt/num.rs#L188-L266 -macro_rules! impl_IntegerCommon { - ($max_len:expr, $t:ident) => { - impl Integer for $t { - #[inline] - fn write(self, buf: &mut Buffer) -> &str { - unsafe { - debug_assert!($max_len <= I128_MAX_LEN); - let buf = mem::transmute::<&mut [u8; I128_MAX_LEN], &mut [u8; $max_len]>( - &mut buf.bytes, - ); - let bytes = self.write_to(buf); - str::from_utf8_unchecked(bytes) - } - } - } - - impl private::Sealed for $t {} - }; -} - macro_rules! impl_Integer { ($($max_len:expr => $t:ident),* as $conv_fn:ident) => {$( - impl_IntegerCommon!($max_len, $t); + impl Integer for $t {} + + impl private::Sealed for $t { + type Buffer = [MaybeUninit; $max_len]; - impl IntegerPrivate<[u8; $max_len]> for $t { #[allow(unused_comparisons)] #[inline] - fn write_to(self, buf: &mut [u8; $max_len]) -> &[u8] { + fn write(self, buf: &mut [MaybeUninit; $max_len]) -> &str { let is_nonnegative = self >= 0; let mut n = if is_nonnegative { self as $conv_fn @@ -206,7 +131,7 @@ (!(self as $conv_fn)).wrapping_add(1) }; let mut curr = buf.len() as isize; - let buf_ptr = buf.as_mut_ptr(); + let buf_ptr = buf.as_mut_ptr() as *mut u8; let lut_ptr = DEC_DIGITS_LUT.as_ptr(); unsafe { @@ -253,7 +178,8 @@ } let len = buf.len() - curr as usize; - unsafe { slice::from_raw_parts(buf_ptr.offset(curr), len) } + let bytes = unsafe { slice::from_raw_parts(buf_ptr.offset(curr), len) }; + unsafe { str::from_utf8_unchecked(bytes) } } } )*}; @@ -288,15 +214,16 @@ #[cfg(target_pointer_width = "64")] impl_Integer!(I64_MAX_LEN => isize, U64_MAX_LEN => usize as u64); -#[cfg(all(feature = "i128"))] macro_rules! impl_Integer128 { ($($max_len:expr => $t:ident),*) => {$( - impl_IntegerCommon!($max_len, $t); + impl Integer for $t {} + + impl private::Sealed for $t { + type Buffer = [MaybeUninit; $max_len]; - impl IntegerPrivate<[u8; $max_len]> for $t { #[allow(unused_comparisons)] #[inline] - fn write_to(self, buf: &mut [u8; $max_len]) -> &[u8] { + fn write(self, buf: &mut [MaybeUninit; $max_len]) -> &str { let is_nonnegative = self >= 0; let n = if is_nonnegative { self as u128 @@ -305,13 +232,13 @@ (!(self as u128)).wrapping_add(1) }; let mut curr = buf.len() as isize; - let buf_ptr = buf.as_mut_ptr(); + let buf_ptr = buf.as_mut_ptr() as *mut u8; unsafe { // Divide by 10^19 which is the highest power less than 2^64. let (n, rem) = udiv128::udivmod_1e19(n); - let buf1 = buf_ptr.offset(curr - U64_MAX_LEN as isize) as *mut [u8; U64_MAX_LEN]; - curr -= rem.write_to(&mut *buf1).len() as isize; + let buf1 = buf_ptr.offset(curr - U64_MAX_LEN as isize) as *mut [MaybeUninit; U64_MAX_LEN]; + curr -= rem.write(&mut *buf1).len() as isize; if n != 0 { // Memset the base10 leading zeros of rem. @@ -321,8 +248,8 @@ // Divide by 10^19 again. let (n, rem) = udiv128::udivmod_1e19(n); - let buf2 = buf_ptr.offset(curr - U64_MAX_LEN as isize) as *mut [u8; U64_MAX_LEN]; - curr -= rem.write_to(&mut *buf2).len() as isize; + let buf2 = buf_ptr.offset(curr - U64_MAX_LEN as isize) as *mut [MaybeUninit; U64_MAX_LEN]; + curr -= rem.write(&mut *buf2).len() as isize; if n != 0 { // Memset the leading zeros. @@ -343,16 +270,15 @@ } let len = buf.len() - curr as usize; - slice::from_raw_parts(buf_ptr.offset(curr), len) + let bytes = slice::from_raw_parts(buf_ptr.offset(curr), len); + str::from_utf8_unchecked(bytes) } } } )*}; } -#[cfg(all(feature = "i128"))] const U128_MAX_LEN: usize = 39; const I128_MAX_LEN: usize = 40; -#[cfg(all(feature = "i128"))] impl_Integer128!(I128_MAX_LEN => i128, U128_MAX_LEN => u128); diff -Nru cargo-0.57.0+ubuntu/vendor/itoa/src/udiv128.rs cargo-0.58.0/vendor/itoa/src/udiv128.rs --- cargo-0.57.0+ubuntu/vendor/itoa/src/udiv128.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itoa/src/udiv128.rs 2022-01-21 02:47:39.000000000 +0000 @@ -12,7 +12,7 @@ let high1 = m >> 64; let m_lo = m as u64; - let high2 = x_hi as u128 * y_lo as u128 + m_lo as u128 >> 64; + let high2 = (x_hi as u128 * y_lo as u128 + m_lo as u128) >> 64; x_hi as u128 * y_hi as u128 + high1 + high2 } @@ -32,9 +32,7 @@ let quot = if n < 1 << 83 { ((n >> 19) as u64 / (d >> 19)) as u128 } else { - let factor = - (8507059173023461586_u64 as u128) << 64 | 10779635027931437427 as u128; - u128_mulhi(n, factor) >> 62 + u128_mulhi(n, 156927543384667019095894735580191660403) >> 62 }; let rem = (n - quot * d as u128) as u64; diff -Nru cargo-0.57.0+ubuntu/vendor/itoa/tests/test.rs cargo-0.58.0/vendor/itoa/tests/test.rs --- cargo-0.57.0+ubuntu/vendor/itoa/tests/test.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/itoa/tests/test.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,28 +1,13 @@ -#![cfg_attr(feature = "cargo-clippy", allow(cast_lossless, string_lit_as_bytes))] #![allow(non_snake_case)] - -extern crate itoa; +#![allow(clippy::cast_lossless)] macro_rules! test { - ( - $( - $(#[$attr:meta])* - $name:ident($value:expr, $expected:expr) - ),* - ) => { + ($($name:ident($value:expr, $expected:expr))*) => { $( - $(#[$attr])* #[test] fn $name() { - #[cfg(feature = "std")] - { - let mut buf = [b'\0'; 40]; - let len = itoa::write(&mut buf[..], $value).unwrap(); - assert_eq!(&buf[0..len], $expected.as_bytes()); - } - - let mut s = String::new(); - itoa::fmt(&mut s, $value).unwrap(); + let mut buffer = itoa::Buffer::new(); + let s = buffer.format($value); assert_eq!(s, $expected); } )* @@ -30,18 +15,15 @@ } test! { - test_u64_0(0u64, "0"), - test_u64_half(::max_value() as u64, "4294967295"), - test_u64_max(::max_value(), "18446744073709551615"), - test_i64_min(::min_value(), "-9223372036854775808"), - - test_i16_0(0i16, "0"), - test_i16_min(::min_value(), "-32768"), - - #[cfg(feature = "i128")] - test_u128_0(0u128, "0"), - #[cfg(feature = "i128")] - test_u128_max(::max_value(), "340282366920938463463374607431768211455"), - #[cfg(feature = "i128")] - test_i128_min(::min_value(), "-170141183460469231731687303715884105728") + test_u64_0(0u64, "0") + test_u64_half(u32::max_value() as u64, "4294967295") + test_u64_max(u64::max_value(), "18446744073709551615") + test_i64_min(i64::min_value(), "-9223372036854775808") + + test_i16_0(0i16, "0") + test_i16_min(i16::min_value(), "-32768") + + test_u128_0(0u128, "0") + test_u128_max(u128::max_value(), "340282366920938463463374607431768211455") + test_i128_min(i128::min_value(), "-170141183460469231731687303715884105728") } diff -Nru cargo-0.57.0+ubuntu/vendor/libc/build.rs cargo-0.58.0/vendor/libc/build.rs --- cargo-0.57.0+ubuntu/vendor/libc/build.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/build.rs 2022-01-21 02:47:39.000000000 +0000 @@ -31,6 +31,7 @@ Some(11) if libc_ci => println!("cargo:rustc-cfg=freebsd11"), Some(12) if libc_ci => println!("cargo:rustc-cfg=freebsd12"), Some(13) if libc_ci => println!("cargo:rustc-cfg=freebsd13"), + Some(14) if libc_ci => println!("cargo:rustc-cfg=freebsd14"), Some(_) | None => println!("cargo:rustc-cfg=freebsd11"), } @@ -72,6 +73,15 @@ println!("cargo:rustc-cfg=libc_cfg_target_vendor"); } + // Rust >= 1.40 supports #[non_exhaustive]. + if rustc_minor_ver >= 40 || rustc_dep_of_std { + println!("cargo:rustc-cfg=libc_non_exhaustive"); + } + + if rustc_minor_ver >= 51 || rustc_dep_of_std { + println!("cargo:rustc-cfg=libc_ptr_addr_of"); + } + // #[thread_local] is currently unstable if rustc_dep_of_std { println!("cargo:rustc-cfg=libc_thread_local"); @@ -141,6 +151,7 @@ s if s.starts_with("11") => Some(11), s if s.starts_with("12") => Some(12), s if s.starts_with("13") => Some(13), + s if s.starts_with("14") => Some(14), _ => None, } } diff -Nru cargo-0.57.0+ubuntu/vendor/libc/.cargo-checksum.json cargo-0.58.0/vendor/libc/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/libc/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"869d572136620d55835903746bcb5cdc54cb2851fd0aeec53220b4bb65ef3013"} \ No newline at end of file +{"files":{},"package":"eef78b64d87775463c549fbd80e19249ef436ea3bf1de2a1eb7e717ec7fab1e9"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/libc/Cargo.toml cargo-0.58.0/vendor/libc/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/libc/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -11,7 +11,7 @@ [package] name = "libc" -version = "0.2.105" +version = "0.2.113" authors = ["The Rust Project Developers"] build = "build.rs" exclude = ["/ci/*", "/.github/*", "/.cirrus.yml", "/triagebot.toml"] diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/lib.rs cargo-0.58.0/vendor/libc/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/lib.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -26,7 +26,7 @@ #![cfg_attr(feature = "rustc-dep-of-std", no_core)] #![cfg_attr( any(feature = "rustc-dep-of-std", target_os = "redox"), - feature(static_nobundle) + feature(static_nobundle, native_link_modifiers, native_link_modifiers_bundle) )] #![cfg_attr(libc_const_extern_fn, feature(const_extern_fn))] @@ -63,7 +63,7 @@ use core::clone::Clone; #[doc(hidden)] #[allow(unused_imports)] - use core::marker::Copy; + use core::marker::{Copy, Send, Sync}; #[doc(hidden)] #[allow(unused_imports)] use core::option::Option; @@ -85,7 +85,7 @@ pub use core::clone::Clone; #[doc(hidden)] #[allow(unused_imports)] - pub use core::marker::Copy; + pub use core::marker::{Copy, Send, Sync}; #[doc(hidden)] #[allow(unused_imports)] pub use core::option::Option; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/macros.rs cargo-0.58.0/vendor/libc/src/macros.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/macros.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/macros.rs 2022-01-21 02:47:39.000000000 +0000 @@ -307,13 +307,13 @@ )*) } -// This macro is used to deprecate items that should be accessed via the mach crate +// This macro is used to deprecate items that should be accessed via the mach2 crate #[allow(unused_macros)] macro_rules! deprecated_mach { (pub const $id:ident: $ty:ty = $expr:expr;) => { #[deprecated( since = "0.2.55", - note = "Use the `mach` crate instead", + note = "Use the `mach2` crate instead", )] #[allow(deprecated)] pub const $id: $ty = $expr; @@ -328,7 +328,7 @@ (pub type $id:ident = $ty:ty;) => { #[deprecated( since = "0.2.55", - note = "Use the `mach` crate instead", + note = "Use the `mach2` crate instead", )] #[allow(deprecated)] pub type $id = $ty; @@ -341,3 +341,19 @@ )* } } + +#[allow(unused_macros)] +#[cfg(not(libc_ptr_addr_of))] +macro_rules! ptr_addr_of { + ($place:expr) => { + &$place + }; +} + +#[allow(unused_macros)] +#[cfg(libc_ptr_addr_of)] +macro_rules! ptr_addr_of { + ($place:expr) => { + ::core::ptr::addr_of!($place) + }; +} diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/solid/aarch64.rs cargo-0.58.0/vendor/libc/src/solid/aarch64.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/solid/aarch64.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/solid/aarch64.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,4 +1,4 @@ pub type c_char = i8; -pub type wchar_t = i16; +pub type wchar_t = u32; pub type c_long = i64; pub type c_ulong = u64; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/solid/arm.rs cargo-0.58.0/vendor/libc/src/solid/arm.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/solid/arm.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/solid/arm.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,4 +1,4 @@ pub type c_char = i8; -pub type wchar_t = i16; +pub type wchar_t = u32; pub type c_long = i32; pub type c_ulong = u32; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/apple/b64/x86_64/mod.rs cargo-0.58.0/vendor/libc/src/unix/bsd/apple/b64/x86_64/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/apple/b64/x86_64/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/apple/b64/x86_64/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -110,62 +110,62 @@ pub struct malloc_zone_t { _reserved1: *mut ::c_void, _reserved2: *mut ::c_void, - pub size: Option ::size_t>, - pub malloc: Option *mut ::c_void>, - pub calloc: Option *mut ::c_void>, - pub valloc: Option *mut ::c_void>, - pub free: Option, - pub realloc: Option *mut ::c_void>, - pub destroy: Option, + pub destroy: ::Option, pub zone_name: *const ::c_char, - pub batch_malloc: Option ::c_uint>, - pub batch_free: Option, pub introspect: *mut malloc_introspection_t, pub version: ::c_uint, - pub memalign: Option *mut ::c_void>, - pub free_definite_size: Option, - pub pressure_relief: Option ::size_t>, - pub claimed_address: Option ::boolean_t>, diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/apple/mod.rs cargo-0.58.0/vendor/libc/src/unix/bsd/apple/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/apple/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/apple/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -215,6 +215,12 @@ pub imr_interface: in_addr, } + pub struct ip_mreqn { + pub imr_multiaddr: in_addr, + pub imr_address: in_addr, + pub imr_ifindex: ::c_int, + } + pub struct aiocb { pub aio_fildes: ::c_int, pub aio_offset: ::off_t, @@ -254,7 +260,7 @@ #[deprecated( since = "0.2.55", - note = "Use the `mach` crate instead", + note = "Use the `mach2` crate instead", )] pub struct mach_timebase_info { pub numer: u32, @@ -522,7 +528,7 @@ #[deprecated( since = "0.2.55", - note = "Use the `mach` crate instead", + note = "Use the `mach2` crate instead", )] pub struct mach_header { pub magic: u32, @@ -536,7 +542,7 @@ #[deprecated( since = "0.2.55", - note = "Use the `mach` crate instead", + note = "Use the `mach2` crate instead", )] pub struct mach_header_64 { pub magic: u32, @@ -948,6 +954,11 @@ pub ri_interval_max_phys_footprint: u64, pub ri_runnable_time: u64, } + + pub struct image_offset { + pub uuid: ::uuid_t, + pub offset: u32, + } } s_no_extra_traits! { @@ -1217,6 +1228,13 @@ pub policy: ::policy_t, pub suspend_count: integer_t, } + + #[cfg_attr(libc_packedN, repr(packed(4)))] + pub struct log2phys { + pub l2p_flags: ::c_uint, + pub l2p_contigbytes: ::off_t, + pub l2p_devoffset: ::off_t, + } } impl siginfo_t { @@ -2467,6 +2485,37 @@ suspend_count.hash(state); } } + + impl PartialEq for log2phys { + fn eq(&self, other: &log2phys) -> bool { + self.l2p_flags == other.l2p_flags + && self.l2p_contigbytes == other.l2p_contigbytes + && self.l2p_devoffset == other.l2p_devoffset + } + } + impl Eq for log2phys {} + impl ::fmt::Debug for log2phys { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let l2p_flags = self.l2p_flags; + let l2p_contigbytes = self.l2p_contigbytes; + let l2p_devoffset = self.l2p_devoffset; + f.debug_struct("log2phys") + .field("l2p_flags", &l2p_flags) + .field("l2p_contigbytes", &l2p_contigbytes) + .field("l2p_devoffset", &l2p_devoffset) + .finish() + } + } + impl ::hash::Hash for log2phys { + fn hash(&self, state: &mut H) { + let l2p_flags = self.l2p_flags; + let l2p_contigbytes = self.l2p_contigbytes; + let l2p_devoffset = self.l2p_devoffset; + l2p_flags.hash(state); + l2p_contigbytes.hash(state); + l2p_devoffset.hash(state); + } + } } } @@ -2943,12 +2992,16 @@ pub const F_RDADVISE: ::c_int = 44; pub const F_RDAHEAD: ::c_int = 45; pub const F_NOCACHE: ::c_int = 48; +pub const F_LOG2PHYS: ::c_int = 49; pub const F_GETPATH: ::c_int = 50; pub const F_FULLFSYNC: ::c_int = 51; pub const F_FREEZE_FS: ::c_int = 53; pub const F_THAW_FS: ::c_int = 54; pub const F_GLOBAL_NOCACHE: ::c_int = 55; pub const F_NODIRECT: ::c_int = 62; +pub const F_LOG2PHYS_EXT: ::c_int = 65; +pub const F_BARRIERFSYNC: ::c_int = 85; +pub const F_GETPATH_NOFIRMLINK: ::c_int = 102; pub const F_ALLOCATECONTIG: ::c_uint = 0x02; pub const F_ALLOCATEALL: ::c_uint = 0x04; @@ -3476,6 +3529,7 @@ pub const IP_BOUND_IF: ::c_int = 25; pub const IP_PKTINFO: ::c_int = 26; pub const IP_RECVTOS: ::c_int = 27; +pub const IP_DONTFRAG: ::c_int = 28; pub const IPV6_JOIN_GROUP: ::c_int = 12; pub const IPV6_LEAVE_GROUP: ::c_int = 13; pub const IPV6_CHECKSUM: ::c_int = 26; @@ -3484,6 +3538,7 @@ pub const IPV6_PKTINFO: ::c_int = 46; pub const IPV6_HOPLIMIT: ::c_int = 47; pub const IPV6_RECVPKTINFO: ::c_int = 61; +pub const IPV6_DONTFRAG: ::c_int = 62; pub const TCP_NOPUSH: ::c_int = 4; pub const TCP_NOOPT: ::c_int = 8; @@ -4790,9 +4845,9 @@ newp: *mut ::c_void, newlen: ::size_t, ) -> ::c_int; - #[deprecated(since = "0.2.55", note = "Use the mach crate")] + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn mach_absolute_time() -> u64; - #[deprecated(since = "0.2.55", note = "Use the mach crate")] + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] #[allow(deprecated)] pub fn mach_timebase_info(info: *mut ::mach_timebase_info) -> ::c_int; pub fn mach_host_self() -> mach_port_t; @@ -4901,6 +4956,23 @@ ) -> kern_return_t; pub fn __error() -> *mut ::c_int; pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int; + pub fn backtrace_symbols(addrs: *const *mut ::c_void, sz: ::c_int) -> *mut *mut ::c_char; + pub fn backtrace_symbols_fd(addrs: *const *mut ::c_void, sz: ::c_int, fd: ::c_int); + pub fn backtrace_from_fp( + startfp: *mut ::c_void, + array: *mut *mut ::c_void, + size: ::c_int, + ) -> ::c_int; + pub fn backtrace_image_offsets( + array: *const *mut ::c_void, + image_offsets: *mut image_offset, + size: ::c_int, + ); + pub fn backtrace_async( + array: *mut *mut ::c_void, + length: ::size_t, + task_id: *mut u32, + ) -> ::size_t; #[cfg_attr( all(target_os = "macos", not(target_arch = "aarch64")), link_name = "statfs$INODE64" @@ -4934,6 +5006,12 @@ flags: ::c_int, data: *mut ::c_void, ) -> ::c_int; + pub fn fmount( + src: *const ::c_char, + fd: ::c_int, + flags: ::c_int, + data: *mut ::c_void, + ) -> ::c_int; pub fn ptrace(request: ::c_int, pid: ::pid_t, addr: *mut ::c_char, data: ::c_int) -> ::c_int; pub fn quotactl( special: *const ::c_char, @@ -5056,14 +5134,14 @@ pub fn brk(addr: *const ::c_void) -> *mut ::c_void; pub fn sbrk(increment: ::c_int) -> *mut ::c_void; pub fn settimeofday(tv: *const ::timeval, tz: *const ::timezone) -> ::c_int; - #[deprecated(since = "0.2.55", note = "Use the mach crate")] + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn _dyld_image_count() -> u32; - #[deprecated(since = "0.2.55", note = "Use the mach crate")] + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] #[allow(deprecated)] pub fn _dyld_get_image_header(image_index: u32) -> *const mach_header; - #[deprecated(since = "0.2.55", note = "Use the mach crate")] + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn _dyld_get_image_vmaddr_slide(image_index: u32) -> ::intptr_t; - #[deprecated(since = "0.2.55", note = "Use the mach crate")] + #[deprecated(since = "0.2.55", note = "Use the `mach2` crate instead")] pub fn _dyld_get_image_name(image_index: u32) -> *const ::c_char; pub fn posix_spawn( @@ -5110,6 +5188,20 @@ flags: *mut ::pid_t, ) -> ::c_int; pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: ::pid_t) -> ::c_int; + pub fn posix_spawnattr_setarchpref_np( + attr: *mut posix_spawnattr_t, + count: ::size_t, + pref: *mut ::cpu_type_t, + subpref: *mut ::cpu_subtype_t, + ocount: *mut ::size_t, + ) -> ::c_int; + pub fn posix_spawnattr_getarchpref_np( + attr: *const posix_spawnattr_t, + count: ::size_t, + pref: *mut ::cpu_type_t, + subpref: *mut ::cpu_subtype_t, + ocount: *mut ::size_t, + ) -> ::c_int; pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> ::c_int; pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> ::c_int; @@ -5183,6 +5275,14 @@ pub fn memset_pattern8(b: *mut ::c_void, pattern8: *const ::c_void, len: ::size_t); pub fn memset_pattern16(b: *mut ::c_void, pattern16: *const ::c_void, len: ::size_t); + // Inherited from BSD but available from Big Sur only + pub fn strtonum( + __numstr: *const ::c_char, + __minval: ::c_longlong, + __maxval: ::c_longlong, + errstrp: *mut *const ::c_char, + ) -> ::c_longlong; + pub fn mstats() -> mstats; pub fn malloc_printf(format: *const ::c_char, ...); pub fn malloc_zone_check(zone: *mut ::malloc_zone_t) -> ::boolean_t; @@ -5344,6 +5444,7 @@ cfg_if! { if #[cfg(target_os = "macos")] { extern "C" { + pub fn clock_settime(clock_id: ::clockid_t, tp: *const ::timespec) -> ::c_int; pub fn memmem( haystack: *const ::c_void, haystacklen: ::size_t, diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -123,11 +123,11 @@ pub st_ctime_nsec: ::c_long, pub st_size: ::off_t, pub st_blocks: i64, - pub st_blksize: u32, + pub __old_st_blksize: u32, pub st_flags: u32, pub st_gen: u32, pub st_lspare: i32, - pub st_qspare1: i64, + pub st_blksize: i64, pub st_qspare2: i64, } @@ -210,6 +210,54 @@ pub shm_ctime: ::time_t, shm_internal: *mut ::c_void, } + + pub struct kinfo_file { + pub f_size: ::size_t, + pub f_pid: ::pid_t, + pub f_uid: ::uid_t, + pub f_fd: ::c_int, + pub f_file: *mut ::c_void, + pub f_type: ::c_short, + pub f_count: ::c_int, + pub f_msgcount: ::c_int, + pub f_offset: ::off_t, + pub f_data: *mut ::c_void, + pub f_flag: ::c_uint, + } + + pub struct kinfo_cputime { + pub cp_user: u64, + pub cp_nice: u64, + pub cp_sys: u64, + pub cp_intr: u64, + pub cp_idel: u64, + cp_unused01: u64, + cp_unused02: u64, + pub cp_sample_pc: u64, + pub cp_sample_sp: u64, + pub cp_msg: [::c_char; 32], + } + + pub struct cpuctl_msr_args_t { + pub msr: ::c_int, + pub data: u64, + } + + pub struct cpuctl_cpuid_args_t { + pub level: ::c_int, + pub data: [u32; 4], + } + + pub struct cpuctl_cpuid_count_args_t { + pub level: ::c_int, + pub level_type: ::c_int, + pub data: [u32; 4], + } + + pub struct cpuctl_update_args_t { + pub data: *mut ::c_void, + pub size: ::size_t, + } } s_no_extra_traits! { @@ -701,6 +749,10 @@ pub const RAND_MAX: ::c_int = 0x7fff_ffff; pub const PTHREAD_STACK_MIN: ::size_t = 16384; pub const SIGSTKSZ: ::size_t = 40960; +pub const SIGCKPT: ::c_int = 33; +pub const SIGCKPTEXIT: ::c_int = 34; +pub const CKPT_FREEZE: ::c_int = 0x1; +pub const CKPT_THAW: ::c_int = 0x2; pub const MADV_INVAL: ::c_int = 10; pub const MADV_SETMAP: ::c_int = 11; pub const O_CLOEXEC: ::c_int = 0x00020000; @@ -708,6 +760,7 @@ pub const F_GETLK: ::c_int = 7; pub const F_SETLK: ::c_int = 8; pub const F_SETLKW: ::c_int = 9; +pub const F_GETPATH: ::c_int = 19; pub const ENOMEDIUM: ::c_int = 93; pub const EASYNC: ::c_int = 99; pub const ELAST: ::c_int = 99; @@ -715,9 +768,6 @@ #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] pub const RLIM_NLIMITS: ::rlim_t = 12; -#[deprecated(since = "0.2.105", note = "Only exists on FreeBSD, not DragonFly BSD")] -pub const XU_NGROUPS: ::c_int = 16; - pub const Q_GETQUOTA: ::c_int = 0x300; pub const Q_SETQUOTA: ::c_int = 0x400; @@ -853,6 +903,14 @@ pub const CTL_P1003_1B_TIMER_MAX: ::c_int = 25; pub const CTL_P1003_1B_MAXID: ::c_int = 26; +pub const CPUCTL_RSMSR: ::c_int = 0xc0106301; +pub const CPUCTL_WRMSR: ::c_int = 0xc0106302; +pub const CPUCTL_CPUID: ::c_int = 0xc0106303; +pub const CPUCTL_UPDATE: ::c_int = 0xc0106304; +pub const CPUCTL_MSRSBIT: ::c_int = 0xc0106305; +pub const CPUCTL_MSRCBIT: ::c_int = 0xc0106306; +pub const CPUCTL_CPUID_COUNT: ::c_int = 0xc0106307; + pub const EVFILT_READ: i16 = -1; pub const EVFILT_WRITE: i16 = -2; pub const EVFILT_AIO: i16 = -3; @@ -878,6 +936,8 @@ pub const EV_EOF: u16 = 0x8000; pub const EV_SYSFLAGS: u16 = 0xf000; +pub const FIODNAME: ::c_ulong = 0x80106678; + pub const NOTE_TRIGGER: u32 = 0x01000000; pub const NOTE_FFNOP: u32 = 0x00000000; pub const NOTE_FFAND: u32 = 0x40000000; @@ -905,6 +965,7 @@ pub const SO_SNDSPACE: ::c_int = 0x100a; pub const SO_CPUHINT: ::c_int = 0x1030; +pub const SO_PASSCRED: ::c_int = 0x4000; pub const PT_FIRSTMACH: ::c_int = 32; @@ -1226,11 +1287,11 @@ | LC_NUMERIC_MASK | LC_TIME_MASK; -pub const TIOCSIG: ::c_uint = 0x2000745f; +pub const TIOCSIG: ::c_ulong = 0x2000745f; pub const BTUARTDISC: ::c_int = 0x7; -pub const TIOCDCDTIMESTAMP: ::c_uint = 0x40107458; -pub const TIOCISPTMASTER: ::c_uint = 0x20007455; -pub const TIOCMODG: ::c_uint = 0x40047403; +pub const TIOCDCDTIMESTAMP: ::c_ulong = 0x40107458; +pub const TIOCISPTMASTER: ::c_ulong = 0x20007455; +pub const TIOCMODG: ::c_ulong = 0x40047403; pub const TIOCMODS: ::c_ulong = 0x80047404; pub const TIOCREMOTE: ::c_ulong = 0x80047469; @@ -1283,9 +1344,11 @@ pub const UTIME_OMIT: c_long = -2; pub const UTIME_NOW: c_long = -1; +pub const MINCORE_SUPER: ::c_int = 0x20; + const_fn! { {const} fn _CMSG_ALIGN(n: usize) -> usize { - (n + 3) & !3 + (n + ::mem::size_of::<::c_long>()) & !::mem::size_of::<::c_long>() } } @@ -1359,6 +1422,13 @@ pub fn aio_waitcomplete(iocbp: *mut *mut aiocb, timeout: *mut ::timespec) -> ::c_int; + pub fn devname_r( + dev: ::dev_t, + mode: ::mode_t, + buf: *mut ::c_char, + len: ::size_t, + ) -> *mut ::c_char; + pub fn waitid( idtype: idtype_t, id: ::id_t, @@ -1407,6 +1477,8 @@ pub fn updlastlogx(fname: *const ::c_char, uid: ::uid_t, ll: *mut lastlogx) -> ::c_int; pub fn getutxuser(name: *const ::c_char) -> utmpx; pub fn utmpxname(file: *const ::c_char) -> ::c_int; + + pub fn sys_checkpoint(tpe: ::c_int, fd: ::c_int, pid: ::pid_t, retval: ::c_int) -> ::c_int; } #[link(name = "rt")] diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -29,6 +29,186 @@ pub shm_dtime: ::time_t, pub shm_ctime: ::time_t, } + + pub struct kinfo_proc { + /// Size of this structure. + pub ki_structsize: ::c_int, + /// Reserved: layout identifier. + pub ki_layout: ::c_int, + /// Address of command arguments. + pub ki_args: *mut ::pargs, + // This is normally "struct proc". + /// Address of proc. + pub ki_paddr: *mut ::c_void, + // This is normally "struct user". + /// Kernel virtual address of u-area. + pub ki_addr: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to trace file. + pub ki_tracep: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to executable file. + pub ki_textvp: *mut ::c_void, + // This is normally "struct filedesc". + /// Pointer to open file info. + pub ki_fd: *mut ::c_void, + // This is normally "struct vmspace". + /// Pointer to kernel vmspace struct. + pub ki_vmspace: *mut ::c_void, + /// Sleep address. + pub ki_wchan: *mut ::c_void, + /// Process identifier. + pub ki_pid: ::pid_t, + /// Parent process ID. + pub ki_ppid: ::pid_t, + /// Process group ID. + pub ki_pgid: ::pid_t, + /// tty process group ID. + pub ki_tpgid: ::pid_t, + /// Process session ID. + pub ki_sid: ::pid_t, + /// Terminal session ID. + pub ki_tsid: ::pid_t, + /// Job control counter. + pub ki_jobc: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short1: ::c_short, + /// Controlling tty dev. + pub ki_tdev: ::dev_t, + /// Signals arrived but not delivered. + pub ki_siglist: ::sigset_t, + /// Current signal mask. + pub ki_sigmask: ::sigset_t, + /// Signals being ignored. + pub ki_sigignore: ::sigset_t, + /// Signals being caught by user. + pub ki_sigcatch: ::sigset_t, + /// Effective user ID. + pub ki_uid: ::uid_t, + /// Real user ID. + pub ki_ruid: ::uid_t, + /// Saved effective user ID. + pub ki_svuid: ::uid_t, + /// Real group ID. + pub ki_rgid: ::gid_t, + /// Saved effective group ID. + pub ki_svgid: ::gid_t, + /// Number of groups. + pub ki_ngroups: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short2: ::c_short, + /// Groups. + pub ki_groups: [::gid_t; ::KI_NGROUPS], + /// Virtual size. + pub ki_size: ::vm_size_t, + /// Current resident set size in pages. + pub ki_rssize: ::segsz_t, + /// Resident set size before last swap. + pub ki_swrss: ::segsz_t, + /// Text size (pages) XXX. + pub ki_tsize: ::segsz_t, + /// Data size (pages) XXX. + pub ki_dsize: ::segsz_t, + /// Stack size (pages). + pub ki_ssize: ::segsz_t, + /// Exit status for wait & stop signal. + pub ki_xstat: ::u_short, + /// Accounting flags. + pub ki_acflag: ::u_short, + /// %cpu for process during `ki_swtime`. + pub ki_pctcpu: ::fixpt_t, + /// Time averaged value of `ki_cpticks`. + pub ki_estcpu: ::u_int, + /// Time since last blocked. + pub ki_slptime: ::u_int, + /// Time swapped in or out. + pub ki_swtime: ::u_int, + /// Number of copy-on-write faults. + pub ki_cow: ::u_int, + /// Real time in microsec. + pub ki_runtime: u64, + /// Starting time. + pub ki_start: ::timeval, + /// Time used by process children. + pub ki_childtime: ::timeval, + /// P_* flags. + pub ki_flag: ::c_long, + /// KI_* flags (below). + pub ki_kiflag: ::c_long, + /// Kernel trace points. + pub ki_traceflag: ::c_int, + /// S* process status. + pub ki_stat: ::c_char, + /// Process "nice" value. + pub ki_nice: i8, // signed char + /// Process lock (prevent swap) count. + pub ki_lock: ::c_char, + /// Run queue index. + pub ki_rqindex: ::c_char, + /// Which cpu we are on. + pub ki_oncpu_old: ::c_uchar, + /// Last cpu we were on. + pub ki_lastcpu_old: ::c_uchar, + /// Thread name. + pub ki_tdname: [::c_char; ::TDNAMLEN + 1], + /// Wchan message. + pub ki_wmesg: [::c_char; ::WMESGLEN + 1], + /// Setlogin name. + pub ki_login: [::c_char; ::LOGNAMELEN + 1], + /// Lock name. + pub ki_lockname: [::c_char; ::LOCKNAMELEN + 1], + /// Command name. + pub ki_comm: [::c_char; ::COMMLEN + 1], + /// Emulation name. + pub ki_emul: [::c_char; ::KI_EMULNAMELEN + 1], + /// Login class. + pub ki_loginclass: [::c_char; ::LOGINCLASSLEN + 1], + /// More thread name. + pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], + /// Spare string space. + pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq + /// Spare room for growth. + pub ki_spareints: [::c_int; ::KI_NSPARE_INT], + /// Which cpu we are on. + pub ki_oncpu: ::c_int, + /// Last cpu we were on. + pub ki_lastcpu: ::c_int, + /// PID of tracing process. + pub ki_tracer: ::c_int, + /// P2_* flags. + pub ki_flag2: ::c_int, + /// Default FIB number. + pub ki_fibnum: ::c_int, + /// Credential flags. + pub ki_cr_flags: ::u_int, + /// Process jail ID. + pub ki_jid: ::c_int, + /// Number of threads in total. + pub ki_numthreads: ::c_int, + /// Thread ID. + pub ki_tid: ::lwpid_t, + /// Process priority. + pub ki_pri: ::priority, + /// Process rusage statistics. + pub ki_rusage: ::rusage, + /// rusage of children processes. + pub ki_rusage_ch: ::rusage, + // This is normally "struct pcb". + /// Kernel virtual addr of pcb. + pub ki_pcb: *mut ::c_void, + /// Kernel virtual addr of stack. + pub ki_kstack: *mut ::c_void, + /// User convenience pointer. + pub ki_udata: *mut ::c_void, + // This is normally "struct thread". + pub ki_tdaddr: *mut ::c_void, + pub ki_spareptrs: [*mut ::c_void; ::KI_NSPARE_PTR], + pub ki_sparelongs: [::c_long; ::KI_NSPARE_LONG], + /// PS_* flags. + pub ki_sflag: ::c_long, + /// kthread flag. + pub ki_tdflags: ::c_long, + } } s_no_extra_traits! { @@ -67,6 +247,17 @@ // Array length changed from 88 to 1024 in FreeBSD 12: pub f_mntonname: [::c_char; 88], } + + pub struct vnstat { + pub vn_fileid: u64, + pub vn_size: u64, + pub vn_mntdir: *mut ::c_char, + pub vn_dev: u32, + pub vn_fsid: u32, + pub vn_type: ::c_int, + pub vn_mode: u16, + pub vn_devname: [::c_char; ::SPECNAMELEN as usize + 1], + } } cfg_if! { @@ -186,12 +377,62 @@ self.d_name[..self.d_namlen as _].hash(state); } } + + impl PartialEq for vnstat { + fn eq(&self, other: &vnstat) -> bool { + let self_vn_devname: &[::c_char] = &self.vn_devname; + let other_vn_devname: &[::c_char] = &other.vn_devname; + + self.vn_fileid == other.vn_fileid && + self.vn_size == other.vn_size && + self.vn_mntdir == other.vn_mntdir && + self.vn_dev == other.vn_dev && + self.vn_fsid == other.vn_fsid && + self.vn_type == other.vn_type && + self.vn_mode == other.vn_mode && + self_vn_devname == other_vn_devname + } + } + impl Eq for vnstat {} + impl ::fmt::Debug for vnstat { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let self_vn_devname: &[::c_char] = &self.vn_devname; + + f.debug_struct("vnstat") + .field("vn_fileid", &self.vn_fileid) + .field("vn_size", &self.vn_size) + .field("vn_mntdir", &self.vn_mntdir) + .field("vn_dev", &self.vn_dev) + .field("vn_fsid", &self.vn_fsid) + .field("vn_type", &self.vn_type) + .field("vn_mode", &self.vn_mode) + .field("vn_devname", &self_vn_devname) + .finish() + } + } + impl ::hash::Hash for vnstat { + fn hash(&self, state: &mut H) { + let self_vn_devname: &[::c_char] = &self.vn_devname; + + self.vn_fileid.hash(state); + self.vn_size.hash(state); + self.vn_mntdir.hash(state); + self.vn_dev.hash(state); + self.vn_fsid.hash(state); + self.vn_type.hash(state); + self.vn_mode.hash(state); + self_vn_devname.hash(state); + } + } } } pub const ELAST: ::c_int = 96; pub const RAND_MAX: ::c_int = 0x7fff_fffd; pub const KI_NSPARE_PTR: usize = 6; +pub const MINCORE_SUPER: ::c_int = 0x20; +/// max length of devicename +pub const SPECNAMELEN: ::c_int = 63; extern "C" { // Return type ::c_int was removed in FreeBSD 12 @@ -218,7 +459,8 @@ cfg_if! { if #[cfg(any(target_arch = "x86_64", - target_arch = "aarch64"))] { + target_arch = "aarch64", + target_arch = "riscv64"))] { mod b64; pub use self::b64::*; } diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -36,6 +36,188 @@ pub offset: ::u_long, pub len: ::size_t, } + + pub struct kinfo_proc { + /// Size of this structure. + pub ki_structsize: ::c_int, + /// Reserved: layout identifier. + pub ki_layout: ::c_int, + /// Address of command arguments. + pub ki_args: *mut ::pargs, + // This is normally "struct proc". + /// Address of proc. + pub ki_paddr: *mut ::c_void, + // This is normally "struct user". + /// Kernel virtual address of u-area. + pub ki_addr: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to trace file. + pub ki_tracep: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to executable file. + pub ki_textvp: *mut ::c_void, + // This is normally "struct filedesc". + /// Pointer to open file info. + pub ki_fd: *mut ::c_void, + // This is normally "struct vmspace". + /// Pointer to kernel vmspace struct. + pub ki_vmspace: *mut ::c_void, + /// Sleep address. + pub ki_wchan: *mut ::c_void, + /// Process identifier. + pub ki_pid: ::pid_t, + /// Parent process ID. + pub ki_ppid: ::pid_t, + /// Process group ID. + pub ki_pgid: ::pid_t, + /// tty process group ID. + pub ki_tpgid: ::pid_t, + /// Process session ID. + pub ki_sid: ::pid_t, + /// Terminal session ID. + pub ki_tsid: ::pid_t, + /// Job control counter. + pub ki_jobc: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short1: ::c_short, + /// Controlling tty dev. + pub ki_tdev_freebsd11: u32, + /// Signals arrived but not delivered. + pub ki_siglist: ::sigset_t, + /// Current signal mask. + pub ki_sigmask: ::sigset_t, + /// Signals being ignored. + pub ki_sigignore: ::sigset_t, + /// Signals being caught by user. + pub ki_sigcatch: ::sigset_t, + /// Effective user ID. + pub ki_uid: ::uid_t, + /// Real user ID. + pub ki_ruid: ::uid_t, + /// Saved effective user ID. + pub ki_svuid: ::uid_t, + /// Real group ID. + pub ki_rgid: ::gid_t, + /// Saved effective group ID. + pub ki_svgid: ::gid_t, + /// Number of groups. + pub ki_ngroups: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short2: ::c_short, + /// Groups. + pub ki_groups: [::gid_t; ::KI_NGROUPS], + /// Virtual size. + pub ki_size: ::vm_size_t, + /// Current resident set size in pages. + pub ki_rssize: ::segsz_t, + /// Resident set size before last swap. + pub ki_swrss: ::segsz_t, + /// Text size (pages) XXX. + pub ki_tsize: ::segsz_t, + /// Data size (pages) XXX. + pub ki_dsize: ::segsz_t, + /// Stack size (pages). + pub ki_ssize: ::segsz_t, + /// Exit status for wait & stop signal. + pub ki_xstat: ::u_short, + /// Accounting flags. + pub ki_acflag: ::u_short, + /// %cpu for process during `ki_swtime`. + pub ki_pctcpu: ::fixpt_t, + /// Time averaged value of `ki_cpticks`. + pub ki_estcpu: ::u_int, + /// Time since last blocked. + pub ki_slptime: ::u_int, + /// Time swapped in or out. + pub ki_swtime: ::u_int, + /// Number of copy-on-write faults. + pub ki_cow: ::u_int, + /// Real time in microsec. + pub ki_runtime: u64, + /// Starting time. + pub ki_start: ::timeval, + /// Time used by process children. + pub ki_childtime: ::timeval, + /// P_* flags. + pub ki_flag: ::c_long, + /// KI_* flags (below). + pub ki_kiflag: ::c_long, + /// Kernel trace points. + pub ki_traceflag: ::c_int, + /// S* process status. + pub ki_stat: ::c_char, + /// Process "nice" value. + pub ki_nice: i8, // signed char + /// Process lock (prevent swap) count. + pub ki_lock: ::c_char, + /// Run queue index. + pub ki_rqindex: ::c_char, + /// Which cpu we are on. + pub ki_oncpu_old: ::c_uchar, + /// Last cpu we were on. + pub ki_lastcpu_old: ::c_uchar, + /// Thread name. + pub ki_tdname: [::c_char; ::TDNAMLEN + 1], + /// Wchan message. + pub ki_wmesg: [::c_char; ::WMESGLEN + 1], + /// Setlogin name. + pub ki_login: [::c_char; ::LOGNAMELEN + 1], + /// Lock name. + pub ki_lockname: [::c_char; ::LOCKNAMELEN + 1], + /// Command name. + pub ki_comm: [::c_char; ::COMMLEN + 1], + /// Emulation name. + pub ki_emul: [::c_char; ::KI_EMULNAMELEN + 1], + /// Login class. + pub ki_loginclass: [::c_char; ::LOGINCLASSLEN + 1], + /// More thread name. + pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], + /// Spare string space. + pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq + /// Spare room for growth. + pub ki_spareints: [::c_int; ::KI_NSPARE_INT], + /// Controlling tty dev. + pub ki_tdev: ::dev_t, + /// Which cpu we are on. + pub ki_oncpu: ::c_int, + /// Last cpu we were on. + pub ki_lastcpu: ::c_int, + /// PID of tracing process. + pub ki_tracer: ::c_int, + /// P2_* flags. + pub ki_flag2: ::c_int, + /// Default FIB number. + pub ki_fibnum: ::c_int, + /// Credential flags. + pub ki_cr_flags: ::u_int, + /// Process jail ID. + pub ki_jid: ::c_int, + /// Number of threads in total. + pub ki_numthreads: ::c_int, + /// Thread ID. + pub ki_tid: ::lwpid_t, + /// Process priority. + pub ki_pri: ::priority, + /// Process rusage statistics. + pub ki_rusage: ::rusage, + /// rusage of children processes. + pub ki_rusage_ch: ::rusage, + // This is normally "struct pcb". + /// Kernel virtual addr of pcb. + pub ki_pcb: *mut ::c_void, + /// Kernel virtual addr of stack. + pub ki_kstack: *mut ::c_void, + /// User convenience pointer. + pub ki_udata: *mut ::c_void, + // This is normally "struct thread". + pub ki_tdaddr: *mut ::c_void, + pub ki_spareptrs: [*mut ::c_void; ::KI_NSPARE_PTR], + pub ki_sparelongs: [::c_long; ::KI_NSPARE_LONG], + /// PS_* flags. + pub ki_sflag: ::c_long, + /// kthread flag. + pub ki_tdflags: ::c_long, + } } s_no_extra_traits! { @@ -74,6 +256,17 @@ pub f_mntfromname: [::c_char; 1024], pub f_mntonname: [::c_char; 1024], } + + pub struct vnstat { + pub vn_fileid: u64, + pub vn_size: u64, + pub vn_dev: u64, + pub vn_fsid: u64, + pub vn_mntdir: *mut ::c_char, + pub vn_type: ::c_int, + pub vn_mode: u16, + pub vn_devname: [::c_char; ::SPECNAMELEN as usize + 1], + } } cfg_if! { @@ -197,6 +390,53 @@ self.d_name[..self.d_namlen as _].hash(state); } } + + impl PartialEq for vnstat { + fn eq(&self, other: &vnstat) -> bool { + let self_vn_devname: &[::c_char] = &self.vn_devname; + let other_vn_devname: &[::c_char] = &other.vn_devname; + + self.vn_fileid == other.vn_fileid && + self.vn_size == other.vn_size && + self.vn_dev == other.vn_dev && + self.vn_fsid == other.vn_fsid && + self.vn_mntdir == other.vn_mntdir && + self.vn_type == other.vn_type && + self.vn_mode == other.vn_mode && + self_vn_devname == other_vn_devname + } + } + impl Eq for vnstat {} + impl ::fmt::Debug for vnstat { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let self_vn_devname: &[::c_char] = &self.vn_devname; + + f.debug_struct("vnstat") + .field("vn_fileid", &self.vn_fileid) + .field("vn_size", &self.vn_size) + .field("vn_dev", &self.vn_dev) + .field("vn_fsid", &self.vn_fsid) + .field("vn_mntdir", &self.vn_mntdir) + .field("vn_type", &self.vn_type) + .field("vn_mode", &self.vn_mode) + .field("vn_devname", &self_vn_devname) + .finish() + } + } + impl ::hash::Hash for vnstat { + fn hash(&self, state: &mut H) { + let self_vn_devname: &[::c_char] = &self.vn_devname; + + self.vn_fileid.hash(state); + self.vn_size.hash(state); + self.vn_dev.hash(state); + self.vn_fsid.hash(state); + self.vn_mntdir.hash(state); + self.vn_type.hash(state); + self.vn_mode.hash(state); + self_vn_devname.hash(state); + } + } } } @@ -207,6 +447,8 @@ pub const SPECNAMELEN: ::c_int = 63; pub const KI_NSPARE_PTR: usize = 6; +pub const MINCORE_SUPER: ::c_int = 0x20; + extern "C" { pub fn setgrent(); pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; @@ -236,7 +478,8 @@ cfg_if! { if #[cfg(any(target_arch = "x86_64", - target_arch = "aarch64"))] { + target_arch = "aarch64", + target_arch = "riscv64"))] { mod b64; pub use self::b64::*; } diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,4 +1,4 @@ -// APIs in FreeBSD 13 that have changed since 11. +// APIs in FreeBSD 14 that have changed since 11. pub type nlink_t = u64; pub type dev_t = u64; @@ -30,17 +30,6 @@ pub ext: [u64; 4], } - pub struct sockcred2 { - pub sc_version: ::c_int, - pub sc_pid: ::pid_t, - pub sc_uid: ::uid_t, - pub sc_euid: ::uid_t, - pub sc_gid: ::gid_t, - pub sc_egid: ::gid_t, - pub sc_ngroups: ::c_int, - pub sc_groups: [::gid_t; 1], - } - pub struct kvm_page { pub kp_version: ::u_int, pub kp_paddr: ::kpaddr_t, @@ -54,6 +43,191 @@ pub struct __c_anonymous_domainset { _priv: [::uintptr_t; 4], } + + pub struct kinfo_proc { + /// Size of this structure. + pub ki_structsize: ::c_int, + /// Reserved: layout identifier. + pub ki_layout: ::c_int, + /// Address of command arguments. + pub ki_args: *mut ::pargs, + // This is normally "struct proc". + /// Address of proc. + pub ki_paddr: *mut ::c_void, + // This is normally "struct user". + /// Kernel virtual address of u-area. + pub ki_addr: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to trace file. + pub ki_tracep: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to executable file. + pub ki_textvp: *mut ::c_void, + // This is normally "struct filedesc". + /// Pointer to open file info. + pub ki_fd: *mut ::c_void, + // This is normally "struct vmspace". + /// Pointer to kernel vmspace struct. + pub ki_vmspace: *mut ::c_void, + /// Sleep address. + pub ki_wchan: *const ::c_void, + /// Process identifier. + pub ki_pid: ::pid_t, + /// Parent process ID. + pub ki_ppid: ::pid_t, + /// Process group ID. + pub ki_pgid: ::pid_t, + /// tty process group ID. + pub ki_tpgid: ::pid_t, + /// Process session ID. + pub ki_sid: ::pid_t, + /// Terminal session ID. + pub ki_tsid: ::pid_t, + /// Job control counter. + pub ki_jobc: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short1: ::c_short, + /// Controlling tty dev. + pub ki_tdev_freebsd11: u32, + /// Signals arrived but not delivered. + pub ki_siglist: ::sigset_t, + /// Current signal mask. + pub ki_sigmask: ::sigset_t, + /// Signals being ignored. + pub ki_sigignore: ::sigset_t, + /// Signals being caught by user. + pub ki_sigcatch: ::sigset_t, + /// Effective user ID. + pub ki_uid: ::uid_t, + /// Real user ID. + pub ki_ruid: ::uid_t, + /// Saved effective user ID. + pub ki_svuid: ::uid_t, + /// Real group ID. + pub ki_rgid: ::gid_t, + /// Saved effective group ID. + pub ki_svgid: ::gid_t, + /// Number of groups. + pub ki_ngroups: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short2: ::c_short, + /// Groups. + pub ki_groups: [::gid_t; ::KI_NGROUPS], + /// Virtual size. + pub ki_size: ::vm_size_t, + /// Current resident set size in pages. + pub ki_rssize: ::segsz_t, + /// Resident set size before last swap. + pub ki_swrss: ::segsz_t, + /// Text size (pages) XXX. + pub ki_tsize: ::segsz_t, + /// Data size (pages) XXX. + pub ki_dsize: ::segsz_t, + /// Stack size (pages). + pub ki_ssize: ::segsz_t, + /// Exit status for wait & stop signal. + pub ki_xstat: ::u_short, + /// Accounting flags. + pub ki_acflag: ::u_short, + /// %cpu for process during `ki_swtime`. + pub ki_pctcpu: ::fixpt_t, + /// Time averaged value of `ki_cpticks`. + pub ki_estcpu: ::u_int, + /// Time since last blocked. + pub ki_slptime: ::u_int, + /// Time swapped in or out. + pub ki_swtime: ::u_int, + /// Number of copy-on-write faults. + pub ki_cow: ::u_int, + /// Real time in microsec. + pub ki_runtime: u64, + /// Starting time. + pub ki_start: ::timeval, + /// Time used by process children. + pub ki_childtime: ::timeval, + /// P_* flags. + pub ki_flag: ::c_long, + /// KI_* flags (below). + pub ki_kiflag: ::c_long, + /// Kernel trace points. + pub ki_traceflag: ::c_int, + /// S* process status. + pub ki_stat: ::c_char, + /// Process "nice" value. + pub ki_nice: i8, // signed char + /// Process lock (prevent swap) count. + pub ki_lock: ::c_char, + /// Run queue index. + pub ki_rqindex: ::c_char, + /// Which cpu we are on. + pub ki_oncpu_old: ::c_uchar, + /// Last cpu we were on. + pub ki_lastcpu_old: ::c_uchar, + /// Thread name. + pub ki_tdname: [::c_char; ::TDNAMLEN + 1], + /// Wchan message. + pub ki_wmesg: [::c_char; ::WMESGLEN + 1], + /// Setlogin name. + pub ki_login: [::c_char; ::LOGNAMELEN + 1], + /// Lock name. + pub ki_lockname: [::c_char; ::LOCKNAMELEN + 1], + /// Command name. + pub ki_comm: [::c_char; ::COMMLEN + 1], + /// Emulation name. + pub ki_emul: [::c_char; ::KI_EMULNAMELEN + 1], + /// Login class. + pub ki_loginclass: [::c_char; ::LOGINCLASSLEN + 1], + /// More thread name. + pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], + /// Spare string space. + pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq + /// Spare room for growth. + pub ki_spareints: [::c_int; ::KI_NSPARE_INT], + /// Controlling tty dev. + pub ki_tdev: u64, + /// Which cpu we are on. + pub ki_oncpu: ::c_int, + /// Last cpu we were on. + pub ki_lastcpu: ::c_int, + /// PID of tracing process. + pub ki_tracer: ::c_int, + /// P2_* flags. + pub ki_flag2: ::c_int, + /// Default FIB number. + pub ki_fibnum: ::c_int, + /// Credential flags. + pub ki_cr_flags: ::u_int, + /// Process jail ID. + pub ki_jid: ::c_int, + /// Number of threads in total. + pub ki_numthreads: ::c_int, + /// Thread ID. + pub ki_tid: ::lwpid_t, + /// Process priority. + pub ki_pri: ::priority, + /// Process rusage statistics. + pub ki_rusage: ::rusage, + /// rusage of children processes. + pub ki_rusage_ch: ::rusage, + // This is normally "struct pcb". + /// Kernel virtual addr of pcb. + pub ki_pcb: *mut ::c_void, + /// Kernel virtual addr of stack. + pub ki_kstack: *mut ::c_void, + /// User convenience pointer. + pub ki_udata: *mut ::c_void, + // This is normally "struct thread". + pub ki_tdaddr: *mut ::c_void, + // This is normally "struct pwddesc". + /// Pointer to process paths info. + pub ki_pd: *mut ::c_void, + pub ki_spareptrs: [*mut ::c_void; ::KI_NSPARE_PTR], + pub ki_sparelongs: [::c_long; ::KI_NSPARE_LONG], + /// PS_* flags. + pub ki_sflag: ::c_long, + /// kthread flag. + pub ki_tdflags: ::c_long, + } } s_no_extra_traits! { @@ -92,6 +266,17 @@ pub f_mntfromname: [::c_char; 1024], pub f_mntonname: [::c_char; 1024], } + + pub struct vnstat { + pub vn_fileid: u64, + pub vn_size: u64, + pub vn_dev: u64, + pub vn_fsid: u64, + pub vn_mntdir: *mut ::c_char, + pub vn_type: ::c_int, + pub vn_mode: u16, + pub vn_devname: [::c_char; ::SPECNAMELEN as usize + 1], + } } cfg_if! { @@ -215,6 +400,53 @@ self.d_name[..self.d_namlen as _].hash(state); } } + + impl PartialEq for vnstat { + fn eq(&self, other: &vnstat) -> bool { + let self_vn_devname: &[::c_char] = &self.vn_devname; + let other_vn_devname: &[::c_char] = &other.vn_devname; + + self.vn_fileid == other.vn_fileid && + self.vn_size == other.vn_size && + self.vn_dev == other.vn_dev && + self.vn_fsid == other.vn_fsid && + self.vn_mntdir == other.vn_mntdir && + self.vn_type == other.vn_type && + self.vn_mode == other.vn_mode && + self_vn_devname == other_vn_devname + } + } + impl Eq for vnstat {} + impl ::fmt::Debug for vnstat { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let self_vn_devname: &[::c_char] = &self.vn_devname; + + f.debug_struct("vnstat") + .field("vn_fileid", &self.vn_fileid) + .field("vn_size", &self.vn_size) + .field("vn_dev", &self.vn_dev) + .field("vn_fsid", &self.vn_fsid) + .field("vn_mntdir", &self.vn_mntdir) + .field("vn_type", &self.vn_type) + .field("vn_mode", &self.vn_mode) + .field("vn_devname", &self_vn_devname) + .finish() + } + } + impl ::hash::Hash for vnstat { + fn hash(&self, state: &mut H) { + let self_vn_devname: &[::c_char] = &self.vn_devname; + + self.vn_fileid.hash(state); + self.vn_size.hash(state); + self.vn_dev.hash(state); + self.vn_fsid.hash(state); + self.vn_mntdir.hash(state); + self.vn_type.hash(state); + self.vn_mode.hash(state); + self_vn_devname.hash(state); + } + } } } @@ -234,16 +466,7 @@ pub const DOMAINSET_POLICY_PREFER: ::c_int = 3; pub const DOMAINSET_POLICY_INTERLEAVE: ::c_int = 4; -f! { - pub fn SOCKCRED2SIZE(ngrps: usize) -> usize { - let ngrps = if ngrps > 0 { - ngrps - 1 - } else { - 0 - }; - ::mem::size_of::() + ::mem::size_of::<::gid_t>() * ngrps - } -} +pub const MINCORE_SUPER: ::c_int = 0x20; extern "C" { pub fn aio_readv(aiocbp: *mut ::aiocb) -> ::c_int; @@ -265,6 +488,8 @@ rmtp: *mut ::timespec, ) -> ::c_int; + pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; + pub fn fdatasync(fd: ::c_int) -> ::c_int; pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t; @@ -290,6 +515,15 @@ mask: *const ::domainset_t, policy: ::c_int, ) -> ::c_int; + + pub fn copy_file_range( + infd: ::c_int, + inoffp: *mut ::off_t, + outfd: ::c_int, + outoffp: *mut ::off_t, + len: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; } #[link(name = "kvm")] @@ -299,7 +533,8 @@ cfg_if! { if #[cfg(any(target_arch = "x86_64", - target_arch = "aarch64"))] { + target_arch = "aarch64", + target_arch = "riscv64"))] { mod b64; pub use self::b64::*; } diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/b64.rs cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/b64.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/b64.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/b64.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,34 @@ +#[repr(C)] +#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))] +pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_mode: ::mode_t, + st_padding0: i16, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + st_padding1: i32, + pub st_rdev: ::dev_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + pub st_size: ::off_t, + pub st_blocks: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: ::fflags_t, + pub st_gen: u64, + pub st_spare: [u64; 10], +} + +impl ::Copy for ::stat {} +impl ::Clone for ::stat { + fn clone(&self) -> ::stat { + *self + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,548 @@ +// APIs in FreeBSD 13 that have changed since 11. + +pub type nlink_t = u64; +pub type dev_t = u64; +pub type ino_t = ::c_ulong; +pub type shmatt_t = ::c_uint; +pub type kpaddr_t = u64; +pub type kssize_t = i64; +pub type domainset_t = __c_anonymous_domainset; + +s! { + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_lpid: ::pid_t, + pub shm_cpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + } + + pub struct kevent { + pub ident: ::uintptr_t, + pub filter: ::c_short, + pub flags: ::c_ushort, + pub fflags: ::c_uint, + pub data: ::intptr_t, + pub udata: *mut ::c_void, + pub ext: [u64; 4], + } + + pub struct kvm_page { + pub kp_version: ::u_int, + pub kp_paddr: ::kpaddr_t, + pub kp_kmap_vaddr: ::kvaddr_t, + pub kp_dmap_vaddr: ::kvaddr_t, + pub kp_prot: ::vm_prot_t, + pub kp_offset: ::off_t, + pub kp_len: ::size_t, + } + + pub struct __c_anonymous_domainset { + _priv: [::uintptr_t; 4], + } + + pub struct kinfo_proc { + /// Size of this structure. + pub ki_structsize: ::c_int, + /// Reserved: layout identifier. + pub ki_layout: ::c_int, + /// Address of command arguments. + pub ki_args: *mut ::pargs, + // This is normally "struct proc". + /// Address of proc. + pub ki_paddr: *mut ::c_void, + // This is normally "struct user". + /// Kernel virtual address of u-area. + pub ki_addr: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to trace file. + pub ki_tracep: *mut ::c_void, + // This is normally "struct vnode". + /// Pointer to executable file. + pub ki_textvp: *mut ::c_void, + // This is normally "struct filedesc". + /// Pointer to open file info. + pub ki_fd: *mut ::c_void, + // This is normally "struct vmspace". + /// Pointer to kernel vmspace struct. + pub ki_vmspace: *mut ::c_void, + /// Sleep address. + pub ki_wchan: *const ::c_void, + /// Process identifier. + pub ki_pid: ::pid_t, + /// Parent process ID. + pub ki_ppid: ::pid_t, + /// Process group ID. + pub ki_pgid: ::pid_t, + /// tty process group ID. + pub ki_tpgid: ::pid_t, + /// Process session ID. + pub ki_sid: ::pid_t, + /// Terminal session ID. + pub ki_tsid: ::pid_t, + /// Job control counter. + pub ki_jobc: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short1: ::c_short, + /// Controlling tty dev. + pub ki_tdev_freebsd11: u32, + /// Signals arrived but not delivered. + pub ki_siglist: ::sigset_t, + /// Current signal mask. + pub ki_sigmask: ::sigset_t, + /// Signals being ignored. + pub ki_sigignore: ::sigset_t, + /// Signals being caught by user. + pub ki_sigcatch: ::sigset_t, + /// Effective user ID. + pub ki_uid: ::uid_t, + /// Real user ID. + pub ki_ruid: ::uid_t, + /// Saved effective user ID. + pub ki_svuid: ::uid_t, + /// Real group ID. + pub ki_rgid: ::gid_t, + /// Saved effective group ID. + pub ki_svgid: ::gid_t, + /// Number of groups. + pub ki_ngroups: ::c_short, + /// Unused (just here for alignment). + pub ki_spare_short2: ::c_short, + /// Groups. + pub ki_groups: [::gid_t; ::KI_NGROUPS], + /// Virtual size. + pub ki_size: ::vm_size_t, + /// Current resident set size in pages. + pub ki_rssize: ::segsz_t, + /// Resident set size before last swap. + pub ki_swrss: ::segsz_t, + /// Text size (pages) XXX. + pub ki_tsize: ::segsz_t, + /// Data size (pages) XXX. + pub ki_dsize: ::segsz_t, + /// Stack size (pages). + pub ki_ssize: ::segsz_t, + /// Exit status for wait & stop signal. + pub ki_xstat: ::u_short, + /// Accounting flags. + pub ki_acflag: ::u_short, + /// %cpu for process during `ki_swtime`. + pub ki_pctcpu: ::fixpt_t, + /// Time averaged value of `ki_cpticks`. + pub ki_estcpu: ::u_int, + /// Time since last blocked. + pub ki_slptime: ::u_int, + /// Time swapped in or out. + pub ki_swtime: ::u_int, + /// Number of copy-on-write faults. + pub ki_cow: ::u_int, + /// Real time in microsec. + pub ki_runtime: u64, + /// Starting time. + pub ki_start: ::timeval, + /// Time used by process children. + pub ki_childtime: ::timeval, + /// P_* flags. + pub ki_flag: ::c_long, + /// KI_* flags (below). + pub ki_kiflag: ::c_long, + /// Kernel trace points. + pub ki_traceflag: ::c_int, + /// S* process status. + pub ki_stat: ::c_char, + /// Process "nice" value. + pub ki_nice: i8, // signed char + /// Process lock (prevent swap) count. + pub ki_lock: ::c_char, + /// Run queue index. + pub ki_rqindex: ::c_char, + /// Which cpu we are on. + pub ki_oncpu_old: ::c_uchar, + /// Last cpu we were on. + pub ki_lastcpu_old: ::c_uchar, + /// Thread name. + pub ki_tdname: [::c_char; ::TDNAMLEN + 1], + /// Wchan message. + pub ki_wmesg: [::c_char; ::WMESGLEN + 1], + /// Setlogin name. + pub ki_login: [::c_char; ::LOGNAMELEN + 1], + /// Lock name. + pub ki_lockname: [::c_char; ::LOCKNAMELEN + 1], + /// Command name. + pub ki_comm: [::c_char; ::COMMLEN + 1], + /// Emulation name. + pub ki_emul: [::c_char; ::KI_EMULNAMELEN + 1], + /// Login class. + pub ki_loginclass: [::c_char; ::LOGINCLASSLEN + 1], + /// More thread name. + pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], + /// Spare string space. + pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq + /// Spare room for growth. + pub ki_spareints: [::c_int; ::KI_NSPARE_INT], + /// Controlling tty dev. + pub ki_tdev: u64, + /// Which cpu we are on. + pub ki_oncpu: ::c_int, + /// Last cpu we were on. + pub ki_lastcpu: ::c_int, + /// PID of tracing process. + pub ki_tracer: ::c_int, + /// P2_* flags. + pub ki_flag2: ::c_int, + /// Default FIB number. + pub ki_fibnum: ::c_int, + /// Credential flags. + pub ki_cr_flags: ::u_int, + /// Process jail ID. + pub ki_jid: ::c_int, + /// Number of threads in total. + pub ki_numthreads: ::c_int, + /// Thread ID. + pub ki_tid: ::lwpid_t, + /// Process priority. + pub ki_pri: ::priority, + /// Process rusage statistics. + pub ki_rusage: ::rusage, + /// rusage of children processes. + pub ki_rusage_ch: ::rusage, + // This is normally "struct pcb". + /// Kernel virtual addr of pcb. + pub ki_pcb: *mut ::c_void, + /// Kernel virtual addr of stack. + pub ki_kstack: *mut ::c_void, + /// User convenience pointer. + pub ki_udata: *mut ::c_void, + // This is normally "struct thread". + pub ki_tdaddr: *mut ::c_void, + // This is normally "struct pwddesc". + /// Pointer to process paths info. + pub ki_pd: *mut ::c_void, + pub ki_spareptrs: [*mut ::c_void; ::KI_NSPARE_PTR], + pub ki_sparelongs: [::c_long; ::KI_NSPARE_LONG], + /// PS_* flags. + pub ki_sflag: ::c_long, + /// kthread flag. + pub ki_tdflags: ::c_long, + } +} + +s_no_extra_traits! { + pub struct dirent { + pub d_fileno: ::ino_t, + pub d_off: ::off_t, + pub d_reclen: u16, + pub d_type: u8, + d_pad0: u8, + pub d_namlen: u16, + d_pad1: u16, + pub d_name: [::c_char; 256], + } + + pub struct statfs { + pub f_version: u32, + pub f_type: u32, + pub f_flags: u64, + pub f_bsize: u64, + pub f_iosize: u64, + pub f_blocks: u64, + pub f_bfree: u64, + pub f_bavail: i64, + pub f_files: u64, + pub f_ffree: i64, + pub f_syncwrites: u64, + pub f_asyncwrites: u64, + pub f_syncreads: u64, + pub f_asyncreads: u64, + f_spare: [u64; 10], + pub f_namemax: u32, + pub f_owner: ::uid_t, + pub f_fsid: ::fsid_t, + f_charspare: [::c_char; 80], + pub f_fstypename: [::c_char; 16], + pub f_mntfromname: [::c_char; 1024], + pub f_mntonname: [::c_char; 1024], + } + + pub struct vnstat { + pub vn_fileid: u64, + pub vn_size: u64, + pub vn_dev: u64, + pub vn_fsid: u64, + pub vn_mntdir: *mut ::c_char, + pub vn_type: ::c_int, + pub vn_mode: u16, + pub vn_devname: [::c_char; ::SPECNAMELEN as usize + 1], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for statfs { + fn eq(&self, other: &statfs) -> bool { + self.f_version == other.f_version + && self.f_type == other.f_type + && self.f_flags == other.f_flags + && self.f_bsize == other.f_bsize + && self.f_iosize == other.f_iosize + && self.f_blocks == other.f_blocks + && self.f_bfree == other.f_bfree + && self.f_bavail == other.f_bavail + && self.f_files == other.f_files + && self.f_ffree == other.f_ffree + && self.f_syncwrites == other.f_syncwrites + && self.f_asyncwrites == other.f_asyncwrites + && self.f_syncreads == other.f_syncreads + && self.f_asyncreads == other.f_asyncreads + && self.f_namemax == other.f_namemax + && self.f_owner == other.f_owner + && self.f_fsid == other.f_fsid + && self.f_fstypename == other.f_fstypename + && self + .f_mntfromname + .iter() + .zip(other.f_mntfromname.iter()) + .all(|(a,b)| a == b) + && self + .f_mntonname + .iter() + .zip(other.f_mntonname.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for statfs {} + impl ::fmt::Debug for statfs { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("statfs") + .field("f_bsize", &self.f_bsize) + .field("f_iosize", &self.f_iosize) + .field("f_blocks", &self.f_blocks) + .field("f_bfree", &self.f_bfree) + .field("f_bavail", &self.f_bavail) + .field("f_files", &self.f_files) + .field("f_ffree", &self.f_ffree) + .field("f_syncwrites", &self.f_syncwrites) + .field("f_asyncwrites", &self.f_asyncwrites) + .field("f_syncreads", &self.f_syncreads) + .field("f_asyncreads", &self.f_asyncreads) + .field("f_namemax", &self.f_namemax) + .field("f_owner", &self.f_owner) + .field("f_fsid", &self.f_fsid) + .field("f_fstypename", &self.f_fstypename) + .field("f_mntfromname", &&self.f_mntfromname[..]) + .field("f_mntonname", &&self.f_mntonname[..]) + .finish() + } + } + impl ::hash::Hash for statfs { + fn hash(&self, state: &mut H) { + self.f_version.hash(state); + self.f_type.hash(state); + self.f_flags.hash(state); + self.f_bsize.hash(state); + self.f_iosize.hash(state); + self.f_blocks.hash(state); + self.f_bfree.hash(state); + self.f_bavail.hash(state); + self.f_files.hash(state); + self.f_ffree.hash(state); + self.f_syncwrites.hash(state); + self.f_asyncwrites.hash(state); + self.f_syncreads.hash(state); + self.f_asyncreads.hash(state); + self.f_namemax.hash(state); + self.f_owner.hash(state); + self.f_fsid.hash(state); + self.f_charspare.hash(state); + self.f_fstypename.hash(state); + self.f_mntfromname.hash(state); + self.f_mntonname.hash(state); + } + } + + impl PartialEq for dirent { + fn eq(&self, other: &dirent) -> bool { + self.d_fileno == other.d_fileno + && self.d_off == other.d_off + && self.d_reclen == other.d_reclen + && self.d_type == other.d_type + && self.d_namlen == other.d_namlen + && self + .d_name[..self.d_namlen as _] + .iter() + .zip(other.d_name.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for dirent {} + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("dirent") + .field("d_fileno", &self.d_fileno) + .field("d_off", &self.d_off) + .field("d_reclen", &self.d_reclen) + .field("d_type", &self.d_type) + .field("d_namlen", &self.d_namlen) + .field("d_name", &&self.d_name[..self.d_namlen as _]) + .finish() + } + } + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { + self.d_fileno.hash(state); + self.d_off.hash(state); + self.d_reclen.hash(state); + self.d_type.hash(state); + self.d_namlen.hash(state); + self.d_name[..self.d_namlen as _].hash(state); + } + } + + impl PartialEq for vnstat { + fn eq(&self, other: &vnstat) -> bool { + let self_vn_devname: &[::c_char] = &self.vn_devname; + let other_vn_devname: &[::c_char] = &other.vn_devname; + + self.vn_fileid == other.vn_fileid && + self.vn_size == other.vn_size && + self.vn_dev == other.vn_dev && + self.vn_fsid == other.vn_fsid && + self.vn_mntdir == other.vn_mntdir && + self.vn_type == other.vn_type && + self.vn_mode == other.vn_mode && + self_vn_devname == other_vn_devname + } + } + impl Eq for vnstat {} + impl ::fmt::Debug for vnstat { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let self_vn_devname: &[::c_char] = &self.vn_devname; + + f.debug_struct("vnstat") + .field("vn_fileid", &self.vn_fileid) + .field("vn_size", &self.vn_size) + .field("vn_dev", &self.vn_dev) + .field("vn_fsid", &self.vn_fsid) + .field("vn_mntdir", &self.vn_mntdir) + .field("vn_type", &self.vn_type) + .field("vn_mode", &self.vn_mode) + .field("vn_devname", &self_vn_devname) + .finish() + } + } + impl ::hash::Hash for vnstat { + fn hash(&self, state: &mut H) { + let self_vn_devname: &[::c_char] = &self.vn_devname; + + self.vn_fileid.hash(state); + self.vn_size.hash(state); + self.vn_dev.hash(state); + self.vn_fsid.hash(state); + self.vn_mntdir.hash(state); + self.vn_type.hash(state); + self.vn_mode.hash(state); + self_vn_devname.hash(state); + } + } + } +} + +pub const RAND_MAX: ::c_int = 0x7fff_ffff; +pub const ELAST: ::c_int = 97; + +pub const KF_TYPE_EVENTFD: ::c_int = 13; + +/// max length of devicename +pub const SPECNAMELEN: ::c_int = 255; +pub const KI_NSPARE_PTR: usize = 5; + +/// domainset policies +pub const DOMAINSET_POLICY_INVALID: ::c_int = 0; +pub const DOMAINSET_POLICY_ROUNDROBIN: ::c_int = 1; +pub const DOMAINSET_POLICY_FIRSTTOUCH: ::c_int = 2; +pub const DOMAINSET_POLICY_PREFER: ::c_int = 3; +pub const DOMAINSET_POLICY_INTERLEAVE: ::c_int = 4; + +pub const MINCORE_SUPER: ::c_int = 0x60; + +extern "C" { + pub fn aio_readv(aiocbp: *mut ::aiocb) -> ::c_int; + pub fn aio_writev(aiocbp: *mut ::aiocb) -> ::c_int; + pub fn setgrent(); + pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; + pub fn freelocale(loc: ::locale_t); + pub fn msgrcv( + msqid: ::c_int, + msgp: *mut ::c_void, + msgsz: ::size_t, + msgtyp: ::c_long, + msgflg: ::c_int, + ) -> ::ssize_t; + pub fn clock_nanosleep( + clk_id: ::clockid_t, + flags: ::c_int, + rqtp: *const ::timespec, + rmtp: *mut ::timespec, + ) -> ::c_int; + + pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; + + pub fn fdatasync(fd: ::c_int) -> ::c_int; + + pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t; + pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; + pub fn elf_aux_info(aux: ::c_int, buf: *mut ::c_void, buflen: ::c_int) -> ::c_int; + pub fn setproctitle_fast(fmt: *const ::c_char, ...); + pub fn timingsafe_bcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int; + pub fn timingsafe_memcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int; + + pub fn cpuset_getdomain( + level: ::cpulevel_t, + which: ::cpuwhich_t, + id: ::id_t, + setsize: ::size_t, + mask: *mut ::domainset_t, + policy: *mut ::c_int, + ) -> ::c_int; + pub fn cpuset_setdomain( + level: ::cpulevel_t, + which: ::cpuwhich_t, + id: ::id_t, + setsize: ::size_t, + mask: *const ::domainset_t, + policy: ::c_int, + ) -> ::c_int; + + pub fn copy_file_range( + infd: ::c_int, + inoffp: *mut ::off_t, + outfd: ::c_int, + outoffp: *mut ::off_t, + len: ::size_t, + flags: ::c_uint, + ) -> ::ssize_t; +} + +#[link(name = "kvm")] +extern "C" { + pub fn kvm_kerndisp(kd: *mut ::kvm_t) -> ::kssize_t; +} + +cfg_if! { + if #[cfg(any(target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "riscv64"))] { + mod b64; + pub use self::b64::*; + } +} + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,5 @@ +pub const PROC_KPTI_CTL: ::c_int = ::PROC_PROCCTL_MD_MIN; +pub const PROC_KPTI_CTL_ENABLE_ON_EXEC: ::c_int = 1; +pub const PROC_KPTI_CTL_DISABLE_ON_EXEC: ::c_int = 2; +pub const PROC_KPTI_STATUS: ::c_int = ::PROC_PROCCTL_MD_MIN + 1; +pub const PROC_KPTI_STATUS_ACTIVE: ::c_int = 0x80000000; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -37,10 +37,208 @@ pub type u_long = ::c_ulong; pub type u_short = ::c_ushort; +pub type caddr_t = *mut ::c_char; + +pub type fhandle_t = fhandle; + // It's an alias over "struct __kvm_t". However, its fields aren't supposed to be used directly, // making the type definition system dependent. Better not bind it exactly. pub type kvm_t = ::c_void; +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash))] +#[derive(PartialEq, Eq)] +#[repr(u32)] +pub enum devstat_support_flags { + DEVSTAT_ALL_SUPPORTED = 0x00, + DEVSTAT_NO_BLOCKSIZE = 0x01, + DEVSTAT_NO_ORDERED_TAGS = 0x02, + DEVSTAT_BS_UNAVAILABLE = 0x04, +} +impl ::Copy for devstat_support_flags {} +impl ::Clone for devstat_support_flags { + fn clone(&self) -> devstat_support_flags { + *self + } +} + +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash))] +#[derive(PartialEq, Eq)] +#[repr(u32)] +pub enum devstat_trans_flags { + DEVSTAT_NO_DATA = 0x00, + DEVSTAT_READ = 0x01, + DEVSTAT_WRITE = 0x02, + DEVSTAT_FREE = 0x03, +} + +impl ::Copy for devstat_trans_flags {} +impl ::Clone for devstat_trans_flags { + fn clone(&self) -> devstat_trans_flags { + *self + } +} + +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash))] +#[derive(PartialEq, Eq)] +#[repr(u32)] +pub enum devstat_tag_type { + DEVSTAT_TAG_SIMPLE = 0x00, + DEVSTAT_TAG_HEAD = 0x01, + DEVSTAT_TAG_ORDERED = 0x02, + DEVSTAT_TAG_NONE = 0x03, +} +impl ::Copy for devstat_tag_type {} +impl ::Clone for devstat_tag_type { + fn clone(&self) -> devstat_tag_type { + *self + } +} + +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash))] +#[derive(PartialEq, Eq)] +#[repr(u32)] +pub enum devstat_match_flags { + DEVSTAT_MATCH_NONE = 0x00, + DEVSTAT_MATCH_TYPE = 0x01, + DEVSTAT_MATCH_IF = 0x02, + DEVSTAT_MATCH_PASS = 0x04, +} +impl ::Copy for devstat_match_flags {} +impl ::Clone for devstat_match_flags { + fn clone(&self) -> devstat_match_flags { + *self + } +} + +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash))] +#[derive(PartialEq, Eq)] +#[repr(u32)] +pub enum devstat_priority { + DEVSTAT_PRIORITY_MIN = 0x000, + DEVSTAT_PRIORITY_OTHER = 0x020, + DEVSTAT_PRIORITY_PASS = 0x030, + DEVSTAT_PRIORITY_FD = 0x040, + DEVSTAT_PRIORITY_WFD = 0x050, + DEVSTAT_PRIORITY_TAPE = 0x060, + DEVSTAT_PRIORITY_CD = 0x090, + DEVSTAT_PRIORITY_DISK = 0x110, + DEVSTAT_PRIORITY_ARRAY = 0x120, + DEVSTAT_PRIORITY_MAX = 0xfff, +} +impl ::Copy for devstat_priority {} +impl ::Clone for devstat_priority { + fn clone(&self) -> devstat_priority { + *self + } +} + +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash))] +#[derive(PartialEq, Eq)] +#[repr(u32)] +pub enum devstat_type_flags { + DEVSTAT_TYPE_DIRECT = 0x000, + DEVSTAT_TYPE_SEQUENTIAL = 0x001, + DEVSTAT_TYPE_PRINTER = 0x002, + DEVSTAT_TYPE_PROCESSOR = 0x003, + DEVSTAT_TYPE_WORM = 0x004, + DEVSTAT_TYPE_CDROM = 0x005, + DEVSTAT_TYPE_SCANNER = 0x006, + DEVSTAT_TYPE_OPTICAL = 0x007, + DEVSTAT_TYPE_CHANGER = 0x008, + DEVSTAT_TYPE_COMM = 0x009, + DEVSTAT_TYPE_ASC0 = 0x00a, + DEVSTAT_TYPE_ASC1 = 0x00b, + DEVSTAT_TYPE_STORARRAY = 0x00c, + DEVSTAT_TYPE_ENCLOSURE = 0x00d, + DEVSTAT_TYPE_FLOPPY = 0x00e, + DEVSTAT_TYPE_MASK = 0x00f, + DEVSTAT_TYPE_IF_SCSI = 0x010, + DEVSTAT_TYPE_IF_IDE = 0x020, + DEVSTAT_TYPE_IF_OTHER = 0x030, + DEVSTAT_TYPE_IF_MASK = 0x0f0, + DEVSTAT_TYPE_PASS = 0x100, +} +impl ::Copy for devstat_type_flags {} +impl ::Clone for devstat_type_flags { + fn clone(&self) -> devstat_type_flags { + *self + } +} + +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash))] +#[derive(PartialEq, Eq)] +#[repr(u32)] +pub enum devstat_metric { + DSM_NONE, + DSM_TOTAL_BYTES, + DSM_TOTAL_BYTES_READ, + DSM_TOTAL_BYTES_WRITE, + DSM_TOTAL_TRANSFERS, + DSM_TOTAL_TRANSFERS_READ, + DSM_TOTAL_TRANSFERS_WRITE, + DSM_TOTAL_TRANSFERS_OTHER, + DSM_TOTAL_BLOCKS, + DSM_TOTAL_BLOCKS_READ, + DSM_TOTAL_BLOCKS_WRITE, + DSM_KB_PER_TRANSFER, + DSM_KB_PER_TRANSFER_READ, + DSM_KB_PER_TRANSFER_WRITE, + DSM_TRANSFERS_PER_SECOND, + DSM_TRANSFERS_PER_SECOND_READ, + DSM_TRANSFERS_PER_SECOND_WRITE, + DSM_TRANSFERS_PER_SECOND_OTHER, + DSM_MB_PER_SECOND, + DSM_MB_PER_SECOND_READ, + DSM_MB_PER_SECOND_WRITE, + DSM_BLOCKS_PER_SECOND, + DSM_BLOCKS_PER_SECOND_READ, + DSM_BLOCKS_PER_SECOND_WRITE, + DSM_MS_PER_TRANSACTION, + DSM_MS_PER_TRANSACTION_READ, + DSM_MS_PER_TRANSACTION_WRITE, + DSM_SKIP, + DSM_TOTAL_BYTES_FREE, + DSM_TOTAL_TRANSFERS_FREE, + DSM_TOTAL_BLOCKS_FREE, + DSM_KB_PER_TRANSFER_FREE, + DSM_MB_PER_SECOND_FREE, + DSM_TRANSFERS_PER_SECOND_FREE, + DSM_BLOCKS_PER_SECOND_FREE, + DSM_MS_PER_TRANSACTION_OTHER, + DSM_MS_PER_TRANSACTION_FREE, + DSM_BUSY_PCT, + DSM_QUEUE_LENGTH, + DSM_TOTAL_DURATION, + DSM_TOTAL_DURATION_READ, + DSM_TOTAL_DURATION_WRITE, + DSM_TOTAL_DURATION_FREE, + DSM_TOTAL_DURATION_OTHER, + DSM_TOTAL_BUSY_TIME, + DSM_MAX, +} +impl ::Copy for devstat_metric {} +impl ::Clone for devstat_metric { + fn clone(&self) -> devstat_metric { + *self + } +} + +#[cfg_attr(feature = "extra_traits", derive(Debug, Hash))] +#[derive(PartialEq, Eq)] +#[repr(u32)] +pub enum devstat_select_mode { + DS_SELECT_ADD, + DS_SELECT_ONLY, + DS_SELECT_REMOVE, + DS_SELECT_ADDONLY, +} +impl ::Copy for devstat_select_mode {} +impl ::Clone for devstat_select_mode { + fn clone(&self) -> devstat_select_mode { + *self + } +} + s! { pub struct aiocb { pub aio_fildes: ::c_int, @@ -87,6 +285,11 @@ pub struct _sem { data: [u32; 4], } + pub struct sembuf { + pub sem_num: ::c_ushort, + pub sem_op: ::c_short, + pub sem_flg: ::c_short, + } pub struct msqid_ds { pub msg_perm: ::ipc_perm, @@ -122,11 +325,6 @@ pub sc_groups: [::gid_t; 1], } - pub struct accept_filter_arg { - pub af_name: [::c_char; 16], - af_arg: [[::c_char; 10]; 24], - } - pub struct ptrace_vm_entry { pub pve_entry: ::c_int, pub pve_timestamp: ::c_int, @@ -140,6 +338,30 @@ pub pve_path: *mut ::c_char, } + pub struct ptrace_lwpinfo { + pub pl_lwpid: lwpid_t, + pub pl_event: ::c_int, + pub pl_flags: ::c_int, + pub pl_sigmask: ::sigset_t, + pub pl_siglist: ::sigset_t, + pub pl_siginfo: ::siginfo_t, + pub pl_tdname: [::c_char; ::MAXCOMLEN as usize + 1], + pub pl_child_pid: ::pid_t, + pub pl_syscall_code: ::c_uint, + pub pl_syscall_narg: ::c_uint, + } + + pub struct ptrace_sc_ret { + pub sr_retval: [::register_t; 2], + pub sr_error: ::c_int, + } + + pub struct ptrace_coredump { + pub pc_fd: ::c_int, + pub pc_flags: u32, + pub pc_limit: ::off_t, + } + pub struct cpuset_t { #[cfg(target_pointer_width = "64")] __bits: [::c_long; 4], @@ -232,33 +454,37 @@ pub kve_path: [[::c_char; 32]; 32], } + pub struct __c_anonymous_filestat { + pub stqe_next: *mut filestat, + } + pub struct filestat { - fs_type: ::c_int, - fs_flags: ::c_int, - fs_fflags: ::c_int, - fs_uflags: ::c_int, - fs_fd: ::c_int, - fs_ref_count: ::c_int, - fs_offset: ::off_t, - fs_typedep: *mut ::c_void, - fs_path: *mut ::c_char, - next: *mut filestat, - fs_cap_rights: cap_rights_t, + pub fs_type: ::c_int, + pub fs_flags: ::c_int, + pub fs_fflags: ::c_int, + pub fs_uflags: ::c_int, + pub fs_fd: ::c_int, + pub fs_ref_count: ::c_int, + pub fs_offset: ::off_t, + pub fs_typedep: *mut ::c_void, + pub fs_path: *mut ::c_char, + pub next: __c_anonymous_filestat, + pub fs_cap_rights: cap_rights_t, } pub struct filestat_list { - stqh_first: *mut filestat, - stqh_last: *mut *mut filestat, + pub stqh_first: *mut filestat, + pub stqh_last: *mut *mut filestat, } pub struct procstat { - tpe: ::c_int, - kd: ::uintptr_t, - vmentries: *mut ::c_void, - files: *mut ::c_void, - argv: *mut ::c_void, - envv: *mut ::c_void, - core: ::uintptr_t, + pub tpe: ::c_int, + pub kd: ::uintptr_t, + pub vmentries: *mut ::c_void, + pub files: *mut ::c_void, + pub argv: *mut ::c_void, + pub envv: *mut ::c_void, + pub core: ::uintptr_t, } pub struct itimerspec { @@ -291,116 +517,6 @@ pub pri_user: u_char, } - pub struct kinfo_proc { - pub ki_structsize: ::c_int, - pub ki_layout: ::c_int, - pub ki_args: *mut pargs, - // This is normally "struct proc". - pub ki_paddr: *mut ::c_void, - // This is normally "struct user". - pub ki_addr: *mut ::c_void, - // This is normally "struct vnode". - pub ki_tracep: *mut ::c_void, - // This is normally "struct vnode". - pub ki_textvp: *mut ::c_void, - // This is normally "struct filedesc". - pub ki_fd: *mut ::c_void, - // This is normally "struct vmspace". - pub ki_vmspace: *mut ::c_void, - #[cfg(freebsd13)] - pub ki_wchan: *const ::c_void, - #[cfg(not(freebsd13))] - pub ki_wchan: *mut ::c_void, - pub ki_pid: ::pid_t, - pub ki_ppid: ::pid_t, - pub ki_pgid: ::pid_t, - pub ki_tpgid: ::pid_t, - pub ki_sid: ::pid_t, - pub ki_tsid: ::pid_t, - pub ki_jobc: ::c_short, - pub ki_spare_short1: ::c_short, - #[cfg(any(freebsd12, freebsd13))] - pub ki_tdev_freebsd11: u32, - #[cfg(freebsd11)] - pub ki_tdev: ::dev_t, - pub ki_siglist: ::sigset_t, - pub ki_sigmask: ::sigset_t, - pub ki_sigignore: ::sigset_t, - pub ki_sigcatch: ::sigset_t, - pub ki_uid: ::uid_t, - pub ki_ruid: ::uid_t, - pub ki_svuid: ::uid_t, - pub ki_rgid: ::gid_t, - pub ki_svgid: ::gid_t, - pub ki_ngroups: ::c_short, - pub ki_spare_short2: ::c_short, - pub ki_groups: [::gid_t; ::KI_NGROUPS], - pub ki_size: ::vm_size_t, - pub ki_rssize: segsz_t, - pub ki_swrss: segsz_t, - pub ki_tsize: segsz_t, - pub ki_dsize: segsz_t, - pub ki_ssize: segsz_t, - pub ki_xstat: ::u_short, - pub ki_acflag: ::u_short, - pub ki_pctcpu: fixpt_t, - pub ki_estcpu: u_int, - pub ki_slptime: u_int, - pub ki_swtime: u_int, - pub ki_cow: u_int, - pub ki_runtime: u64, - pub ki_start: ::timeval, - pub ki_childtime: ::timeval, - pub ki_flag: ::c_long, - pub ki_kiflag: ::c_long, - pub ki_traceflag: ::c_int, - pub ki_stat: ::c_char, - pub ki_nice: i8, // signed char - pub ki_lock: ::c_char, - pub ki_rqindex: ::c_char, - pub ki_oncpu_old: ::c_uchar, - pub ki_lastcpu_old: ::c_uchar, - pub ki_tdname: [::c_char; TDNAMLEN + 1], - pub ki_wmesg: [::c_char; ::WMESGLEN + 1], - pub ki_login: [::c_char; ::LOGNAMELEN + 1], - pub ki_lockname: [::c_char; ::LOCKNAMELEN + 1], - pub ki_comm: [::c_char; ::COMMLEN + 1], - pub ki_emul: [::c_char; ::KI_EMULNAMELEN + 1], - pub ki_loginclass: [::c_char; ::LOGINCLASSLEN + 1], - pub ki_moretdname: [::c_char; ::MAXCOMLEN - ::TDNAMLEN + 1], - pub ki_sparestrings: [[::c_char; 23]; 2], // little hack to allow PartialEq - pub ki_spareints: [::c_int; ::KI_NSPARE_INT], - #[cfg(freebsd13)] - pub ki_tdev: u64, - #[cfg(freebsd12)] - pub ki_tdev: ::dev_t, - pub ki_oncpu: ::c_int, - pub ki_lastcpu: ::c_int, - pub ki_tracer: ::c_int, - pub ki_flag2: ::c_int, - pub ki_fibnum: ::c_int, - pub ki_cr_flags: u_int, - pub ki_jid: ::c_int, - pub ki_numthreads: ::c_int, - pub ki_tid: lwpid_t, - pub ki_pri: priority, - pub ki_rusage: ::rusage, - pub ki_rusage_ch: ::rusage, - // This is normally "struct pcb". - pub ki_pcb: *mut ::c_void, - pub ki_kstack: *mut ::c_void, - pub ki_udata: *mut ::c_void, - // This is normally "struct thread". - pub ki_tdaddr: *mut ::c_void, - // This is normally "struct pwddesc". - #[cfg(freebsd13)] - pub ki_pd: *mut ::c_void, - pub ki_spareptrs: [*mut ::c_void; ::KI_NSPARE_PTR], - pub ki_sparelongs: [::c_long; ::KI_NSPARE_LONG], - pub ki_sflag: ::c_long, - pub ki_tdflags: ::c_long, - } - pub struct kvm_swap { pub ksw_devname: [::c_char; 32], pub ksw_used: u_int, @@ -427,6 +543,418 @@ pub n_type: ::c_uchar, pub n_value: ::kvaddr_t, } + + pub struct __c_anonymous_sem { + _priv: ::uintptr_t, + } + + pub struct semid_ds { + pub sem_perm: ::ipc_perm, + pub __sem_base: *mut __c_anonymous_sem, + pub sem_nsems: ::c_ushort, + pub sem_otime: ::time_t, + pub sem_ctime: ::time_t, + } + + pub struct vmtotal { + pub t_vm: u64, + pub t_avm: u64, + pub t_rm: u64, + pub t_arm: u64, + pub t_vmshr: u64, + pub t_avmshr: u64, + pub t_rmshr: u64, + pub t_armshr: u64, + pub t_free: u64, + pub t_rq: i16, + pub t_dw: i16, + pub t_pw: i16, + pub t_sl: i16, + pub t_sw: i16, + pub t_pad: [u16; 3], + } + + pub struct sockstat { + pub inp_ppcb: u64, + pub so_addr: u64, + pub so_pcb: u64, + pub unp_conn: u64, + pub dom_family: ::c_int, + pub proto: ::c_int, + pub so_rcv_sb_state: ::c_int, + pub so_snd_sb_state: ::c_int, + /// Socket address. + pub sa_local: ::sockaddr_storage, + /// Peer address. + pub sa_peer: ::sockaddr_storage, + pub type_: ::c_int, + pub dname: [::c_char; 32], + #[cfg(any(freebsd12, freebsd13, freebsd14))] + pub sendq: ::c_uint, + #[cfg(any(freebsd12, freebsd13, freebsd14))] + pub recvq: ::c_uint, + } + + pub struct shmstat { + pub size: u64, + pub mode: u16, + } + + pub struct rusage_ext { + pub rux_runtime: u64, + pub rux_uticks: u64, + pub rux_sticks: u64, + pub rux_iticks: u64, + pub rux_uu: u64, + pub rux_su: u64, + pub rux_tu: u64, + } + + pub struct if_clonereq { + pub ifcr_total: ::c_int, + pub ifcr_count: ::c_int, + pub ifcr_buffer: *mut ::c_char, + } + + pub struct if_msghdr { + /// to skip over non-understood messages + pub ifm_msglen: ::c_ushort, + /// future binary compatibility + pub ifm_version: ::c_uchar, + /// message type + pub ifm_type: ::c_uchar, + /// like rtm_addrs + pub ifm_addrs: ::c_int, + /// value of if_flags + pub ifm_flags: ::c_int, + /// index for associated ifp + pub ifm_index: ::c_ushort, + pub _ifm_spare1: ::c_ushort, + /// statistics and other data about if + pub ifm_data: if_data, + } + + pub struct if_msghdrl { + /// to skip over non-understood messages + pub ifm_msglen: ::c_ushort, + /// future binary compatibility + pub ifm_version: ::c_uchar, + /// message type + pub ifm_type: ::c_uchar, + /// like rtm_addrs + pub ifm_addrs: ::c_int, + /// value of if_flags + pub ifm_flags: ::c_int, + /// index for associated ifp + pub ifm_index: ::c_ushort, + /// spare space to grow if_index, see if_var.h + pub _ifm_spare1: ::c_ushort, + /// length of if_msghdrl incl. if_data + pub ifm_len: ::c_ushort, + /// offset of if_data from beginning + pub ifm_data_off: ::c_ushort, + pub _ifm_spare2: ::c_int, + /// statistics and other data about if + pub ifm_data: if_data, + } + + pub struct ifa_msghdr { + /// to skip over non-understood messages + pub ifam_msglen: ::c_ushort, + /// future binary compatibility + pub ifam_version: ::c_uchar, + /// message type + pub ifam_type: ::c_uchar, + /// like rtm_addrs + pub ifam_addrs: ::c_int, + /// value of ifa_flags + pub ifam_flags: ::c_int, + /// index for associated ifp + pub ifam_index: ::c_ushort, + pub _ifam_spare1: ::c_ushort, + /// value of ifa_ifp->if_metric + pub ifam_metric: ::c_int, + } + + pub struct ifa_msghdrl { + /// to skip over non-understood messages + pub ifam_msglen: ::c_ushort, + /// future binary compatibility + pub ifam_version: ::c_uchar, + /// message type + pub ifam_type: ::c_uchar, + /// like rtm_addrs + pub ifam_addrs: ::c_int, + /// value of ifa_flags + pub ifam_flags: ::c_int, + /// index for associated ifp + pub ifam_index: ::c_ushort, + /// spare space to grow if_index, see if_var.h + pub _ifam_spare1: ::c_ushort, + /// length of ifa_msghdrl incl. if_data + pub ifam_len: ::c_ushort, + /// offset of if_data from beginning + pub ifam_data_off: ::c_ushort, + /// value of ifa_ifp->if_metric + pub ifam_metric: ::c_int, + /// statistics and other data about if or address + pub ifam_data: if_data, + } + + pub struct ifma_msghdr { + /// to skip over non-understood messages + pub ifmam_msglen: ::c_ushort, + /// future binary compatibility + pub ifmam_version: ::c_uchar, + /// message type + pub ifmam_type: ::c_uchar, + /// like rtm_addrs + pub ifmam_addrs: ::c_int, + /// value of ifa_flags + pub ifmam_flags: ::c_int, + /// index for associated ifp + pub ifmam_index: ::c_ushort, + pub _ifmam_spare1: ::c_ushort, + } + + pub struct if_announcemsghdr { + /// to skip over non-understood messages + pub ifan_msglen: ::c_ushort, + /// future binary compatibility + pub ifan_version: ::c_uchar, + /// message type + pub ifan_type: ::c_uchar, + /// index for associated ifp + pub ifan_index: ::c_ushort, + /// if name, e.g. "en0" + pub ifan_name: [::c_char; ::IFNAMSIZ as usize], + /// what type of announcement + pub ifan_what: ::c_ushort, + } + + pub struct ifreq_buffer { + pub length: ::size_t, + pub buffer: *mut ::c_void, + } + + pub struct ifaliasreq { + /// if name, e.g. "en0" + pub ifra_name: [::c_char; ::IFNAMSIZ as usize], + pub ifra_addr: ::sockaddr, + pub ifra_broadaddr: ::sockaddr, + pub ifra_mask: ::sockaddr, + pub ifra_vhid: ::c_int, + } + + /// 9.x compat + pub struct oifaliasreq { + /// if name, e.g. "en0" + pub ifra_name: [::c_char; ::IFNAMSIZ as usize], + pub ifra_addr: ::sockaddr, + pub ifra_broadaddr: ::sockaddr, + pub ifra_mask: ::sockaddr, + } + + pub struct ifmediareq { + /// if name, e.g. "en0" + pub ifm_name: [::c_char; ::IFNAMSIZ as usize], + /// current media options + pub ifm_current: ::c_int, + /// don't care mask + pub ifm_mask: ::c_int, + /// media status + pub ifm_status: ::c_int, + /// active options + pub ifm_active: ::c_int, + /// # entries in ifm_ulist array + pub ifm_count: ::c_int, + /// media words + pub ifm_ulist: *mut ::c_int, + } + + pub struct ifdrv { + /// if name, e.g. "en0" + pub ifd_name: [::c_char; ::IFNAMSIZ as usize], + pub ifd_cmd: ::c_ulong, + pub ifd_len: ::size_t, + pub ifd_data: *mut ::c_void, + } + + pub struct ifi2creq { + /// i2c address (0xA0, 0xA2) + pub dev_addr: u8, + /// read offset + pub offset: u8, + /// read length + pub len: u8, + pub spare0: u8, + pub spare1: u32, + /// read buffer + pub data: [u8; 8], + } + + pub struct ifrsshash { + /// if name, e.g. "en0" + pub ifrh_name: [::c_char; ::IFNAMSIZ as usize], + /// RSS_FUNC_ + pub ifrh_func: u8, + pub ifrh_spare0: u8, + pub ifrh_spare1: u16, + /// RSS_TYPE_ + pub ifrh_types: u32, + } + + pub struct ifmibdata { + /// name of interface + pub ifmd_name: [::c_char; ::IFNAMSIZ as usize], + /// number of promiscuous listeners + pub ifmd_pcount: ::c_int, + /// interface flags + pub ifmd_flags: ::c_int, + /// instantaneous length of send queue + pub ifmd_snd_len: ::c_int, + /// maximum length of send queue + pub ifmd_snd_maxlen: ::c_int, + /// number of drops in send queue + pub ifmd_snd_drops: ::c_int, + /// for future expansion + pub ifmd_filler: [::c_int; 4], + /// generic information and statistics + pub ifmd_data: if_data, + } + + pub struct ifmib_iso_8802_3 { + pub dot3StatsAlignmentErrors: u32, + pub dot3StatsFCSErrors: u32, + pub dot3StatsSingleCollisionFrames: u32, + pub dot3StatsMultipleCollisionFrames: u32, + pub dot3StatsSQETestErrors: u32, + pub dot3StatsDeferredTransmissions: u32, + pub dot3StatsLateCollisions: u32, + pub dot3StatsExcessiveCollisions: u32, + pub dot3StatsInternalMacTransmitErrors: u32, + pub dot3StatsCarrierSenseErrors: u32, + pub dot3StatsFrameTooLongs: u32, + pub dot3StatsInternalMacReceiveErrors: u32, + pub dot3StatsEtherChipSet: u32, + pub dot3StatsMissedFrames: u32, + pub dot3StatsCollFrequencies: [u32; 16], + pub dot3Compliance: u32, + } + + pub struct __c_anonymous_ph { + pub ph1: u64, + pub ph2: u64, + } + + pub struct fid { + pub fid_len: ::c_ushort, + pub fid_data0: ::c_ushort, + pub fid_data: [::c_char; ::MAXFIDSZ as usize], + } + + pub struct fhandle { + pub fh_fsid: ::fsid_t, + pub fh_fid: fid, + } + + pub struct bintime { + pub sec: ::time_t, + pub frac: u64, + } + + pub struct clockinfo { + /// clock frequency + pub hz: ::c_int, + /// micro-seconds per hz tick + pub tick: ::c_int, + pub spare: ::c_int, + /// statistics clock frequency + pub stathz: ::c_int, + /// profiling clock frequency + pub profhz: ::c_int, + } + + pub struct __c_anonymous_stailq_entry_devstat { + pub stqe_next: *mut devstat, + } + + pub struct devstat { + /// Update sequence + pub sequence0: ::u_int, + /// Allocated entry + pub allocated: ::c_int, + /// started ops + pub start_count: ::u_int, + /// completed ops + pub end_count: ::u_int, + /// busy time unaccounted for since this time + pub busy_from: bintime, + pub dev_links: __c_anonymous_stailq_entry_devstat, + /// Devstat device number. + pub device_number: u32, + pub device_name: [::c_char; DEVSTAT_NAME_LEN as usize], + pub unit_number: ::c_int, + pub bytes: [u64; DEVSTAT_N_TRANS_FLAGS as usize], + pub operations: [u64; DEVSTAT_N_TRANS_FLAGS as usize], + pub duration: [bintime; DEVSTAT_N_TRANS_FLAGS as usize], + pub busy_time: bintime, + /// Time the device was created. + pub creation_time: bintime, + /// Block size, bytes + pub block_size: u32, + /// The number of simple, ordered, and head of queue tags sent. + pub tag_types: [u64; 3], + /// Which statistics are supported by a given device. + pub flags: devstat_support_flags, + /// Device type + pub device_type: devstat_type_flags, + /// Controls list pos. + pub priority: devstat_priority, + /// Identification for GEOM nodes + pub id: *const ::c_void, + /// Update sequence + pub sequence1: ::u_int, + } + + pub struct devstat_match { + pub match_fields: devstat_match_flags, + pub device_type: devstat_type_flags, + pub num_match_categories: ::c_int, + } + + pub struct devstat_match_table { + pub match_str: *const ::c_char, + pub type_: devstat_type_flags, + pub match_field: devstat_match_flags, + } + + pub struct device_selection { + pub device_number: u32, + pub device_name: [::c_char; DEVSTAT_NAME_LEN as usize], + pub unit_number: ::c_int, + pub selected: ::c_int, + pub bytes: u64, + pub position: ::c_int, + } + + pub struct devinfo { + pub devices: *mut devstat, + pub mem_ptr: *mut u8, + pub generation: ::c_long, + pub numdevs: ::c_int, + } + + pub struct sockcred2 { + pub sc_version: ::c_int, + pub sc_pid: ::pid_t, + pub sc_uid: ::uid_t, + pub sc_euid: ::uid_t, + pub sc_gid: ::gid_t, + pub sc_egid: ::gid_t, + pub sc_ngroups: ::c_int, + pub sc_groups: [::gid_t; 1], + } } s_no_extra_traits! { @@ -489,6 +1017,14 @@ __unused2: [::c_long; 7] } + pub struct ptsstat { + #[cfg(any(freebsd12, freebsd13, freebsd14))] + pub dev: u64, + #[cfg(not(any(freebsd12, freebsd13, freebsd14)))] + pub dev: u32, + pub devname: [::c_char; SPECNAMELEN as usize + 1], + } + #[cfg(libc_union)] pub union __c_anonymous_elf32_auxv_union { pub a_val: ::c_int, @@ -499,6 +1035,130 @@ #[cfg(libc_union)] pub a_un: __c_anonymous_elf32_auxv_union, } + + #[cfg(libc_union)] + pub union __c_anonymous_ifi_epoch { + pub tt: ::time_t, + pub ph: u64, + } + + #[cfg(libc_union)] + pub union __c_anonymous_ifi_lastchange { + pub tv: ::timeval, + pub ph: __c_anonymous_ph, + } + + pub struct if_data { + /// ethernet, tokenring, etc + pub ifi_type: u8, + /// e.g., AUI, Thinnet, 10base-T, etc + pub ifi_physical: u8, + /// media address length + pub ifi_addrlen: u8, + /// media header length + pub ifi_hdrlen: u8, + /// current link state + pub ifi_link_state: u8, + /// carp vhid + pub ifi_vhid: u8, + /// length of this data struct + pub ifi_datalen: u16, + /// maximum transmission unit + pub ifi_mtu: u32, + /// routing metric (external only) + pub ifi_metric: u32, + /// linespeed + pub ifi_baudrate: u64, + /// packets received on interface + pub ifi_ipackets: u64, + /// input errors on interface + pub ifi_ierrors: u64, + /// packets sent on interface + pub ifi_opackets: u64, + /// output errors on interface + pub ifi_oerrors: u64, + /// collisions on csma interfaces + pub ifi_collisions: u64, + /// total number of octets received + pub ifi_ibytes: u64, + /// total number of octets sent + pub ifi_obytes: u64, + /// packets received via multicast + pub ifi_imcasts: u64, + /// packets sent via multicast + pub ifi_omcasts: u64, + /// dropped on input + pub ifi_iqdrops: u64, + /// dropped on output + pub ifi_oqdrops: u64, + /// destined for unsupported protocol + pub ifi_noproto: u64, + /// HW offload capabilities, see IFCAP + pub ifi_hwassist: u64, + /// uptime at attach or stat reset + #[cfg(libc_union)] + pub __ifi_epoch: __c_anonymous_ifi_epoch, + /// uptime at attach or stat reset + #[cfg(not(libc_union))] + pub __ifi_epoch: u64, + /// time of last administrative change + #[cfg(libc_union)] + pub __ifi_lastchange: __c_anonymous_ifi_lastchange, + /// time of last administrative change + #[cfg(not(libc_union))] + pub __ifi_lastchange: ::timeval, + } + + #[cfg(libc_union)] + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: ::sockaddr, + pub ifru_dstaddr: ::sockaddr, + pub ifru_broadaddr: ::sockaddr, + pub ifru_buffer: ifreq_buffer, + pub ifru_flags: [::c_short; 2], + pub ifru_index: ::c_short, + pub ifru_jid: ::c_int, + pub ifru_metric: ::c_int, + pub ifru_mtu: ::c_int, + pub ifru_phys: ::c_int, + pub ifru_media: ::c_int, + pub ifru_data: ::caddr_t, + pub ifru_cap: [::c_int; 2], + pub ifru_fib: ::c_uint, + pub ifru_vlan_pcp: ::c_uchar, + } + + pub struct ifreq { + /// if name, e.g. "en0" + pub ifr_name: [::c_char; ::IFNAMSIZ], + #[cfg(libc_union)] + pub ifr_ifru: __c_anonymous_ifr_ifru, + #[cfg(not(libc_union))] + pub ifr_ifru: ::sockaddr, + } + + pub struct ifstat { + /// if name, e.g. "en0" + pub ifs_name: [::c_char; ::IFNAMSIZ as usize], + pub ascii: [::c_char; ::IFSTATMAX as usize + 1], + } + + pub struct ifrsskey { + /// if name, e.g. "en0" + pub ifrk_name: [::c_char; ::IFNAMSIZ as usize], + /// RSS_FUNC_ + pub ifrk_func: u8, + pub ifrk_spare0: u8, + pub ifrk_keylen: u16, + pub ifrk_key: [u8; ::RSS_KEYLEN as usize], + } + + pub struct ifdownreason { + pub ifdr_name: [::c_char; ::IFNAMSIZ as usize], + pub ifdr_reason: u32, + pub ifdr_vendor: u32, + pub ifdr_msg: [::c_char; ::IFDR_MSG_SIZE as usize], + } } cfg_if! { @@ -719,6 +1379,35 @@ self.sigev_notify_thread_id.hash(state); } } + + impl PartialEq for ptsstat { + fn eq(&self, other: &ptsstat) -> bool { + let self_devname: &[::c_char] = &self.devname; + let other_devname: &[::c_char] = &other.devname; + + self.dev == other.dev && self_devname == other_devname + } + } + impl Eq for ptsstat {} + impl ::fmt::Debug for ptsstat { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let self_devname: &[::c_char] = &self.devname; + + f.debug_struct("ptsstat") + .field("dev", &self.dev) + .field("devname", &self_devname) + .finish() + } + } + impl ::hash::Hash for ptsstat { + fn hash(&self, state: &mut H) { + let self_devname: &[::c_char] = &self.devname; + + self.dev.hash(state); + self_devname.hash(state); + } + } + #[cfg(libc_union)] impl PartialEq for __c_anonymous_elf32_auxv_union { fn eq(&self, other: &__c_anonymous_elf32_auxv_union) -> bool { @@ -766,9 +1455,364 @@ .finish() } } + + #[cfg(libc_union)] + impl PartialEq for __c_anonymous_ifr_ifru { + fn eq(&self, other: &__c_anonymous_ifr_ifru) -> bool { + unsafe { + self.ifru_addr == other.ifru_addr && + self.ifru_dstaddr == other.ifru_dstaddr && + self.ifru_broadaddr == other.ifru_broadaddr && + self.ifru_buffer == other.ifru_buffer && + self.ifru_flags == other.ifru_flags && + self.ifru_index == other.ifru_index && + self.ifru_jid == other.ifru_jid && + self.ifru_metric == other.ifru_metric && + self.ifru_mtu == other.ifru_mtu && + self.ifru_phys == other.ifru_phys && + self.ifru_media == other.ifru_media && + self.ifru_data == other.ifru_data && + self.ifru_cap == other.ifru_cap && + self.ifru_fib == other.ifru_fib && + self.ifru_vlan_pcp == other.ifru_vlan_pcp + } + } + } + #[cfg(libc_union)] + impl Eq for __c_anonymous_ifr_ifru {} + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_ifr_ifru { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ifr_ifru") + .field("ifru_addr", unsafe { &self.ifru_addr }) + .field("ifru_dstaddr", unsafe { &self.ifru_dstaddr }) + .field("ifru_broadaddr", unsafe { &self.ifru_broadaddr }) + .field("ifru_buffer", unsafe { &self.ifru_buffer }) + .field("ifru_flags", unsafe { &self.ifru_flags }) + .field("ifru_index", unsafe { &self.ifru_index }) + .field("ifru_jid", unsafe { &self.ifru_jid }) + .field("ifru_metric", unsafe { &self.ifru_metric }) + .field("ifru_mtu", unsafe { &self.ifru_mtu }) + .field("ifru_phys", unsafe { &self.ifru_phys }) + .field("ifru_media", unsafe { &self.ifru_media }) + .field("ifru_data", unsafe { &self.ifru_data }) + .field("ifru_cap", unsafe { &self.ifru_cap }) + .field("ifru_fib", unsafe { &self.ifru_fib }) + .field("ifru_vlan_pcp", unsafe { &self.ifru_vlan_pcp }) + .finish() + } + } + #[cfg(libc_union)] + impl ::hash::Hash for __c_anonymous_ifr_ifru { + fn hash(&self, state: &mut H) { + unsafe { self.ifru_addr.hash(state) }; + unsafe { self.ifru_dstaddr.hash(state) }; + unsafe { self.ifru_broadaddr.hash(state) }; + unsafe { self.ifru_buffer.hash(state) }; + unsafe { self.ifru_flags.hash(state) }; + unsafe { self.ifru_index.hash(state) }; + unsafe { self.ifru_jid.hash(state) }; + unsafe { self.ifru_metric.hash(state) }; + unsafe { self.ifru_mtu.hash(state) }; + unsafe { self.ifru_phys.hash(state) }; + unsafe { self.ifru_media.hash(state) }; + unsafe { self.ifru_data.hash(state) }; + unsafe { self.ifru_cap.hash(state) }; + unsafe { self.ifru_fib.hash(state) }; + unsafe { self.ifru_vlan_pcp.hash(state) }; + } + } + + impl PartialEq for ifreq { + fn eq(&self, other: &ifreq) -> bool { + self.ifr_name == other.ifr_name && self.ifr_ifru == other.ifr_ifru + } + } + impl Eq for ifreq {} + impl ::fmt::Debug for ifreq { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ifreq") + .field("ifr_name", &self.ifr_name) + .field("ifr_ifru", &self.ifr_ifru) + .finish() + } + } + impl ::hash::Hash for ifreq { + fn hash(&self, state: &mut H) { + self.ifr_name.hash(state); + self.ifr_ifru.hash(state); + } + } + + impl PartialEq for ifstat { + fn eq(&self, other: &ifstat) -> bool { + let self_ascii: &[::c_char] = &self.ascii; + let other_ascii: &[::c_char] = &other.ascii; + + self.ifs_name == other.ifs_name && self_ascii == other_ascii + } + } + impl Eq for ifstat {} + impl ::fmt::Debug for ifstat { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let ascii: &[::c_char] = &self.ascii; + + f.debug_struct("ifstat") + .field("ifs_name", &self.ifs_name) + .field("ascii", &ascii) + .finish() + } + } + impl ::hash::Hash for ifstat { + fn hash(&self, state: &mut H) { + self.ifs_name.hash(state); + self.ascii.hash(state); + } + } + + impl PartialEq for ifrsskey { + fn eq(&self, other: &ifrsskey) -> bool { + let self_ifrk_key: &[u8] = &self.ifrk_key; + let other_ifrk_key: &[u8] = &other.ifrk_key; + + self.ifrk_name == other.ifrk_name && + self.ifrk_func == other.ifrk_func && + self.ifrk_spare0 == other.ifrk_spare0 && + self.ifrk_keylen == other.ifrk_keylen && + self_ifrk_key == other_ifrk_key + } + } + impl Eq for ifrsskey {} + impl ::fmt::Debug for ifrsskey { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let ifrk_key: &[u8] = &self.ifrk_key; + + f.debug_struct("ifrsskey") + .field("ifrk_name", &self.ifrk_name) + .field("ifrk_func", &self.ifrk_func) + .field("ifrk_spare0", &self.ifrk_spare0) + .field("ifrk_keylen", &self.ifrk_keylen) + .field("ifrk_key", &ifrk_key) + .finish() + } + } + impl ::hash::Hash for ifrsskey { + fn hash(&self, state: &mut H) { + self.ifrk_name.hash(state); + self.ifrk_func.hash(state); + self.ifrk_spare0.hash(state); + self.ifrk_keylen.hash(state); + self.ifrk_key.hash(state); + } + } + + impl PartialEq for ifdownreason { + fn eq(&self, other: &ifdownreason) -> bool { + let self_ifdr_msg: &[::c_char] = &self.ifdr_msg; + let other_ifdr_msg: &[::c_char] = &other.ifdr_msg; + + self.ifdr_name == other.ifdr_name && + self.ifdr_reason == other.ifdr_reason && + self.ifdr_vendor == other.ifdr_vendor && + self_ifdr_msg == other_ifdr_msg + } + } + impl Eq for ifdownreason {} + impl ::fmt::Debug for ifdownreason { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + let ifdr_msg: &[::c_char] = &self.ifdr_msg; + + f.debug_struct("ifdownreason") + .field("ifdr_name", &self.ifdr_name) + .field("ifdr_reason", &self.ifdr_reason) + .field("ifdr_vendor", &self.ifdr_vendor) + .field("ifdr_msg", &ifdr_msg) + .finish() + } + } + impl ::hash::Hash for ifdownreason { + fn hash(&self, state: &mut H) { + self.ifdr_name.hash(state); + self.ifdr_reason.hash(state); + self.ifdr_vendor.hash(state); + self.ifdr_msg.hash(state); + } + } + + #[cfg(libc_union)] + impl PartialEq for __c_anonymous_ifi_epoch { + fn eq(&self, other: &__c_anonymous_ifi_epoch) -> bool { + unsafe { + self.tt == other.tt && + self.ph == other.ph + } + } + } + #[cfg(libc_union)] + impl Eq for __c_anonymous_ifi_epoch {} + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_ifi_epoch { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("__c_anonymous_ifi_epoch") + .field("tt", unsafe { &self.tt }) + .field("ph", unsafe { &self.ph }) + .finish() + } + } + #[cfg(libc_union)] + impl ::hash::Hash for __c_anonymous_ifi_epoch { + fn hash(&self, state: &mut H) { + unsafe { + self.tt.hash(state); + self.ph.hash(state); + } + } + } + + #[cfg(libc_union)] + impl PartialEq for __c_anonymous_ifi_lastchange { + fn eq(&self, other: &__c_anonymous_ifi_lastchange) -> bool { + unsafe { + self.tv == other.tv && + self.ph == other.ph + } + } + } + #[cfg(libc_union)] + impl Eq for __c_anonymous_ifi_lastchange {} + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_ifi_lastchange { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("__c_anonymous_ifi_lastchange") + .field("tv", unsafe { &self.tv }) + .field("ph", unsafe { &self.ph }) + .finish() + } + } + #[cfg(libc_union)] + impl ::hash::Hash for __c_anonymous_ifi_lastchange { + fn hash(&self, state: &mut H) { + unsafe { + self.tv.hash(state); + self.ph.hash(state); + } + } + } + + impl PartialEq for if_data { + fn eq(&self, other: &if_data) -> bool { + self.ifi_type == other.ifi_type && + self.ifi_physical == other.ifi_physical && + self.ifi_addrlen == other.ifi_addrlen && + self.ifi_hdrlen == other.ifi_hdrlen && + self.ifi_link_state == other.ifi_link_state && + self.ifi_vhid == other.ifi_vhid && + self.ifi_datalen == other.ifi_datalen && + self.ifi_mtu == other.ifi_mtu && + self.ifi_metric == other.ifi_metric && + self.ifi_baudrate == other.ifi_baudrate && + self.ifi_ipackets == other.ifi_ipackets && + self.ifi_ierrors == other.ifi_ierrors && + self.ifi_opackets == other.ifi_opackets && + self.ifi_oerrors == other.ifi_oerrors && + self.ifi_collisions == other.ifi_collisions && + self.ifi_ibytes == other.ifi_ibytes && + self.ifi_obytes == other.ifi_obytes && + self.ifi_imcasts == other.ifi_imcasts && + self.ifi_omcasts == other.ifi_omcasts && + self.ifi_iqdrops == other.ifi_iqdrops && + self.ifi_oqdrops == other.ifi_oqdrops && + self.ifi_noproto == other.ifi_noproto && + self.ifi_hwassist == other.ifi_hwassist && + self.__ifi_epoch == other.__ifi_epoch && + self.__ifi_lastchange == other.__ifi_lastchange + } + } + impl Eq for if_data {} + impl ::fmt::Debug for if_data { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("if_data") + .field("ifi_type", &self.ifi_type) + .field("ifi_physical", &self.ifi_physical) + .field("ifi_addrlen", &self.ifi_addrlen) + .field("ifi_hdrlen", &self.ifi_hdrlen) + .field("ifi_link_state", &self.ifi_link_state) + .field("ifi_vhid", &self.ifi_vhid) + .field("ifi_datalen", &self.ifi_datalen) + .field("ifi_mtu", &self.ifi_mtu) + .field("ifi_metric", &self.ifi_metric) + .field("ifi_baudrate", &self.ifi_baudrate) + .field("ifi_ipackets", &self.ifi_ipackets) + .field("ifi_ierrors", &self.ifi_ierrors) + .field("ifi_opackets", &self.ifi_opackets) + .field("ifi_oerrors", &self.ifi_oerrors) + .field("ifi_collisions", &self.ifi_collisions) + .field("ifi_ibytes", &self.ifi_ibytes) + .field("ifi_obytes", &self.ifi_obytes) + .field("ifi_imcasts", &self.ifi_imcasts) + .field("ifi_omcasts", &self.ifi_omcasts) + .field("ifi_iqdrops", &self.ifi_iqdrops) + .field("ifi_oqdrops", &self.ifi_oqdrops) + .field("ifi_noproto", &self.ifi_noproto) + .field("ifi_hwassist", &self.ifi_hwassist) + .field("__ifi_epoch", &self.__ifi_epoch) + .field("__ifi_lastchange", &self.__ifi_lastchange) + .finish() + } + } + impl ::hash::Hash for if_data { + fn hash(&self, state: &mut H) { + self.ifi_type.hash(state); + self.ifi_physical.hash(state); + self.ifi_addrlen.hash(state); + self.ifi_hdrlen.hash(state); + self.ifi_link_state.hash(state); + self.ifi_vhid.hash(state); + self.ifi_datalen.hash(state); + self.ifi_mtu.hash(state); + self.ifi_metric.hash(state); + self.ifi_baudrate.hash(state); + self.ifi_ipackets.hash(state); + self.ifi_ierrors.hash(state); + self.ifi_opackets.hash(state); + self.ifi_oerrors.hash(state); + self.ifi_collisions.hash(state); + self.ifi_ibytes.hash(state); + self.ifi_obytes.hash(state); + self.ifi_imcasts.hash(state); + self.ifi_omcasts.hash(state); + self.ifi_iqdrops.hash(state); + self.ifi_oqdrops.hash(state); + self.ifi_noproto.hash(state); + self.ifi_hwassist.hash(state); + self.__ifi_epoch.hash(state); + self.__ifi_lastchange.hash(state); + } + } } } +#[cfg_attr(feature = "extra_traits", derive(Debug))] +#[repr(u32)] +pub enum dot3Vendors { + dot3VendorAMD = 1, + dot3VendorIntel = 2, + dot3VendorNational = 4, + dot3VendorFujitsu = 5, + dot3VendorDigital = 6, + dot3VendorWesternDigital = 7, +} +impl ::Copy for dot3Vendors {} +impl ::Clone for dot3Vendors { + fn clone(&self) -> dot3Vendors { + *self + } +} + +// sys/devicestat.h +pub const DEVSTAT_N_TRANS_FLAGS: ::c_int = 4; +pub const DEVSTAT_NAME_LEN: ::c_int = 16; + pub const SIGEV_THREAD_ID: ::c_int = 4; pub const EXTATTR_NAMESPACE_EMPTY: ::c_int = 0; @@ -803,6 +1847,15 @@ pub const RLIMIT_UMTXP: ::c_int = 14; #[deprecated(since = "0.2.64", note = "Not stable across OS versions")] pub const RLIM_NLIMITS: ::rlim_t = 15; +pub const RLIM_SAVED_MAX: ::rlim_t = ::RLIM_INFINITY; +pub const RLIM_SAVED_CUR: ::rlim_t = ::RLIM_INFINITY; + +pub const CP_USER: ::c_int = 0; +pub const CP_NICE: ::c_int = 1; +pub const CP_SYS: ::c_int = 2; +pub const CP_INTR: ::c_int = 3; +pub const CP_IDLE: ::c_int = 4; +pub const CPUSTATES: ::c_int = 5; pub const NI_NOFQDN: ::c_int = 0x00000001; pub const NI_NUMERICHOST: ::c_int = 0x00000002; @@ -904,6 +1957,58 @@ pub const CTL_MACHDEP: ::c_int = 7; pub const CTL_USER: ::c_int = 8; pub const CTL_P1003_1B: ::c_int = 9; + +// sys/sysctl.h +pub const CTL_MAXNAME: ::c_int = 24; + +pub const CTLTYPE: ::c_int = 0xf; +pub const CTLTYPE_NODE: ::c_int = 1; +pub const CTLTYPE_INT: ::c_int = 2; +pub const CTLTYPE_STRING: ::c_int = 3; +pub const CTLTYPE_S64: ::c_int = 4; +pub const CTLTYPE_OPAQUE: ::c_int = 5; +pub const CTLTYPE_STRUCT: ::c_int = CTLTYPE_OPAQUE; +pub const CTLTYPE_UINT: ::c_int = 6; +pub const CTLTYPE_LONG: ::c_int = 7; +pub const CTLTYPE_ULONG: ::c_int = 8; +pub const CTLTYPE_U64: ::c_int = 9; +pub const CTLTYPE_U8: ::c_int = 0xa; +pub const CTLTYPE_U16: ::c_int = 0xb; +pub const CTLTYPE_S8: ::c_int = 0xc; +pub const CTLTYPE_S16: ::c_int = 0xd; +pub const CTLTYPE_S32: ::c_int = 0xe; +pub const CTLTYPE_U32: ::c_int = 0xf; + +pub const CTLFLAG_RD: ::c_int = 0x80000000; +pub const CTLFLAG_WR: ::c_int = 0x40000000; +pub const CTLFLAG_RW: ::c_int = CTLFLAG_RD | CTLFLAG_WR; +pub const CTLFLAG_DORMANT: ::c_int = 0x20000000; +pub const CTLFLAG_ANYBODY: ::c_int = 0x10000000; +pub const CTLFLAG_SECURE: ::c_int = 0x08000000; +pub const CTLFLAG_PRISON: ::c_int = 0x04000000; +pub const CTLFLAG_DYN: ::c_int = 0x02000000; +pub const CTLFLAG_SKIP: ::c_int = 0x01000000; +pub const CTLMASK_SECURE: ::c_int = 0x00F00000; +pub const CTLFLAG_TUN: ::c_int = 0x00080000; +pub const CTLFLAG_RDTUN: ::c_int = CTLFLAG_RD | CTLFLAG_TUN; +pub const CTLFLAG_RWTUN: ::c_int = CTLFLAG_RW | CTLFLAG_TUN; +pub const CTLFLAG_MPSAFE: ::c_int = 0x00040000; +pub const CTLFLAG_VNET: ::c_int = 0x00020000; +pub const CTLFLAG_DYING: ::c_int = 0x00010000; +pub const CTLFLAG_CAPRD: ::c_int = 0x00008000; +pub const CTLFLAG_CAPWR: ::c_int = 0x00004000; +pub const CTLFLAG_STATS: ::c_int = 0x00002000; +pub const CTLFLAG_NOFETCH: ::c_int = 0x00001000; +pub const CTLFLAG_CAPRW: ::c_int = CTLFLAG_CAPRD | CTLFLAG_CAPWR; +pub const CTLFLAG_NEEDGIANT: ::c_int = 0x00000800; + +pub const CTLSHIFT_SECURE: ::c_int = 20; +pub const CTLFLAG_SECURE1: ::c_int = CTLFLAG_SECURE | (0 << CTLSHIFT_SECURE); +pub const CTLFLAG_SECURE2: ::c_int = CTLFLAG_SECURE | (1 << CTLSHIFT_SECURE); +pub const CTLFLAG_SECURE3: ::c_int = CTLFLAG_SECURE | (2 << CTLSHIFT_SECURE); + +pub const OID_AUTO: ::c_int = -1; + pub const CTL_SYSCTL_DEBUG: ::c_int = 0; pub const CTL_SYSCTL_NAME: ::c_int = 1; pub const CTL_SYSCTL_NEXT: ::c_int = 2; @@ -911,6 +2016,8 @@ pub const CTL_SYSCTL_OIDFMT: ::c_int = 4; pub const CTL_SYSCTL_OIDDESCR: ::c_int = 5; pub const CTL_SYSCTL_OIDLABEL: ::c_int = 6; +pub const CTL_SYSCTL_NEXTNOSKIP: ::c_int = 7; + pub const KERN_OSTYPE: ::c_int = 1; pub const KERN_OSRELEASE: ::c_int = 2; pub const KERN_OSREV: ::c_int = 3; @@ -948,6 +2055,9 @@ pub const KERN_IOV_MAX: ::c_int = 35; pub const KERN_HOSTUUID: ::c_int = 36; pub const KERN_ARND: ::c_int = 37; +pub const KERN_MAXPHYS: ::c_int = 38; +pub const KERN_STACKTOP: ::c_int = 39; + pub const KERN_PROC_ALL: ::c_int = 0; pub const KERN_PROC_PID: ::c_int = 1; pub const KERN_PROC_PGRP: ::c_int = 2; @@ -975,6 +2085,10 @@ pub const KERN_PROC_UMASK: ::c_int = 39; pub const KERN_PROC_OSREL: ::c_int = 40; pub const KERN_PROC_SIGTRAMP: ::c_int = 41; +pub const KERN_PROC_CWD: ::c_int = 42; +pub const KERN_PROC_NFDS: ::c_int = 43; +pub const KERN_PROC_SIGFASTBLK: ::c_int = 44; + pub const KIPC_MAXSOCKBUF: ::c_int = 1; pub const KIPC_SOCKBUF_WASTE: ::c_int = 2; pub const KIPC_SOMAXCONN: ::c_int = 3; @@ -982,6 +2096,7 @@ pub const KIPC_MAX_PROTOHDR: ::c_int = 5; pub const KIPC_MAX_HDR: ::c_int = 6; pub const KIPC_MAX_DATALEN: ::c_int = 7; + pub const HW_MACHINE: ::c_int = 1; pub const HW_MODEL: ::c_int = 2; pub const HW_NCPU: ::c_int = 3; @@ -994,6 +2109,7 @@ pub const HW_FLOATINGPT: ::c_int = 10; pub const HW_MACHINE_ARCH: ::c_int = 11; pub const HW_REALMEM: ::c_int = 12; + pub const USER_CS_PATH: ::c_int = 1; pub const USER_BC_BASE_MAX: ::c_int = 2; pub const USER_BC_DIM_MAX: ::c_int = 3; @@ -1014,6 +2130,8 @@ pub const USER_POSIX2_UPE: ::c_int = 18; pub const USER_STREAM_MAX: ::c_int = 19; pub const USER_TZNAME_MAX: ::c_int = 20; +pub const USER_LOCALBASE: ::c_int = 21; + pub const CTL_P1003_1B_ASYNCHRONOUS_IO: ::c_int = 1; pub const CTL_P1003_1B_MAPPED_FILES: ::c_int = 2; pub const CTL_P1003_1B_MEMLOCK: ::c_int = 3; @@ -1039,14 +2157,18 @@ pub const CTL_P1003_1B_SEM_VALUE_MAX: ::c_int = 23; pub const CTL_P1003_1B_SIGQUEUE_MAX: ::c_int = 24; pub const CTL_P1003_1B_TIMER_MAX: ::c_int = 25; -pub const TIOCGPTN: ::c_uint = 0x4004740f; -pub const TIOCPTMASTER: ::c_uint = 0x2000741c; -pub const TIOCSIG: ::c_uint = 0x2004745f; + +pub const TIOCGPTN: ::c_ulong = 0x4004740f; +pub const TIOCPTMASTER: ::c_ulong = 0x2000741c; +pub const TIOCSIG: ::c_ulong = 0x2004745f; pub const TIOCM_DCD: ::c_int = 0x40; pub const H4DISC: ::c_int = 0x7; +pub const VM_TOTAL: ::c_int = 1; + pub const BIOCSETFNR: ::c_ulong = 0x80104282; +pub const FIODGNAME: ::c_ulong = 0x80106678; pub const FIONWRITE: ::c_ulong = 0x40046677; pub const FIONSPACE: ::c_ulong = 0x40046676; pub const FIOSEEKDATA: ::c_ulong = 0xc0086661; @@ -1096,6 +2218,21 @@ pub const LOCAL_CONNWAIT: ::c_int = 4; pub const LOCAL_VENDOR: ::c_int = SO_VENDOR; +pub const PL_EVENT_NONE: ::c_int = 0; +pub const PL_EVENT_SIGNAL: ::c_int = 1; +pub const PL_FLAG_SA: ::c_int = 0x01; +pub const PL_FLAG_BOUND: ::c_int = 0x02; +pub const PL_FLAG_SCE: ::c_int = 0x04; +pub const PL_FLAG_SCX: ::c_int = 0x08; +pub const PL_FLAG_EXEC: ::c_int = 0x10; +pub const PL_FLAG_SI: ::c_int = 0x20; +pub const PL_FLAG_FORKED: ::c_int = 0x40; +pub const PL_FLAG_CHILD: ::c_int = 0x80; +pub const PL_FLAG_BORN: ::c_int = 0x100; +pub const PL_FLAG_EXITED: ::c_int = 0x200; +pub const PL_FLAG_VFORKED: ::c_int = 0x400; +pub const PL_FLAG_VFORK_DONE: ::c_int = 0x800; + pub const PT_LWPINFO: ::c_int = 13; pub const PT_GETNUMLWPS: ::c_int = 14; pub const PT_GETLWPLIST: ::c_int = 15; @@ -1110,6 +2247,9 @@ pub const PT_LWP_EVENTS: ::c_int = 24; pub const PT_GET_EVENT_MASK: ::c_int = 25; pub const PT_SET_EVENT_MASK: ::c_int = 26; +pub const PT_GET_SC_ARGS: ::c_int = 27; +pub const PT_GET_SC_RET: ::c_int = 28; +pub const PT_COREDUMP: ::c_int = 29; pub const PT_GETREGS: ::c_int = 33; pub const PT_SETREGS: ::c_int = 34; pub const PT_GETFPREGS: ::c_int = 35; @@ -1129,6 +2269,9 @@ pub const PTRACE_VFORK: ::c_int = 0x0020; pub const PTRACE_DEFAULT: ::c_int = PTRACE_EXEC; +pub const PC_COMPRESS: u32 = 0x00000001; +pub const PC_ALL: u32 = 0x00000002; + pub const PROC_SPROTECT: ::c_int = 1; pub const PROC_REAP_ACQUIRE: ::c_int = 2; pub const PROC_REAP_RELEASE: ::c_int = 3; @@ -1149,6 +2292,33 @@ pub const PROC_STACKGAP_STATUS: ::c_int = 18; pub const PROC_PROCCTL_MD_MIN: ::c_int = 0x10000000; +pub const PPROT_SET: ::c_int = 1; +pub const PPROT_CLEAR: ::c_int = 2; +pub const PPROT_DESCEND: ::c_int = 0x10; +pub const PPROT_INHERIT: ::c_int = 0x20; + +pub const PROC_TRACE_CTL_ENABLE: ::c_int = 1; +pub const PROC_TRACE_CTL_DISABLE: ::c_int = 2; +pub const PROC_TRACE_CTL_DISABLE_EXEC: ::c_int = 3; + +pub const PROC_TRAPCAP_CTL_ENABLE: ::c_int = 1; +pub const PROC_TRAPCAP_CTL_DISABLE: ::c_int = 2; + +pub const PROC_ASLR_FORCE_ENABLE: ::c_int = 1; +pub const PROC_ASLR_FORCE_DISABLE: ::c_int = 2; +pub const PROC_ASLR_NOFORCE: ::c_int = 3; +pub const PROC_ASLR_ACTIVE: ::c_int = 0x80000000; + +pub const PROC_PROTMAX_FORCE_ENABLE: ::c_int = 1; +pub const PROC_PROTMAX_FORCE_DISABLE: ::c_int = 2; +pub const PROC_PROTMAX_NOFORCE: ::c_int = 3; +pub const PROC_PROTMAX_ACTIVE: ::c_int = 0x80000000; + +pub const PROC_STACKGAP_ENABLE: ::c_int = 0x0001; +pub const PROC_STACKGAP_DISABLE: ::c_int = 0x0002; +pub const PROC_STACKGAP_ENABLE_EXEC: ::c_int = 0x0004; +pub const PROC_STACKGAP_DISABLE_EXEC: ::c_int = 0x0008; + pub const AF_SLOW: ::c_int = 33; pub const AF_SCLUSTER: ::c_int = 34; pub const AF_ARP: ::c_int = 35; @@ -1157,40 +2327,218 @@ pub const AF_INET_SDP: ::c_int = 40; pub const AF_INET6_SDP: ::c_int = 42; -// https://github.com/freebsd/freebsd/blob/master/sys/net/if.h#L140 -pub const IFF_UP: ::c_int = 0x1; // (n) interface is up -pub const IFF_BROADCAST: ::c_int = 0x2; // (i) broadcast address valid -pub const IFF_DEBUG: ::c_int = 0x4; // (n) turn on debugging -pub const IFF_LOOPBACK: ::c_int = 0x8; // (i) is a loopback net -pub const IFF_POINTOPOINT: ::c_int = 0x10; // (i) is a point-to-point link - // 0x20 was IFF_SMART -pub const IFF_RUNNING: ::c_int = 0x40; // (d) resources allocated +// sys/net/if.h +pub const IF_MAXUNIT: ::c_int = 0x7fff; +/// (n) interface is up +pub const IFF_UP: ::c_int = 0x1; +/// (i) broadcast address valid +pub const IFF_BROADCAST: ::c_int = 0x2; +/// (n) turn on debugging +pub const IFF_DEBUG: ::c_int = 0x4; +/// (i) is a loopback net +pub const IFF_LOOPBACK: ::c_int = 0x8; +/// (i) is a point-to-point link +pub const IFF_POINTOPOINT: ::c_int = 0x10; +/// (i) calls if_input in net epoch +pub const IFF_KNOWSEPOCH: ::c_int = 0x20; +/// (d) resources allocated +pub const IFF_RUNNING: ::c_int = 0x40; #[doc(hidden)] #[deprecated( since = "0.2.54", note = "IFF_DRV_RUNNING is deprecated. Use the portable IFF_RUNNING instead" )] +/// (d) resources allocate pub const IFF_DRV_RUNNING: ::c_int = 0x40; -pub const IFF_NOARP: ::c_int = 0x80; // (n) no address resolution protocol -pub const IFF_PROMISC: ::c_int = 0x100; // (n) receive all packets -pub const IFF_ALLMULTI: ::c_int = 0x200; // (n) receive all multicast packets -pub const IFF_OACTIVE: ::c_int = 0x400; // (d) tx hardware queue is full +/// (n) no address resolution protocol +pub const IFF_NOARP: ::c_int = 0x80; +/// (n) receive all packets +pub const IFF_PROMISC: ::c_int = 0x100; +/// (n) receive all multicast packets +pub const IFF_ALLMULTI: ::c_int = 0x200; +/// (d) tx hardware queue is full +pub const IFF_OACTIVE: ::c_int = 0x400; #[doc(hidden)] #[deprecated(since = "0.2.54", note = "Use the portable `IFF_OACTIVE` instead")] +/// (d) tx hardware queue is full pub const IFF_DRV_OACTIVE: ::c_int = 0x400; -pub const IFF_SIMPLEX: ::c_int = 0x800; // (i) can't hear own transmissions -pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit -pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit -pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit -pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection -pub const IFF_MULTICAST: ::c_int = 0x8000; // (i) supports multicast - // (i) unconfigurable using ioctl(2) +/// (i) can't hear own transmissions +pub const IFF_SIMPLEX: ::c_int = 0x800; +/// per link layer defined bit +pub const IFF_LINK0: ::c_int = 0x1000; +/// per link layer defined bit +pub const IFF_LINK1: ::c_int = 0x2000; +/// per link layer defined bit +pub const IFF_LINK2: ::c_int = 0x4000; +/// use alternate physical connection +pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; +/// (i) supports multicast +pub const IFF_MULTICAST: ::c_int = 0x8000; +/// (i) unconfigurable using ioctl(2) pub const IFF_CANTCONFIG: ::c_int = 0x10000; -pub const IFF_PPROMISC: ::c_int = 0x20000; // (n) user-requested promisc mode -pub const IFF_MONITOR: ::c_int = 0x40000; // (n) user-requested monitor mode -pub const IFF_STATICARP: ::c_int = 0x80000; // (n) static ARP -pub const IFF_DYING: ::c_int = 0x200000; // (n) interface is winding down -pub const IFF_RENAMING: ::c_int = 0x400000; // (n) interface is being renamed +/// (n) user-requested promisc mode +pub const IFF_PPROMISC: ::c_int = 0x20000; +/// (n) user-requested monitor mode +pub const IFF_MONITOR: ::c_int = 0x40000; +/// (n) static ARP +pub const IFF_STATICARP: ::c_int = 0x80000; +/// (n) interface is winding down +pub const IFF_DYING: ::c_int = 0x200000; +/// (n) interface is being renamed +pub const IFF_RENAMING: ::c_int = 0x400000; +/// interface is not part of any groups +pub const IFF_NOGROUP: ::c_int = 0x800000; + +/// link invalid/unknown +pub const LINK_STATE_UNKNOWN: ::c_int = 0; +/// link is down +pub const LINK_STATE_DOWN: ::c_int = 1; +/// link is up +pub const LINK_STATE_UP: ::c_int = 2; + +/// can offload checksum on RX +pub const IFCAP_RXCSUM: ::c_int = 0x00001; +/// can offload checksum on TX +pub const IFCAP_TXCSUM: ::c_int = 0x00002; +/// can be a network console +pub const IFCAP_NETCONS: ::c_int = 0x00004; +/// VLAN-compatible MTU +pub const IFCAP_VLAN_MTU: ::c_int = 0x00008; +/// hardware VLAN tag support +pub const IFCAP_VLAN_HWTAGGING: ::c_int = 0x00010; +/// 9000 byte MTU supported +pub const IFCAP_JUMBO_MTU: ::c_int = 0x00020; +/// driver supports polling +pub const IFCAP_POLLING: ::c_int = 0x00040; +/// can do IFCAP_HWCSUM on VLANs +pub const IFCAP_VLAN_HWCSUM: ::c_int = 0x00080; +/// can do TCP Segmentation Offload +pub const IFCAP_TSO4: ::c_int = 0x00100; +/// can do TCP6 Segmentation Offload +pub const IFCAP_TSO6: ::c_int = 0x00200; +/// can do Large Receive Offload +pub const IFCAP_LRO: ::c_int = 0x00400; +/// wake on any unicast frame +pub const IFCAP_WOL_UCAST: ::c_int = 0x00800; +/// wake on any multicast frame +pub const IFCAP_WOL_MCAST: ::c_int = 0x01000; +/// wake on any Magic Packet +pub const IFCAP_WOL_MAGIC: ::c_int = 0x02000; +/// interface can offload TCP +pub const IFCAP_TOE4: ::c_int = 0x04000; +/// interface can offload TCP6 +pub const IFCAP_TOE6: ::c_int = 0x08000; +/// interface hw can filter vlan tag +pub const IFCAP_VLAN_HWFILTER: ::c_int = 0x10000; +/// can do IFCAP_TSO on VLANs +pub const IFCAP_VLAN_HWTSO: ::c_int = 0x40000; +/// the runtime link state is dynamic +pub const IFCAP_LINKSTATE: ::c_int = 0x80000; +/// netmap mode supported/enabled +pub const IFCAP_NETMAP: ::c_int = 0x100000; +/// can offload checksum on IPv6 RX +pub const IFCAP_RXCSUM_IPV6: ::c_int = 0x200000; +/// can offload checksum on IPv6 TX +pub const IFCAP_TXCSUM_IPV6: ::c_int = 0x400000; +/// manages counters internally +pub const IFCAP_HWSTATS: ::c_int = 0x800000; +/// hardware supports TX rate limiting +pub const IFCAP_TXRTLMT: ::c_int = 0x1000000; +/// hardware rx timestamping +pub const IFCAP_HWRXTSTMP: ::c_int = 0x2000000; +/// understands M_EXTPG mbufs +pub const IFCAP_MEXTPG: ::c_int = 0x4000000; +/// can do TLS encryption and segmentation for TCP +pub const IFCAP_TXTLS4: ::c_int = 0x8000000; +/// can do TLS encryption and segmentation for TCP6 +pub const IFCAP_TXTLS6: ::c_int = 0x10000000; +/// can do IFCAN_HWCSUM on VXLANs +pub const IFCAP_VXLAN_HWCSUM: ::c_int = 0x20000000; +/// can do IFCAP_TSO on VXLANs +pub const IFCAP_VXLAN_HWTSO: ::c_int = 0x40000000; +/// can do TLS with rate limiting +pub const IFCAP_TXTLS_RTLMT: ::c_int = 0x80000000; + +pub const IFCAP_HWCSUM_IPV6: ::c_int = IFCAP_RXCSUM_IPV6 | IFCAP_TXCSUM_IPV6; +pub const IFCAP_HWCSUM: ::c_int = IFCAP_RXCSUM | IFCAP_TXCSUM; +pub const IFCAP_TSO: ::c_int = IFCAP_TSO4 | IFCAP_TSO6; +pub const IFCAP_WOL: ::c_int = IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC; +pub const IFCAP_TOE: ::c_int = IFCAP_TOE4 | IFCAP_TOE6; +pub const IFCAP_TXTLS: ::c_int = IFCAP_TXTLS4 | IFCAP_TXTLS6; +pub const IFCAP_CANTCHANGE: ::c_int = IFCAP_NETMAP; + +pub const IFQ_MAXLEN: ::c_int = 50; +pub const IFNET_SLOWHZ: ::c_int = 1; + +pub const IFAN_ARRIVAL: ::c_int = 0; +pub const IFAN_DEPARTURE: ::c_int = 1; + +pub const IFSTATMAX: ::c_int = 800; + +pub const RSS_FUNC_NONE: ::c_int = 0; +pub const RSS_FUNC_PRIVATE: ::c_int = 1; +pub const RSS_FUNC_TOEPLITZ: ::c_int = 2; + +pub const RSS_TYPE_IPV4: ::c_int = 0x00000001; +pub const RSS_TYPE_TCP_IPV4: ::c_int = 0x00000002; +pub const RSS_TYPE_IPV6: ::c_int = 0x00000004; +pub const RSS_TYPE_IPV6_EX: ::c_int = 0x00000008; +pub const RSS_TYPE_TCP_IPV6: ::c_int = 0x00000010; +pub const RSS_TYPE_TCP_IPV6_EX: ::c_int = 0x00000020; +pub const RSS_TYPE_UDP_IPV4: ::c_int = 0x00000040; +pub const RSS_TYPE_UDP_IPV6: ::c_int = 0x00000080; +pub const RSS_TYPE_UDP_IPV6_EX: ::c_int = 0x00000100; +pub const RSS_KEYLEN: ::c_int = 128; + +pub const IFNET_PCP_NONE: ::c_int = 0xff; +pub const IFDR_MSG_SIZE: ::c_int = 64; +pub const IFDR_REASON_MSG: ::c_int = 1; +pub const IFDR_REASON_VENDOR: ::c_int = 2; + +// sys/net/if_mib.h + +/// non-interface-specific +pub const IFMIB_SYSTEM: ::c_int = 1; +/// per-interface data table +pub const IFMIB_IFDATA: ::c_int = 2; + +/// generic stats for all kinds of ifaces +pub const IFDATA_GENERAL: ::c_int = 1; +/// specific to the type of interface +pub const IFDATA_LINKSPECIFIC: ::c_int = 2; +/// driver name and unit +pub const IFDATA_DRIVERNAME: ::c_int = 3; + +/// number of interfaces configured +pub const IFMIB_IFCOUNT: ::c_int = 1; + +/// functions not specific to a type of iface +pub const NETLINK_GENERIC: ::c_int = 0; + +pub const DOT3COMPLIANCE_STATS: ::c_int = 1; +pub const DOT3COMPLIANCE_COLLS: ::c_int = 2; + +pub const dot3ChipSetAMD7990: ::c_int = 1; +pub const dot3ChipSetAMD79900: ::c_int = 2; +pub const dot3ChipSetAMD79C940: ::c_int = 3; + +pub const dot3ChipSetIntel82586: ::c_int = 1; +pub const dot3ChipSetIntel82596: ::c_int = 2; +pub const dot3ChipSetIntel82557: ::c_int = 3; + +pub const dot3ChipSetNational8390: ::c_int = 1; +pub const dot3ChipSetNationalSonic: ::c_int = 2; + +pub const dot3ChipSetFujitsu86950: ::c_int = 1; + +pub const dot3ChipSetDigitalDC21040: ::c_int = 1; +pub const dot3ChipSetDigitalDC21140: ::c_int = 2; +pub const dot3ChipSetDigitalDC21041: ::c_int = 3; +pub const dot3ChipSetDigitalDC21140A: ::c_int = 4; +pub const dot3ChipSetDigitalDC21142: ::c_int = 5; + +pub const dot3ChipSetWesternDigital83C690: ::c_int = 1; +pub const dot3ChipSetWesternDigital83C790: ::c_int = 2; // sys/netinet/in.h // Protocols (RFC 1700) @@ -1616,8 +2964,6 @@ // fcntl commands pub const F_ADD_SEALS: ::c_int = 19; -pub const F_DUP2FD: ::c_int = 10; -pub const F_DUP2FD_CLOEXEC: ::c_int = 18; pub const F_GET_SEALS: ::c_int = 20; pub const F_OGETLK: ::c_int = 7; pub const F_OSETLK: ::c_int = 8; @@ -1625,6 +2971,7 @@ pub const F_RDAHEAD: ::c_int = 16; pub const F_READAHEAD: ::c_int = 15; pub const F_SETLK_REMOTE: ::c_int = 14; +pub const F_KINFO: ::c_int = 22; // for use with F_ADD_SEALS pub const F_SEAL_GROW: ::c_int = 4; @@ -1654,6 +3001,11 @@ pub const RFTSIGZMB: ::c_int = 524288; pub const RFSPAWN: ::c_int = 2147483648; +// For eventfd +pub const EFD_SEMAPHORE: ::c_int = 0x1; +pub const EFD_NONBLOCK: ::c_int = 0x4; +pub const EFD_CLOEXEC: ::c_int = 0x100000; + pub const MALLOCX_ZERO: ::c_int = 0x40; /// size of returned wchan message @@ -1766,11 +3118,7 @@ pub const KVME_FLAG_SUPER: ::c_int = 0x00000008; pub const KVME_FLAG_GROWS_UP: ::c_int = 0x00000010; pub const KVME_FLAG_GROWS_DOWN: ::c_int = 0x00000020; -cfg_if! { - if #[cfg(any(freebsd12, freebsd13))] { - pub const KVME_FLAG_USER_WIRED: ::c_int = 0x00000040; - } -} +pub const KVME_FLAG_USER_WIRED: ::c_int = 0x00000040; pub const KKST_MAXLEN: ::c_int = 1024; /// Stack is valid. @@ -1811,6 +3159,8 @@ pub const PRI_MIN_IDLE: ::c_int = 224; pub const PRI_MAX_IDLE: ::c_int = PRI_MAX; +pub const NZERO: ::c_int = 0; + // Resource utilization information. pub const RUSAGE_THREAD: ::c_int = 1; @@ -1891,6 +3241,387 @@ pub const _POSIX2_LINE_MAX: ::c_int = 2048; pub const _POSIX2_RE_DUP_MAX: ::c_int = 255; +// sys/proc.h +pub const TDF_BORROWING: ::c_int = 0x00000001; +pub const TDF_INPANIC: ::c_int = 0x00000002; +pub const TDF_INMEM: ::c_int = 0x00000004; +pub const TDF_SINTR: ::c_int = 0x00000008; +pub const TDF_TIMEOUT: ::c_int = 0x00000010; +pub const TDF_IDLETD: ::c_int = 0x00000020; +pub const TDF_CANSWAP: ::c_int = 0x00000040; +pub const TDF_KTH_SUSP: ::c_int = 0x00000100; +pub const TDF_ALLPROCSUSP: ::c_int = 0x00000200; +pub const TDF_BOUNDARY: ::c_int = 0x00000400; +pub const TDF_ASTPENDING: ::c_int = 0x00000800; +pub const TDF_SBDRY: ::c_int = 0x00002000; +pub const TDF_UPIBLOCKED: ::c_int = 0x00004000; +pub const TDF_NEEDSUSPCHK: ::c_int = 0x00008000; +pub const TDF_NEEDRESCHED: ::c_int = 0x00010000; +pub const TDF_NEEDSIGCHK: ::c_int = 0x00020000; +pub const TDF_NOLOAD: ::c_int = 0x00040000; +pub const TDF_SERESTART: ::c_int = 0x00080000; +pub const TDF_THRWAKEUP: ::c_int = 0x00100000; +pub const TDF_SEINTR: ::c_int = 0x00200000; +pub const TDF_SWAPINREQ: ::c_int = 0x00400000; +pub const TDF_UNUSED23: ::c_int = 0x00800000; +pub const TDF_SCHED0: ::c_int = 0x01000000; +pub const TDF_SCHED1: ::c_int = 0x02000000; +pub const TDF_SCHED2: ::c_int = 0x04000000; +pub const TDF_SCHED3: ::c_int = 0x08000000; +pub const TDF_ALRMPEND: ::c_int = 0x10000000; +pub const TDF_PROFPEND: ::c_int = 0x20000000; +pub const TDF_MACPEND: ::c_int = 0x40000000; + +pub const TDB_SUSPEND: ::c_int = 0x00000001; +pub const TDB_XSIG: ::c_int = 0x00000002; +pub const TDB_USERWR: ::c_int = 0x00000004; +pub const TDB_SCE: ::c_int = 0x00000008; +pub const TDB_SCX: ::c_int = 0x00000010; +pub const TDB_EXEC: ::c_int = 0x00000020; +pub const TDB_FORK: ::c_int = 0x00000040; +pub const TDB_STOPATFORK: ::c_int = 0x00000080; +pub const TDB_CHILD: ::c_int = 0x00000100; +pub const TDB_BORN: ::c_int = 0x00000200; +pub const TDB_EXIT: ::c_int = 0x00000400; +pub const TDB_VFORK: ::c_int = 0x00000800; +pub const TDB_FSTP: ::c_int = 0x00001000; +pub const TDB_STEP: ::c_int = 0x00002000; + +pub const TDP_OLDMASK: ::c_int = 0x00000001; +pub const TDP_INKTR: ::c_int = 0x00000002; +pub const TDP_INKTRACE: ::c_int = 0x00000004; +pub const TDP_BUFNEED: ::c_int = 0x00000008; +pub const TDP_COWINPROGRESS: ::c_int = 0x00000010; +pub const TDP_ALTSTACK: ::c_int = 0x00000020; +pub const TDP_DEADLKTREAT: ::c_int = 0x00000040; +pub const TDP_NOFAULTING: ::c_int = 0x00000080; +pub const TDP_OWEUPC: ::c_int = 0x00000200; +pub const TDP_ITHREAD: ::c_int = 0x00000400; +pub const TDP_SYNCIO: ::c_int = 0x00000800; +pub const TDP_SCHED1: ::c_int = 0x00001000; +pub const TDP_SCHED2: ::c_int = 0x00002000; +pub const TDP_SCHED3: ::c_int = 0x00004000; +pub const TDP_SCHED4: ::c_int = 0x00008000; +pub const TDP_GEOM: ::c_int = 0x00010000; +pub const TDP_SOFTDEP: ::c_int = 0x00020000; +pub const TDP_NORUNNINGBUF: ::c_int = 0x00040000; +pub const TDP_WAKEUP: ::c_int = 0x00080000; +pub const TDP_INBDFLUSH: ::c_int = 0x00100000; +pub const TDP_KTHREAD: ::c_int = 0x00200000; +pub const TDP_CALLCHAIN: ::c_int = 0x00400000; +pub const TDP_IGNSUSP: ::c_int = 0x00800000; +pub const TDP_AUDITREC: ::c_int = 0x01000000; +pub const TDP_RFPPWAIT: ::c_int = 0x02000000; +pub const TDP_RESETSPUR: ::c_int = 0x04000000; +pub const TDP_NERRNO: ::c_int = 0x08000000; +pub const TDP_EXECVMSPC: ::c_int = 0x40000000; + +pub const TDI_SUSPENDED: ::c_int = 0x0001; +pub const TDI_SLEEPING: ::c_int = 0x0002; +pub const TDI_SWAPPED: ::c_int = 0x0004; +pub const TDI_LOCK: ::c_int = 0x0008; +pub const TDI_IWAIT: ::c_int = 0x0010; + +pub const P_ADVLOCK: ::c_int = 0x00000001; +pub const P_CONTROLT: ::c_int = 0x00000002; +pub const P_KPROC: ::c_int = 0x00000004; +pub const P_UNUSED3: ::c_int = 0x00000008; +pub const P_PPWAIT: ::c_int = 0x00000010; +pub const P_PROFIL: ::c_int = 0x00000020; +pub const P_STOPPROF: ::c_int = 0x00000040; +pub const P_HADTHREADS: ::c_int = 0x00000080; +pub const P_SUGID: ::c_int = 0x00000100; +pub const P_SYSTEM: ::c_int = 0x00000200; +pub const P_SINGLE_EXIT: ::c_int = 0x00000400; +pub const P_TRACED: ::c_int = 0x00000800; +pub const P_WAITED: ::c_int = 0x00001000; +pub const P_WEXIT: ::c_int = 0x00002000; +pub const P_EXEC: ::c_int = 0x00004000; +pub const P_WKILLED: ::c_int = 0x00008000; +pub const P_CONTINUED: ::c_int = 0x00010000; +pub const P_STOPPED_SIG: ::c_int = 0x00020000; +pub const P_STOPPED_TRACE: ::c_int = 0x00040000; +pub const P_STOPPED_SINGLE: ::c_int = 0x00080000; +pub const P_PROTECTED: ::c_int = 0x00100000; +pub const P_SIGEVENT: ::c_int = 0x00200000; +pub const P_SINGLE_BOUNDARY: ::c_int = 0x00400000; +pub const P_HWPMC: ::c_int = 0x00800000; +pub const P_JAILED: ::c_int = 0x01000000; +pub const P_TOTAL_STOP: ::c_int = 0x02000000; +pub const P_INEXEC: ::c_int = 0x04000000; +pub const P_STATCHILD: ::c_int = 0x08000000; +pub const P_INMEM: ::c_int = 0x10000000; +pub const P_SWAPPINGOUT: ::c_int = 0x20000000; +pub const P_SWAPPINGIN: ::c_int = 0x40000000; +pub const P_PPTRACE: ::c_int = 0x80000000; +pub const P_STOPPED: ::c_int = P_STOPPED_SIG | P_STOPPED_SINGLE | P_STOPPED_TRACE; + +pub const P2_INHERIT_PROTECTED: ::c_int = 0x00000001; +pub const P2_NOTRACE: ::c_int = 0x00000002; +pub const P2_NOTRACE_EXEC: ::c_int = 0x00000004; +pub const P2_AST_SU: ::c_int = 0x00000008; +pub const P2_PTRACE_FSTP: ::c_int = 0x00000010; +pub const P2_TRAPCAP: ::c_int = 0x00000020; +pub const P2_STKGAP_DISABLE: ::c_int = 0x00000800; +pub const P2_STKGAP_DISABLE_EXEC: ::c_int = 0x00001000; + +pub const P_TREE_ORPHANED: ::c_int = 0x00000001; +pub const P_TREE_FIRST_ORPHAN: ::c_int = 0x00000002; +pub const P_TREE_REAPER: ::c_int = 0x00000004; + +pub const SIDL: ::c_char = 1; +pub const SRUN: ::c_char = 2; +pub const SSLEEP: ::c_char = 3; +pub const SSTOP: ::c_char = 4; +pub const SZOMB: ::c_char = 5; +pub const SWAIT: ::c_char = 6; +pub const SLOCK: ::c_char = 7; + +pub const P_MAGIC: ::c_int = 0xbeefface; + +pub const TDP_SIGFASTBLOCK: ::c_int = 0x00000100; +pub const TDP_UIOHELD: ::c_int = 0x10000000; +pub const TDP_SIGFASTPENDING: ::c_int = 0x80000000; +pub const TDP2_COMPAT32RB: ::c_int = 0x00000002; +pub const P2_PROTMAX_ENABLE: ::c_int = 0x00000200; +pub const P2_PROTMAX_DISABLE: ::c_int = 0x00000400; +pub const TDP2_SBPAGES: ::c_int = 0x00000001; +pub const P2_ASLR_ENABLE: ::c_int = 0x00000040; +pub const P2_ASLR_DISABLE: ::c_int = 0x00000080; +pub const P2_ASLR_IGNSTART: ::c_int = 0x00000100; +pub const P_TREE_GRPEXITED: ::c_int = 0x00000008; + +// libprocstat.h +pub const PS_FST_VTYPE_VNON: ::c_int = 1; +pub const PS_FST_VTYPE_VREG: ::c_int = 2; +pub const PS_FST_VTYPE_VDIR: ::c_int = 3; +pub const PS_FST_VTYPE_VBLK: ::c_int = 4; +pub const PS_FST_VTYPE_VCHR: ::c_int = 5; +pub const PS_FST_VTYPE_VLNK: ::c_int = 6; +pub const PS_FST_VTYPE_VSOCK: ::c_int = 7; +pub const PS_FST_VTYPE_VFIFO: ::c_int = 8; +pub const PS_FST_VTYPE_VBAD: ::c_int = 9; +pub const PS_FST_VTYPE_UNKNOWN: ::c_int = 255; + +pub const PS_FST_TYPE_VNODE: ::c_int = 1; +pub const PS_FST_TYPE_FIFO: ::c_int = 2; +pub const PS_FST_TYPE_SOCKET: ::c_int = 3; +pub const PS_FST_TYPE_PIPE: ::c_int = 4; +pub const PS_FST_TYPE_PTS: ::c_int = 5; +pub const PS_FST_TYPE_KQUEUE: ::c_int = 6; +pub const PS_FST_TYPE_MQUEUE: ::c_int = 8; +pub const PS_FST_TYPE_SHM: ::c_int = 9; +pub const PS_FST_TYPE_SEM: ::c_int = 10; +pub const PS_FST_TYPE_UNKNOWN: ::c_int = 11; +pub const PS_FST_TYPE_NONE: ::c_int = 12; +pub const PS_FST_TYPE_PROCDESC: ::c_int = 13; +pub const PS_FST_TYPE_DEV: ::c_int = 14; +pub const PS_FST_TYPE_EVENTFD: ::c_int = 15; + +pub const PS_FST_UFLAG_RDIR: ::c_int = 0x0001; +pub const PS_FST_UFLAG_CDIR: ::c_int = 0x0002; +pub const PS_FST_UFLAG_JAIL: ::c_int = 0x0004; +pub const PS_FST_UFLAG_TRACE: ::c_int = 0x0008; +pub const PS_FST_UFLAG_TEXT: ::c_int = 0x0010; +pub const PS_FST_UFLAG_MMAP: ::c_int = 0x0020; +pub const PS_FST_UFLAG_CTTY: ::c_int = 0x0040; + +pub const PS_FST_FFLAG_READ: ::c_int = 0x0001; +pub const PS_FST_FFLAG_WRITE: ::c_int = 0x0002; +pub const PS_FST_FFLAG_NONBLOCK: ::c_int = 0x0004; +pub const PS_FST_FFLAG_APPEND: ::c_int = 0x0008; +pub const PS_FST_FFLAG_SHLOCK: ::c_int = 0x0010; +pub const PS_FST_FFLAG_EXLOCK: ::c_int = 0x0020; +pub const PS_FST_FFLAG_ASYNC: ::c_int = 0x0040; +pub const PS_FST_FFLAG_SYNC: ::c_int = 0x0080; +pub const PS_FST_FFLAG_NOFOLLOW: ::c_int = 0x0100; +pub const PS_FST_FFLAG_CREAT: ::c_int = 0x0200; +pub const PS_FST_FFLAG_TRUNC: ::c_int = 0x0400; +pub const PS_FST_FFLAG_EXCL: ::c_int = 0x0800; +pub const PS_FST_FFLAG_DIRECT: ::c_int = 0x1000; +pub const PS_FST_FFLAG_EXEC: ::c_int = 0x2000; +pub const PS_FST_FFLAG_HASLOCK: ::c_int = 0x4000; + +// sys/mount.h + +/// File identifier. +/// These are unique per filesystem on a single machine. +/// +/// Note that the offset of fid_data is 4 bytes, so care must be taken to avoid +/// undefined behavior accessing unaligned fields within an embedded struct. +pub const MAXFIDSZ: ::c_int = 16; +/// Length of type name including null. +pub const MFSNAMELEN: ::c_int = 16; +cfg_if! { + if #[cfg(any(freebsd10, freebsd11))] { + /// Size of on/from name bufs. + pub const MNAMELEN: ::c_int = 88; + } else { + /// Size of on/from name bufs. + pub const MNAMELEN: ::c_int = 1024; + } +} + +/// Using journaled soft updates. +pub const MNT_SUJ: u64 = 0x100000000; +/// Mounted by automountd(8). +pub const MNT_AUTOMOUNTED: u64 = 0x200000000; +/// Filesys metadata untrusted. +pub const MNT_UNTRUSTED: u64 = 0x800000000; + +/// Require TLS. +pub const MNT_EXTLS: u64 = 0x4000000000; +/// Require TLS with client cert. +pub const MNT_EXTLSCERT: u64 = 0x8000000000; +/// Require TLS with user cert. +pub const MNT_EXTLSCERTUSER: u64 = 0x10000000000; + +/// Filesystem is stored locally. +pub const MNT_LOCAL: u64 = 0x000001000; +/// Quotas are enabled on fs. +pub const MNT_QUOTA: u64 = 0x000002000; +/// Identifies the root fs. +pub const MNT_ROOTFS: u64 = 0x000004000; +/// Mounted by a user. +pub const MNT_USER: u64 = 0x000008000; +/// Do not show entry in df. +pub const MNT_IGNORE: u64 = 0x000800000; +/// Filesystem is verified. +pub const MNT_VERIFIED: u64 = 0x400000000; + +/// Do not cover a mount point. +pub const MNT_NOCOVER: u64 = 0x001000000000; +/// Only mount on empty dir. +pub const MNT_EMPTYDIR: u64 = 0x002000000000; +/// Recursively unmount uppers. +pub const MNT_RECURSE: u64 = 0x100000000000; +/// Unmount in async context. +pub const MNT_DEFERRED: u64 = 0x200000000000; + +/// Forced unmount in progress. +pub const MNTK_UNMOUNTF: u32 = 0x00000001; +/// Filtered async flag. +pub const MNTK_ASYNC: u32 = 0x00000002; +/// Async disabled by softdep. +pub const MNTK_SOFTDEP: u32 = 0x00000004; +/// Don't do msync. +pub const MNTK_NOMSYNC: u32 = 0x00000008; +/// Lock draining is happening. +pub const MNTK_DRAINING: u32 = 0x00000010; +/// Refcount expiring is happening. +pub const MNTK_REFEXPIRE: u32 = 0x00000020; +/// Allow shared locking for more ops. +pub const MNTK_EXTENDED_SHARED: u32 = 0x00000040; +/// Allow shared locking for writes. +pub const MNTK_SHARED_WRITES: u32 = 0x00000080; +/// Disallow page faults during reads and writes. Filesystem shall properly handle i/o +/// state on EFAULT. +pub const MNTK_NO_IOPF: u32 = 0x00000100; +/// Pending recursive unmount. +pub const MNTK_RECURSE: u32 = 0x00000200; +/// Waiting to drain MNTK_UPPER_PENDING. +pub const MNTK_UPPER_WAITER: u32 = 0x00000400; +pub const MNTK_LOOKUP_EXCL_DOTDOT: u32 = 0x00000800; +pub const MNTK_UNMAPPED_BUFS: u32 = 0x00002000; +/// FS uses the buffer cache. +pub const MNTK_USES_BCACHE: u32 = 0x00004000; +/// Keep use ref for text. +pub const MNTK_TEXT_REFS: u32 = 0x00008000; +pub const MNTK_VMSETSIZE_BUG: u32 = 0x00010000; +/// A hack for F_ISUNIONSTACK. +pub const MNTK_UNIONFS: u32 = 0x00020000; +/// fast path lookup is supported. +pub const MNTK_FPLOOKUP: u32 = 0x00040000; +/// Suspended by all-fs suspension. +pub const MNTK_SUSPEND_ALL: u32 = 0x00080000; +/// Waiting on unmount taskqueue. +pub const MNTK_TASKQUEUE_WAITER: u32 = 0x00100000; +/// Disable async. +pub const MNTK_NOASYNC: u32 = 0x00800000; +/// Unmount in progress. +pub const MNTK_UNMOUNT: u32 = 0x01000000; +/// Waiting for unmount to finish. +pub const MNTK_MWAIT: u32 = 0x02000000; +/// Request write suspension. +pub const MNTK_SUSPEND: u32 = 0x08000000; +/// Block secondary writes. +pub const MNTK_SUSPEND2: u32 = 0x04000000; +/// Write operations are suspended. +pub const MNTK_SUSPENDED: u32 = 0x10000000; +/// auto disable cache for nullfs mounts over this fs. +pub const MNTK_NULL_NOCACHE: u32 = 0x20000000; +/// FS supports shared lock lookups. +pub const MNTK_LOOKUP_SHARED: u32 = 0x40000000; +/// Don't send KNOTEs from VOP hooks. +pub const MNTK_NOKNOTE: u32 = 0x80000000; + +/// Get configured filesystems. +pub const VFS_VFSCONF: ::c_int = 0; +/// Generic filesystem information. +pub const VFS_GENERIC: ::c_int = 0; + +/// int: highest defined filesystem type. +pub const VFS_MAXTYPENUM: ::c_int = 1; +/// struct: vfsconf for filesystem given as next argument. +pub const VFS_CONF: ::c_int = 2; + +/// Synchronously wait for I/O to complete. +pub const MNT_WAIT: ::c_int = 1; +/// Start all I/O, but do not wait for it. +pub const MNT_NOWAIT: ::c_int = 2; +/// Push data not written by filesystem syncer. +pub const MNT_LAZY: ::c_int = 3; +/// Suspend file system after sync. +pub const MNT_SUSPEND: ::c_int = 4; + +pub const MAXSECFLAVORS: ::c_int = 5; + +/// Statically compiled into kernel. +pub const VFCF_STATIC: ::c_int = 0x00010000; +/// May get data over the network. +pub const VFCF_NETWORK: ::c_int = 0x00020000; +/// Writes are not implemented. +pub const VFCF_READONLY: ::c_int = 0x00040000; +/// Data does not represent real files. +pub const VFCF_SYNTHETIC: ::c_int = 0x00080000; +/// Aliases some other mounted FS. +pub const VFCF_LOOPBACK: ::c_int = 0x00100000; +/// Stores file names as Unicode. +pub const VFCF_UNICODE: ::c_int = 0x00200000; +/// Can be mounted from within a jail. +pub const VFCF_JAIL: ::c_int = 0x00400000; +/// Supports delegated administration. +pub const VFCF_DELEGADMIN: ::c_int = 0x00800000; +/// Stop at Boundary: defer stop requests to kernel->user (AST) transition. +pub const VFCF_SBDRY: ::c_int = 0x01000000; + +// time.h + +/// not on dst +pub const DST_NONE: ::c_int = 0; +/// USA style dst +pub const DST_USA: ::c_int = 1; +/// Australian style dst +pub const DST_AUST: ::c_int = 2; +/// Western European dst +pub const DST_WET: ::c_int = 3; +/// Middle European dst +pub const DST_MET: ::c_int = 4; +/// Eastern European dst +pub const DST_EET: ::c_int = 5; +/// Canada +pub const DST_CAN: ::c_int = 6; + +pub const CPUCLOCK_WHICH_PID: ::c_int = 0; +pub const CPUCLOCK_WHICH_TID: ::c_int = 1; + +pub const MFD_CLOEXEC: ::c_uint = 0x00000001; +pub const MFD_ALLOW_SEALING: ::c_uint = 0x00000002; +pub const MFD_HUGETLB: ::c_uint = 0x00000004; + +pub const SHM_RENAME_NOREPLACE: ::c_int = 1 << 0; +pub const SHM_RENAME_EXCHANGE: ::c_int = 1 << 1; + const_fn! { {const} fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES @@ -1986,6 +3717,26 @@ let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); 0 != cpuset.__bits[idx] & (1 << offset) } + + pub fn CPU_COUNT(cpuset: &cpuset_t) -> ::c_int { + let mut s: u32 = 0; + let cpuset_size = ::mem::size_of::(); + let bitset_bits = ::mem::size_of::<::c_long>(); + + for i in cpuset.__bits[..(cpuset_size / bitset_bits)].iter() { + s += i.count_ones(); + }; + s as ::c_int + } + + pub fn SOCKCRED2SIZE(ngrps: usize) -> usize { + let ngrps = if ngrps > 0 { + ngrps - 1 + } else { + 0 + }; + ::mem::size_of::() + ::mem::size_of::<::gid_t>() * ngrps + } } safe_f! { @@ -1994,6 +3745,26 @@ } } +cfg_if! { + if #[cfg(not(any(freebsd10, freebsd11)))] { + extern "C" { + pub fn fhlink(fhp: *mut fhandle_t, to: *const ::c_char) -> ::c_int; + pub fn fhlinkat(fhp: *mut fhandle_t, tofd: ::c_int, to: *const ::c_char) -> ::c_int; + pub fn fhreadlink( + fhp: *mut fhandle_t, + buf: *mut ::c_char, + bufsize: ::size_t, + ) -> ::c_int; + pub fn getfhat( + fd: ::c_int, + path: *mut ::c_char, + fhp: *mut fhandle, + flag: ::c_int, + ) -> ::c_int; + } + } +} + extern "C" { pub fn __error() -> *mut ::c_int; @@ -2009,6 +3780,13 @@ ) -> ::c_int; pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int; + pub fn devname_r( + dev: ::dev_t, + mode: ::mode_t, + buf: *mut ::c_char, + len: ::c_int, + ) -> *mut ::c_char; + pub fn extattr_delete_fd( fd: ::c_int, attrnamespace: ::c_int, @@ -2098,8 +3876,6 @@ sevp: *mut sigevent, ) -> ::c_int; - pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int; - pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, advise: ::c_int) -> ::c_int; pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int; pub fn mkostemps(template: *mut ::c_char, suffixlen: ::c_int, flags: ::c_int) -> ::c_int; @@ -2121,6 +3897,9 @@ pub fn shmat(shmid: ::c_int, shmaddr: *const ::c_void, shmflg: ::c_int) -> *mut ::c_void; pub fn shmdt(shmaddr: *const ::c_void) -> ::c_int; pub fn shmctl(shmid: ::c_int, cmd: ::c_int, buf: *mut ::shmid_ds) -> ::c_int; + pub fn semget(key: ::key_t, nsems: ::c_int, semflg: ::c_int) -> ::c_int; + pub fn semctl(semid: ::c_int, semnum: ::c_int, cmd: ::c_int, ...) -> ::c_int; + pub fn semop(semid: ::c_int, sops: *mut sembuf, nsops: ::size_t) -> ::c_int; pub fn msgctl(msqid: ::c_int, cmd: ::c_int, buf: *mut ::msqid_ds) -> ::c_int; pub fn msgget(key: ::key_t, msgflg: ::c_int) -> ::c_int; pub fn msgsnd( @@ -2231,6 +4010,15 @@ cpusetp: *const cpuset_t, ) -> ::c_int; + // sched.h linux compatibility api + pub fn sched_getaffinity(pid: ::pid_t, cpusetsz: ::size_t, cpuset: *mut ::cpuset_t) -> ::c_int; + pub fn sched_setaffinity( + pid: ::pid_t, + cpusetsz: ::size_t, + cpuset: *const ::cpuset_t, + ) -> ::c_int; + pub fn sched_getcpu() -> ::c_int; + pub fn pthread_mutex_consistent(mutex: *mut ::pthread_mutex_t) -> ::c_int; pub fn pthread_mutexattr_getrobust( @@ -2276,7 +4064,25 @@ needlelen: ::size_t, ) -> *mut ::c_void; + pub fn fhopen(fhp: *const fhandle_t, flags: ::c_int) -> ::c_int; + pub fn fhstat(fhp: *const fhandle, buf: *mut ::stat) -> ::c_int; + pub fn fhstatfs(fhp: *const fhandle_t, buf: *mut ::statfs) -> ::c_int; + pub fn getfh(path: *const ::c_char, fhp: *mut fhandle_t) -> ::c_int; + pub fn lgetfh(path: *const ::c_char, fhp: *mut fhandle_t) -> ::c_int; + pub fn getfsstat(buf: *mut ::statfs, bufsize: ::c_long, mode: ::c_int) -> ::c_int; + #[cfg_attr( + all(target_os = "freebsd", freebsd11), + link_name = "getmntinfo@FBSD_1.0" + )] + pub fn getmntinfo(mntbufp: *mut *mut ::statfs, mode: ::c_int) -> ::c_int; + pub fn mount( + type_: *const ::c_char, + dir: *const ::c_char, + flags: ::c_int, + data: *mut ::c_void, + ) -> ::c_int; pub fn nmount(iov: *mut ::iovec, niov: ::c_uint, flags: ::c_int) -> ::c_int; + pub fn setproctitle(fmt: *const ::c_char, ...); pub fn rfork(flags: ::c_int) -> ::c_int; pub fn cpuset_getaffinity( @@ -2353,6 +4159,16 @@ pub fn procctl(idtype: ::idtype_t, id: ::id_t, cmd: ::c_int, data: *mut ::c_void) -> ::c_int; pub fn getpagesize() -> ::c_int; + + pub fn adjtime(arg1: *const ::timeval, arg2: *mut ::timeval) -> ::c_int; + pub fn clock_getcpuclockid2(arg1: ::id_t, arg2: ::c_int, arg3: *mut clockid_t) -> ::c_int; + + pub fn shm_rename( + path_from: *const ::c_char, + path_to: *const ::c_char, + flags: ::c_int, + ) -> ::c_int; + pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int; } #[link(name = "kvm")] @@ -2481,6 +4297,73 @@ ) -> *mut kinfo_vmentry; pub fn procstat_freevmmap(procstat: *mut procstat, vmmap: *mut kinfo_vmentry); pub fn procstat_close(procstat: *mut procstat); + pub fn procstat_freeargv(procstat: *mut procstat); + pub fn procstat_freeenvv(procstat: *mut procstat); + pub fn procstat_freegroups(procstat: *mut procstat, groups: *mut ::gid_t); + pub fn procstat_freeptlwpinfo(procstat: *mut procstat, pl: *mut ptrace_lwpinfo); + pub fn procstat_getargv( + procstat: *mut procstat, + kp: *mut kinfo_proc, + nchr: ::size_t, + ) -> *mut *mut ::c_char; + pub fn procstat_getenvv( + procstat: *mut procstat, + kp: *mut kinfo_proc, + nchr: ::size_t, + ) -> *mut *mut ::c_char; + pub fn procstat_getgroups( + procstat: *mut procstat, + kp: *mut kinfo_proc, + count: *mut ::c_uint, + ) -> *mut ::gid_t; + pub fn procstat_getosrel( + procstat: *mut procstat, + kp: *mut kinfo_proc, + osrelp: *mut ::c_int, + ) -> ::c_int; + pub fn procstat_getpathname( + procstat: *mut procstat, + kp: *mut kinfo_proc, + pathname: *mut ::c_char, + maxlen: ::size_t, + ) -> ::c_int; + pub fn procstat_getrlimit( + procstat: *mut procstat, + kp: *mut kinfo_proc, + which: ::c_int, + rlimit: *mut ::rlimit, + ) -> ::c_int; + pub fn procstat_getumask( + procstat: *mut procstat, + kp: *mut kinfo_proc, + maskp: *mut ::c_ushort, + ) -> ::c_int; + pub fn procstat_open_core(filename: *const ::c_char) -> *mut procstat; + pub fn procstat_open_kvm(nlistf: *const ::c_char, memf: *const ::c_char) -> *mut procstat; + pub fn procstat_get_socket_info( + proc_: *mut procstat, + fst: *mut filestat, + sock: *mut sockstat, + errbuf: *mut ::c_char, + ) -> ::c_int; + pub fn procstat_get_vnode_info( + proc_: *mut procstat, + fst: *mut filestat, + vn: *mut vnstat, + errbuf: *mut ::c_char, + ) -> ::c_int; + pub fn procstat_get_pts_info( + proc_: *mut procstat, + fst: *mut filestat, + pts: *mut ptsstat, + errbuf: *mut ::c_char, + ) -> ::c_int; + pub fn procstat_get_shm_info( + proc_: *mut procstat, + fst: *mut filestat, + shm: *mut shmstat, + errbuf: *mut ::c_char, + ) -> ::c_int; } #[link(name = "rt")] @@ -2497,8 +4380,40 @@ ) -> ::c_int; } +#[link(name = "devstat")] +extern "C" { + pub fn devstat_getnumdevs(kd: *mut kvm_t) -> ::c_int; + pub fn devstat_getgeneration(kd: *mut kvm_t) -> ::c_long; + pub fn devstat_getversion(kd: *mut kvm_t) -> ::c_int; + pub fn devstat_checkversion(kd: *mut kvm_t) -> ::c_int; + pub fn devstat_selectdevs( + dev_select: *mut *mut device_selection, + num_selected: *mut ::c_int, + num_selections: *mut ::c_int, + select_generation: *mut ::c_long, + current_generation: ::c_long, + devices: *mut devstat, + numdevs: ::c_int, + matches: *mut devstat_match, + num_matches: ::c_int, + dev_selections: *mut *mut ::c_char, + num_dev_selections: ::c_int, + select_mode: devstat_select_mode, + maxshowdevs: ::c_int, + perf_select: ::c_int, + ) -> ::c_int; + pub fn devstat_buildmatch( + match_str: *mut ::c_char, + matches: *mut *mut devstat_match, + num_matches: *mut ::c_int, + ) -> ::c_int; +} + cfg_if! { - if #[cfg(freebsd13)] { + if #[cfg(freebsd14)] { + mod freebsd14; + pub use self::freebsd14::*; + } else if #[cfg(freebsd13)] { mod freebsd13; pub use self::freebsd13::*; } else if #[cfg(freebsd12)] { @@ -2531,6 +4446,9 @@ } else if #[cfg(target_arch = "powerpc")] { mod powerpc; pub use self::powerpc::*; + } else if #[cfg(target_arch = "riscv64")] { + mod riscv64; + pub use self::riscv64::*; } else { // Unknown target_arch } diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/freebsd/riscv64.rs cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/riscv64.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/freebsd/riscv64.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/riscv64.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,154 @@ +pub type c_char = u8; +pub type c_long = i64; +pub type c_ulong = u64; +pub type wchar_t = ::c_int; +pub type time_t = i64; +pub type suseconds_t = ::c_long; +pub type register_t = i64; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + +s_no_extra_traits! { + pub struct gpregs { + pub gp_ra: ::register_t, + pub gp_sp: ::register_t, + pub gp_gp: ::register_t, + pub gp_tp: ::register_t, + pub gp_t: [::register_t; 7], + pub gp_s: [::register_t; 12], + pub gp_a: [::register_t; 8], + pub gp_sepc: ::register_t, + pub gp_sstatus: ::register_t, + } + + pub struct fpregs { + pub fp_x: [[::register_t; 2]; 32], + pub fp_fcsr: ::register_t, + pub fp_flags: ::c_int, + pub fp_pad: ::c_int, + } + + pub struct mcontext_t { + pub mc_gpregs: gpregs, + pub mc_fpregs: fpregs, + pub mc_flags: ::c_int, + pub mc_pad: ::c_int, + pub mc_spare: [u64; 8], + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for gpregs { + fn eq(&self, other: &gpregs) -> bool { + self.gp_ra == other.gp_ra && + self.gp_sp == other.gp_sp && + self.gp_gp == other.gp_gp && + self.gp_tp == other.gp_tp && + self.gp_t.iter().zip(other.gp_t.iter()).all(|(a, b)| a == b) && + self.gp_s.iter().zip(other.gp_s.iter()).all(|(a, b)| a == b) && + self.gp_a.iter().zip(other.gp_a.iter()).all(|(a, b)| a == b) && + self.gp_sepc == other.gp_sepc && + self.gp_sstatus == other.gp_sstatus + } + } + impl Eq for gpregs {} + impl ::fmt::Debug for gpregs { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("gpregs") + .field("gp_ra", &self.gp_ra) + .field("gp_sp", &self.gp_sp) + .field("gp_gp", &self.gp_gp) + .field("gp_tp", &self.gp_tp) + .field("gp_t", &self.gp_t) + .field("gp_s", &self.gp_s) + .field("gp_a", &self.gp_a) + .field("gp_sepc", &self.gp_sepc) + .field("gp_sstatus", &self.gp_sstatus) + .finish() + } + } + impl ::hash::Hash for gpregs { + fn hash(&self, state: &mut H) { + self.gp_ra.hash(state); + self.gp_sp.hash(state); + self.gp_gp.hash(state); + self.gp_tp.hash(state); + self.gp_t.hash(state); + self.gp_s.hash(state); + self.gp_a.hash(state); + self.gp_sepc.hash(state); + self.gp_sstatus.hash(state); + } + } + impl PartialEq for fpregs { + fn eq(&self, other: &fpregs) -> bool { + self.fp_x == other.fp_x && + self.fp_fcsr == other.fp_fcsr && + self.fp_flags == other.fp_flags && + self.fp_pad == other.fp_pad + } + } + impl Eq for fpregs {} + impl ::fmt::Debug for fpregs { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("fpregs") + .field("fp_x", &self.fp_x) + .field("fp_fcsr", &self.fp_fcsr) + .field("fp_flags", &self.fp_flags) + .field("fp_pad", &self.fp_pad) + .finish() + } + } + impl ::hash::Hash for fpregs { + fn hash(&self, state: &mut H) { + self.fp_x.hash(state); + self.fp_fcsr.hash(state); + self.fp_flags.hash(state); + self.fp_pad.hash(state); + } + } + impl PartialEq for mcontext_t { + fn eq(&self, other: &mcontext_t) -> bool { + self.mc_gpregs == other.mc_gpregs && + self.mc_fpregs == other.mc_fpregs && + self.mc_flags == other.mc_flags && + self.mc_pad == other.mc_pad && + self.mc_spare.iter().zip(other.mc_spare.iter()).all(|(a, b)| a == b) + } + } + impl Eq for mcontext_t {} + impl ::fmt::Debug for mcontext_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("mcontext_t") + .field("mc_gpregs", &self.mc_gpregs) + .field("mc_fpregs", &self.mc_fpregs) + .field("mc_flags", &self.mc_flags) + .field("mc_pad", &self.mc_pad) + .field("mc_spare", &self.mc_spare) + .finish() + } + } + impl ::hash::Hash for mcontext_t { + fn hash(&self, state: &mut H) { + self.mc_gpregs.hash(state); + self.mc_fpregs.hash(state); + self.mc_flags.hash(state); + self.mc_pad.hash(state); + self.mc_spare.hash(state); + } + } + } +} + +pub const MAP_32BIT: ::c_int = 0x00080000; +pub const MINSIGSTKSZ: ::size_t = 4096; // 1024 * 4 diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -93,6 +93,23 @@ #[cfg(libc_union)] pub a_un: __c_anonymous_elf64_auxv_union, } + + pub struct kinfo_file { + pub kf_structsize: ::c_int, + pub kf_type: ::c_int, + pub kf_fd: ::c_int, + pub kf_ref_count: ::c_int, + pub kf_flags: ::c_int, + _kf_pad0: ::c_int, + pub kf_offset: i64, + _priv: [::uintptr_t; 38], // FIXME if needed + pub kf_status: u16, + _kf_pad1: u16, + _kf_ispare0: ::c_int, + pub kf_cap_rights: ::cap_rights_t, + _kf_cap_spare: u64, + pub kf_path: [::c_char; ::PATH_MAX as usize], + } } cfg_if! { @@ -236,6 +253,52 @@ .finish() } } + + impl PartialEq for kinfo_file { + fn eq(&self, other: &kinfo_file) -> bool { + self.kf_structsize == other.kf_structsize && + self.kf_type == other.kf_type && + self.kf_fd == other.kf_fd && + self.kf_ref_count == other.kf_ref_count && + self.kf_flags == other.kf_flags && + self.kf_offset == other.kf_offset && + self.kf_status == other.kf_status && + self.kf_cap_rights == other.kf_cap_rights && + self.kf_path + .iter() + .zip(other.kf_path.iter()) + .all(|(a,b)| a == b) + } + } + impl Eq for kinfo_file {} + impl ::fmt::Debug for kinfo_file { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("kinfo_file") + .field("kf_structsize", &self.kf_structsize) + .field("kf_type", &self.kf_type) + .field("kf_fd", &self.kf_fd) + .field("kf_ref_count", &self.kf_ref_count) + .field("kf_flags", &self.kf_flags) + .field("kf_offset", &self.kf_offset) + .field("kf_status", &self.kf_status) + .field("kf_cap_rights", &self.kf_cap_rights) + .field("kf_path", &&self.kf_path[..]) + .finish() + } + } + impl ::hash::Hash for kinfo_file { + fn hash(&self, state: &mut H) { + self.kf_structsize.hash(state); + self.kf_type.hash(state); + self.kf_fd.hash(state); + self.kf_ref_count.hash(state); + self.kf_flags.hash(state); + self.kf_offset.hash(state); + self.kf_status.hash(state); + self.kf_cap_rights.hash(state); + self.kf_path.hash(state); + } + } } } diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/mod.rs cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/freebsdlike/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/freebsdlike/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -90,6 +90,12 @@ pub imr_interface: in_addr, } + pub struct ip_mreqn { + pub imr_multiaddr: in_addr, + pub imr_address: in_addr, + pub imr_ifindex: ::c_int, + } + pub struct glob_t { pub gl_pathc: ::size_t, pub gl_matchc: ::size_t, @@ -266,6 +272,11 @@ pub time_state: ::c_int, } + pub struct accept_filter_arg { + pub af_name: [::c_char; 16], + af_arg: [[::c_char; 10]; 24], + } + pub struct ptrace_io_desc { pub piod_op: ::c_int, pub piod_offs: *mut ::c_void, @@ -573,6 +584,8 @@ pub const F_TLOCK: ::c_int = 2; pub const F_ULOCK: ::c_int = 0; pub const F_DUPFD_CLOEXEC: ::c_int = 17; +pub const F_DUP2FD: ::c_int = 10; +pub const F_DUP2FD_CLOEXEC: ::c_int = 18; pub const SIGHUP: ::c_int = 1; pub const SIGINT: ::c_int = 2; pub const SIGQUIT: ::c_int = 3; @@ -724,6 +737,14 @@ | ::POLLHUP | ::POLLNVAL; +pub const AI_PASSIVE: ::c_int = 0x00000001; +pub const AI_CANONNAME: ::c_int = 0x00000002; +pub const AI_NUMERICHOST: ::c_int = 0x00000004; +pub const AI_NUMERICSERV: ::c_int = 0x00000008; +pub const AI_ALL: ::c_int = 0x00000100; +pub const AI_ADDRCONFIG: ::c_int = 0x00000400; +pub const AI_V4MAPPED: ::c_int = 0x00000800; + pub const EAI_AGAIN: ::c_int = 2; pub const EAI_BADFLAGS: ::c_int = 3; pub const EAI_FAIL: ::c_int = 4; @@ -814,7 +835,6 @@ pub const MINCORE_MODIFIED: ::c_int = 0x4; pub const MINCORE_REFERENCED_OTHER: ::c_int = 0x8; pub const MINCORE_MODIFIED_OTHER: ::c_int = 0x10; -pub const MINCORE_SUPER: ::c_int = 0x20; pub const AF_UNSPEC: ::c_int = 0; pub const AF_LOCAL: ::c_int = 1; @@ -1179,30 +1199,30 @@ pub const LOG_CONSOLE: ::c_int = 14 << 3; pub const LOG_NFACILITIES: ::c_int = 24; -pub const TIOCEXCL: ::c_uint = 0x2000740d; -pub const TIOCNXCL: ::c_uint = 0x2000740e; +pub const TIOCEXCL: ::c_ulong = 0x2000740d; +pub const TIOCNXCL: ::c_ulong = 0x2000740e; pub const TIOCFLUSH: ::c_ulong = 0x80047410; -pub const TIOCGETA: ::c_uint = 0x402c7413; +pub const TIOCGETA: ::c_ulong = 0x402c7413; pub const TIOCSETA: ::c_ulong = 0x802c7414; pub const TIOCSETAW: ::c_ulong = 0x802c7415; pub const TIOCSETAF: ::c_ulong = 0x802c7416; -pub const TIOCGETD: ::c_uint = 0x4004741a; +pub const TIOCGETD: ::c_ulong = 0x4004741a; pub const TIOCSETD: ::c_ulong = 0x8004741b; -pub const TIOCGDRAINWAIT: ::c_uint = 0x40047456; +pub const TIOCGDRAINWAIT: ::c_ulong = 0x40047456; pub const TIOCSDRAINWAIT: ::c_ulong = 0x80047457; -pub const TIOCTIMESTAMP: ::c_uint = 0x40107459; -pub const TIOCMGDTRWAIT: ::c_uint = 0x4004745a; +pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459; +pub const TIOCMGDTRWAIT: ::c_ulong = 0x4004745a; pub const TIOCMSDTRWAIT: ::c_ulong = 0x8004745b; -pub const TIOCDRAIN: ::c_uint = 0x2000745e; +pub const TIOCDRAIN: ::c_ulong = 0x2000745e; pub const TIOCEXT: ::c_ulong = 0x80047460; -pub const TIOCSCTTY: ::c_uint = 0x20007461; +pub const TIOCSCTTY: ::c_ulong = 0x20007461; pub const TIOCCONS: ::c_ulong = 0x80047462; -pub const TIOCGSID: ::c_uint = 0x40047463; -pub const TIOCSTAT: ::c_uint = 0x20007465; +pub const TIOCGSID: ::c_ulong = 0x40047463; +pub const TIOCSTAT: ::c_ulong = 0x20007465; pub const TIOCUCNTL: ::c_ulong = 0x80047466; pub const TIOCSWINSZ: ::c_ulong = 0x80087467; -pub const TIOCGWINSZ: ::c_uint = 0x40087468; -pub const TIOCMGET: ::c_uint = 0x4004746a; +pub const TIOCGWINSZ: ::c_ulong = 0x40087468; +pub const TIOCMGET: ::c_ulong = 0x4004746a; pub const TIOCM_LE: ::c_int = 0x1; pub const TIOCM_DTR: ::c_int = 0x2; pub const TIOCM_RTS: ::c_int = 0x4; @@ -1217,8 +1237,8 @@ pub const TIOCMBIC: ::c_ulong = 0x8004746b; pub const TIOCMBIS: ::c_ulong = 0x8004746c; pub const TIOCMSET: ::c_ulong = 0x8004746d; -pub const TIOCSTART: ::c_uint = 0x2000746e; -pub const TIOCSTOP: ::c_uint = 0x2000746f; +pub const TIOCSTART: ::c_ulong = 0x2000746e; +pub const TIOCSTOP: ::c_ulong = 0x2000746f; pub const TIOCPKT: ::c_ulong = 0x80047470; pub const TIOCPKT_DATA: ::c_int = 0x0; pub const TIOCPKT_FLUSHREAD: ::c_int = 0x1; @@ -1228,13 +1248,13 @@ pub const TIOCPKT_NOSTOP: ::c_int = 0x10; pub const TIOCPKT_DOSTOP: ::c_int = 0x20; pub const TIOCPKT_IOCTL: ::c_int = 0x40; -pub const TIOCNOTTY: ::c_uint = 0x20007471; +pub const TIOCNOTTY: ::c_ulong = 0x20007471; pub const TIOCSTI: ::c_ulong = 0x80017472; -pub const TIOCOUTQ: ::c_uint = 0x40047473; +pub const TIOCOUTQ: ::c_ulong = 0x40047473; pub const TIOCSPGRP: ::c_ulong = 0x80047476; -pub const TIOCGPGRP: ::c_uint = 0x40047477; -pub const TIOCCDTR: ::c_uint = 0x20007478; -pub const TIOCSDTR: ::c_uint = 0x20007479; +pub const TIOCGPGRP: ::c_ulong = 0x40047477; +pub const TIOCCDTR: ::c_ulong = 0x20007478; +pub const TIOCSDTR: ::c_ulong = 0x20007479; pub const TTYDISC: ::c_int = 0x0; pub const SLIPDISC: ::c_int = 0x4; pub const PPPDISC: ::c_int = 0x5; @@ -1252,7 +1272,6 @@ pub const FIODTYPE: ::c_ulong = 0x4004667a; pub const FIOGETLBA: ::c_ulong = 0x40046679; -pub const FIODGNAME: ::c_ulong = 0x80106678; pub const B0: speed_t = 0; pub const B50: speed_t = 50; @@ -1409,12 +1428,6 @@ pub fn sem_init(sem: *mut sem_t, pshared: ::c_int, value: ::c_uint) -> ::c_int; pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; - pub fn devname_r( - dev: ::dev_t, - mode: ::mode_t, - buf: *mut ::c_char, - len: ::c_int, - ) -> *mut ::c_char; pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int; pub fn accept4( s: ::c_int, @@ -1476,6 +1489,8 @@ flags: ::c_int, ) -> ::c_int; pub fn getpriority(which: ::c_int, who: ::c_int) -> ::c_int; + pub fn getresgid(rgid: *mut ::gid_t, egid: *mut ::gid_t, sgid: *mut ::gid_t) -> ::c_int; + pub fn getresuid(ruid: *mut ::uid_t, euid: *mut ::uid_t, suid: *mut ::uid_t) -> ::c_int; pub fn getutxent() -> *mut utmpx; pub fn getutxid(ut: *const utmpx) -> *mut utmpx; pub fn getutxline(ut: *const utmpx) -> *mut utmpx; @@ -1510,6 +1525,8 @@ pub fn newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t; pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char; pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; + pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int; + pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, advise: ::c_int) -> ::c_int; pub fn ppoll( fds: *mut ::pollfd, nfds: ::nfds_t, diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/netbsdlike/mod.rs cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/netbsdlike/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -747,6 +747,7 @@ pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void; pub fn gethostid() -> ::c_long; pub fn sethostid(hostid: ::c_long) -> ::c_int; + pub fn ftok(path: *const ::c_char, id: ::c_int) -> ::key_t; } cfg_if! { diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -343,6 +343,14 @@ pub sc_groups: [::gid_t; 1], } + pub struct uucred { + pub cr_unused: ::c_ushort, + pub cr_uid: ::uid_t, + pub cr_gid: ::gid_t, + pub cr_ngroups: ::c_int, + pub cr_groups: [::gid_t; NGROUPS_MAX as usize], + } + pub struct unpcbid { pub unp_pid: ::pid_t, pub unp_euid: ::uid_t, @@ -538,6 +546,35 @@ #[cfg(libc_union)] pub fae: *mut posix_spawn_file_actions_entry_t, } + + pub struct ptrace_lwpinfo { + pub pl_lwpid: lwpid_t, + pub pl_event: ::c_int, + } + + pub struct ptrace_lwpstatus { + pub pl_lwpid: lwpid_t, + pub pl_sigpend: sigset_t, + pub pl_sigmask: sigset_t, + pub pl_name: [::c_char; 20], + pub pl_private: *mut ::c_void, + } + + pub struct ptrace_siginfo { + pub psi_siginfo: siginfo_t, + pub psi_lwpid: lwpid_t, + } + + pub struct ptrace_event { + pub pe_set_event: ::c_int, + } + + pub struct sysctldesc { + pub descr_num: i32, + pub descr_ver: u32, + pub descr_len: u32, + pub descr_str: [::c_char; 1], + } } s_no_extra_traits! { @@ -1216,6 +1253,7 @@ pub const F_GETNOSIGPIPE: ::c_int = 13; pub const F_SETNOSIGPIPE: ::c_int = 14; pub const F_MAXFD: ::c_int = 11; +pub const F_GETPATH: ::c_int = 15; pub const IP_RECVDSTADDR: ::c_int = 7; pub const IP_SENDSRCADDR: ::c_int = IP_RECVDSTADDR; @@ -1385,6 +1423,15 @@ pub const MAP_HASSEMAPHORE: ::c_int = 0x200; pub const MAP_WIRED: ::c_int = 0x800; pub const MAP_STACK: ::c_int = 0x2000; +// map alignment aliases for MAP_ALIGNED +pub const MAP_ALIGNMENT_SHIFT: ::c_int = 24; +pub const MAP_ALIGNMENT_MASK: ::c_int = 0xff << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNMENT_64KB: ::c_int = 16 << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNMENT_16MB: ::c_int = 24 << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNMENT_4GB: ::c_int = 32 << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNMENT_1TB: ::c_int = 40 << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNMENT_256TB: ::c_int = 48 << MAP_ALIGNMENT_SHIFT; +pub const MAP_ALIGNMENT_64PB: ::c_int = 56 << MAP_ALIGNMENT_SHIFT; // mremap flag pub const MAP_REMAPDUP: ::c_int = 0x004; @@ -1598,6 +1645,10 @@ pub const LITTLE_ENDIAN: ::c_int = 1234; pub const BIG_ENDIAN: ::c_int = 4321; +pub const PL_EVENT_NONE: ::c_int = 0; +pub const PL_EVENT_SIGNAL: ::c_int = 1; +pub const PL_EVENT_SUSPENDED: ::c_int = 2; + cfg_if! { if #[cfg(any(target_arch = "sparc", target_arch = "sparc64", target_arch = "x86", target_arch = "x86_64"))] { @@ -1696,6 +1747,13 @@ pub const TMP_MAX: ::c_uint = 308915776; +pub const AI_PASSIVE: ::c_int = 0x00000001; +pub const AI_CANONNAME: ::c_int = 0x00000002; +pub const AI_NUMERICHOST: ::c_int = 0x00000004; +pub const AI_NUMERICSERV: ::c_int = 0x00000008; +pub const AI_ADDRCONFIG: ::c_int = 0x00000400; +pub const AI_SRV: ::c_int = 0x00000800; + pub const NI_MAXHOST: ::socklen_t = 1025; pub const NI_MAXSERV: ::socklen_t = 32; @@ -1955,6 +2013,15 @@ pub const PT_SET_EVENT_MASK: ::c_int = 16; pub const PT_GET_EVENT_MASK: ::c_int = 17; pub const PT_GET_PROCESS_STATE: ::c_int = 18; +pub const PT_SET_SIGINFO: ::c_int = 19; +pub const PT_GET_SIGINFO: ::c_int = 20; +pub const PT_RESUME: ::c_int = 21; +pub const PT_SUSPEND: ::c_int = 23; +pub const PT_STOP: ::c_int = 23; +pub const PT_LWPSTATUS: ::c_int = 24; +pub const PT_LWPNEXT: ::c_int = 25; +pub const PT_SET_SIGPASS: ::c_int = 26; +pub const PT_GET_SIGPASS: ::c_int = 27; pub const PT_FIRSTMACH: ::c_int = 32; pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01; @@ -1982,6 +2049,8 @@ pub const KVME_FLAG_GROWS_UP: ::c_int = 0x000000010; pub const KVME_FLAG_GROWS_DOWN: ::c_int = 0x000000020; +pub const NGROUPS_MAX: ::c_int = 16; + const_fn! { {const} fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES @@ -2036,6 +2105,14 @@ }; ::mem::size_of::() + ::mem::size_of::<::gid_t>() * ngrps } + + pub fn PROT_MPROTECT(x: ::c_int) -> ::c_int { + x << 3 + } + + pub fn PROT_MPROTECT_EXTRACT(x: ::c_int) -> ::c_int { + (x >> 3) & 0x7 + } } safe_f! { @@ -2096,6 +2173,12 @@ pub fn fchflags(fd: ::c_int, flags: ::c_ulong) -> ::c_int; pub fn lchflags(path: *const ::c_char, flags: ::c_ulong) -> ::c_int; + pub fn execvpe( + file: *const ::c_char, + argv: *const *const ::c_char, + envp: *const *const ::c_char, + ) -> ::c_int; + pub fn extattr_delete_fd( fd: ::c_int, attrnamespace: ::c_int, @@ -2515,10 +2598,23 @@ pub fn emalloc(n: ::size_t) -> *mut ::c_void; pub fn ecalloc(n: ::size_t, c: ::size_t) -> *mut ::c_void; pub fn erealloc(p: *mut ::c_void, n: ::size_t) -> *mut ::c_void; + pub fn ereallocarr(p: *mut ::c_void, n: ::size_t, s: ::size_t); pub fn estrdup(s: *const ::c_char) -> *mut ::c_char; pub fn estrndup(s: *const ::c_char, len: ::size_t) -> *mut ::c_char; pub fn estrlcpy(dst: *mut ::c_char, src: *const ::c_char, len: ::size_t) -> ::size_t; pub fn estrlcat(dst: *mut ::c_char, src: *const ::c_char, len: ::size_t) -> ::size_t; + pub fn estrtoi( + nptr: *const ::c_char, + base: ::c_int, + lo: ::intmax_t, + hi: ::intmax_t, + ) -> ::intmax_t; + pub fn estrtou( + nptr: *const ::c_char, + base: ::c_int, + lo: ::uintmax_t, + hi: ::uintmax_t, + ) -> ::uintmax_t; pub fn easprintf(string: *mut *mut ::c_char, fmt: *const ::c_char, ...) -> ::c_int; pub fn evasprintf(string: *mut *mut ::c_char, fmt: *const ::c_char, ...) -> ::c_int; pub fn esetfunc( @@ -2586,6 +2682,50 @@ tpe: ::c_int, ); + pub fn getxattr( + path: *const ::c_char, + name: *const ::c_char, + value: *mut ::c_void, + size: ::size_t, + ) -> ::ssize_t; + pub fn lgetxattr( + path: *const ::c_char, + name: *const ::c_char, + value: *mut ::c_void, + size: ::size_t, + ) -> ::ssize_t; + pub fn fgetxattr( + filedes: ::c_int, + name: *const ::c_char, + value: *mut ::c_void, + size: ::size_t, + ) -> ::ssize_t; + pub fn setxattr( + path: *const ::c_char, + name: *const ::c_char, + value: *const ::c_void, + size: ::size_t, + ) -> ::c_int; + pub fn lsetxattr( + path: *const ::c_char, + name: *const ::c_char, + value: *const ::c_void, + size: ::size_t, + ) -> ::c_int; + pub fn fsetxattr( + filedes: ::c_int, + name: *const ::c_char, + value: *const ::c_void, + size: ::size_t, + flags: ::c_int, + ) -> ::c_int; + pub fn listxattr(path: *const ::c_char, list: *mut ::c_char, size: ::size_t) -> ::ssize_t; + pub fn llistxattr(path: *const ::c_char, list: *mut ::c_char, size: ::size_t) -> ::ssize_t; + pub fn flistxattr(filedes: ::c_int, list: *mut ::c_char, size: ::size_t) -> ::ssize_t; + pub fn removexattr(path: *const ::c_char, name: *const ::c_char) -> ::c_int; + pub fn lremovexattr(path: *const ::c_char, name: *const ::c_char) -> ::c_int; + pub fn fremovexattr(fd: ::c_int, path: *const ::c_char, name: *const ::c_char) -> ::c_int; + pub fn string_to_flags( string_p: *mut *mut ::c_char, setp: *mut ::c_ulong, diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/netbsdlike/openbsd/arm.rs cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/openbsd/arm.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/netbsdlike/openbsd/arm.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/openbsd/arm.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,16 @@ +pub type c_long = i32; +pub type c_ulong = u32; +pub type c_char = u8; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_double>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + +pub const _MAX_PAGE_SHIFT: u32 = 12; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mips64.rs cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mips64.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mips64.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mips64.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,8 @@ +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = i8; + +#[doc(hidden)] +pub const _ALIGNBYTES: usize = 7; + +pub const _MAX_PAGE_SHIFT: u32 = 14; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -209,6 +209,12 @@ pub sin_zero: [i8; 8], } + pub struct splice { + pub sp_fd: ::c_int, + pub sp_max: ::off_t, + pub sp_idle: ::timeval, + } + pub struct kevent { pub ident: ::uintptr_t, pub filter: ::c_short, @@ -401,6 +407,16 @@ pub kve_inheritance: ::c_int, pub kve_flags: u8, } + + pub struct ptrace_state { + pub pe_report_event: ::c_int, + pub pe_other_pid: ::pid_t, + pub pe_tid: ::pid_t, + } + + pub struct ptrace_thread_state { + pub pts_tid: ::pid_t, + } } impl siginfo_t { @@ -1163,7 +1179,9 @@ pub const EV_FLAG1: u16 = 0x2000; pub const EV_ERROR: u16 = 0x4000; pub const EV_EOF: u16 = 0x8000; -pub const EV_SYSFLAGS: u16 = 0xf000; + +#[deprecated(since = "0.2.113", note = "Not stable across OS versions")] +pub const EV_SYSFLAGS: u16 = 0xf800; pub const NOTE_LOWAT: u32 = 0x00000001; pub const NOTE_EOF: u32 = 0x00000002; @@ -1186,6 +1204,14 @@ pub const TMP_MAX: ::c_uint = 0x7fffffff; +pub const AI_PASSIVE: ::c_int = 1; +pub const AI_CANONNAME: ::c_int = 2; +pub const AI_NUMERICHOST: ::c_int = 4; +pub const AI_EXT: ::c_int = 8; +pub const AI_NUMERICSERV: ::c_int = 16; +pub const AI_FQDN: ::c_int = 32; +pub const AI_ADDRCONFIG: ::c_int = 64; + pub const NI_NUMERICHOST: ::c_int = 1; pub const NI_NUMERICSERV: ::c_int = 2; pub const NI_NOFQDN: ::c_int = 4; @@ -1420,6 +1446,11 @@ pub const MINSIGSTKSZ: ::size_t = 3_usize << _MAX_PAGE_SHIFT; pub const SIGSTKSZ: ::size_t = MINSIGSTKSZ + (1_usize << _MAX_PAGE_SHIFT) * 4; +pub const PT_SET_EVENT_MASK: ::c_int = 12; +pub const PT_GET_EVENT_MASK: ::c_int = 13; +pub const PT_GET_PROCESS_STATE: ::c_int = 14; +pub const PT_GET_THREAD_FIRST: ::c_int = 15; +pub const PT_GET_THREAD_NEXT: ::c_int = 16; pub const PT_FIRSTMACH: ::c_int = 32; pub const SOCK_CLOEXEC: ::c_int = 0x8000; @@ -1527,6 +1558,8 @@ servlen: ::size_t, flags: ::c_int, ) -> ::c_int; + pub fn getresgid(rgid: *mut ::gid_t, egid: *mut ::gid_t, sgid: *mut ::gid_t) -> ::c_int; + pub fn getresuid(ruid: *mut ::uid_t, euid: *mut ::uid_t, suid: *mut ::uid_t) -> ::c_int; pub fn kevent( kq: ::c_int, changelist: *const ::kevent, @@ -1596,6 +1629,22 @@ pub fn calloc_conceal(nmemb: ::size_t, size: ::size_t) -> *mut ::c_void; } +#[link(name = "execinfo")] +extern "C" { + pub fn backtrace(addrlist: *mut *mut ::c_void, len: ::size_t) -> ::size_t; + pub fn backtrace_symbols(addrlist: *const *mut ::c_void, len: ::size_t) -> *mut *mut ::c_char; + pub fn backtrace_symbols_fd( + addrlist: *const *mut ::c_void, + len: ::size_t, + fd: ::c_int, + ) -> ::c_int; + pub fn backtrace_symbols_fmt( + addrlist: *const *mut ::c_void, + len: ::size_t, + fmt: *const ::c_char, + ) -> *mut *mut ::c_char; +} + cfg_if! { if #[cfg(libc_union)] { extern { @@ -1607,18 +1656,33 @@ } cfg_if! { - if #[cfg(target_arch = "x86")] { - mod x86; - pub use self::x86::*; - } else if #[cfg(target_arch = "x86_64")] { - mod x86_64; - pub use self::x86_64::*; - } else if #[cfg(target_arch = "aarch64")] { + if #[cfg(target_arch = "aarch64")] { mod aarch64; pub use self::aarch64::*; + } else if #[cfg(target_arch = "arm")] { + mod arm; + pub use self::arm::*; + } else if #[cfg(target_arch = "mips64")] { + mod mips64; + pub use self::mips64::*; + } else if #[cfg(target_arch = "powerpc")] { + mod powerpc; + pub use self::powerpc::*; + } else if #[cfg(target_arch = "powerpc64")] { + mod powerpc64; + pub use self::powerpc64::*; + } else if #[cfg(target_arch = "riscv64")] { + mod riscv64; + pub use self::riscv64::*; } else if #[cfg(target_arch = "sparc64")] { mod sparc64; pub use self::sparc64::*; + } else if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; } else { // Unknown target_arch } diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,16 @@ +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = u8; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + +pub const _MAX_PAGE_SHIFT: u32 = 12; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/netbsdlike/openbsd/powerpc.rs cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/openbsd/powerpc.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/netbsdlike/openbsd/powerpc.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/openbsd/powerpc.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,16 @@ +pub type c_long = i32; +pub type c_ulong = u32; +pub type c_char = u8; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_double>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + +pub const _MAX_PAGE_SHIFT: u32 = 12; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/netbsdlike/openbsd/riscv64.rs cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/openbsd/riscv64.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/bsd/netbsdlike/openbsd/riscv64.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/bsd/netbsdlike/openbsd/riscv64.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,16 @@ +pub type c_long = i64; +pub type c_ulong = u64; +pub type c_char = u8; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} + +pub const _MAX_PAGE_SHIFT: u32 = 12; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/haiku/b32.rs cargo-0.58.0/vendor/libc/src/unix/haiku/b32.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/haiku/b32.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/haiku/b32.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,3 +1,20 @@ pub type c_long = i32; pub type c_ulong = u32; pub type time_t = i32; + +pub type Elf_Addr = ::Elf32_Addr; +pub type Elf_Half = ::Elf32_Half; +pub type Elf_Phdr = ::Elf32_Phdr; + +s! { + pub struct Elf32_Phdr { + pub p_type: ::Elf32_Word, + pub p_offset: ::Elf32_Off, + pub p_vaddr: ::Elf32_Addr, + pub p_paddr: ::Elf32_Addr, + pub p_filesz: ::Elf32_Word, + pub p_memsz: ::Elf32_Word, + pub p_flags: ::Elf32_Word, + pub p_align: ::Elf32_Word, + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/haiku/b64.rs cargo-0.58.0/vendor/libc/src/unix/haiku/b64.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/haiku/b64.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/haiku/b64.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,3 +1,20 @@ pub type c_ulong = u64; pub type c_long = i64; pub type time_t = i64; + +pub type Elf_Addr = ::Elf64_Addr; +pub type Elf_Half = ::Elf64_Half; +pub type Elf_Phdr = ::Elf64_Phdr; + +s! { + pub struct Elf64_Phdr { + pub p_type: ::Elf64_Word, + pub p_flags: ::Elf64_Word, + pub p_offset: ::Elf64_Off, + pub p_vaddr: ::Elf64_Addr, + pub p_paddr: ::Elf64_Addr, + pub p_filesz: ::Elf64_Xword, + pub p_memsz: ::Elf64_Xword, + pub p_align: ::Elf64_Xword, + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/haiku/mod.rs cargo-0.58.0/vendor/libc/src/unix/haiku/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/haiku/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/haiku/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -31,6 +31,22 @@ pub type idtype_t = ::c_uint; pub type fd_mask = u32; +pub type Elf32_Addr = u32; +pub type Elf32_Half = u16; +pub type Elf32_Lword = u64; +pub type Elf32_Off = u32; +pub type Elf32_Sword = i32; +pub type Elf32_Word = u32; + +pub type Elf64_Addr = u64; +pub type Elf64_Half = u16; +pub type Elf64_Lword = u64; +pub type Elf64_Off = u64; +pub type Elf64_Sword = i32; +pub type Elf64_Sxword = i64; +pub type Elf64_Word = u32; +pub type Elf64_Xword = u64; + #[cfg_attr(feature = "extra_traits", derive(Debug))] pub enum timezone {} impl ::Copy for timezone {} @@ -102,6 +118,16 @@ pub ai_next: *mut addrinfo, } + pub struct ifaddrs { + pub ifa_next: *mut ifaddrs, + pub ifa_name: *mut ::c_char, + pub ifa_flags: ::c_uint, + pub ifa_addr: *mut ::sockaddr, + pub ifa_netmask: *mut ::sockaddr, + pub ifa_dstaddr: *mut ::sockaddr, + pub ida_data: *mut ::c_void, + } + pub struct fd_set { // size for 1024 bits, and a fd_mask with size u32 fds_bits: [fd_mask; 32], @@ -333,6 +359,17 @@ pub sdl_slen: u8, pub sdl_data: [u8; 46], } + + pub struct dl_phdr_info { + pub dlpi_addr: Elf_Addr, + pub dlpi_name: *const ::c_char, + pub dlpi_phdr: *const Elf_Phdr, + pub dlpi_phnum: Elf_Half, + pub dlpi_adds: ::c_ulonglong, + pub dlpi_subs: ::c_ulonglong, + pub dlpi_tls_modid: usize, + pub dlpi_tls_data: *mut ::c_void, + } } s_no_extra_traits! { @@ -1450,6 +1487,12 @@ pub fn getpriority(which: ::c_int, who: id_t) -> ::c_int; pub fn setpriority(which: ::c_int, who: id_t, priority: ::c_int) -> ::c_int; + pub fn endusershell(); + pub fn getpass(prompt: *const ::c_char) -> *mut ::c_char; + pub fn getusershell() -> *mut ::c_char; + pub fn issetugid() -> ::c_int; + pub fn setusershell(); + pub fn utimensat( fd: ::c_int, path: *const ::c_char, @@ -1465,6 +1508,8 @@ pub fn labs(i: ::c_long) -> ::c_long; pub fn rand() -> ::c_int; pub fn srand(seed: ::c_uint); + pub fn getifaddrs(ifap: *mut *mut ::ifaddrs) -> ::c_int; + pub fn freeifaddrs(ifa: *mut ::ifaddrs); } #[link(name = "bsd")] @@ -1638,6 +1683,23 @@ pub fn pututxline(ut: *const utmpx) -> *mut utmpx; pub fn setutxent(); pub fn endutxent(); + + pub fn dl_iterate_phdr( + callback: ::Option< + unsafe extern "C" fn( + info: *mut dl_phdr_info, + size: usize, + data: *mut ::c_void, + ) -> ::c_int, + >, + data: *mut ::c_void, + ) -> ::c_int; + + pub fn strsep(string: *mut *mut ::c_char, delimiters: *const ::c_char) -> *mut ::c_char; + pub fn explicit_bzero(buf: *mut ::c_void, len: ::size_t); + + pub fn login_tty(_fd: ::c_int) -> ::c_int; + pub fn fgetln(stream: *mut ::FILE, _length: *mut ::size_t) -> *mut ::c_char; } cfg_if! { diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/android/b64/aarch64/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/android/b64/aarch64/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/android/b64/aarch64/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/android/b64/aarch64/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -48,6 +48,13 @@ __unused4: ::c_uint, __unused5: ::c_uint, } + + pub struct user_regs_struct { + pub regs: [u64; 31], + pub sp: u64, + pub pc: u64, + pub pstate: u64, + } } pub const O_DIRECT: ::c_int = 0x10000; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/android/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/android/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/android/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/android/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -73,6 +73,12 @@ pub cmsg_type: ::c_int, } + pub struct ip_mreqn { + pub imr_multiaddr: ::in_addr, + pub imr_address: ::in_addr, + pub imr_ifindex: ::c_int, + } + pub struct termios { pub c_iflag: ::tcflag_t, pub c_oflag: ::tcflag_t, @@ -349,6 +355,12 @@ pub instruction_pointer: ::__u64, pub args: [::__u64; 6], } + + pub struct ptrace_peeksiginfo_args { + pub off: ::__u64, + pub flags: ::__u32, + pub nr: ::__s32, + } } s_no_extra_traits! { @@ -806,6 +818,8 @@ pub const USER_PROCESS: ::c_short = 7; +pub const _POSIX_VDISABLE: ::cc_t = 0; + // linux/falloc.h pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01; pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02; @@ -1202,6 +1216,9 @@ pub const SO_RCVTIMEO: ::c_int = 20; pub const SO_SNDTIMEO: ::c_int = 21; pub const SO_BINDTODEVICE: ::c_int = 25; +pub const SO_ATTACH_FILTER: ::c_int = 26; +pub const SO_DETACH_FILTER: ::c_int = 27; +pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER; pub const SO_TIMESTAMP: ::c_int = 29; pub const SO_ACCEPTCONN: ::c_int = 30; pub const SO_PEERSEC: ::c_int = 31; @@ -1338,6 +1355,10 @@ pub const TCSETS: ::c_int = 0x5402; pub const TCSETSW: ::c_int = 0x5403; pub const TCSETSF: ::c_int = 0x5404; +pub const TCGETS2: ::c_int = 0x802c542a; +pub const TCSETS2: ::c_int = 0x402c542b; +pub const TCSETSW2: ::c_int = 0x402c542c; +pub const TCSETSF2: ::c_int = 0x402c542d; pub const TCGETA: ::c_int = 0x5405; pub const TCSETA: ::c_int = 0x5406; pub const TCSETAW: ::c_int = 0x5407; @@ -1531,6 +1552,10 @@ pub const B3000000: ::speed_t = 0o010015; pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; +pub const IBSHIFT: ::tcflag_t = 16; + +pub const BLKSSZGET: ::c_int = 0x1268; +pub const BLKPBSZGET: ::c_int = 0x127B; pub const EAI_AGAIN: ::c_int = 2; pub const EAI_BADFLAGS: ::c_int = 3; @@ -2320,6 +2345,9 @@ pub const ALG_OP_DECRYPT: ::c_int = 0; pub const ALG_OP_ENCRYPT: ::c_int = 1; +// sys/mman.h +pub const MLOCK_ONFAULT: ::c_int = 0x01; + // uapi/linux/vm_sockets.h pub const VMADDR_CID_ANY: ::c_uint = 0xFFFFFFFF; pub const VMADDR_CID_HYPERVISOR: ::c_uint = 0; @@ -2574,6 +2602,7 @@ pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int; pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int; + pub fn mlock2(addr: *const ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/arch/generic/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/arch/generic/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/arch/generic/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/arch/generic/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,3 +1,16 @@ +s! { + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; 19], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } +} + // include/uapi/asm-generic/socket.h // arch/alpha/include/uapi/asm/socket.h // tools/include/uapi/asm-generic/socket.h @@ -98,3 +111,124 @@ // pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP; pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; + +// Ioctl Constants + +cfg_if! { + if #[cfg(not(any(target_arch = "mips", + target_arch = "mips64", + target_arch = "powerpc", + target_arch = "powerpc64", + target_arch = "sparc", + target_arch = "sparc64")))] { + + pub const TCGETS: ::Ioctl = 0x5401; + pub const TCSETS: ::Ioctl = 0x5402; + pub const TCSETSW: ::Ioctl = 0x5403; + pub const TCSETSF: ::Ioctl = 0x5404; + pub const TCGETA: ::Ioctl = 0x5405; + pub const TCSETA: ::Ioctl = 0x5406; + pub const TCSETAW: ::Ioctl = 0x5407; + pub const TCSETAF: ::Ioctl = 0x5408; + pub const TCSBRK: ::Ioctl = 0x5409; + pub const TCXONC: ::Ioctl = 0x540A; + pub const TCFLSH: ::Ioctl = 0x540B; + pub const TIOCEXCL: ::Ioctl = 0x540C; + pub const TIOCNXCL: ::Ioctl = 0x540D; + pub const TIOCSCTTY: ::Ioctl = 0x540E; + pub const TIOCGPGRP: ::Ioctl = 0x540F; + pub const TIOCSPGRP: ::Ioctl = 0x5410; + pub const TIOCOUTQ: ::Ioctl = 0x5411; + pub const TIOCSTI: ::Ioctl = 0x5412; + pub const TIOCGWINSZ: ::Ioctl = 0x5413; + pub const TIOCSWINSZ: ::Ioctl = 0x5414; + pub const TIOCMGET: ::Ioctl = 0x5415; + pub const TIOCMBIS: ::Ioctl = 0x5416; + pub const TIOCMBIC: ::Ioctl = 0x5417; + pub const TIOCMSET: ::Ioctl = 0x5418; + pub const TIOCGSOFTCAR: ::Ioctl = 0x5419; + pub const TIOCSSOFTCAR: ::Ioctl = 0x541A; + pub const FIONREAD: ::Ioctl = 0x541B; + pub const TIOCINQ: ::Ioctl = FIONREAD; + pub const TIOCLINUX: ::Ioctl = 0x541C; + pub const TIOCCONS: ::Ioctl = 0x541D; + pub const TIOCGSERIAL: ::Ioctl = 0x541E; + pub const TIOCSSERIAL: ::Ioctl = 0x541F; + pub const TIOCPKT: ::Ioctl = 0x5420; + pub const FIONBIO: ::Ioctl = 0x5421; + pub const TIOCNOTTY: ::Ioctl = 0x5422; + pub const TIOCSETD: ::Ioctl = 0x5423; + pub const TIOCGETD: ::Ioctl = 0x5424; + pub const TCSBRKP: ::Ioctl = 0x5425; + pub const TIOCSBRK: ::Ioctl = 0x5427; + pub const TIOCCBRK: ::Ioctl = 0x5428; + pub const TIOCGSID: ::Ioctl = 0x5429; + pub const TCGETS2: ::Ioctl = 0x802c542a; + pub const TCSETS2: ::Ioctl = 0x402c542b; + pub const TCSETSW2: ::Ioctl = 0x402c542c; + pub const TCSETSF2: ::Ioctl = 0x402c542d; + pub const TIOCGRS485: ::Ioctl = 0x542E; + pub const TIOCSRS485: ::Ioctl = 0x542F; + pub const TIOCGPTN: ::Ioctl = 0x80045430; + pub const TIOCSPTLCK: ::Ioctl = 0x40045431; + pub const TIOCGDEV: ::Ioctl = 0x80045432; + pub const TCGETX: ::Ioctl = 0x5432; + pub const TCSETX: ::Ioctl = 0x5433; + pub const TCSETXF: ::Ioctl = 0x5434; + pub const TCSETXW: ::Ioctl = 0x5435; + pub const TIOCSIG: ::Ioctl = 0x40045436; + pub const TIOCVHANGUP: ::Ioctl = 0x5437; + pub const TIOCGPKT: ::Ioctl = 0x80045438; + pub const TIOCGPTLCK: ::Ioctl = 0x80045439; + pub const TIOCGEXCL: ::Ioctl = 0x80045440; + pub const TIOCGPTPEER: ::Ioctl = 0x5441; +// pub const TIOCGISO7816: ::Ioctl = 0x80285442; +// pub const TIOCSISO7816: ::Ioctl = 0xc0285443; + pub const FIONCLEX: ::Ioctl = 0x5450; + pub const FIOCLEX: ::Ioctl = 0x5451; + pub const FIOASYNC: ::Ioctl = 0x5452; + pub const TIOCSERCONFIG: ::Ioctl = 0x5453; + pub const TIOCSERGWILD: ::Ioctl = 0x5454; + pub const TIOCSERSWILD: ::Ioctl = 0x5455; + pub const TIOCGLCKTRMIOS: ::Ioctl = 0x5456; + pub const TIOCSLCKTRMIOS: ::Ioctl = 0x5457; + pub const TIOCSERGSTRUCT: ::Ioctl = 0x5458; + pub const TIOCSERGETLSR: ::Ioctl = 0x5459; + pub const TIOCSERGETMULTI: ::Ioctl = 0x545A; + pub const TIOCSERSETMULTI: ::Ioctl = 0x545B; + pub const TIOCMIWAIT: ::Ioctl = 0x545C; + pub const TIOCGICOUNT: ::Ioctl = 0x545D; + } +} + +cfg_if! { + if #[cfg(any(target_arch = "arm", + target_arch = "s390x"))] { + pub const FIOQSIZE: ::Ioctl = 0x545E; + } else if #[cfg(not(any(target_arch = "mips", + target_arch = "mips64", + target_arch = "powerpc", + target_arch = "powerpc64", + target_arch = "sparc", + target_arch = "sparc64")))] { + pub const FIOQSIZE: ::Ioctl = 0x5460; + } +} + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; +pub const TIOCM_DSR: ::c_int = 0x100; + +pub const BOTHER: ::speed_t = 0o010000; +pub const IBSHIFT: ::tcflag_t = 16; + +pub const BLKSSZGET: ::c_int = 0x1268; +pub const BLKPBSZGET: ::c_int = 0x127B; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/arch/mips/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/arch/mips/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/arch/mips/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/arch/mips/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,3 +1,16 @@ +s! { + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; 23], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } +} + // arch/mips/include/uapi/asm/socket.h pub const SOL_SOCKET: ::c_int = 0xffff; @@ -94,3 +107,106 @@ // pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP; pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; + +// Ioctl Constants + +pub const TCGETS: ::Ioctl = 0x540d; +pub const TCSETS: ::Ioctl = 0x540e; +pub const TCSETSW: ::Ioctl = 0x540f; +pub const TCSETSF: ::Ioctl = 0x5410; +pub const TCGETA: ::Ioctl = 0x5401; +pub const TCSETA: ::Ioctl = 0x5402; +pub const TCSETAW: ::Ioctl = 0x5403; +pub const TCSETAF: ::Ioctl = 0x5404; +pub const TCSBRK: ::Ioctl = 0x5405; +pub const TCXONC: ::Ioctl = 0x5406; +pub const TCFLSH: ::Ioctl = 0x5407; +pub const TIOCEXCL: ::Ioctl = 0x740d; +pub const TIOCNXCL: ::Ioctl = 0x740e; +pub const TIOCSCTTY: ::Ioctl = 0x5480; +pub const TIOCGPGRP: ::Ioctl = 0x40047477; +pub const TIOCSPGRP: ::Ioctl = 0x80047476; +pub const TIOCOUTQ: ::Ioctl = 0x7472; +pub const TIOCSTI: ::Ioctl = 0x5472; +pub const TIOCGWINSZ: ::Ioctl = 0x40087468; +pub const TIOCSWINSZ: ::Ioctl = 0x80087467; +pub const TIOCMGET: ::Ioctl = 0x741d; +pub const TIOCMBIS: ::Ioctl = 0x741b; +pub const TIOCMBIC: ::Ioctl = 0x741c; +pub const TIOCMSET: ::Ioctl = 0x741a; +pub const TIOCGSOFTCAR: ::Ioctl = 0x5481; +pub const TIOCSSOFTCAR: ::Ioctl = 0x5482; +pub const FIONREAD: ::Ioctl = 0x467f; +pub const TIOCINQ: ::Ioctl = FIONREAD; +pub const TIOCLINUX: ::Ioctl = 0x5483; +pub const TIOCCONS: ::Ioctl = 0x80047478; +pub const TIOCGSERIAL: ::Ioctl = 0x5484; +pub const TIOCSSERIAL: ::Ioctl = 0x5485; +pub const TIOCPKT: ::Ioctl = 0x5470; +pub const FIONBIO: ::Ioctl = 0x667e; +pub const TIOCNOTTY: ::Ioctl = 0x5471; +pub const TIOCSETD: ::Ioctl = 0x7401; +pub const TIOCGETD: ::Ioctl = 0x7400; +pub const TCSBRKP: ::Ioctl = 0x5486; +pub const TIOCSBRK: ::Ioctl = 0x5427; +pub const TIOCCBRK: ::Ioctl = 0x5428; +pub const TIOCGSID: ::Ioctl = 0x7416; +pub const TCGETS2: ::Ioctl = 0x4030542a; +pub const TCSETS2: ::Ioctl = 0x8030542b; +pub const TCSETSW2: ::Ioctl = 0x8030542c; +pub const TCSETSF2: ::Ioctl = 0x8030542d; +pub const TIOCGPTN: ::Ioctl = 0x40045430; +pub const TIOCSPTLCK: ::Ioctl = 0x80045431; +pub const TIOCGDEV: ::Ioctl = 0x40045432; +pub const TIOCSIG: ::Ioctl = 0x80045436; +pub const TIOCVHANGUP: ::Ioctl = 0x5437; +pub const TIOCGPKT: ::Ioctl = 0x40045438; +pub const TIOCGPTLCK: ::Ioctl = 0x40045439; +pub const TIOCGEXCL: ::Ioctl = 0x40045440; +pub const TIOCGPTPEER: ::Ioctl = 0x20005441; +//pub const TIOCGISO7816: ::Ioctl = 0x40285442; +//pub const TIOCSISO7816: ::Ioctl = 0xc0285443; +pub const FIONCLEX: ::Ioctl = 0x6602; +pub const FIOCLEX: ::Ioctl = 0x6601; +pub const FIOASYNC: ::Ioctl = 0x667d; +pub const TIOCSERCONFIG: ::Ioctl = 0x5488; +pub const TIOCSERGWILD: ::Ioctl = 0x5489; +pub const TIOCSERSWILD: ::Ioctl = 0x548a; +pub const TIOCGLCKTRMIOS: ::Ioctl = 0x548b; +pub const TIOCSLCKTRMIOS: ::Ioctl = 0x548c; +pub const TIOCSERGSTRUCT: ::Ioctl = 0x548d; +pub const TIOCSERGETLSR: ::Ioctl = 0x548e; +pub const TIOCSERGETMULTI: ::Ioctl = 0x548f; +pub const TIOCSERSETMULTI: ::Ioctl = 0x5490; +pub const TIOCMIWAIT: ::Ioctl = 0x5491; +pub const TIOCGICOUNT: ::Ioctl = 0x5492; +pub const FIOQSIZE: ::Ioctl = 0x667f; +pub const TIOCSLTC: ::Ioctl = 0x7475; +pub const TIOCGETP: ::Ioctl = 0x7408; +pub const TIOCSETP: ::Ioctl = 0x7409; +pub const TIOCSETN: ::Ioctl = 0x740a; + +cfg_if! { + if #[cfg(target_env = "musl")] { + pub const TIOCGRS485: ::Ioctl = 0x4020542e; + pub const TIOCSRS485: ::Ioctl = 0xc020542f; + } +} + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x010; +pub const TIOCM_SR: ::c_int = 0x020; +pub const TIOCM_CTS: ::c_int = 0x040; +pub const TIOCM_CAR: ::c_int = 0x100; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RNG: ::c_int = 0x200; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; +pub const TIOCM_DSR: ::c_int = 0x400; + +pub const BOTHER: ::speed_t = 0o010000; +pub const IBSHIFT: ::tcflag_t = 16; + +pub const BLKSSZGET: ::c_int = 0x20001268; +pub const BLKPBSZGET: ::c_int = 0x2000127B; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/arch/powerpc/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/arch/powerpc/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/arch/powerpc/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/arch/powerpc/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -89,3 +89,103 @@ // pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP; pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; + +// Ioctl Constants + +cfg_if! { + if #[cfg(target_env = "musl")] { + pub const TCGETS: ::Ioctl = 0x402c7413; + pub const TCSETS: ::Ioctl = 0x802c7414; + pub const TCSETSW: ::Ioctl = 0x802c7415; + pub const TCSETSF: ::Ioctl = 0x802c7416; + } else { + pub const TCGETS: ::Ioctl = 0x403c7413; + pub const TCSETS: ::Ioctl = 0x803c7414; + pub const TCSETSW: ::Ioctl = 0x803c7415; + pub const TCSETSF: ::Ioctl = 0x803c7416; + } +} + +pub const TCGETA: ::Ioctl = 0x40147417; +pub const TCSETA: ::Ioctl = 0x80147418; +pub const TCSETAW: ::Ioctl = 0x80147419; +pub const TCSETAF: ::Ioctl = 0x8014741C; +pub const TCSBRK: ::Ioctl = 0x2000741D; +pub const TCXONC: ::Ioctl = 0x2000741E; +pub const TCFLSH: ::Ioctl = 0x2000741F; +pub const TIOCEXCL: ::Ioctl = 0x540C; +pub const TIOCNXCL: ::Ioctl = 0x540D; +pub const TIOCSCTTY: ::Ioctl = 0x540E; +pub const TIOCGPGRP: ::Ioctl = 0x40047477; +pub const TIOCSPGRP: ::Ioctl = 0x80047476; +pub const TIOCOUTQ: ::Ioctl = 0x40047473; +pub const TIOCSTI: ::Ioctl = 0x5412; +pub const TIOCGWINSZ: ::Ioctl = 0x40087468; +pub const TIOCSWINSZ: ::Ioctl = 0x80087467; +pub const TIOCMGET: ::Ioctl = 0x5415; +pub const TIOCMBIS: ::Ioctl = 0x5416; +pub const TIOCMBIC: ::Ioctl = 0x5417; +pub const TIOCMSET: ::Ioctl = 0x5418; +pub const TIOCGSOFTCAR: ::Ioctl = 0x5419; +pub const TIOCSSOFTCAR: ::Ioctl = 0x541A; +pub const FIONREAD: ::Ioctl = 0x4004667F; +pub const TIOCINQ: ::Ioctl = FIONREAD; +pub const TIOCLINUX: ::Ioctl = 0x541C; +pub const TIOCCONS: ::Ioctl = 0x541D; +pub const TIOCGSERIAL: ::Ioctl = 0x541E; +pub const TIOCSSERIAL: ::Ioctl = 0x541F; +pub const TIOCPKT: ::Ioctl = 0x5420; +pub const FIONBIO: ::Ioctl = 0x8004667e; +pub const TIOCNOTTY: ::Ioctl = 0x5422; +pub const TIOCSETD: ::Ioctl = 0x5423; +pub const TIOCGETD: ::Ioctl = 0x5424; +pub const TCSBRKP: ::Ioctl = 0x5425; +pub const TIOCSBRK: ::Ioctl = 0x5427; +pub const TIOCCBRK: ::Ioctl = 0x5428; +pub const TIOCGSID: ::Ioctl = 0x5429; +pub const TIOCGRS485: ::Ioctl = 0x542e; +pub const TIOCSRS485: ::Ioctl = 0x542f; +pub const TIOCGPTN: ::Ioctl = 0x40045430; +pub const TIOCSPTLCK: ::Ioctl = 0x80045431; +pub const TIOCGDEV: ::Ioctl = 0x40045432; +pub const TIOCSIG: ::Ioctl = 0x80045436; +pub const TIOCVHANGUP: ::Ioctl = 0x5437; +pub const TIOCGPKT: ::Ioctl = 0x40045438; +pub const TIOCGPTLCK: ::Ioctl = 0x40045439; +pub const TIOCGEXCL: ::Ioctl = 0x40045440; +pub const TIOCGPTPEER: ::Ioctl = 0x20005441; +//pub const TIOCGISO7816: ::Ioctl = 0x40285442; +//pub const TIOCSISO7816: ::Ioctl = 0xc0285443; +pub const FIONCLEX: ::Ioctl = 0x20006602; +pub const FIOCLEX: ::Ioctl = 0x20006601; +pub const FIOASYNC: ::Ioctl = 0x8004667d; +pub const TIOCSERCONFIG: ::Ioctl = 0x5453; +pub const TIOCSERGWILD: ::Ioctl = 0x5454; +pub const TIOCSERSWILD: ::Ioctl = 0x5455; +pub const TIOCGLCKTRMIOS: ::Ioctl = 0x5456; +pub const TIOCSLCKTRMIOS: ::Ioctl = 0x5457; +pub const TIOCSERGSTRUCT: ::Ioctl = 0x5458; +pub const TIOCSERGETLSR: ::Ioctl = 0x5459; +pub const TIOCSERGETMULTI: ::Ioctl = 0x545A; +pub const TIOCSERSETMULTI: ::Ioctl = 0x545B; +pub const TIOCMIWAIT: ::Ioctl = 0x545C; +pub const TIOCGICOUNT: ::Ioctl = 0x545D; +//pub const FIOQSIZE: ::Ioctl = 0x40086680; + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; +pub const TIOCM_DSR: ::c_int = 0x100; + +pub const BOTHER: ::speed_t = 0o0037; +pub const IBSHIFT: ::tcflag_t = 16; + +pub const BLKSSZGET: ::c_int = 0x20001268; +pub const BLKPBSZGET: ::c_int = 0x2000127B; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/arch/sparc/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/arch/sparc/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/arch/sparc/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/arch/sparc/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,3 +1,16 @@ +s! { + pub struct termios2 { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; 19], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } +} + // arch/sparc/include/uapi/asm/socket.h pub const SOL_SOCKET: ::c_int = 0xffff; @@ -86,3 +99,100 @@ // pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP; pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS; pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING; + +// Ioctl Constants + +pub const TCGETS: ::Ioctl = 0x40245408; +pub const TCSETS: ::Ioctl = 0x80245409; +pub const TCSETSW: ::Ioctl = 0x8024540a; +pub const TCSETSF: ::Ioctl = 0x8024540b; +pub const TCGETA: ::Ioctl = 0x40125401; +pub const TCSETA: ::Ioctl = 0x80125402; +pub const TCSETAW: ::Ioctl = 0x80125403; +pub const TCSETAF: ::Ioctl = 0x80125404; +pub const TCSBRK: ::Ioctl = 0x20005405; +pub const TCXONC: ::Ioctl = 0x20005406; +pub const TCFLSH: ::Ioctl = 0x20005407; +pub const TIOCEXCL: ::Ioctl = 0x2000740d; +pub const TIOCNXCL: ::Ioctl = 0x2000740e; +pub const TIOCSCTTY: ::Ioctl = 0x20007484; +pub const TIOCGPGRP: ::Ioctl = 0x40047483; +pub const TIOCSPGRP: ::Ioctl = 0x80047482; +pub const TIOCOUTQ: ::Ioctl = 0x40047473; +pub const TIOCSTI: ::Ioctl = 0x80017472; +pub const TIOCGWINSZ: ::Ioctl = 0x40087468; +pub const TIOCSWINSZ: ::Ioctl = 0x80087467; +pub const TIOCMGET: ::Ioctl = 0x4004746a; +pub const TIOCMBIS: ::Ioctl = 0x8004746c; +pub const TIOCMBIC: ::Ioctl = 0x8004746b; +pub const TIOCMSET: ::Ioctl = 0x8004746d; +pub const TIOCGSOFTCAR: ::Ioctl = 0x40047464; +pub const TIOCSSOFTCAR: ::Ioctl = 0x80047465; +pub const FIONREAD: ::Ioctl = 0x4004667f; +pub const TIOCINQ: ::Ioctl = FIONREAD; +pub const TIOCLINUX: ::Ioctl = 0x541C; +pub const TIOCCONS: ::Ioctl = 0x20007424; +pub const TIOCGSERIAL: ::Ioctl = 0x541E; +pub const TIOCSSERIAL: ::Ioctl = 0x541F; +pub const TIOCPKT: ::Ioctl = 0x80047470; +pub const FIONBIO: ::Ioctl = 0x8004667e; +pub const TIOCNOTTY: ::Ioctl = 0x20007471; +pub const TIOCSETD: ::Ioctl = 0x80047401; +pub const TIOCGETD: ::Ioctl = 0x40047400; +pub const TCSBRKP: ::Ioctl = 0x5425; +pub const TIOCSBRK: ::Ioctl = 0x2000747b; +pub const TIOCCBRK: ::Ioctl = 0x2000747a; +pub const TIOCGSID: ::Ioctl = 0x40047485; +pub const TCGETS2: ::Ioctl = 0x402c540c; +pub const TCSETS2: ::Ioctl = 0x802c540d; +pub const TCSETSW2: ::Ioctl = 0x802c540e; +pub const TCSETSF2: ::Ioctl = 0x802c540f; +pub const TIOCGPTN: ::Ioctl = 0x40047486; +pub const TIOCSPTLCK: ::Ioctl = 0x80047487; +pub const TIOCGDEV: ::Ioctl = 0x40045432; +pub const TIOCSIG: ::Ioctl = 0x80047488; +pub const TIOCVHANGUP: ::Ioctl = 0x20005437; +pub const TIOCGPKT: ::Ioctl = 0x40045438; +pub const TIOCGPTLCK: ::Ioctl = 0x40045439; +pub const TIOCGEXCL: ::Ioctl = 0x40045440; +pub const TIOCGPTPEER: ::Ioctl = 0x20007489; +pub const FIONCLEX: ::Ioctl = 0x20006602; +pub const FIOCLEX: ::Ioctl = 0x20006601; +pub const TIOCSERCONFIG: ::Ioctl = 0x5453; +pub const TIOCSERGWILD: ::Ioctl = 0x5454; +pub const TIOCSERSWILD: ::Ioctl = 0x5455; +pub const TIOCGLCKTRMIOS: ::Ioctl = 0x5456; +pub const TIOCSLCKTRMIOS: ::Ioctl = 0x5457; +pub const TIOCSERGSTRUCT: ::Ioctl = 0x5458; +pub const TIOCSERGETLSR: ::Ioctl = 0x5459; +pub const TIOCSERGETMULTI: ::Ioctl = 0x545A; +pub const TIOCSERSETMULTI: ::Ioctl = 0x545B; +pub const TIOCMIWAIT: ::Ioctl = 0x545C; +pub const TIOCGICOUNT: ::Ioctl = 0x545D; +pub const TIOCSTART: ::Ioctl = 0x2000746e; +pub const TIOCSTOP: ::Ioctl = 0x2000746f; + +//pub const FIOASYNC: ::Ioctl = 0x4004667d; +//pub const FIOQSIZE: ::Ioctl = ; +//pub const TIOCGISO7816: ::Ioctl = 0x40285443; +//pub const TIOCSISO7816: ::Ioctl = 0xc0285444; +//pub const TIOCGRS485: ::Ioctl = 0x40205441; +//pub const TIOCSRS485: ::Ioctl = 0xc0205442; + +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; +pub const TIOCM_DSR: ::c_int = 0x100; + +pub const BOTHER: ::speed_t = 0x1000; +pub const IBSHIFT: ::tcflag_t = 16; + +pub const BLKSSZGET: ::c_int = 0x20001268; +pub const BLKPBSZGET: ::c_int = 0x2000127B; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b32/arm/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/arm/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b32/arm/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/arm/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -141,17 +141,6 @@ __glibc_reserved5: ::c_ulong, } - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 19], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } - pub struct siginfo_t { pub si_signo: ::c_int, pub si_errno: ::c_int, @@ -172,6 +161,12 @@ pub ss_flags: ::c_int, pub ss_size: ::size_t } + + pub struct seccomp_notif_sizes { + pub seccomp_notif: ::__u16, + pub seccomp_notif_resp: ::__u16, + pub seccomp_data: ::__u16, + } } pub const RLIM_INFINITY: ::rlim_t = !0; @@ -305,10 +300,6 @@ pub const SOCK_STREAM: ::c_int = 1; pub const SOCK_DGRAM: ::c_int = 2; -pub const FIOCLEX: ::c_ulong = 0x5451; -pub const FIONCLEX: ::c_ulong = 0x5450; -pub const FIONBIO: ::c_ulong = 0x5421; - pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; @@ -419,7 +410,6 @@ pub const B38400: ::speed_t = 0o000017; pub const EXTA: ::speed_t = B19200; pub const EXTB: ::speed_t = B38400; -pub const BOTHER: ::speed_t = 0o010000; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; @@ -436,6 +426,11 @@ pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; +pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; +pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; +pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; +pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; + pub const VEOL: usize = 11; pub const VEOL2: usize = 16; pub const VMIN: usize = 6; @@ -443,52 +438,11 @@ pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; pub const EXTPROC: ::tcflag_t = 0x00010000; -pub const TCGETS: ::c_ulong = 0x5401; -pub const TCSETS: ::c_ulong = 0x5402; -pub const TCSETSW: ::c_ulong = 0x5403; -pub const TCSETSF: ::c_ulong = 0x5404; -pub const TCGETA: ::c_ulong = 0x5405; -pub const TCSETA: ::c_ulong = 0x5406; -pub const TCSETAW: ::c_ulong = 0x5407; -pub const TCSETAF: ::c_ulong = 0x5408; -pub const TCSBRK: ::c_ulong = 0x5409; -pub const TCXONC: ::c_ulong = 0x540A; -pub const TCFLSH: ::c_ulong = 0x540B; -pub const TIOCINQ: ::c_ulong = 0x541B; -pub const TIOCGPGRP: ::c_ulong = 0x540F; -pub const TIOCSPGRP: ::c_ulong = 0x5410; -pub const TIOCOUTQ: ::c_ulong = 0x5411; -pub const TIOCGWINSZ: ::c_ulong = 0x5413; -pub const TIOCSWINSZ: ::c_ulong = 0x5414; -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; -pub const FIONREAD: ::c_ulong = 0x541B; - -pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; -pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; -pub const TIOCEXCL: ::c_ulong = 0x540C; -pub const TIOCNXCL: ::c_ulong = 0x540D; -pub const TIOCSCTTY: ::c_ulong = 0x540E; -pub const TIOCSTI: ::c_ulong = 0x5412; -pub const TIOCMGET: ::c_ulong = 0x5415; -pub const TIOCMBIS: ::c_ulong = 0x5416; -pub const TIOCMBIC: ::c_ulong = 0x5417; -pub const TIOCMSET: ::c_ulong = 0x5418; -pub const TIOCCONS: ::c_ulong = 0x541D; pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 0x541C; -pub const TIOCGSERIAL: ::c_ulong = 0x541E; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - // Syscall table pub const SYS_restart_syscall: ::c_long = 0; pub const SYS_exit: ::c_long = 1; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b32/mips/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/mips/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b32/mips/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/mips/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -153,17 +153,6 @@ pub l_pid: ::pid_t, pad: [::c_long; 4], } - - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 23], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } } pub const O_LARGEFILE: ::c_int = 0x2000; @@ -668,10 +657,6 @@ pub const SOCK_STREAM: ::c_int = 2; pub const SOCK_DGRAM: ::c_int = 1; -pub const FIOCLEX: ::c_ulong = 0x6601; -pub const FIONCLEX: ::c_ulong = 0x6602; -pub const FIONBIO: ::c_ulong = 0x667e; - pub const SA_SIGINFO: ::c_int = 0x00000008; pub const SA_NOCLDWAIT: ::c_int = 0x00010000; @@ -726,38 +711,6 @@ pub const SFD_NONBLOCK: ::c_int = 0x80; -pub const TCGETS: ::c_ulong = 0x540d; -pub const TCSETS: ::c_ulong = 0x540e; -pub const TCSETSW: ::c_ulong = 0x540f; -pub const TCSETSF: ::c_ulong = 0x5410; -pub const TCGETA: ::c_ulong = 0x5401; -pub const TCSETA: ::c_ulong = 0x5402; -pub const TCSETAW: ::c_ulong = 0x5403; -pub const TCSETAF: ::c_ulong = 0x5404; -pub const TCSBRK: ::c_ulong = 0x5405; -pub const TCXONC: ::c_ulong = 0x5406; -pub const TCFLSH: ::c_ulong = 0x5407; -pub const TIOCGSOFTCAR: ::c_ulong = 0x5481; -pub const TIOCSSOFTCAR: ::c_ulong = 0x5482; -pub const TIOCINQ: ::c_ulong = 0x467f; -pub const TIOCLINUX: ::c_ulong = 0x5483; -pub const TIOCGSERIAL: ::c_ulong = 0x5484; -pub const TIOCEXCL: ::c_ulong = 0x740d; -pub const TIOCNXCL: ::c_ulong = 0x740e; -pub const TIOCSCTTY: ::c_ulong = 0x5480; -pub const TIOCGPGRP: ::c_ulong = 0x40047477; -pub const TIOCSPGRP: ::c_ulong = 0x80047476; -pub const TIOCOUTQ: ::c_ulong = 0x7472; -pub const TIOCSTI: ::c_ulong = 0x5472; -pub const TIOCGWINSZ: ::c_ulong = 0x40087468; -pub const TIOCSWINSZ: ::c_ulong = 0x80087467; -pub const TIOCMGET: ::c_ulong = 0x741d; -pub const TIOCMBIS: ::c_ulong = 0x741b; -pub const TIOCMBIC: ::c_ulong = 0x741c; -pub const TIOCMSET: ::c_ulong = 0x741a; -pub const FIONREAD: ::c_ulong = 0x467f; -pub const TIOCCONS: ::c_ulong = 0x80047478; - pub const RTLD_DEEPBIND: ::c_int = 0x10; pub const RTLD_GLOBAL: ::c_int = 0x4; pub const RTLD_NOLOAD: ::c_int = 0x8; @@ -837,7 +790,6 @@ pub const B38400: ::speed_t = 0o000017; pub const EXTA: ::speed_t = B19200; pub const EXTB: ::speed_t = B38400; -pub const BOTHER: ::speed_t = 0o010000; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; @@ -854,13 +806,6 @@ pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; -pub const TIOCM_ST: ::c_int = 0x010; -pub const TIOCM_SR: ::c_int = 0x020; -pub const TIOCM_CTS: ::c_int = 0x040; -pub const TIOCM_CAR: ::c_int = 0x100; -pub const TIOCM_RNG: ::c_int = 0x200; -pub const TIOCM_DSR: ::c_int = 0x400; - pub const EHWPOISON: ::c_int = 168; cfg_if! { diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b32/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b32/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -11,6 +11,7 @@ pub type msglen_t = ::c_ulong; pub type nlink_t = u32; pub type __u64 = ::c_ulonglong; +pub type __s64 = ::c_longlong; pub type __fsword_t = i32; pub type fsblkcnt64_t = u64; pub type fsfilcnt64_t = u64; @@ -322,9 +323,6 @@ pub const PTRACE_GETREGS: ::c_uint = 12; pub const PTRACE_SETREGS: ::c_uint = 13; -pub const TIOCSBRK: ::c_int = 0x5427; -pub const TIOCCBRK: ::c_int = 0x5428; - extern "C" { pub fn sysctl( name: *mut ::c_int, diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b32/powerpc.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/powerpc.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b32/powerpc.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/powerpc.rs 2022-01-21 02:47:39.000000000 +0000 @@ -192,15 +192,6 @@ pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 0x541C; -pub const TIOCGSERIAL: ::c_ulong = 0x541E; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - pub const MADV_SOFT_OFFLINE: ::c_int = 101; pub const MAP_LOCKED: ::c_int = 0x00080; pub const MAP_NORESERVE: ::c_int = 0x00040; @@ -306,10 +297,6 @@ pub const SOCK_STREAM: ::c_int = 1; pub const SOCK_DGRAM: ::c_int = 2; -pub const FIOCLEX: ::c_ulong = 0x20006601; -pub const FIONCLEX: ::c_ulong = 0x20006602; -pub const FIONBIO: ::c_ulong = 0x8004667e; - pub const MCL_CURRENT: ::c_int = 0x2000; pub const MCL_FUTURE: ::c_int = 0x4000; @@ -323,18 +310,6 @@ pub const EFD_NONBLOCK: ::c_int = 0x800; pub const SFD_NONBLOCK: ::c_int = 0x0800; -pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; -pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; -pub const TIOCEXCL: ::c_ulong = 0x540C; -pub const TIOCNXCL: ::c_ulong = 0x540D; -pub const TIOCSCTTY: ::c_ulong = 0x540E; -pub const TIOCSTI: ::c_ulong = 0x5412; -pub const TIOCMGET: ::c_ulong = 0x5415; -pub const TIOCMBIS: ::c_ulong = 0x5416; -pub const TIOCMBIC: ::c_ulong = 0x5417; -pub const TIOCMSET: ::c_ulong = 0x5418; -pub const TIOCCONS: ::c_ulong = 0x541D; - pub const SIGCHLD: ::c_int = 17; pub const SIGBUS: ::c_int = 7; pub const SIGUSR1: ::c_int = 10; @@ -446,7 +421,6 @@ pub const B3000000: ::speed_t = 0o0034; pub const B3500000: ::speed_t = 0o0035; pub const B4000000: ::speed_t = 0o0036; -pub const BOTHER: ::speed_t = 0o0037; pub const VEOL: usize = 6; pub const VEOL2: usize = 8; @@ -455,26 +429,6 @@ pub const TOSTOP: ::tcflag_t = 0x400000; pub const FLUSHO: ::tcflag_t = 0x800000; pub const EXTPROC: ::tcflag_t = 0x10000000; -pub const TCGETS: ::c_ulong = 0x403c7413; -pub const TCSETS: ::c_ulong = 0x803c7414; -pub const TCSETSW: ::c_ulong = 0x803c7415; -pub const TCSETSF: ::c_ulong = 0x803c7416; -pub const TCGETA: ::c_ulong = 0x40147417; -pub const TCSETA: ::c_ulong = 0x80147418; -pub const TCSETAW: ::c_ulong = 0x80147419; -pub const TCSETAF: ::c_ulong = 0x8014741c; -pub const TCSBRK: ::c_ulong = 0x2000741d; -pub const TCXONC: ::c_ulong = 0x2000741e; -pub const TCFLSH: ::c_ulong = 0x2000741f; -pub const TIOCINQ: ::c_ulong = 0x4004667f; -pub const TIOCGPGRP: ::c_ulong = 0x40047477; -pub const TIOCSPGRP: ::c_ulong = 0x80047476; -pub const TIOCOUTQ: ::c_ulong = 0x40047473; -pub const TIOCGWINSZ: ::c_ulong = 0x40087468; -pub const TIOCSWINSZ: ::c_ulong = 0x80087467; -pub const TIOCGRS485: ::c_int = 0x542e; -pub const TIOCSRS485: ::c_int = 0x542f; -pub const FIONREAD: ::c_ulong = 0x4004667f; pub const SYS_restart_syscall: ::c_long = 0; pub const SYS_exit: ::c_long = 1; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -203,10 +203,6 @@ pub const RTLD_DEEPBIND: ::c_int = 0x8; pub const RTLD_GLOBAL: ::c_int = 0x100; pub const RTLD_NOLOAD: ::c_int = 0x4; -pub const TIOCGSOFTCAR: ::c_ulong = 21529; -pub const TIOCSSOFTCAR: ::c_ulong = 21530; -pub const TIOCGRS485: ::c_int = 21550; -pub const TIOCSRS485: ::c_int = 21551; pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; pub const RLIMIT_AS: ::__rlimit_resource_t = 9; pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; @@ -341,23 +337,6 @@ pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 21532; -pub const TIOCGSERIAL: ::c_ulong = 21534; -pub const TIOCEXCL: ::c_ulong = 21516; -pub const TIOCNXCL: ::c_ulong = 21517; -pub const TIOCSCTTY: ::c_ulong = 21518; -pub const TIOCSTI: ::c_ulong = 21522; -pub const TIOCMGET: ::c_ulong = 21525; -pub const TIOCMBIS: ::c_ulong = 21526; -pub const TIOCMBIC: ::c_ulong = 21527; -pub const TIOCMSET: ::c_ulong = 21528; -pub const TIOCCONS: ::c_ulong = 21533; -pub const TIOCM_ST: ::c_int = 8; -pub const TIOCM_SR: ::c_int = 16; -pub const TIOCM_CTS: ::c_int = 32; -pub const TIOCM_CAR: ::c_int = 64; -pub const TIOCM_RNG: ::c_int = 128; -pub const TIOCM_DSR: ::c_int = 256; pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; @@ -381,9 +360,6 @@ pub const ENAVAIL: ::c_int = 119; pub const EISNAM: ::c_int = 120; pub const EREMOTEIO: ::c_int = 121; -pub const FIOCLEX: ::c_ulong = 21585; -pub const FIONCLEX: ::c_ulong = 21584; -pub const FIONBIO: ::c_ulong = 21537; pub const MCL_CURRENT: ::c_int = 1; pub const MCL_FUTURE: ::c_int = 2; pub const SIGSTKSZ: ::size_t = 8192; @@ -479,24 +455,6 @@ pub const TOSTOP: ::tcflag_t = 256; pub const FLUSHO: ::tcflag_t = 4096; pub const EXTPROC: ::tcflag_t = 65536; -pub const TCGETS: ::c_ulong = 21505; -pub const TCSETS: ::c_ulong = 21506; -pub const TCSETSW: ::c_ulong = 21507; -pub const TCSETSF: ::c_ulong = 21508; -pub const TCGETA: ::c_ulong = 21509; -pub const TCSETA: ::c_ulong = 21510; -pub const TCSETAW: ::c_ulong = 21511; -pub const TCSETAF: ::c_ulong = 21512; -pub const TCSBRK: ::c_ulong = 21513; -pub const TCXONC: ::c_ulong = 21514; -pub const TCFLSH: ::c_ulong = 21515; -pub const TIOCINQ: ::c_ulong = 21531; -pub const TIOCGPGRP: ::c_ulong = 21519; -pub const TIOCSPGRP: ::c_ulong = 21520; -pub const TIOCOUTQ: ::c_ulong = 21521; -pub const TIOCGWINSZ: ::c_ulong = 21523; -pub const TIOCSWINSZ: ::c_ulong = 21524; -pub const FIONREAD: ::c_ulong = 21531; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -191,17 +191,6 @@ __glibc_reserved1: ::c_ulong, __glibc_reserved2: ::c_ulong, } - - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 19], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } } pub const RLIM_INFINITY: ::rlim_t = !0; @@ -210,9 +199,6 @@ pub const RTLD_GLOBAL: ::c_int = 0x100; pub const RTLD_NOLOAD: ::c_int = 0x4; -pub const TIOCGSOFTCAR: ::c_ulong = 0x40047464; -pub const TIOCSSOFTCAR: ::c_ulong = 0x80047465; - pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; pub const RLIMIT_AS: ::__rlimit_resource_t = 9; pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; @@ -367,25 +353,6 @@ pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 0x541C; -pub const TIOCGSERIAL: ::c_ulong = 0x541E; -pub const TIOCEXCL: ::c_ulong = 0x2000740d; -pub const TIOCNXCL: ::c_ulong = 0x2000740e; -pub const TIOCSCTTY: ::c_ulong = 0x20007484; -pub const TIOCSTI: ::c_ulong = 0x80017472; -pub const TIOCMGET: ::c_ulong = 0x4004746a; -pub const TIOCMBIS: ::c_ulong = 0x8004746c; -pub const TIOCMBIC: ::c_ulong = 0x8004746b; -pub const TIOCMSET: ::c_ulong = 0x8004746d; -pub const TIOCCONS: ::c_ulong = 0x20007424; - -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - pub const O_DIRECTORY: ::c_int = 0o200000; pub const O_NOFOLLOW: ::c_int = 0o400000; pub const O_LARGEFILE: ::c_int = 0x40000; @@ -401,10 +368,6 @@ pub const EISNAM: ::c_int = 120; pub const EREMOTEIO: ::c_int = 121; -pub const FIOCLEX: ::c_ulong = 0x20006601; -pub const FIONCLEX: ::c_ulong = 0x20006602; -pub const FIONBIO: ::c_ulong = 0x8004667e; - pub const MCL_CURRENT: ::c_int = 0x2000; pub const MCL_FUTURE: ::c_int = 0x4000; @@ -480,7 +443,6 @@ pub const B38400: ::speed_t = 0o000017; pub const EXTA: ::speed_t = B19200; pub const EXTB: ::speed_t = B38400; -pub const BOTHER: ::speed_t = 0x1000; pub const B57600: ::speed_t = 0x1001; pub const B115200: ::speed_t = 0x1002; pub const B230400: ::speed_t = 0x1003; @@ -504,24 +466,6 @@ pub const TOSTOP: ::tcflag_t = 0x100; pub const FLUSHO: ::tcflag_t = 0x1000; pub const EXTPROC: ::tcflag_t = 0x10000; -pub const TCGETS: ::c_ulong = 0x40245408; -pub const TCSETS: ::c_ulong = 0x80245409; -pub const TCSETSW: ::c_ulong = 0x8024540a; -pub const TCSETSF: ::c_ulong = 0x8024540b; -pub const TCGETA: ::c_ulong = 0x40125401; -pub const TCSETA: ::c_ulong = 0x80125402; -pub const TCSETAW: ::c_ulong = 0x80125403; -pub const TCSETAF: ::c_ulong = 0x80125404; -pub const TCSBRK: ::c_ulong = 0x20005405; -pub const TCXONC: ::c_ulong = 0x20005406; -pub const TCFLSH: ::c_ulong = 0x20005407; -pub const TIOCINQ: ::c_ulong = 0x4004667f; -pub const TIOCGPGRP: ::c_ulong = 0x40047483; -pub const TIOCSPGRP: ::c_ulong = 0x80047482; -pub const TIOCOUTQ: ::c_ulong = 0x40047473; -pub const TIOCGWINSZ: ::c_ulong = 0x40087468; -pub const TIOCSWINSZ: ::c_ulong = 0x80087467; -pub const FIONREAD: ::c_ulong = 0x4004667f; pub const SYS_restart_syscall: ::c_long = 0; pub const SYS_exit: ::c_long = 1; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b32/x86/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/x86/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b32/x86/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b32/x86/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -215,17 +215,6 @@ __glibc_reserved5: ::c_ulong, } - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 19], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } - pub struct siginfo_t { pub si_signo: ::c_int, pub si_errno: ::c_int, @@ -246,6 +235,12 @@ pub ss_flags: ::c_int, pub ss_size: ::size_t } + + pub struct seccomp_notif_sizes { + pub seccomp_notif: ::__u16, + pub seccomp_notif_resp: ::__u16, + pub seccomp_data: ::__u16, + } } s_no_extra_traits! { @@ -511,10 +506,6 @@ pub const F_GETOWN: ::c_int = 9; pub const F_SETOWN: ::c_int = 8; -pub const FIOCLEX: ::c_ulong = 0x5451; -pub const FIONCLEX: ::c_ulong = 0x5450; -pub const FIONBIO: ::c_ulong = 0x5421; - pub const PTRACE_GETFPXREGS: ::c_uint = 18; pub const PTRACE_SETFPXREGS: ::c_uint = 19; pub const PTRACE_SYSEMU: ::c_uint = 31; @@ -608,18 +599,6 @@ pub const VTDLY: ::tcflag_t = 0o040000; pub const XTABS: ::tcflag_t = 0o014000; -pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; -pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; -pub const TIOCEXCL: ::c_ulong = 0x540C; -pub const TIOCNXCL: ::c_ulong = 0x540D; -pub const TIOCSCTTY: ::c_ulong = 0x540E; -pub const TIOCSTI: ::c_ulong = 0x5412; -pub const TIOCMGET: ::c_ulong = 0x5415; -pub const TIOCMBIS: ::c_ulong = 0x5416; -pub const TIOCMBIC: ::c_ulong = 0x5417; -pub const TIOCMSET: ::c_ulong = 0x5418; -pub const TIOCCONS: ::c_ulong = 0x541D; - pub const B0: ::speed_t = 0o000000; pub const B50: ::speed_t = 0o000001; pub const B75: ::speed_t = 0o000002; @@ -638,7 +617,6 @@ pub const B38400: ::speed_t = 0o000017; pub const EXTA: ::speed_t = B19200; pub const EXTB: ::speed_t = B38400; -pub const BOTHER: ::speed_t = 0o010000; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; @@ -662,40 +640,11 @@ pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; pub const EXTPROC: ::tcflag_t = 0x00010000; -pub const TCGETS: ::c_ulong = 0x5401; -pub const TCSETS: ::c_ulong = 0x5402; -pub const TCSETSW: ::c_ulong = 0x5403; -pub const TCSETSF: ::c_ulong = 0x5404; -pub const TCGETA: ::c_ulong = 0x5405; -pub const TCSETA: ::c_ulong = 0x5406; -pub const TCSETAW: ::c_ulong = 0x5407; -pub const TCSETAF: ::c_ulong = 0x5408; -pub const TCSBRK: ::c_ulong = 0x5409; -pub const TCXONC: ::c_ulong = 0x540A; -pub const TCFLSH: ::c_ulong = 0x540B; -pub const TIOCINQ: ::c_ulong = 0x541B; -pub const TIOCGPGRP: ::c_ulong = 0x540F; -pub const TIOCSPGRP: ::c_ulong = 0x5410; -pub const TIOCOUTQ: ::c_ulong = 0x5411; -pub const TIOCGWINSZ: ::c_ulong = 0x5413; -pub const TIOCSWINSZ: ::c_ulong = 0x5414; -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; -pub const FIONREAD: ::c_ulong = 0x541B; pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 0x541C; -pub const TIOCGSERIAL: ::c_ulong = 0x541E; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - // Syscall table pub const SYS_restart_syscall: ::c_long = 0; pub const SYS_exit: ::c_long = 1; @@ -1137,6 +1086,11 @@ pub const REG_UESP: ::c_int = 17; pub const REG_SS: ::c_int = 18; +pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; +pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; +pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; +pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; + extern "C" { pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int; pub fn setcontext(ucp: *const ucontext_t) -> ::c_int; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -6,6 +6,7 @@ pub type blksize_t = i32; pub type suseconds_t = i64; pub type __u64 = ::c_ulonglong; +pub type __s64 = ::c_longlong; s! { pub struct sigaction { @@ -142,6 +143,13 @@ __size: [usize; 8] } + pub struct user_regs_struct { + pub regs: [::c_ulonglong; 31], + pub sp: ::c_ulonglong, + pub pc: ::c_ulonglong, + pub pstate: ::c_ulonglong, + } + pub struct ipc_perm { pub __key: ::key_t, pub uid: ::uid_t, @@ -168,17 +176,6 @@ __unused5: ::c_ulong } - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 19], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } - pub struct siginfo_t { pub si_signo: ::c_int, pub si_errno: ::c_int, @@ -205,6 +202,12 @@ pub imr_address: ::in_addr, pub imr_ifindex: ::c_int, } + + pub struct seccomp_notif_sizes { + pub seccomp_notif: ::__u16, + pub seccomp_notif_resp: ::__u16, + pub seccomp_data: ::__u16, + } } pub const VEOF: usize = 4; @@ -380,29 +383,6 @@ pub const SFD_NONBLOCK: ::c_int = 0x0800; -pub const TIOCEXCL: ::c_ulong = 0x540C; -pub const TIOCNXCL: ::c_ulong = 0x540D; -pub const TIOCSCTTY: ::c_ulong = 0x540E; -pub const TIOCSTI: ::c_ulong = 0x5412; -pub const TIOCMGET: ::c_ulong = 0x5415; -pub const TIOCMBIS: ::c_ulong = 0x5416; -pub const TIOCMBIC: ::c_ulong = 0x5417; -pub const TIOCMSET: ::c_ulong = 0x5418; -pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; -pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; -pub const TIOCCONS: ::c_ulong = 0x541D; -pub const TIOCSBRK: ::c_ulong = 0x5427; -pub const TIOCCBRK: ::c_ulong = 0x5428; -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; - -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - pub const SFD_CLOEXEC: ::c_int = 0x080000; pub const NCCS: usize = 32; @@ -453,10 +433,6 @@ pub const EDEADLOCK: ::c_int = 35; -pub const FIOCLEX: ::c_ulong = 0x5451; -pub const FIONCLEX: ::c_ulong = 0x5450; -pub const FIONBIO: ::c_ulong = 0x5421; - pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; @@ -532,7 +508,6 @@ pub const B38400: ::speed_t = 0o000017; pub const EXTA: ::speed_t = B19200; pub const EXTB: ::speed_t = B38400; -pub const BOTHER: ::speed_t = 0o010000; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; @@ -549,6 +524,11 @@ pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; +pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; +pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; +pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; +pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; + pub const VEOL: usize = 11; pub const VEOL2: usize = 16; pub const VMIN: usize = 6; @@ -556,32 +536,11 @@ pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; pub const EXTPROC: ::tcflag_t = 0x00010000; -pub const TCGETS: ::c_ulong = 0x5401; -pub const TCSETS: ::c_ulong = 0x5402; -pub const TCSETSW: ::c_ulong = 0x5403; -pub const TCSETSF: ::c_ulong = 0x5404; -pub const TCGETA: ::c_ulong = 0x5405; -pub const TCSETA: ::c_ulong = 0x5406; -pub const TCSETAW: ::c_ulong = 0x5407; -pub const TCSETAF: ::c_ulong = 0x5408; -pub const TCSBRK: ::c_ulong = 0x5409; -pub const TCXONC: ::c_ulong = 0x540A; -pub const TCFLSH: ::c_ulong = 0x540B; -pub const TIOCINQ: ::c_ulong = 0x541B; -pub const TIOCGPGRP: ::c_ulong = 0x540F; -pub const TIOCSPGRP: ::c_ulong = 0x5410; -pub const TIOCOUTQ: ::c_ulong = 0x5411; -pub const TIOCGWINSZ: ::c_ulong = 0x5413; -pub const TIOCSWINSZ: ::c_ulong = 0x5414; -pub const FIONREAD: ::c_ulong = 0x541B; pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 0x541C; -pub const TIOCGSERIAL: ::c_ulong = 0x541E; - // sys/auxv.h pub const HWCAP_FP: ::c_ulong = 1 << 0; pub const HWCAP_ASIMD: ::c_ulong = 1 << 1; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -8,6 +8,7 @@ pub type suseconds_t = i64; pub type wchar_t = i32; pub type __u64 = ::c_ulong; +pub type __s64 = ::c_long; s! { pub struct stat { @@ -183,17 +184,6 @@ __unused4: ::c_ulong, __unused5: ::c_ulong } - - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 23], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } } pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; @@ -756,10 +746,6 @@ pub const SOCK_STREAM: ::c_int = 2; pub const SOCK_DGRAM: ::c_int = 1; -pub const FIOCLEX: ::c_ulong = 0x6601; -pub const FIONCLEX: ::c_ulong = 0x6602; -pub const FIONBIO: ::c_ulong = 0x667e; - pub const SA_ONSTACK: ::c_int = 0x08000000; pub const SA_SIGINFO: ::c_int = 0x00000008; pub const SA_NOCLDWAIT: ::c_int = 0x00010000; @@ -826,40 +812,6 @@ pub const SFD_NONBLOCK: ::c_int = 0x80; -pub const TCGETS: ::c_ulong = 0x540d; -pub const TCSETS: ::c_ulong = 0x540e; -pub const TCSETSW: ::c_ulong = 0x540f; -pub const TCSETSF: ::c_ulong = 0x5410; -pub const TCGETA: ::c_ulong = 0x5401; -pub const TCSETA: ::c_ulong = 0x5402; -pub const TCSETAW: ::c_ulong = 0x5403; -pub const TCSETAF: ::c_ulong = 0x5404; -pub const TCSBRK: ::c_ulong = 0x5405; -pub const TCXONC: ::c_ulong = 0x5406; -pub const TCFLSH: ::c_ulong = 0x5407; -pub const TIOCSBRK: ::c_ulong = 0x5427; -pub const TIOCCBRK: ::c_ulong = 0x5428; -pub const TIOCGSOFTCAR: ::c_ulong = 0x5481; -pub const TIOCSSOFTCAR: ::c_ulong = 0x5482; -pub const TIOCINQ: ::c_ulong = 0x467f; -pub const TIOCLINUX: ::c_ulong = 0x5483; -pub const TIOCGSERIAL: ::c_ulong = 0x5484; -pub const TIOCEXCL: ::c_ulong = 0x740d; -pub const TIOCNXCL: ::c_ulong = 0x740e; -pub const TIOCSCTTY: ::c_ulong = 0x5480; -pub const TIOCGPGRP: ::c_ulong = 0x40047477; -pub const TIOCSPGRP: ::c_ulong = 0x80047476; -pub const TIOCOUTQ: ::c_ulong = 0x7472; -pub const TIOCSTI: ::c_ulong = 0x5472; -pub const TIOCGWINSZ: ::c_ulong = 0x40087468; -pub const TIOCSWINSZ: ::c_ulong = 0x80087467; -pub const TIOCMGET: ::c_ulong = 0x741d; -pub const TIOCMBIS: ::c_ulong = 0x741b; -pub const TIOCMBIC: ::c_ulong = 0x741c; -pub const TIOCMSET: ::c_ulong = 0x741a; -pub const FIONREAD: ::c_ulong = 0x467f; -pub const TIOCCONS: ::c_ulong = 0x80047478; - pub const RTLD_DEEPBIND: ::c_int = 0x10; pub const RTLD_GLOBAL: ::c_int = 0x4; pub const RTLD_NOLOAD: ::c_int = 0x8; @@ -939,7 +891,6 @@ pub const B38400: ::speed_t = 0o000017; pub const EXTA: ::speed_t = B19200; pub const EXTB: ::speed_t = B38400; -pub const BOTHER: ::speed_t = 0o010000; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; @@ -956,13 +907,6 @@ pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; -pub const TIOCM_ST: ::c_int = 0x010; -pub const TIOCM_SR: ::c_int = 0x020; -pub const TIOCM_CTS: ::c_int = 0x040; -pub const TIOCM_CAR: ::c_int = 0x100; -pub const TIOCM_RNG: ::c_int = 0x200; -pub const TIOCM_DSR: ::c_int = 0x400; - pub const EHWPOISON: ::c_int = 168; extern "C" { diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -10,6 +10,7 @@ pub type blksize_t = i64; pub type suseconds_t = i64; pub type __u64 = ::c_ulong; +pub type __s64 = ::c_long; s! { pub struct sigaction { @@ -207,9 +208,6 @@ pub const VEOF: usize = 4; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; -pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; -pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; - pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; pub const RLIMIT_AS: ::__rlimit_resource_t = 9; pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; @@ -381,29 +379,6 @@ pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 0x541C; -pub const TIOCGSERIAL: ::c_ulong = 0x541E; -pub const TIOCEXCL: ::c_ulong = 0x540C; -pub const TIOCNXCL: ::c_ulong = 0x540D; -pub const TIOCSCTTY: ::c_ulong = 0x540E; -pub const TIOCSTI: ::c_ulong = 0x5412; -pub const TIOCMGET: ::c_ulong = 0x5415; -pub const TIOCMBIS: ::c_ulong = 0x5416; -pub const TIOCMBIC: ::c_ulong = 0x5417; -pub const TIOCMSET: ::c_ulong = 0x5418; -pub const TIOCCONS: ::c_ulong = 0x541D; -pub const TIOCSBRK: ::c_ulong = 0x5427; -pub const TIOCCBRK: ::c_ulong = 0x5428; -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; - -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - pub const SFD_CLOEXEC: ::c_int = 0x080000; pub const NCCS: usize = 32; @@ -506,10 +481,6 @@ pub const EISNAM: ::c_int = 120; pub const EREMOTEIO: ::c_int = 121; -pub const FIOCLEX: ::c_ulong = 0x20006601; -pub const FIONCLEX: ::c_ulong = 0x20006602; -pub const FIONBIO: ::c_ulong = 0x8004667e; - pub const MCL_CURRENT: ::c_int = 0x2000; pub const MCL_FUTURE: ::c_int = 0x4000; @@ -599,7 +570,6 @@ pub const B3000000: ::speed_t = 0o0034; pub const B3500000: ::speed_t = 0o0035; pub const B4000000: ::speed_t = 0o0036; -pub const BOTHER: ::speed_t = 0o0037; pub const VEOL: usize = 6; pub const VEOL2: usize = 8; @@ -608,24 +578,6 @@ pub const TOSTOP: ::tcflag_t = 0x400000; pub const FLUSHO: ::tcflag_t = 0x800000; pub const EXTPROC: ::tcflag_t = 0x10000000; -pub const TCGETS: ::c_ulong = 0x403c7413; -pub const TCSETS: ::c_ulong = 0x803c7414; -pub const TCSETSW: ::c_ulong = 0x803c7415; -pub const TCSETSF: ::c_ulong = 0x803c7416; -pub const TCGETA: ::c_ulong = 0x40147417; -pub const TCSETA: ::c_ulong = 0x80147418; -pub const TCSETAW: ::c_ulong = 0x80147419; -pub const TCSETAF: ::c_ulong = 0x8014741c; -pub const TCSBRK: ::c_ulong = 0x2000741d; -pub const TCXONC: ::c_ulong = 0x2000741e; -pub const TCFLSH: ::c_ulong = 0x2000741f; -pub const TIOCINQ: ::c_ulong = 0x4004667f; -pub const TIOCGPGRP: ::c_ulong = 0x40047477; -pub const TIOCSPGRP: ::c_ulong = 0x80047476; -pub const TIOCOUTQ: ::c_ulong = 0x40047473; -pub const TIOCGWINSZ: ::c_ulong = 0x40087468; -pub const TIOCSWINSZ: ::c_ulong = 0x80087467; -pub const FIONREAD: ::c_ulong = 0x4004667f; // Syscall table pub const SYS_restart_syscall: ::c_long = 0; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -11,6 +11,7 @@ pub type fsfilcnt64_t = ::c_ulong; pub type suseconds_t = i64; pub type __u64 = ::c_ulonglong; +pub type __s64 = ::c_longlong; s! { pub struct pthread_attr_t { @@ -205,10 +206,6 @@ pub const RTLD_DEEPBIND: ::c_int = 0x8; pub const RTLD_GLOBAL: ::c_int = 0x100; pub const RTLD_NOLOAD: ::c_int = 0x4; -pub const TIOCGSOFTCAR: ::c_ulong = 21529; -pub const TIOCSSOFTCAR: ::c_ulong = 21530; -pub const TIOCGRS485: ::c_int = 21550; -pub const TIOCSRS485: ::c_int = 21551; pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; pub const RLIMIT_AS: ::__rlimit_resource_t = 9; pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; @@ -356,23 +353,6 @@ pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 21532; -pub const TIOCGSERIAL: ::c_ulong = 21534; -pub const TIOCEXCL: ::c_ulong = 21516; -pub const TIOCNXCL: ::c_ulong = 21517; -pub const TIOCSCTTY: ::c_ulong = 21518; -pub const TIOCSTI: ::c_ulong = 21522; -pub const TIOCMGET: ::c_ulong = 21525; -pub const TIOCMBIS: ::c_ulong = 21526; -pub const TIOCMBIC: ::c_ulong = 21527; -pub const TIOCMSET: ::c_ulong = 21528; -pub const TIOCCONS: ::c_ulong = 21533; -pub const TIOCM_ST: ::c_int = 8; -pub const TIOCM_SR: ::c_int = 16; -pub const TIOCM_CTS: ::c_int = 32; -pub const TIOCM_CAR: ::c_int = 64; -pub const TIOCM_RNG: ::c_int = 128; -pub const TIOCM_DSR: ::c_int = 256; pub const SFD_CLOEXEC: ::c_int = 524288; pub const NCCS: usize = 32; pub const O_TRUNC: ::c_int = 512; @@ -419,9 +399,6 @@ pub const ENAVAIL: ::c_int = 119; pub const EISNAM: ::c_int = 120; pub const EREMOTEIO: ::c_int = 121; -pub const FIOCLEX: ::c_ulong = 21585; -pub const FIONCLEX: ::c_ulong = 21584; -pub const FIONBIO: ::c_ulong = 21537; pub const MCL_CURRENT: ::c_int = 1; pub const MCL_FUTURE: ::c_int = 2; pub const SIGSTKSZ: ::size_t = 8192; @@ -517,24 +494,6 @@ pub const TOSTOP: ::tcflag_t = 256; pub const FLUSHO: ::tcflag_t = 4096; pub const EXTPROC: ::tcflag_t = 65536; -pub const TCGETS: ::c_ulong = 21505; -pub const TCSETS: ::c_ulong = 21506; -pub const TCSETSW: ::c_ulong = 21507; -pub const TCSETSF: ::c_ulong = 21508; -pub const TCGETA: ::c_ulong = 21509; -pub const TCSETA: ::c_ulong = 21510; -pub const TCSETAW: ::c_ulong = 21511; -pub const TCSETAF: ::c_ulong = 21512; -pub const TCSBRK: ::c_ulong = 21513; -pub const TCXONC: ::c_ulong = 21514; -pub const TCFLSH: ::c_ulong = 21515; -pub const TIOCINQ: ::c_ulong = 21531; -pub const TIOCGPGRP: ::c_ulong = 21519; -pub const TIOCSPGRP: ::c_ulong = 21520; -pub const TIOCOUTQ: ::c_ulong = 21521; -pub const TIOCGWINSZ: ::c_ulong = 21523; -pub const TIOCSWINSZ: ::c_ulong = 21524; -pub const FIONREAD: ::c_ulong = 21531; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const SYS_read: ::c_long = 63; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b64/s390x.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/s390x.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b64/s390x.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/s390x.rs 2022-01-21 02:47:39.000000000 +0000 @@ -11,6 +11,7 @@ pub type wchar_t = i32; pub type greg_t = u64; pub type __u64 = u64; +pub type __s64 = i64; s! { pub struct sigaction { @@ -153,17 +154,6 @@ __f_spare: [::c_int; 6], } - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 19], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } - pub struct __psw_t { pub mask: u64, pub addr: u64, @@ -340,9 +330,6 @@ pub const ENOSYS: ::c_int = 38; pub const ENOTCONN: ::c_int = 107; pub const ETIMEDOUT: ::c_int = 110; -pub const FIOCLEX: ::c_ulong = 0x5451; -pub const FIONCLEX: ::c_ulong = 0x5450; -pub const FIONBIO: ::c_ulong = 0x5421; pub const O_APPEND: ::c_int = 1024; pub const O_CREAT: ::c_int = 64; pub const O_EXCL: ::c_int = 128; @@ -515,51 +502,10 @@ pub const SFD_NONBLOCK: ::c_int = 0x0800; -pub const TCGETS: ::c_ulong = 0x5401; -pub const TCSETS: ::c_ulong = 0x5402; -pub const TCSETSW: ::c_ulong = 0x5403; -pub const TCSETSF: ::c_ulong = 0x5404; -pub const TCGETA: ::c_ulong = 0x5405; -pub const TCSETA: ::c_ulong = 0x5406; -pub const TCSETAW: ::c_ulong = 0x5407; -pub const TCSETAF: ::c_ulong = 0x5408; -pub const TCSBRK: ::c_ulong = 0x5409; -pub const TCXONC: ::c_ulong = 0x540A; -pub const TCFLSH: ::c_ulong = 0x540B; -pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; -pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; -pub const TIOCINQ: ::c_ulong = 0x541B; -pub const TIOCEXCL: ::c_ulong = 0x540C; -pub const TIOCNXCL: ::c_ulong = 0x540D; -pub const TIOCSCTTY: ::c_ulong = 0x540E; -pub const TIOCGPGRP: ::c_ulong = 0x540F; -pub const TIOCSPGRP: ::c_ulong = 0x5410; -pub const TIOCOUTQ: ::c_ulong = 0x5411; -pub const TIOCSTI: ::c_ulong = 0x5412; -pub const TIOCGWINSZ: ::c_ulong = 0x5413; -pub const TIOCSWINSZ: ::c_ulong = 0x5414; -pub const TIOCMGET: ::c_ulong = 0x5415; -pub const TIOCMBIS: ::c_ulong = 0x5416; -pub const TIOCMBIC: ::c_ulong = 0x5417; -pub const TIOCMSET: ::c_ulong = 0x5418; -pub const FIONREAD: ::c_ulong = 0x541B; -pub const TIOCCONS: ::c_ulong = 0x541D; -pub const TIOCSBRK: ::c_ulong = 0x5427; -pub const TIOCCBRK: ::c_ulong = 0x5428; - pub const TCSANOW: ::c_int = 0; pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 0x541C; -pub const TIOCGSERIAL: ::c_ulong = 0x541E; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - pub const VTIME: usize = 5; pub const VSWTC: usize = 7; pub const VSTART: usize = 8; @@ -617,7 +563,6 @@ pub const HUPCL: ::tcflag_t = 0o002000; pub const CLOCAL: ::tcflag_t = 0o004000; pub const CBAUDEX: ::tcflag_t = 0o010000; -pub const BOTHER: ::speed_t = 0o010000; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -10,6 +10,7 @@ pub type blksize_t = i64; pub type suseconds_t = i32; pub type __u64 = ::c_ulonglong; +pub type __s64 = ::c_longlong; s! { pub struct sigaction { @@ -193,17 +194,6 @@ __reserved1: ::c_ulong, __reserved2: ::c_ulong } - - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 19], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } } pub const POSIX_FADV_DONTNEED: ::c_int = 4; @@ -215,9 +205,6 @@ pub const RTLD_NOLOAD: ::c_int = 0x4; pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; -pub const TIOCGSOFTCAR: ::c_ulong = 0x40047464; -pub const TIOCSSOFTCAR: ::c_ulong = 0x80047465; - pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; pub const RLIMIT_AS: ::__rlimit_resource_t = 9; pub const RLIMIT_MEMLOCK: ::__rlimit_resource_t = 8; @@ -364,7 +351,7 @@ pub const O_ASYNC: ::c_int = 0x40; pub const O_NDELAY: ::c_int = 0x4004; -pub const PTRACE_DETACH: ::c_uint = 11; +pub const PTRACE_DETACH: ::c_uint = 17; pub const EFD_NONBLOCK: ::c_int = 0x4000; @@ -387,27 +374,6 @@ pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 0x541C; -pub const TIOCGSERIAL: ::c_ulong = 0x541E; -pub const TIOCEXCL: ::c_ulong = 0x2000740d; -pub const TIOCNXCL: ::c_ulong = 0x2000740e; -pub const TIOCCONS: ::c_ulong = 0x20007424; -pub const TIOCMGET: ::c_ulong = 0x4004746a; -pub const TIOCMBIC: ::c_ulong = 0x8004746b; -pub const TIOCMBIS: ::c_ulong = 0x8004746c; -pub const TIOCMSET: ::c_ulong = 0x8004746d; -pub const TIOCSTI: ::c_ulong = 0x80017472; -pub const TIOCCBRK: ::c_ulong = 0x2000747a; -pub const TIOCSBRK: ::c_ulong = 0x2000747b; -pub const TIOCSCTTY: ::c_ulong = 0x20007484; - -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - pub const SFD_CLOEXEC: ::c_int = 0x400000; pub const NCCS: usize = 17; @@ -480,10 +446,6 @@ pub const EISNAM: ::c_int = 120; pub const EREMOTEIO: ::c_int = 121; -pub const FIOCLEX: ::c_ulong = 0x20006601; -pub const FIONCLEX: ::c_ulong = 0x20006602; -pub const FIONBIO: ::c_ulong = 0x8004667e; - pub const MCL_CURRENT: ::c_int = 0x2000; pub const MCL_FUTURE: ::c_int = 0x4000; @@ -559,7 +521,6 @@ pub const B38400: ::speed_t = 0o000017; pub const EXTA: ::speed_t = B19200; pub const EXTB: ::speed_t = B38400; -pub const BOTHER: ::speed_t = 0x1000; pub const B57600: ::speed_t = 0x1001; pub const B115200: ::speed_t = 0x1002; pub const B230400: ::speed_t = 0x1003; @@ -583,24 +544,6 @@ pub const TOSTOP: ::tcflag_t = 0x100; pub const FLUSHO: ::tcflag_t = 0x1000; pub const EXTPROC: ::tcflag_t = 0x10000; -pub const TCGETS: ::c_ulong = 0x40245408; -pub const TCSETS: ::c_ulong = 0x80245409; -pub const TCSETSW: ::c_ulong = 0x8024540a; -pub const TCSETSF: ::c_ulong = 0x8024540b; -pub const TCGETA: ::c_ulong = 0x40125401; -pub const TCSETA: ::c_ulong = 0x80125402; -pub const TCSETAW: ::c_ulong = 0x80125403; -pub const TCSETAF: ::c_ulong = 0x80125404; -pub const TCSBRK: ::c_ulong = 0x20005405; -pub const TCXONC: ::c_ulong = 0x20005406; -pub const TCFLSH: ::c_ulong = 0x20005407; -pub const TIOCINQ: ::c_ulong = 0x4004667f; -pub const TIOCGPGRP: ::c_ulong = 0x40047483; -pub const TIOCSPGRP: ::c_ulong = 0x80047482; -pub const TIOCOUTQ: ::c_ulong = 0x40047473; -pub const TIOCGWINSZ: ::c_ulong = 0x40087468; -pub const TIOCSWINSZ: ::c_ulong = 0x80087467; -pub const FIONREAD: ::c_ulong = 0x4004667f; pub const SYS_restart_syscall: ::c_long = 0; pub const SYS_exit: ::c_long = 1; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -7,6 +7,7 @@ pub type greg_t = i64; pub type suseconds_t = i64; pub type __u64 = ::c_ulonglong; +pub type __s64 = ::c_longlong; s! { pub struct sigaction { @@ -259,22 +260,17 @@ __unused5: u64 } - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 19], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } - pub struct ip_mreqn { pub imr_multiaddr: ::in_addr, pub imr_address: ::in_addr, pub imr_ifindex: ::c_int, } + + pub struct seccomp_notif_sizes { + pub seccomp_notif: ::__u16, + pub seccomp_notif_resp: ::__u16, + pub seccomp_data: ::__u16, + } } s_no_extra_traits! { @@ -409,10 +405,6 @@ pub const RTLD_DEEPBIND: ::c_int = 0x8; pub const RTLD_GLOBAL: ::c_int = 0x100; pub const RTLD_NOLOAD: ::c_int = 0x4; -pub const TIOCGSOFTCAR: ::c_ulong = 0x5419; -pub const TIOCSSOFTCAR: ::c_ulong = 0x541A; -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; pub const RLIMIT_RSS: ::__rlimit_resource_t = 5; pub const RLIMIT_AS: ::__rlimit_resource_t = 9; @@ -577,25 +569,6 @@ pub const TCSADRAIN: ::c_int = 1; pub const TCSAFLUSH: ::c_int = 2; -pub const TIOCLINUX: ::c_ulong = 0x541C; -pub const TIOCGSERIAL: ::c_ulong = 0x541E; -pub const TIOCEXCL: ::c_ulong = 0x540C; -pub const TIOCNXCL: ::c_ulong = 0x540D; -pub const TIOCSCTTY: ::c_ulong = 0x540E; -pub const TIOCSTI: ::c_ulong = 0x5412; -pub const TIOCMGET: ::c_ulong = 0x5415; -pub const TIOCMBIS: ::c_ulong = 0x5416; -pub const TIOCMBIC: ::c_ulong = 0x5417; -pub const TIOCMSET: ::c_ulong = 0x5418; -pub const TIOCCONS: ::c_ulong = 0x541D; - -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - pub const SFD_CLOEXEC: ::c_int = 0x080000; pub const NCCS: usize = 32; @@ -655,10 +628,6 @@ pub const EISNAM: ::c_int = 120; pub const EREMOTEIO: ::c_int = 121; -pub const FIOCLEX: ::c_ulong = 0x5451; -pub const FIONCLEX: ::c_ulong = 0x5450; -pub const FIONBIO: ::c_ulong = 0x5421; - pub const PTRACE_GETFPREGS: ::c_uint = 14; pub const PTRACE_SETFPREGS: ::c_uint = 15; pub const PTRACE_GETFPXREGS: ::c_uint = 18; @@ -744,7 +713,6 @@ pub const B38400: ::speed_t = 0o000017; pub const EXTA: ::speed_t = B19200; pub const EXTB: ::speed_t = B38400; -pub const BOTHER: ::speed_t = 0o010000; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; @@ -768,26 +736,6 @@ pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; pub const EXTPROC: ::tcflag_t = 0x00010000; -pub const TCGETS: ::c_ulong = 0x5401; -pub const TCSETS: ::c_ulong = 0x5402; -pub const TCSETSW: ::c_ulong = 0x5403; -pub const TCSETSF: ::c_ulong = 0x5404; -pub const TCGETA: ::c_ulong = 0x5405; -pub const TCSETA: ::c_ulong = 0x5406; -pub const TCSETAW: ::c_ulong = 0x5407; -pub const TCSETAF: ::c_ulong = 0x5408; -pub const TCSBRK: ::c_ulong = 0x5409; -pub const TCXONC: ::c_ulong = 0x540A; -pub const TCFLSH: ::c_ulong = 0x540B; -pub const TIOCINQ: ::c_ulong = 0x541B; -pub const TIOCGPGRP: ::c_ulong = 0x540F; -pub const TIOCSPGRP: ::c_ulong = 0x5410; -pub const TIOCOUTQ: ::c_ulong = 0x5411; -pub const TIOCGWINSZ: ::c_ulong = 0x5413; -pub const TIOCSWINSZ: ::c_ulong = 0x5414; -pub const FIONREAD: ::c_ulong = 0x541B; -pub const TIOCSBRK: ::c_ulong = 0x5427; -pub const TIOCCBRK: ::c_ulong = 0x5428; // offsets in user_regs_structs, from sys/reg.h pub const R15: ::c_int = 0; @@ -843,6 +791,11 @@ pub const REG_OLDMASK: ::c_int = 21; pub const REG_CR2: ::c_int = 22; +pub const SECCOMP_SET_MODE_STRICT: ::c_uint = 0; +pub const SECCOMP_SET_MODE_FILTER: ::c_uint = 1; +pub const SECCOMP_GET_ACTION_AVAIL: ::c_uint = 2; +pub const SECCOMP_GET_NOTIF_SIZES: ::c_uint = 3; + extern "C" { pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int; pub fn setcontext(ucp: *const ucontext_t) -> ::c_int; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/gnu/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/gnu/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -4,6 +4,16 @@ pub type Lmid_t = ::c_long; pub type regoff_t = ::c_int; +cfg_if! { + if #[cfg(doc)] { + // Used in `linux::arch` to define ioctl constants. + pub(crate) type Ioctl = ::c_ulong; + } else { + #[doc(hidden)] + pub type Ioctl = ::c_ulong; + } +} + s! { pub struct statx { pub stx_mask: u32, @@ -308,6 +318,38 @@ pub semvmx: ::c_int, pub semaem: ::c_int, } + + pub struct ptrace_peeksiginfo_args { + pub off: ::__u64, + pub flags: ::__u32, + pub nr: ::__s32, + } + + pub struct __c_anonymous_ptrace_syscall_info_entry { + pub nr: ::__u64, + pub args: [::__u64; 6], + } + + pub struct __c_anonymous_ptrace_syscall_info_exit { + pub sval: ::__s64, + pub is_error: ::__u8, + } + + pub struct __c_anonymous_ptrace_syscall_info_seccomp { + pub nr: ::__u64, + pub args: [::__u64; 6], + pub ret_data: ::__u32, + } + + pub struct ptrace_syscall_info { + pub op: ::__u8, + pub pad: [::__u8; 3], + pub arch: ::__u32, + pub instruction_pointer: ::__u64, + pub stack_pointer: ::__u64, + #[cfg(libc_union)] + pub u: __c_anonymous_ptrace_syscall_info_data, + } } impl siginfo_t { @@ -395,6 +437,18 @@ self.sifields().sigchld.si_stime } } + + pub union __c_anonymous_ptrace_syscall_info_data { + pub entry: __c_anonymous_ptrace_syscall_info_entry, + pub exit: __c_anonymous_ptrace_syscall_info_exit, + pub seccomp: __c_anonymous_ptrace_syscall_info_seccomp, + } + impl ::Copy for __c_anonymous_ptrace_syscall_info_data {} + impl ::Clone for __c_anonymous_ptrace_syscall_info_data { + fn clone(&self) -> __c_anonymous_ptrace_syscall_info_data { + *self + } + } } } @@ -493,6 +547,44 @@ self.__glibc_reserved.hash(state); } } + + #[cfg(libc_union)] + impl PartialEq for __c_anonymous_ptrace_syscall_info_data { + fn eq(&self, other: &__c_anonymous_ptrace_syscall_info_data) -> bool { + unsafe { + self.entry == other.entry || + self.exit == other.exit || + self.seccomp == other.seccomp + } + } + } + + #[cfg(libc_union)] + impl Eq for __c_anonymous_ptrace_syscall_info_data {} + + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_ptrace_syscall_info_data { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + unsafe { + f.debug_struct("__c_anonymous_ptrace_syscall_info_data") + .field("entry", &self.entry) + .field("exit", &self.exit) + .field("seccomp", &self.seccomp) + .finish() + } + } + } + + #[cfg(libc_union)] + impl ::hash::Hash for __c_anonymous_ptrace_syscall_info_data { + fn hash(&self, state: &mut H) { + unsafe { + self.entry.hash(state); + self.exit.hash(state); + self.seccomp.hash(state); + } + } + } } } @@ -587,6 +679,7 @@ pub const RTLD_DI_TLS_DATA: ::c_int = 10; pub const SOCK_NONBLOCK: ::c_int = O_NONBLOCK; +pub const PIDFD_NONBLOCK: ::c_uint = O_NONBLOCK as ::c_uint; pub const SOL_RXRPC: ::c_int = 272; pub const SOL_PPPOL2TP: ::c_int = 273; @@ -774,6 +867,7 @@ pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53; pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53; pub const F2FS_SUPER_MAGIC: ::c_long = 0xf2f52010; + pub const FUSE_SUPER_MAGIC: ::c_long = 0x65735546; pub const FUTEXFS_SUPER_MAGIC: ::c_long = 0xbad1dea; pub const HOSTFS_SUPER_MAGIC: ::c_long = 0x00c0ffee; pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849; @@ -828,6 +922,7 @@ pub const EXT3_SUPER_MAGIC: ::c_uint = 0x0000ef53; pub const EXT4_SUPER_MAGIC: ::c_uint = 0x0000ef53; pub const F2FS_SUPER_MAGIC: ::c_uint = 0xf2f52010; + pub const FUSE_SUPER_MAGIC: ::c_uint = 0x65735546; pub const FUTEXFS_SUPER_MAGIC: ::c_uint = 0xbad1dea; pub const HOSTFS_SUPER_MAGIC: ::c_uint = 0x00c0ffee; pub const HPFS_SUPER_MAGIC: ::c_uint = 0xf995e849; @@ -889,6 +984,7 @@ pub const PTRACE_INTERRUPT: ::c_uint = 0x4207; pub const PTRACE_LISTEN: ::c_uint = 0x4208; pub const PTRACE_PEEKSIGINFO: ::c_uint = 0x4209; +pub const PTRACE_GET_SYSCALL_INFO: ::c_uint = 0x420e; // linux/fs.h @@ -950,12 +1046,6 @@ pub const GENL_ID_VFS_DQUOT: ::c_int = ::NLMSG_MIN_TYPE + 1; pub const GENL_ID_PMCRAID: ::c_int = ::NLMSG_MIN_TYPE + 2; -pub const TIOCM_LE: ::c_int = 0x001; -pub const TIOCM_DTR: ::c_int = 0x002; -pub const TIOCM_RTS: ::c_int = 0x004; -pub const TIOCM_CD: ::c_int = TIOCM_CAR; -pub const TIOCM_RI: ::c_int = TIOCM_RNG; - // elf.h pub const NT_PRSTATUS: ::c_int = 1; pub const NT_PRFPREG: ::c_int = 2; @@ -1274,6 +1364,8 @@ pub fn explicit_bzero(s: *mut ::c_void, len: ::size_t); // Added in `glibc` 2.29 pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void; + + pub fn ctermid(s: *mut ::c_char) -> *mut ::c_char; } extern "C" { @@ -1327,6 +1419,9 @@ pub fn pthread_setname_np(thread: ::pthread_t, name: *const ::c_char) -> ::c_int; pub fn sethostid(hostid: ::c_long) -> ::c_int; + + pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int; + pub fn mlock2(addr: *const ::c_void, len: ::size_t, flags: ::c_uint) -> ::c_int; } extern "C" { @@ -1338,6 +1433,7 @@ extra_info: *mut *mut ::c_void, flags: ::c_int, ) -> ::c_int; + pub fn malloc_trim(__pad: ::size_t) -> ::c_int; } cfg_if! { diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1330,6 +1330,7 @@ pub const POSIX_MADV_RANDOM: ::c_int = 1; pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; pub const POSIX_MADV_WILLNEED: ::c_int = 3; +pub const POSIX_SPAWN_USEVFORK: ::c_int = 64; pub const S_IEXEC: mode_t = 64; pub const S_IWRITE: mode_t = 128; @@ -1824,6 +1825,77 @@ pub const CLOSE_RANGE_UNSHARE: ::c_uint = 1 << 1; pub const CLOSE_RANGE_CLOEXEC: ::c_uint = 1 << 2; +// linux/filter.h +pub const SKF_AD_OFF: ::c_int = -0x1000; +pub const SKF_AD_PROTOCOL: ::c_int = 0; +pub const SKF_AD_PKTTYPE: ::c_int = 4; +pub const SKF_AD_IFINDEX: ::c_int = 8; +pub const SKF_AD_NLATTR: ::c_int = 12; +pub const SKF_AD_NLATTR_NEST: ::c_int = 16; +pub const SKF_AD_MARK: ::c_int = 20; +pub const SKF_AD_QUEUE: ::c_int = 24; +pub const SKF_AD_HATYPE: ::c_int = 28; +pub const SKF_AD_RXHASH: ::c_int = 32; +pub const SKF_AD_CPU: ::c_int = 36; +pub const SKF_AD_ALU_XOR_X: ::c_int = 40; +pub const SKF_AD_VLAN_TAG: ::c_int = 44; +pub const SKF_AD_VLAN_TAG_PRESENT: ::c_int = 48; +pub const SKF_AD_PAY_OFFSET: ::c_int = 52; +pub const SKF_AD_RANDOM: ::c_int = 56; +pub const SKF_AD_VLAN_TPID: ::c_int = 60; +pub const SKF_AD_MAX: ::c_int = 64; +pub const SKF_NET_OFF: ::c_int = -0x100000; +pub const SKF_LL_OFF: ::c_int = -0x200000; +pub const BPF_NET_OFF: ::c_int = SKF_NET_OFF; +pub const BPF_LL_OFF: ::c_int = SKF_LL_OFF; +pub const BPF_MEMWORDS: ::c_int = 16; +pub const BPF_MAXINSNS: ::c_int = 4096; + +// linux/bpf_common.h +pub const BPF_LD: ::__u32 = 0x00; +pub const BPF_LDX: ::__u32 = 0x01; +pub const BPF_ST: ::__u32 = 0x02; +pub const BPF_STX: ::__u32 = 0x03; +pub const BPF_ALU: ::__u32 = 0x04; +pub const BPF_JMP: ::__u32 = 0x05; +pub const BPF_RET: ::__u32 = 0x06; +pub const BPF_MISC: ::__u32 = 0x07; +pub const BPF_W: ::__u32 = 0x00; +pub const BPF_H: ::__u32 = 0x08; +pub const BPF_B: ::__u32 = 0x10; +pub const BPF_IMM: ::__u32 = 0x00; +pub const BPF_ABS: ::__u32 = 0x20; +pub const BPF_IND: ::__u32 = 0x40; +pub const BPF_MEM: ::__u32 = 0x60; +pub const BPF_LEN: ::__u32 = 0x80; +pub const BPF_MSH: ::__u32 = 0xa0; +pub const BPF_ADD: ::__u32 = 0x00; +pub const BPF_SUB: ::__u32 = 0x10; +pub const BPF_MUL: ::__u32 = 0x20; +pub const BPF_DIV: ::__u32 = 0x30; +pub const BPF_OR: ::__u32 = 0x40; +pub const BPF_AND: ::__u32 = 0x50; +pub const BPF_LSH: ::__u32 = 0x60; +pub const BPF_RSH: ::__u32 = 0x70; +pub const BPF_NEG: ::__u32 = 0x80; +pub const BPF_MOD: ::__u32 = 0x90; +pub const BPF_XOR: ::__u32 = 0xa0; +pub const BPF_JA: ::__u32 = 0x00; +pub const BPF_JEQ: ::__u32 = 0x10; +pub const BPF_JGT: ::__u32 = 0x20; +pub const BPF_JGE: ::__u32 = 0x30; +pub const BPF_JSET: ::__u32 = 0x40; +pub const BPF_K: ::__u32 = 0x00; +pub const BPF_X: ::__u32 = 0x08; + +// linux/openat2.h +pub const RESOLVE_NO_XDEV: ::__u64 = 0x01; +pub const RESOLVE_NO_MAGICLINKS: ::__u64 = 0x02; +pub const RESOLVE_NO_SYMLINKS: ::__u64 = 0x04; +pub const RESOLVE_BENEATH: ::__u64 = 0x08; +pub const RESOLVE_IN_ROOT: ::__u64 = 0x10; +pub const RESOLVE_CACHED: ::__u64 = 0x20; + // these are used in the p_type field of Elf32_Phdr and Elf64_Phdr, which has // the type Elf32Word and Elf64Word respectively. Luckily, both of those are u32 // so we can use that type here to avoid having to cast. @@ -2574,6 +2646,7 @@ // include/uapi/asm-generic/mman-common.h pub const MAP_FIXED_NOREPLACE: ::c_int = 0x100000; +pub const MLOCK_ONFAULT: ::c_uint = 0x01; // uapi/linux/vm_sockets.h pub const VMADDR_CID_ANY: ::c_uint = 0xFFFFFFFF; @@ -3088,19 +3161,6 @@ pub const CAN_RAW_FD_FRAMES: ::c_int = 5; pub const CAN_RAW_JOIN_FILTERS: ::c_int = 6; -#[deprecated( - since = "0.2.102", - note = "Errnoeously uses c_int; should use c_short." -)] -#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64")))] -pub const POLLRDHUP: ::c_int = 0x2000; -#[deprecated( - since = "0.2.102", - note = "Errnoeously uses c_int; should use c_short." -)] -#[cfg(any(target_arch = "sparc", target_arch = "sparc64"))] -pub const POLLRDHUP: ::c_int = 0x800; - f! { pub fn NLA_ALIGN(len: ::c_int) -> ::c_int { return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1) @@ -3224,6 +3284,22 @@ pub fn SO_EE_OFFENDER(ee: *const ::sock_extended_err) -> *mut ::sockaddr { ee.offset(1) as *mut ::sockaddr } + + pub fn BPF_RVAL(code: ::__u32) -> ::__u32 { + code & 0x18 + } + + pub fn BPF_MISCOP(code: ::__u32) -> ::__u32 { + code & 0xf8 + } + + pub fn BPF_STMT(code: ::__u16, k: ::__u32) -> sock_filter { + sock_filter{code: code, jt: 0, jf: 0, k: k} + } + + pub fn BPF_JUMP(code: ::__u16, k: ::__u32, jt: ::__u8, jf: ::__u8) -> sock_filter { + sock_filter{code: code, jt: jt, jf: jf, k: k} + } } cfg_if! { @@ -3955,3 +4031,10 @@ } } expand_align!(); + +cfg_if! { + if #[cfg(libc_non_exhaustive)] { + mod non_exhaustive; + pub use self::non_exhaustive::*; + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b32/arm/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/arm/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b32/arm/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/arm/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -161,10 +161,6 @@ pub const O_ASYNC: ::c_int = 0x2000; pub const O_LARGEFILE: ::c_int = 0o400000; -pub const FIOCLEX: ::c_int = 0x5451; -pub const FIONCLEX: ::c_int = 0x5450; -pub const FIONBIO: ::c_int = 0x5421; - pub const RLIMIT_RSS: ::c_int = 5; pub const RLIMIT_NOFILE: ::c_int = 7; pub const RLIMIT_AS: ::c_int = 9; @@ -404,55 +400,9 @@ pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; -pub const TCGETS: ::c_int = 0x5401; -pub const TCSETS: ::c_int = 0x5402; -pub const TCSETSW: ::c_int = 0x5403; -pub const TCSETSF: ::c_int = 0x5404; -pub const TCGETA: ::c_int = 0x5405; -pub const TCSETA: ::c_int = 0x5406; -pub const TCSETAW: ::c_int = 0x5407; -pub const TCSETAF: ::c_int = 0x5408; -pub const TCSBRK: ::c_int = 0x5409; -pub const TCXONC: ::c_int = 0x540A; -pub const TCFLSH: ::c_int = 0x540B; -pub const TIOCGSOFTCAR: ::c_int = 0x5419; -pub const TIOCSSOFTCAR: ::c_int = 0x541A; -pub const TIOCLINUX: ::c_int = 0x541C; -pub const TIOCGSERIAL: ::c_int = 0x541E; -pub const TIOCEXCL: ::c_int = 0x540C; -pub const TIOCNXCL: ::c_int = 0x540D; -pub const TIOCSCTTY: ::c_int = 0x540E; -pub const TIOCGPGRP: ::c_int = 0x540F; -pub const TIOCSPGRP: ::c_int = 0x5410; -pub const TIOCOUTQ: ::c_int = 0x5411; -pub const TIOCSTI: ::c_int = 0x5412; -pub const TIOCGWINSZ: ::c_int = 0x5413; -pub const TIOCSWINSZ: ::c_int = 0x5414; -pub const TIOCMGET: ::c_int = 0x5415; -pub const TIOCMBIS: ::c_int = 0x5416; -pub const TIOCMBIC: ::c_int = 0x5417; -pub const TIOCMSET: ::c_int = 0x5418; -pub const FIONREAD: ::c_int = 0x541B; -pub const TIOCCONS: ::c_int = 0x541D; - -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; - pub const POLLWRNORM: ::c_short = 0x100; pub const POLLWRBAND: ::c_short = 0x200; -pub const TIOCM_LE: ::c_int = 0x001; -pub const TIOCM_DTR: ::c_int = 0x002; -pub const TIOCM_RTS: ::c_int = 0x004; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; -pub const TIOCM_CD: ::c_int = TIOCM_CAR; -pub const TIOCM_RI: ::c_int = TIOCM_RNG; - // Syscall table pub const SYS_restart_syscall: ::c_long = 0; pub const SYS_exit: ::c_long = 1; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b32/hexagon.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/hexagon.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b32/hexagon.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/hexagon.rs 2022-01-21 02:47:39.000000000 +0000 @@ -129,17 +129,6 @@ pub f_namemax: ::c_ulong, __f_spare: [::c_int; 6], } - - pub struct termios2 { - pub c_iflag: ::tcflag_t, - pub c_oflag: ::tcflag_t, - pub c_cflag: ::tcflag_t, - pub c_lflag: ::tcflag_t, - pub c_line: ::cc_t, - pub c_cc: [::cc_t; 19], - pub c_ispeed: ::speed_t, - pub c_ospeed: ::speed_t, - } } pub const AF_FILE: ::c_int = 1; @@ -234,12 +223,6 @@ pub const F_GETOWNER_UIDS: ::c_int = 17; pub const F_GETOWN_EX: ::c_int = 16; pub const F_GETSIG: ::c_int = 11; -pub const FIOASYNC: ::c_int = 21586; -pub const FIOCLEX: ::c_int = 21585; -pub const FIONBIO: ::c_int = 21537; -pub const FIONCLEX: ::c_int = 21584; -pub const FIONREAD: ::c_int = 21531; -pub const FIOQSIZE: ::c_int = 21600; pub const F_LINUX_SPECIFIC_BASE: ::c_int = 1024; pub const FLUSHO: ::c_int = 4096; pub const F_OFD_GETLK: ::c_int = 36; @@ -666,83 +649,10 @@ pub const SYS_write: ::c_int = 64; pub const SYS_writev: ::c_int = 66; pub const SYS_statx: ::c_int = 291; -pub const TCFLSH: ::c_int = 21515; -pub const TCGETA: ::c_int = 21509; -pub const TCGETS: ::c_int = 21505; -pub const TCGETX: ::c_int = 21554; -pub const TCSBRK: ::c_int = 21513; -pub const TCSBRKP: ::c_int = 21541; -pub const TCSETA: ::c_int = 21510; -pub const TCSETAF: ::c_int = 21512; -pub const TCSETAW: ::c_int = 21511; -pub const TCSETS: ::c_int = 21506; -pub const TCSETSF: ::c_int = 21508; -pub const TCSETSW: ::c_int = 21507; -pub const TCSETX: ::c_int = 21555; -pub const TCSETXF: ::c_int = 21556; -pub const TCSETXW: ::c_int = 21557; -pub const TCXONC: ::c_int = 21514; -pub const TIOCCONS: ::c_int = 21533; -pub const TIOCEXCL: ::c_int = 21516; -pub const TIOCGETD: ::c_int = 21540; -pub const TIOCGICOUNT: ::c_int = 21597; -pub const TIOCGLCKTRMIOS: ::c_int = 21590; -pub const TIOCGPGRP: ::c_int = 21519; -pub const TIOCGRS485: ::c_int = 21550; -pub const TIOCGSERIAL: ::c_int = 21534; -pub const TIOCGSID: ::c_int = 21545; -pub const TIOCGSOFTCAR: ::c_int = 21529; -pub const TIOCGWINSZ: ::c_int = 21523; -pub const TIOCLINUX: ::c_int = 21532; -pub const TIOCMBIC: ::c_int = 21527; -pub const TIOCMBIS: ::c_int = 21526; -pub const TIOCM_CAR: ::c_int = 64; -pub const TIOCM_CD: ::c_int = 64; -pub const TIOCM_CTS: ::c_int = 32; -pub const TIOCM_DSR: ::c_int = 256; -pub const TIOCM_DTR: ::c_int = 2; -pub const TIOCMGET: ::c_int = 21525; -pub const TIOCMIWAIT: ::c_int = 21596; -pub const TIOCM_LE: ::c_int = 1; pub const TIOCM_LOOP: ::c_int = 32768; pub const TIOCM_OUT1: ::c_int = 8192; pub const TIOCM_OUT2: ::c_int = 16384; -pub const TIOCM_RI: ::c_int = 128; -pub const TIOCM_RNG: ::c_int = 128; -pub const TIOCM_RTS: ::c_int = 4; -pub const TIOCMSET: ::c_int = 21528; -pub const TIOCM_SR: ::c_int = 16; -pub const TIOCM_ST: ::c_int = 8; -pub const TIOCNOTTY: ::c_int = 21538; -pub const TIOCNXCL: ::c_int = 21517; -pub const TIOCOUTQ: ::c_int = 21521; -pub const TIOCPKT: ::c_int = 21536; -pub const TIOCPKT_DATA: ::c_int = 0; -pub const TIOCPKT_DOSTOP: ::c_int = 32; -pub const TIOCPKT_FLUSHREAD: ::c_int = 1; -pub const TIOCPKT_FLUSHWRITE: ::c_int = 2; -pub const TIOCPKT_IOCTL: ::c_int = 64; -pub const TIOCPKT_NOSTOP: ::c_int = 16; -pub const TIOCPKT_START: ::c_int = 8; -pub const TIOCPKT_STOP: ::c_int = 4; -pub const TIOCSCTTY: ::c_int = 21518; -pub const TIOCSERCONFIG: ::c_int = 21587; -pub const TIOCSERGETLSR: ::c_int = 21593; -pub const TIOCSERGETMULTI: ::c_int = 21594; -pub const TIOCSERGSTRUCT: ::c_int = 21592; -pub const TIOCSERGWILD: ::c_int = 21588; -pub const TIOCSERSETMULTI: ::c_int = 21595; -pub const TIOCSERSWILD: ::c_int = 21589; pub const TIOCSER_TEMT: ::c_int = 1; -pub const TIOCSETD: ::c_int = 21539; -pub const TIOCSLCKTRMIOS: ::c_int = 21591; -pub const TIOCSPGRP: ::c_int = 21520; -pub const TIOCSRS485: ::c_int = 21551; -pub const TIOCSSERIAL: ::c_int = 21535; -pub const TIOCSSOFTCAR: ::c_int = 21530; -pub const TIOCSTI: ::c_int = 21522; -pub const TIOCSWINSZ: ::c_int = 21524; -pub const TIOCVHANGUP: ::c_int = 21559; pub const TOSTOP: ::c_int = 256; pub const VEOF: ::c_int = 4; pub const VEOL2: ::c_int = 16; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b32/mips/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/mips/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b32/mips/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/mips/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -172,10 +172,6 @@ pub const O_ASYNC: ::c_int = 0o10000; pub const O_LARGEFILE: ::c_int = 0x2000; -pub const FIOCLEX: ::c_int = 0x6601; -pub const FIONCLEX: ::c_int = 0x6602; -pub const FIONBIO: ::c_int = 0x667E; - pub const RLIMIT_RSS: ::c_int = 7; pub const RLIMIT_NOFILE: ::c_int = 5; pub const RLIMIT_AS: ::c_int = 6; @@ -413,55 +409,9 @@ pub const TOSTOP: ::tcflag_t = 0o100000; pub const FLUSHO: ::tcflag_t = 0o020000; -pub const TCGETS: ::c_int = 0x540D; -pub const TCSETS: ::c_int = 0x540E; -pub const TCSETSW: ::c_int = 0x540F; -pub const TCSETSF: ::c_int = 0x5410; -pub const TCGETA: ::c_int = 0x5401; -pub const TCSETA: ::c_int = 0x5402; -pub const TCSETAW: ::c_int = 0x5403; -pub const TCSETAF: ::c_int = 0x5404; -pub const TCSBRK: ::c_int = 0x5405; -pub const TCXONC: ::c_int = 0x5406; -pub const TCFLSH: ::c_int = 0x5407; -pub const TIOCGSOFTCAR: ::c_int = 0x5481; -pub const TIOCSSOFTCAR: ::c_int = 0x5482; -pub const TIOCLINUX: ::c_int = 0x5483; -pub const TIOCGSERIAL: ::c_int = 0x5484; -pub const TIOCEXCL: ::c_int = 0x740D; -pub const TIOCNXCL: ::c_int = 0x740E; -pub const TIOCSCTTY: ::c_int = 0x5480; -pub const TIOCGPGRP: ::c_int = 0x40047477; -pub const TIOCSPGRP: ::c_int = 0x80047476; -pub const TIOCOUTQ: ::c_int = 0x7472; -pub const TIOCSTI: ::c_int = 0x5472; -pub const TIOCGWINSZ: ::c_int = 0x40087468; -pub const TIOCSWINSZ: ::c_int = 0x80087467; -pub const TIOCMGET: ::c_int = 0x741D; -pub const TIOCMBIS: ::c_int = 0x741B; -pub const TIOCMBIC: ::c_int = 0x741C; -pub const TIOCMSET: ::c_int = 0x741A; -pub const FIONREAD: ::c_int = 0x467F; -pub const TIOCCONS: ::c_int = 0x80047478; - -pub const TIOCGRS485: ::c_int = 0x4020542E; -pub const TIOCSRS485: ::c_int = 0xC020542F; - pub const POLLWRNORM: ::c_short = 0x4; pub const POLLWRBAND: ::c_short = 0x100; -pub const TIOCM_LE: ::c_int = 0x001; -pub const TIOCM_DTR: ::c_int = 0x002; -pub const TIOCM_RTS: ::c_int = 0x004; -pub const TIOCM_ST: ::c_int = 0x010; -pub const TIOCM_SR: ::c_int = 0x020; -pub const TIOCM_CTS: ::c_int = 0x040; -pub const TIOCM_CAR: ::c_int = 0x100; -pub const TIOCM_CD: ::c_int = TIOCM_CAR; -pub const TIOCM_RNG: ::c_int = 0x200; -pub const TIOCM_RI: ::c_int = TIOCM_RNG; -pub const TIOCM_DSR: ::c_int = 0x400; - pub const SYS_syscall: ::c_long = 4000 + 0; pub const SYS_exit: ::c_long = 4000 + 1; pub const SYS_fork: ::c_long = 4000 + 2; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b32/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b32/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -38,12 +38,6 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; -pub const TIOCINQ: ::c_int = ::FIONREAD; - -extern "C" { - pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; -} - cfg_if! { if #[cfg(any(target_arch = "x86"))] { mod x86; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b32/powerpc.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/powerpc.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b32/powerpc.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/powerpc.rs 2022-01-21 02:47:39.000000000 +0000 @@ -165,10 +165,6 @@ pub const O_ASYNC: ::c_int = 0x2000; pub const O_LARGEFILE: ::c_int = 0x10000; -pub const FIOCLEX: ::c_int = 0x20006601; -pub const FIONCLEX: ::c_int = 0x20006602; -pub const FIONBIO: ::c_int = 0x8004667E; - pub const RLIMIT_RSS: ::c_int = 5; pub const RLIMIT_NOFILE: ::c_int = 7; pub const RLIMIT_AS: ::c_int = 9; @@ -406,55 +402,9 @@ pub const TOSTOP: ::tcflag_t = 0x00400000; pub const FLUSHO: ::tcflag_t = 0x00800000; -pub const TCGETS: ::c_int = 0x402C7413; -pub const TCSETS: ::c_int = 0x802C7414; -pub const TCSETSW: ::c_int = 0x802C7415; -pub const TCSETSF: ::c_int = 0x802C7416; -pub const TCGETA: ::c_int = 0x40147417; -pub const TCSETA: ::c_int = 0x80147418; -pub const TCSETAW: ::c_int = 0x80147419; -pub const TCSETAF: ::c_int = 0x8014741C; -pub const TCSBRK: ::c_int = 0x2000741D; -pub const TCXONC: ::c_int = 0x2000741E; -pub const TCFLSH: ::c_int = 0x2000741F; -pub const TIOCGSOFTCAR: ::c_int = 0x5419; -pub const TIOCSSOFTCAR: ::c_int = 0x541A; -pub const TIOCLINUX: ::c_int = 0x541C; -pub const TIOCGSERIAL: ::c_int = 0x541E; -pub const TIOCEXCL: ::c_int = 0x540C; -pub const TIOCNXCL: ::c_int = 0x540D; -pub const TIOCSCTTY: ::c_int = 0x540E; -pub const TIOCGPGRP: ::c_int = 0x40047477; -pub const TIOCSPGRP: ::c_int = 0x80047476; -pub const TIOCOUTQ: ::c_int = 0x40047473; -pub const TIOCSTI: ::c_int = 0x5412; -pub const TIOCGWINSZ: ::c_int = 0x40087468; -pub const TIOCSWINSZ: ::c_int = 0x80087467; -pub const TIOCMGET: ::c_int = 0x5415; -pub const TIOCMBIS: ::c_int = 0x5416; -pub const TIOCMBIC: ::c_int = 0x5417; -pub const TIOCMSET: ::c_int = 0x5418; -pub const FIONREAD: ::c_int = 0x4004667F; -pub const TIOCCONS: ::c_int = 0x541D; - -pub const TIOCGRS485: ::c_int = 0x542e; -pub const TIOCSRS485: ::c_int = 0x542f; - pub const POLLWRNORM: ::c_short = 0x100; pub const POLLWRBAND: ::c_short = 0x200; -pub const TIOCM_LE: ::c_int = 0x001; -pub const TIOCM_DTR: ::c_int = 0x002; -pub const TIOCM_RTS: ::c_int = 0x004; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; -pub const TIOCM_CD: ::c_int = TIOCM_CAR; -pub const TIOCM_RI: ::c_int = TIOCM_RNG; - // Syscall table pub const SYS_restart_syscall: ::c_long = 0; pub const SYS_exit: ::c_long = 1; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b32/x86/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/x86/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b32/x86/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b32/x86/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -221,10 +221,6 @@ pub const O_ASYNC: ::c_int = 0x2000; pub const O_LARGEFILE: ::c_int = 0o0100000; -pub const FIOCLEX: ::c_int = 0x5451; -pub const FIONCLEX: ::c_int = 0x5450; -pub const FIONBIO: ::c_int = 0x5421; - pub const RLIMIT_RSS: ::c_int = 5; pub const RLIMIT_NOFILE: ::c_int = 7; pub const RLIMIT_AS: ::c_int = 9; @@ -465,55 +461,9 @@ pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; -pub const TCGETS: ::c_int = 0x5401; -pub const TCSETS: ::c_int = 0x5402; -pub const TCSETSW: ::c_int = 0x5403; -pub const TCSETSF: ::c_int = 0x5404; -pub const TCGETA: ::c_int = 0x5405; -pub const TCSETA: ::c_int = 0x5406; -pub const TCSETAW: ::c_int = 0x5407; -pub const TCSETAF: ::c_int = 0x5408; -pub const TCSBRK: ::c_int = 0x5409; -pub const TCXONC: ::c_int = 0x540A; -pub const TCFLSH: ::c_int = 0x540B; -pub const TIOCGSOFTCAR: ::c_int = 0x5419; -pub const TIOCSSOFTCAR: ::c_int = 0x541A; -pub const TIOCLINUX: ::c_int = 0x541C; -pub const TIOCGSERIAL: ::c_int = 0x541E; -pub const TIOCEXCL: ::c_int = 0x540C; -pub const TIOCNXCL: ::c_int = 0x540D; -pub const TIOCSCTTY: ::c_int = 0x540E; -pub const TIOCGPGRP: ::c_int = 0x540F; -pub const TIOCSPGRP: ::c_int = 0x5410; -pub const TIOCOUTQ: ::c_int = 0x5411; -pub const TIOCSTI: ::c_int = 0x5412; -pub const TIOCGWINSZ: ::c_int = 0x5413; -pub const TIOCSWINSZ: ::c_int = 0x5414; -pub const TIOCMGET: ::c_int = 0x5415; -pub const TIOCMBIS: ::c_int = 0x5416; -pub const TIOCMBIC: ::c_int = 0x5417; -pub const TIOCMSET: ::c_int = 0x5418; -pub const FIONREAD: ::c_int = 0x541B; -pub const TIOCCONS: ::c_int = 0x541D; - -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; - pub const POLLWRNORM: ::c_short = 0x100; pub const POLLWRBAND: ::c_short = 0x200; -pub const TIOCM_LE: ::c_int = 0x001; -pub const TIOCM_DTR: ::c_int = 0x002; -pub const TIOCM_RTS: ::c_int = 0x004; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; -pub const TIOCM_CD: ::c_int = TIOCM_CAR; -pub const TIOCM_RI: ::c_int = TIOCM_RNG; - // Syscall table pub const SYS_restart_syscall: ::c_long = 0; pub const SYS_exit: ::c_long = 1; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -49,6 +49,13 @@ __unused: [::c_uint; 2], } + pub struct user_regs_struct { + pub regs: [::c_ulonglong; 31], + pub sp: ::c_ulonglong, + pub pc: ::c_ulonglong, + pub pstate: ::c_ulonglong, + } + pub struct ipc_perm { pub __ipc_perm_key: ::key_t, pub uid: ::uid_t, @@ -551,7 +558,6 @@ pub const RLIMIT_NLIMITS: ::c_int = 15; pub const RLIM_NLIMITS: ::c_int = RLIMIT_NLIMITS; -pub const TIOCINQ: ::c_int = ::FIONREAD; pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; pub const CBAUD: ::tcflag_t = 0o0010017; @@ -621,9 +627,6 @@ pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; -pub const FIOCLEX: ::c_int = 0x5451; -pub const FIONCLEX: ::c_int = 0x5450; -pub const FIONBIO: ::c_int = 0x5421; pub const EDEADLK: ::c_int = 35; pub const EDEADLOCK: ::c_int = EDEADLK; @@ -634,55 +637,6 @@ pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; -pub const TCGETS: ::c_int = 0x5401; -pub const TCSETS: ::c_int = 0x5402; -pub const TCSETSW: ::c_int = 0x5403; -pub const TCSETSF: ::c_int = 0x5404; -pub const TCGETA: ::c_int = 0x5405; -pub const TCSETA: ::c_int = 0x5406; -pub const TCSETAW: ::c_int = 0x5407; -pub const TCSETAF: ::c_int = 0x5408; -pub const TCSBRK: ::c_int = 0x5409; -pub const TCXONC: ::c_int = 0x540A; -pub const TCFLSH: ::c_int = 0x540B; -pub const TIOCGSOFTCAR: ::c_int = 0x5419; -pub const TIOCSSOFTCAR: ::c_int = 0x541A; -pub const TIOCLINUX: ::c_int = 0x541C; -pub const TIOCGSERIAL: ::c_int = 0x541E; -pub const TIOCEXCL: ::c_int = 0x540C; -pub const TIOCNXCL: ::c_int = 0x540D; -pub const TIOCSCTTY: ::c_int = 0x540E; -pub const TIOCGPGRP: ::c_int = 0x540F; -pub const TIOCSPGRP: ::c_int = 0x5410; -pub const TIOCOUTQ: ::c_int = 0x5411; -pub const TIOCSTI: ::c_int = 0x5412; -pub const TIOCGWINSZ: ::c_int = 0x5413; -pub const TIOCSWINSZ: ::c_int = 0x5414; -pub const TIOCMGET: ::c_int = 0x5415; -pub const TIOCMBIS: ::c_int = 0x5416; -pub const TIOCMBIC: ::c_int = 0x5417; -pub const TIOCMSET: ::c_int = 0x5418; -pub const FIONREAD: ::c_int = 0x541B; -pub const TIOCCONS: ::c_int = 0x541D; - -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; - -pub const TIOCM_LE: ::c_int = 0x001; -pub const TIOCM_DTR: ::c_int = 0x002; -pub const TIOCM_RTS: ::c_int = 0x004; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; -pub const TIOCM_CD: ::c_int = TIOCM_CAR; -pub const TIOCM_RI: ::c_int = TIOCM_RNG; - -extern "C" { - pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; -} cfg_if! { if #[cfg(libc_align)] { diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b64/mips64.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/mips64.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b64/mips64.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/mips64.rs 2022-01-21 02:47:39.000000000 +0000 @@ -505,6 +505,7 @@ pub const EPROTONOSUPPORT: ::c_int = 120; pub const ESOCKTNOSUPPORT: ::c_int = 121; pub const EOPNOTSUPP: ::c_int = 122; +pub const ENOTSUP: ::c_int = EOPNOTSUPP; pub const EPFNOSUPPORT: ::c_int = 123; pub const EAFNOSUPPORT: ::c_int = 124; pub const EADDRINUSE: ::c_int = 125; @@ -557,10 +558,6 @@ pub const SOCK_STREAM: ::c_int = 2; pub const SOCK_DGRAM: ::c_int = 1; -pub const FIOCLEX: ::c_int = 0x6601; -pub const FIONCLEX: ::c_int = 0x6602; -pub const FIONBIO: ::c_int = 0x667e; - pub const SA_ONSTACK: ::c_int = 0x08000000; pub const SA_SIGINFO: ::c_int = 0x00000008; pub const SA_NOCLDWAIT: ::c_int = 0x00010000; @@ -609,38 +606,6 @@ pub const F_OFD_SETLK: ::c_int = 37; pub const F_OFD_SETLKW: ::c_int = 38; -pub const TCGETS: ::c_int = 0x540d; -pub const TCSETS: ::c_int = 0x540e; -pub const TCSETSW: ::c_int = 0x540f; -pub const TCSETSF: ::c_int = 0x5410; -pub const TCGETA: ::c_int = 0x5401; -pub const TCSETA: ::c_int = 0x5402; -pub const TCSETAW: ::c_int = 0x5403; -pub const TCSETAF: ::c_int = 0x5404; -pub const TCSBRK: ::c_int = 0x5405; -pub const TCXONC: ::c_int = 0x5406; -pub const TCFLSH: ::c_int = 0x5407; -pub const TIOCGSOFTCAR: ::c_int = 0x5481; -pub const TIOCSSOFTCAR: ::c_int = 0x5482; -pub const TIOCINQ: ::c_int = 0x467f; -pub const TIOCLINUX: ::c_int = 0x5483; -pub const TIOCGSERIAL: ::c_int = 0x5484; -pub const TIOCEXCL: ::c_int = 0x740d; -pub const TIOCNXCL: ::c_int = 0x740e; -pub const TIOCSCTTY: ::c_int = 0x5480; -pub const TIOCGPGRP: ::c_int = 0x40047477; -pub const TIOCSPGRP: ::c_int = 0x80047476_u32 as i32; -pub const TIOCOUTQ: ::c_int = 0x7472; -pub const TIOCSTI: ::c_int = 0x5472; -pub const TIOCGWINSZ: ::c_int = 0x40087468; -pub const TIOCSWINSZ: ::c_int = 0x80087467_u32 as i32; -pub const TIOCMGET: ::c_int = 0x741d; -pub const TIOCMBIS: ::c_int = 0x741b; -pub const TIOCMBIC: ::c_int = 0x741c; -pub const TIOCMSET: ::c_int = 0x741a; -pub const FIONREAD: ::c_int = 0x467f; -pub const TIOCCONS: ::c_int = 0x80047478_u32 as i32; - pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; @@ -696,7 +661,6 @@ pub const VTDLY: ::tcflag_t = 0o040000; pub const XTABS: ::tcflag_t = 0o014000; -pub const BOTHER: ::speed_t = 0o010000; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; @@ -713,15 +677,4 @@ pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; -pub const TIOCM_ST: ::c_int = 0x010; -pub const TIOCM_SR: ::c_int = 0x020; -pub const TIOCM_CTS: ::c_int = 0x040; -pub const TIOCM_CAR: ::c_int = 0x100; -pub const TIOCM_RNG: ::c_int = 0x200; -pub const TIOCM_DSR: ::c_int = 0x400; - pub const EHWPOISON: ::c_int = 168; - -extern "C" { - pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; -} diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b64/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b64/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -163,6 +163,9 @@ } else if #[cfg(any(target_arch = "x86_64"))] { mod x86_64; pub use self::x86_64::*; + } else if #[cfg(any(target_arch = "riscv64"))] { + mod riscv64; + pub use self::riscv64::*; } else { // Unknown target_arch } diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b64/powerpc64.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/powerpc64.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b64/powerpc64.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/powerpc64.rs 2022-01-21 02:47:39.000000000 +0000 @@ -601,9 +601,6 @@ pub const SYS_epoll_pwait2: ::c_long = 441; pub const SYS_mount_setattr: ::c_long = 442; -pub const FIOCLEX: ::c_int = 0x20006601; -pub const FIONCLEX: ::c_int = 0x20006602; -pub const FIONBIO: ::c_int = 0x8004667e; pub const EDEADLK: ::c_int = 58; pub const EDEADLOCK: ::c_int = EDEADLK; @@ -614,53 +611,9 @@ pub const IEXTEN: ::tcflag_t = 0x00000400; pub const TOSTOP: ::tcflag_t = 0x00400000; pub const FLUSHO: ::tcflag_t = 0x00800000; -pub const TCGETS: ::c_int = 0x403c7413; -pub const TCSETS: ::c_int = 0x803c7414; -pub const TCSETSW: ::c_int = 0x803c7415; -pub const TCSETSF: ::c_int = 0x803c7416; -pub const TCGETA: ::c_int = 0x40147417; -pub const TCSETA: ::c_int = 0x80147418; -pub const TCSETAW: ::c_int = 0x80147419; -pub const TCSETAF: ::c_int = 0x8014741c; -pub const TCSBRK: ::c_int = 0x2000741d; -pub const TCXONC: ::c_int = 0x2000741e; -pub const TCFLSH: ::c_int = 0x2000741f; -pub const TIOCGSOFTCAR: ::c_int = 0x5419; -pub const TIOCSSOFTCAR: ::c_int = 0x541A; -pub const TIOCLINUX: ::c_int = 0x541C; -pub const TIOCGSERIAL: ::c_int = 0x541E; -pub const TIOCEXCL: ::c_int = 0x540C; -pub const TIOCNXCL: ::c_int = 0x540D; -pub const TIOCSCTTY: ::c_int = 0x540E; -pub const TIOCGPGRP: ::c_int = 0x40047477; -pub const TIOCSPGRP: ::c_int = 0x80047476; -pub const TIOCOUTQ: ::c_int = 0x40047473; -pub const TIOCGWINSZ: ::c_int = 0x40087468; -pub const TIOCSWINSZ: ::c_int = 0x80087467; -pub const TIOCMGET: ::c_int = 0x5415; -pub const TIOCMBIS: ::c_int = 0x5416; -pub const TIOCMBIC: ::c_int = 0x5417; -pub const TIOCMSET: ::c_int = 0x5418; -pub const FIONREAD: ::c_int = 0x4004667f; -pub const TIOCCONS: ::c_int = 0x541D; -pub const TIOCM_LE: ::c_int = 0x001; -pub const TIOCM_DTR: ::c_int = 0x002; -pub const TIOCM_RTS: ::c_int = 0x004; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; -pub const TIOCM_CD: ::c_int = TIOCM_CAR; -pub const TIOCM_RI: ::c_int = TIOCM_RNG; - -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; pub const RLIMIT_NLIMITS: ::c_int = 15; pub const RLIM_NLIMITS: ::c_int = RLIMIT_NLIMITS; -pub const TIOCINQ: ::c_int = ::FIONREAD; pub const MCL_CURRENT: ::c_int = 0x2000; pub const MCL_FUTURE: ::c_int = 0x4000; pub const CBAUD: ::tcflag_t = 0xff; @@ -732,7 +685,3 @@ pub const B3000000: ::speed_t = 0o00034; pub const B3500000: ::speed_t = 0o00035; pub const B4000000: ::speed_t = 0o00036; - -extern "C" { - pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; -} diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,699 @@ +//! RISC-V-specific definitions for 64-bit linux-like values + +pub type c_char = u8; +pub type wchar_t = ::c_int; + +pub type nlink_t = ::c_uint; +pub type blksize_t = ::c_int; +pub type fsblkcnt64_t = ::c_ulong; +pub type fsfilcnt64_t = ::c_ulong; +pub type __u64 = ::c_ulonglong; + +s! { + pub struct pthread_attr_t { + __size: [::c_ulong; 7], + } + + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub __pad1: ::dev_t, + pub st_size: ::off_t, + pub st_blksize: ::blksize_t, + pub __pad2: ::c_int, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_int; 2usize], + } + + pub struct stat64 { + pub st_dev: ::dev_t, + pub st_ino: ::ino64_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub __pad1: ::dev_t, + pub st_size: ::off64_t, + pub st_blksize: ::blksize_t, + pub __pad2: ::c_int, + pub st_blocks: ::blkcnt_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + __unused: [::c_int; 2], + } + + pub struct statfs { + pub f_type: ::c_long, + pub f_bsize: ::c_long, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_long, + pub f_frsize: ::c_long, + pub f_flags: ::c_long, + pub f_spare: [::c_long; 4], + } + + pub struct statfs64 { + pub f_type: ::c_long, + pub f_bsize: ::c_long, + pub f_blocks: ::fsblkcnt64_t, + pub f_bfree: ::fsblkcnt64_t, + pub f_bavail: ::fsblkcnt64_t, + pub f_files: ::fsfilcnt64_t, + pub f_ffree: ::fsfilcnt64_t, + pub f_fsid: ::fsid_t, + pub f_namelen: ::c_long, + pub f_frsize: ::c_long, + pub f_flags: ::c_long, + pub f_spare: [::c_long; 4], + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + pub __f_spare: [::c_int; 6], + } + + pub struct statvfs64 { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt64_t, + pub f_bfree: ::fsblkcnt64_t, + pub f_bavail: ::fsblkcnt64_t, + pub f_files: ::fsfilcnt64_t, + pub f_ffree: ::fsfilcnt64_t, + pub f_favail: ::fsfilcnt64_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + pub __f_spare: [::c_int; 6], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + #[doc(hidden)] + #[deprecated( + since="0.2.54", + note="Please leave a comment on \ + https://github.com/rust-lang/libc/pull/1316 if you're using \ + this field" + )] + pub _pad: [::c_int; 29], + _align: [u64; 0], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t, + } + + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_int, + pub sa_restorer: ::Option, + } + + pub struct ipc_perm { + pub __key: ::key_t, + pub uid: ::uid_t, + pub gid: ::gid_t, + pub cuid: ::uid_t, + pub cgid: ::gid_t, + pub mode: ::c_ushort, + __pad1: ::c_ushort, + pub __seq: ::c_ushort, + __pad2: ::c_ushort, + __unused1: ::c_ulong, + __unused2: ::c_ulong, + } + + pub struct shmid_ds { + pub shm_perm: ::ipc_perm, + pub shm_segsz: ::size_t, + pub shm_atime: ::time_t, + pub shm_dtime: ::time_t, + pub shm_ctime: ::time_t, + pub shm_cpid: ::pid_t, + pub shm_lpid: ::pid_t, + pub shm_nattch: ::shmatt_t, + __unused5: ::c_ulong, + __unused6: ::c_ulong, + } + + pub struct flock { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off_t, + pub l_len: ::off_t, + pub l_pid: ::pid_t, + } + + pub struct flock64 { + pub l_type: ::c_short, + pub l_whence: ::c_short, + pub l_start: ::off64_t, + pub l_len: ::off64_t, + pub l_pid: ::pid_t, + } +} + +pub const SYS_read: ::c_long = 63; +pub const SYS_write: ::c_long = 64; +pub const SYS_close: ::c_long = 57; +pub const SYS_fstat: ::c_long = 80; +pub const SYS_lseek: ::c_long = 62; +pub const SYS_mmap: ::c_long = 222; +pub const SYS_mprotect: ::c_long = 226; +pub const SYS_munmap: ::c_long = 215; +pub const SYS_brk: ::c_long = 214; +pub const SYS_rt_sigaction: ::c_long = 134; +pub const SYS_rt_sigprocmask: ::c_long = 135; +pub const SYS_rt_sigreturn: ::c_long = 139; +pub const SYS_ioctl: ::c_long = 29; +pub const SYS_pread64: ::c_long = 67; +pub const SYS_pwrite64: ::c_long = 68; +pub const SYS_readv: ::c_long = 65; +pub const SYS_writev: ::c_long = 66; +pub const SYS_sched_yield: ::c_long = 124; +pub const SYS_mremap: ::c_long = 216; +pub const SYS_msync: ::c_long = 227; +pub const SYS_mincore: ::c_long = 232; +pub const SYS_madvise: ::c_long = 233; +pub const SYS_shmget: ::c_long = 194; +pub const SYS_shmat: ::c_long = 196; +pub const SYS_shmctl: ::c_long = 195; +pub const SYS_dup: ::c_long = 23; +pub const SYS_nanosleep: ::c_long = 101; +pub const SYS_getitimer: ::c_long = 102; +pub const SYS_setitimer: ::c_long = 103; +pub const SYS_getpid: ::c_long = 172; +pub const SYS_sendfile: ::c_long = 71; +pub const SYS_socket: ::c_long = 198; +pub const SYS_connect: ::c_long = 203; +pub const SYS_accept: ::c_long = 202; +pub const SYS_sendto: ::c_long = 206; +pub const SYS_recvfrom: ::c_long = 207; +pub const SYS_sendmsg: ::c_long = 211; +pub const SYS_recvmsg: ::c_long = 212; +pub const SYS_shutdown: ::c_long = 210; +pub const SYS_bind: ::c_long = 200; +pub const SYS_listen: ::c_long = 201; +pub const SYS_getsockname: ::c_long = 204; +pub const SYS_getpeername: ::c_long = 205; +pub const SYS_socketpair: ::c_long = 199; +pub const SYS_setsockopt: ::c_long = 208; +pub const SYS_getsockopt: ::c_long = 209; +pub const SYS_clone: ::c_long = 220; +pub const SYS_execve: ::c_long = 221; +pub const SYS_exit: ::c_long = 93; +pub const SYS_wait4: ::c_long = 260; +pub const SYS_kill: ::c_long = 129; +pub const SYS_uname: ::c_long = 160; +pub const SYS_semget: ::c_long = 190; +pub const SYS_semop: ::c_long = 193; +pub const SYS_semctl: ::c_long = 191; +pub const SYS_shmdt: ::c_long = 197; +pub const SYS_msgget: ::c_long = 186; +pub const SYS_msgsnd: ::c_long = 189; +pub const SYS_msgrcv: ::c_long = 188; +pub const SYS_msgctl: ::c_long = 187; +pub const SYS_fcntl: ::c_long = 25; +pub const SYS_flock: ::c_long = 32; +pub const SYS_fsync: ::c_long = 82; +pub const SYS_fdatasync: ::c_long = 83; +pub const SYS_truncate: ::c_long = 45; +pub const SYS_ftruncate: ::c_long = 46; +pub const SYS_getcwd: ::c_long = 17; +pub const SYS_chdir: ::c_long = 49; +pub const SYS_fchdir: ::c_long = 50; +pub const SYS_fchmod: ::c_long = 52; +pub const SYS_fchown: ::c_long = 55; +pub const SYS_umask: ::c_long = 166; +pub const SYS_gettimeofday: ::c_long = 169; +pub const SYS_getrlimit: ::c_long = 163; +pub const SYS_getrusage: ::c_long = 165; +pub const SYS_sysinfo: ::c_long = 179; +pub const SYS_times: ::c_long = 153; +pub const SYS_ptrace: ::c_long = 117; +pub const SYS_getuid: ::c_long = 174; +pub const SYS_syslog: ::c_long = 116; +pub const SYS_getgid: ::c_long = 176; +pub const SYS_setuid: ::c_long = 146; +pub const SYS_setgid: ::c_long = 144; +pub const SYS_geteuid: ::c_long = 175; +pub const SYS_getegid: ::c_long = 177; +pub const SYS_setpgid: ::c_long = 154; +pub const SYS_getppid: ::c_long = 173; +pub const SYS_setsid: ::c_long = 157; +pub const SYS_setreuid: ::c_long = 145; +pub const SYS_setregid: ::c_long = 143; +pub const SYS_getgroups: ::c_long = 158; +pub const SYS_setgroups: ::c_long = 159; +pub const SYS_setresuid: ::c_long = 147; +pub const SYS_getresuid: ::c_long = 148; +pub const SYS_setresgid: ::c_long = 149; +pub const SYS_getresgid: ::c_long = 150; +pub const SYS_getpgid: ::c_long = 155; +pub const SYS_setfsuid: ::c_long = 151; +pub const SYS_setfsgid: ::c_long = 152; +pub const SYS_getsid: ::c_long = 156; +pub const SYS_capget: ::c_long = 90; +pub const SYS_capset: ::c_long = 91; +pub const SYS_rt_sigpending: ::c_long = 136; +pub const SYS_rt_sigtimedwait: ::c_long = 137; +pub const SYS_rt_sigqueueinfo: ::c_long = 138; +pub const SYS_rt_sigsuspend: ::c_long = 133; +pub const SYS_sigaltstack: ::c_long = 132; +pub const SYS_personality: ::c_long = 92; +pub const SYS_statfs: ::c_long = 43; +pub const SYS_fstatfs: ::c_long = 44; +pub const SYS_getpriority: ::c_long = 141; +pub const SYS_setpriority: ::c_long = 140; +pub const SYS_sched_setparam: ::c_long = 118; +pub const SYS_sched_getparam: ::c_long = 121; +pub const SYS_sched_setscheduler: ::c_long = 119; +pub const SYS_sched_getscheduler: ::c_long = 120; +pub const SYS_sched_get_priority_max: ::c_long = 125; +pub const SYS_sched_get_priority_min: ::c_long = 126; +pub const SYS_sched_rr_get_interval: ::c_long = 127; +pub const SYS_mlock: ::c_long = 228; +pub const SYS_munlock: ::c_long = 229; +pub const SYS_mlockall: ::c_long = 230; +pub const SYS_munlockall: ::c_long = 231; +pub const SYS_vhangup: ::c_long = 58; +pub const SYS_pivot_root: ::c_long = 41; +pub const SYS_prctl: ::c_long = 167; +pub const SYS_adjtimex: ::c_long = 171; +pub const SYS_setrlimit: ::c_long = 164; +pub const SYS_chroot: ::c_long = 51; +pub const SYS_sync: ::c_long = 81; +pub const SYS_acct: ::c_long = 89; +pub const SYS_settimeofday: ::c_long = 170; +pub const SYS_mount: ::c_long = 40; +pub const SYS_umount2: ::c_long = 39; +pub const SYS_swapon: ::c_long = 224; +pub const SYS_swapoff: ::c_long = 225; +pub const SYS_reboot: ::c_long = 142; +pub const SYS_sethostname: ::c_long = 161; +pub const SYS_setdomainname: ::c_long = 162; +pub const SYS_init_module: ::c_long = 105; +pub const SYS_delete_module: ::c_long = 106; +pub const SYS_quotactl: ::c_long = 60; +pub const SYS_nfsservctl: ::c_long = 42; +pub const SYS_gettid: ::c_long = 178; +pub const SYS_readahead: ::c_long = 213; +pub const SYS_setxattr: ::c_long = 5; +pub const SYS_lsetxattr: ::c_long = 6; +pub const SYS_fsetxattr: ::c_long = 7; +pub const SYS_getxattr: ::c_long = 8; +pub const SYS_lgetxattr: ::c_long = 9; +pub const SYS_fgetxattr: ::c_long = 10; +pub const SYS_listxattr: ::c_long = 11; +pub const SYS_llistxattr: ::c_long = 12; +pub const SYS_flistxattr: ::c_long = 13; +pub const SYS_removexattr: ::c_long = 14; +pub const SYS_lremovexattr: ::c_long = 15; +pub const SYS_fremovexattr: ::c_long = 16; +pub const SYS_tkill: ::c_long = 130; +pub const SYS_futex: ::c_long = 98; +pub const SYS_sched_setaffinity: ::c_long = 122; +pub const SYS_sched_getaffinity: ::c_long = 123; +pub const SYS_io_setup: ::c_long = 0; +pub const SYS_io_destroy: ::c_long = 1; +pub const SYS_io_getevents: ::c_long = 4; +pub const SYS_io_submit: ::c_long = 2; +pub const SYS_io_cancel: ::c_long = 3; +pub const SYS_lookup_dcookie: ::c_long = 18; +pub const SYS_remap_file_pages: ::c_long = 234; +pub const SYS_getdents64: ::c_long = 61; +pub const SYS_set_tid_address: ::c_long = 96; +pub const SYS_restart_syscall: ::c_long = 128; +pub const SYS_semtimedop: ::c_long = 192; +pub const SYS_fadvise64: ::c_long = 223; +pub const SYS_timer_create: ::c_long = 107; +pub const SYS_timer_settime: ::c_long = 110; +pub const SYS_timer_gettime: ::c_long = 108; +pub const SYS_timer_getoverrun: ::c_long = 109; +pub const SYS_timer_delete: ::c_long = 111; +pub const SYS_clock_settime: ::c_long = 112; +pub const SYS_clock_gettime: ::c_long = 113; +pub const SYS_clock_getres: ::c_long = 114; +pub const SYS_clock_nanosleep: ::c_long = 115; +pub const SYS_exit_group: ::c_long = 94; +pub const SYS_epoll_ctl: ::c_long = 21; +pub const SYS_tgkill: ::c_long = 131; +pub const SYS_mbind: ::c_long = 235; +pub const SYS_set_mempolicy: ::c_long = 237; +pub const SYS_get_mempolicy: ::c_long = 236; +pub const SYS_mq_open: ::c_long = 180; +pub const SYS_mq_unlink: ::c_long = 181; +pub const SYS_mq_timedsend: ::c_long = 182; +pub const SYS_mq_timedreceive: ::c_long = 183; +pub const SYS_mq_notify: ::c_long = 184; +pub const SYS_mq_getsetattr: ::c_long = 185; +pub const SYS_kexec_load: ::c_long = 104; +pub const SYS_waitid: ::c_long = 95; +pub const SYS_add_key: ::c_long = 217; +pub const SYS_request_key: ::c_long = 218; +pub const SYS_keyctl: ::c_long = 219; +pub const SYS_ioprio_set: ::c_long = 30; +pub const SYS_ioprio_get: ::c_long = 31; +pub const SYS_inotify_add_watch: ::c_long = 27; +pub const SYS_inotify_rm_watch: ::c_long = 28; +pub const SYS_migrate_pages: ::c_long = 238; +pub const SYS_openat: ::c_long = 56; +pub const SYS_mkdirat: ::c_long = 34; +pub const SYS_mknodat: ::c_long = 33; +pub const SYS_fchownat: ::c_long = 54; +pub const SYS_newfstatat: ::c_long = 79; +pub const SYS_unlinkat: ::c_long = 35; +pub const SYS_linkat: ::c_long = 37; +pub const SYS_symlinkat: ::c_long = 36; +pub const SYS_readlinkat: ::c_long = 78; +pub const SYS_fchmodat: ::c_long = 53; +pub const SYS_faccessat: ::c_long = 48; +pub const SYS_pselect6: ::c_long = 72; +pub const SYS_ppoll: ::c_long = 73; +pub const SYS_unshare: ::c_long = 97; +pub const SYS_set_robust_list: ::c_long = 99; +pub const SYS_get_robust_list: ::c_long = 100; +pub const SYS_splice: ::c_long = 76; +pub const SYS_tee: ::c_long = 77; +pub const SYS_sync_file_range: ::c_long = 84; +pub const SYS_vmsplice: ::c_long = 75; +pub const SYS_move_pages: ::c_long = 239; +pub const SYS_utimensat: ::c_long = 88; +pub const SYS_epoll_pwait: ::c_long = 22; +pub const SYS_timerfd_create: ::c_long = 85; +pub const SYS_fallocate: ::c_long = 47; +pub const SYS_timerfd_settime: ::c_long = 86; +pub const SYS_timerfd_gettime: ::c_long = 87; +pub const SYS_accept4: ::c_long = 242; +pub const SYS_signalfd4: ::c_long = 74; +pub const SYS_eventfd2: ::c_long = 19; +pub const SYS_epoll_create1: ::c_long = 20; +pub const SYS_dup3: ::c_long = 24; +pub const SYS_pipe2: ::c_long = 59; +pub const SYS_inotify_init1: ::c_long = 26; +pub const SYS_preadv: ::c_long = 69; +pub const SYS_pwritev: ::c_long = 70; +pub const SYS_rt_tgsigqueueinfo: ::c_long = 240; +pub const SYS_perf_event_open: ::c_long = 241; +pub const SYS_recvmmsg: ::c_long = 243; +pub const SYS_fanotify_init: ::c_long = 262; +pub const SYS_fanotify_mark: ::c_long = 263; +pub const SYS_prlimit64: ::c_long = 261; +pub const SYS_name_to_handle_at: ::c_long = 264; +pub const SYS_open_by_handle_at: ::c_long = 265; +pub const SYS_clock_adjtime: ::c_long = 266; +pub const SYS_syncfs: ::c_long = 267; +pub const SYS_sendmmsg: ::c_long = 269; +pub const SYS_setns: ::c_long = 268; +pub const SYS_getcpu: ::c_long = 168; +pub const SYS_process_vm_readv: ::c_long = 270; +pub const SYS_process_vm_writev: ::c_long = 271; +pub const SYS_kcmp: ::c_long = 272; +pub const SYS_finit_module: ::c_long = 273; +pub const SYS_sched_setattr: ::c_long = 274; +pub const SYS_sched_getattr: ::c_long = 275; +pub const SYS_renameat2: ::c_long = 276; +pub const SYS_seccomp: ::c_long = 277; +pub const SYS_getrandom: ::c_long = 278; +pub const SYS_memfd_create: ::c_long = 279; +pub const SYS_bpf: ::c_long = 280; +pub const SYS_execveat: ::c_long = 281; +pub const SYS_userfaultfd: ::c_long = 282; +pub const SYS_membarrier: ::c_long = 283; +pub const SYS_mlock2: ::c_long = 284; +pub const SYS_copy_file_range: ::c_long = 285; +pub const SYS_preadv2: ::c_long = 286; +pub const SYS_pwritev2: ::c_long = 287; +pub const SYS_pkey_mprotect: ::c_long = 288; +pub const SYS_pkey_alloc: ::c_long = 289; +pub const SYS_pkey_free: ::c_long = 290; +pub const SYS_statx: ::c_long = 291; + +pub const O_APPEND: ::c_int = 1024; +pub const O_DIRECT: ::c_int = 0x4000; +pub const O_DIRECTORY: ::c_int = 0x10000; +pub const O_LARGEFILE: ::c_int = 0; +pub const O_NOFOLLOW: ::c_int = 0x20000; +pub const O_CREAT: ::c_int = 64; +pub const O_EXCL: ::c_int = 128; +pub const O_NOCTTY: ::c_int = 256; +pub const O_NONBLOCK: ::c_int = 2048; +pub const O_SYNC: ::c_int = 1052672; +pub const O_RSYNC: ::c_int = 1052672; +pub const O_DSYNC: ::c_int = 4096; +pub const O_ASYNC: ::c_int = 0x2000; + +pub const SIGSTKSZ: ::size_t = 8192; +pub const MINSIGSTKSZ: ::size_t = 2048; + +pub const ENAMETOOLONG: ::c_int = 36; +pub const ENOLCK: ::c_int = 37; +pub const ENOSYS: ::c_int = 38; +pub const ENOTEMPTY: ::c_int = 39; +pub const ELOOP: ::c_int = 40; +pub const ENOMSG: ::c_int = 42; +pub const EIDRM: ::c_int = 43; +pub const ECHRNG: ::c_int = 44; +pub const EL2NSYNC: ::c_int = 45; +pub const EL3HLT: ::c_int = 46; +pub const EL3RST: ::c_int = 47; +pub const ELNRNG: ::c_int = 48; +pub const EUNATCH: ::c_int = 49; +pub const ENOCSI: ::c_int = 50; +pub const EL2HLT: ::c_int = 51; +pub const EBADE: ::c_int = 52; +pub const EBADR: ::c_int = 53; +pub const EXFULL: ::c_int = 54; +pub const ENOANO: ::c_int = 55; +pub const EBADRQC: ::c_int = 56; +pub const EBADSLT: ::c_int = 57; +pub const EMULTIHOP: ::c_int = 72; +pub const EOVERFLOW: ::c_int = 75; +pub const ENOTUNIQ: ::c_int = 76; +pub const EBADFD: ::c_int = 77; +pub const EBADMSG: ::c_int = 74; +pub const EREMCHG: ::c_int = 78; +pub const ELIBACC: ::c_int = 79; +pub const ELIBBAD: ::c_int = 80; +pub const ELIBSCN: ::c_int = 81; +pub const ELIBMAX: ::c_int = 82; +pub const ELIBEXEC: ::c_int = 83; +pub const EILSEQ: ::c_int = 84; +pub const ERESTART: ::c_int = 85; +pub const ESTRPIPE: ::c_int = 86; +pub const EUSERS: ::c_int = 87; +pub const ENOTSOCK: ::c_int = 88; +pub const EDESTADDRREQ: ::c_int = 89; +pub const EMSGSIZE: ::c_int = 90; +pub const EPROTOTYPE: ::c_int = 91; +pub const ENOPROTOOPT: ::c_int = 92; +pub const EPROTONOSUPPORT: ::c_int = 93; +pub const ESOCKTNOSUPPORT: ::c_int = 94; +pub const EOPNOTSUPP: ::c_int = 95; +pub const EPFNOSUPPORT: ::c_int = 96; +pub const EAFNOSUPPORT: ::c_int = 97; +pub const EADDRINUSE: ::c_int = 98; +pub const EADDRNOTAVAIL: ::c_int = 99; +pub const ENETDOWN: ::c_int = 100; +pub const ENETUNREACH: ::c_int = 101; +pub const ENETRESET: ::c_int = 102; +pub const ECONNABORTED: ::c_int = 103; +pub const ECONNRESET: ::c_int = 104; +pub const ENOBUFS: ::c_int = 105; +pub const EISCONN: ::c_int = 106; +pub const ENOTCONN: ::c_int = 107; +pub const ESHUTDOWN: ::c_int = 108; +pub const ETOOMANYREFS: ::c_int = 109; +pub const ETIMEDOUT: ::c_int = 110; +pub const ECONNREFUSED: ::c_int = 111; +pub const EHOSTDOWN: ::c_int = 112; +pub const EHOSTUNREACH: ::c_int = 113; +pub const EALREADY: ::c_int = 114; +pub const EINPROGRESS: ::c_int = 115; +pub const ESTALE: ::c_int = 116; +pub const EDQUOT: ::c_int = 122; +pub const ENOMEDIUM: ::c_int = 123; +pub const EMEDIUMTYPE: ::c_int = 124; +pub const ECANCELED: ::c_int = 125; +pub const ENOKEY: ::c_int = 126; +pub const EKEYEXPIRED: ::c_int = 127; +pub const EKEYREVOKED: ::c_int = 128; +pub const EKEYREJECTED: ::c_int = 129; +pub const EOWNERDEAD: ::c_int = 130; +pub const ENOTRECOVERABLE: ::c_int = 131; +pub const EHWPOISON: ::c_int = 133; +pub const ERFKILL: ::c_int = 132; + +pub const SA_ONSTACK: ::c_int = 0x08000000; +pub const SA_SIGINFO: ::c_int = 0x00000004; +pub const SA_NOCLDWAIT: ::c_int = 0x00000002; + +pub const SIGCHLD: ::c_int = 17; +pub const SIGBUS: ::c_int = 7; +pub const SIGTTIN: ::c_int = 21; +pub const SIGTTOU: ::c_int = 22; +pub const SIGXCPU: ::c_int = 24; +pub const SIGXFSZ: ::c_int = 25; +pub const SIGVTALRM: ::c_int = 26; +pub const SIGPROF: ::c_int = 27; +pub const SIGWINCH: ::c_int = 28; +pub const SIGUSR1: ::c_int = 10; +pub const SIGUSR2: ::c_int = 12; +pub const SIGCONT: ::c_int = 18; +pub const SIGSTOP: ::c_int = 19; +pub const SIGTSTP: ::c_int = 20; +pub const SIGURG: ::c_int = 23; +pub const SIGIO: ::c_int = 29; +pub const SIGSYS: ::c_int = 31; +pub const SIGSTKFLT: ::c_int = 16; +pub const SIGPOLL: ::c_int = 29; +pub const SIGPWR: ::c_int = 30; +pub const SIG_SETMASK: ::c_int = 2; +pub const SIG_BLOCK: ::c_int = 0x000000; +pub const SIG_UNBLOCK: ::c_int = 0x01; + +pub const F_GETLK: ::c_int = 5; +pub const F_GETOWN: ::c_int = 9; +pub const F_SETLK: ::c_int = 6; +pub const F_SETLKW: ::c_int = 7; +pub const F_SETOWN: ::c_int = 8; +pub const F_OFD_GETLK: ::c_int = 36; +pub const F_OFD_SETLK: ::c_int = 37; +pub const F_OFD_SETLKW: ::c_int = 38; + +pub const VEOF: usize = 4; + +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; + +pub const SOCK_STREAM: ::c_int = 1; +pub const SOCK_DGRAM: ::c_int = 2; + +pub const MAP_ANON: ::c_int = 0x0020; +pub const MAP_GROWSDOWN: ::c_int = 0x0100; +pub const MAP_DENYWRITE: ::c_int = 0x0800; +pub const MAP_EXECUTABLE: ::c_int = 0x01000; +pub const MAP_LOCKED: ::c_int = 0x02000; +pub const MAP_NORESERVE: ::c_int = 0x04000; +pub const MAP_POPULATE: ::c_int = 0x08000; +pub const MAP_NONBLOCK: ::c_int = 0x010000; +pub const MAP_STACK: ::c_int = 0x020000; +pub const MAP_HUGETLB: ::c_int = 0x040000; +pub const MAP_SYNC: ::c_int = 0x080000; + +pub const RLIMIT_NLIMITS: ::c_int = 15; +pub const MCL_CURRENT: ::c_int = 0x0001; +pub const MCL_FUTURE: ::c_int = 0x0002; +pub const CBAUD: ::tcflag_t = 0o0010017; +pub const TAB1: ::c_int = 0x00000800; +pub const TAB2: ::c_int = 0x00001000; +pub const TAB3: ::c_int = 0x00001800; +pub const CR1: ::c_int = 0x00000200; +pub const CR2: ::c_int = 0x00000400; +pub const CR3: ::c_int = 0x00000600; +pub const FF1: ::c_int = 0x00008000; +pub const BS1: ::c_int = 0x00002000; +pub const VT1: ::c_int = 0x00004000; +pub const VWERASE: usize = 14; +pub const VREPRINT: usize = 12; +pub const VSUSP: usize = 10; +pub const VSTART: usize = 8; +pub const VSTOP: usize = 9; +pub const VDISCARD: usize = 13; +pub const VTIME: usize = 5; +pub const IXON: ::tcflag_t = 0x00000400; +pub const IXOFF: ::tcflag_t = 0x00001000; +pub const ONLCR: ::tcflag_t = 0x4; +pub const CSIZE: ::tcflag_t = 0x00000030; +pub const CS6: ::tcflag_t = 0x00000010; +pub const CS7: ::tcflag_t = 0x00000020; +pub const CS8: ::tcflag_t = 0x00000030; +pub const CSTOPB: ::tcflag_t = 0x00000040; +pub const CREAD: ::tcflag_t = 0x00000080; +pub const PARENB: ::tcflag_t = 0x00000100; +pub const PARODD: ::tcflag_t = 0x00000200; +pub const HUPCL: ::tcflag_t = 0x00000400; +pub const CLOCAL: ::tcflag_t = 0x00000800; +pub const ECHOKE: ::tcflag_t = 0x00000800; +pub const ECHOE: ::tcflag_t = 0x00000010; +pub const ECHOK: ::tcflag_t = 0x00000020; +pub const ECHONL: ::tcflag_t = 0x00000040; +pub const ECHOPRT: ::tcflag_t = 0x00000400; +pub const ECHOCTL: ::tcflag_t = 0x00000200; +pub const ISIG: ::tcflag_t = 0x00000001; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const PENDIN: ::tcflag_t = 0x00004000; +pub const NOFLSH: ::tcflag_t = 0x00000080; +pub const CIBAUD: ::tcflag_t = 0o02003600000; +pub const CBAUDEX: ::tcflag_t = 0o010000; +pub const VSWTC: usize = 7; +pub const OLCUC: ::tcflag_t = 0o000002; +pub const NLDLY: ::tcflag_t = 0o000400; +pub const CRDLY: ::tcflag_t = 0o003000; +pub const TABDLY: ::tcflag_t = 0o014000; +pub const BSDLY: ::tcflag_t = 0o020000; +pub const FFDLY: ::tcflag_t = 0o100000; +pub const VTDLY: ::tcflag_t = 0o040000; +pub const XTABS: ::tcflag_t = 0o014000; +pub const B57600: ::speed_t = 0o010001; +pub const B115200: ::speed_t = 0o010002; +pub const B230400: ::speed_t = 0o010003; +pub const B460800: ::speed_t = 0o010004; +pub const B500000: ::speed_t = 0o010005; +pub const B576000: ::speed_t = 0o010006; +pub const B921600: ::speed_t = 0o010007; +pub const B1000000: ::speed_t = 0o010010; +pub const B1152000: ::speed_t = 0o010011; +pub const B1500000: ::speed_t = 0o010012; +pub const B2000000: ::speed_t = 0o010013; +pub const B2500000: ::speed_t = 0o010014; +pub const B3000000: ::speed_t = 0o010015; +pub const B3500000: ::speed_t = 0o010016; +pub const B4000000: ::speed_t = 0o010017; + +pub const EDEADLK: ::c_int = 35; +pub const EDEADLOCK: ::c_int = EDEADLK; +pub const EXTPROC: ::tcflag_t = 0x00010000; +pub const VEOL: usize = 11; +pub const VEOL2: usize = 16; +pub const VMIN: usize = 6; +pub const IEXTEN: ::tcflag_t = 0x00008000; +pub const TOSTOP: ::tcflag_t = 0x00000100; +pub const FLUSHO: ::tcflag_t = 0x00001000; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b64/s390x.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/s390x.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b64/s390x.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/s390x.rs 2022-01-21 02:47:39.000000000 +0000 @@ -141,9 +141,6 @@ pub const ENOSYS: ::c_int = 38; pub const ENOTCONN: ::c_int = 107; pub const ETIMEDOUT: ::c_int = 110; -pub const FIOCLEX: ::c_ulong = 0x5451; -pub const FIONCLEX: ::c_ulong = 0x5450; -pub const FIONBIO: ::c_ulong = 0x5421; pub const O_APPEND: ::c_int = 1024; pub const O_CREAT: ::c_int = 64; pub const O_EXCL: ::c_int = 128; @@ -296,45 +293,6 @@ pub const F_OFD_SETLK: ::c_int = 37; pub const F_OFD_SETLKW: ::c_int = 38; -pub const TCGETS: ::c_int = 0x5401; -pub const TCSETS: ::c_int = 0x5402; -pub const TCSETSW: ::c_int = 0x5403; -pub const TCSETSF: ::c_int = 0x5404; -pub const TCGETA: ::c_int = 0x5405; -pub const TCSETA: ::c_int = 0x5406; -pub const TCSETAW: ::c_int = 0x5407; -pub const TCSETAF: ::c_int = 0x5408; -pub const TCSBRK: ::c_int = 0x5409; -pub const TCXONC: ::c_int = 0x540A; -pub const TCFLSH: ::c_int = 0x540B; -pub const TIOCGSOFTCAR: ::c_int = 0x5419; -pub const TIOCSSOFTCAR: ::c_int = 0x541A; -pub const TIOCINQ: ::c_int = 0x541B; -pub const TIOCEXCL: ::c_int = 0x540C; -pub const TIOCNXCL: ::c_int = 0x540D; -pub const TIOCSCTTY: ::c_int = 0x540E; -pub const TIOCGPGRP: ::c_int = 0x540F; -pub const TIOCSPGRP: ::c_int = 0x5410; -pub const TIOCOUTQ: ::c_int = 0x5411; -pub const TIOCSTI: ::c_int = 0x5412; -pub const TIOCGWINSZ: ::c_int = 0x5413; -pub const TIOCSWINSZ: ::c_int = 0x5414; -pub const TIOCMGET: ::c_int = 0x5415; -pub const TIOCMBIS: ::c_int = 0x5416; -pub const TIOCMBIC: ::c_int = 0x5417; -pub const TIOCMSET: ::c_int = 0x5418; -pub const FIONREAD: ::c_int = 0x541B; -pub const TIOCCONS: ::c_int = 0x541D; - -pub const TIOCLINUX: ::c_int = 0x541C; -pub const TIOCGSERIAL: ::c_int = 0x541E; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; - pub const VTIME: usize = 5; pub const VSWTC: usize = 7; pub const VSTART: usize = 8; @@ -374,7 +332,6 @@ pub const HUPCL: ::tcflag_t = 0o002000; pub const CLOCAL: ::tcflag_t = 0o004000; pub const CBAUDEX: ::tcflag_t = 0o010000; -pub const BOTHER: ::speed_t = 0o010000; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; @@ -752,7 +709,3 @@ pub const SYS_process_madvise: ::c_long = 440; pub const SYS_epoll_pwait2: ::c_long = 441; pub const SYS_mount_setattr: ::c_long = 442; - -extern "C" { - pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; -} diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -673,9 +673,6 @@ pub const O_DSYNC: ::c_int = 4096; pub const O_ASYNC: ::c_int = 0x2000; -pub const TIOCGRS485: ::c_int = 0x542E; -pub const TIOCSRS485: ::c_int = 0x542F; - pub const SIGSTKSZ: ::size_t = 8192; pub const MINSIGSTKSZ: ::size_t = 2048; @@ -822,7 +819,6 @@ pub const RLIMIT_NLIMITS: ::c_int = 15; pub const RLIM_NLIMITS: ::c_int = RLIMIT_NLIMITS; -pub const TIOCINQ: ::c_int = ::FIONREAD; pub const MCL_CURRENT: ::c_int = 0x0001; pub const MCL_FUTURE: ::c_int = 0x0002; pub const CBAUD: ::tcflag_t = 0o0010017; @@ -892,9 +888,6 @@ pub const B3500000: ::speed_t = 0o010016; pub const B4000000: ::speed_t = 0o010017; -pub const FIOCLEX: ::c_int = 0x5451; -pub const FIONCLEX: ::c_int = 0x5450; -pub const FIONBIO: ::c_int = 0x5421; pub const EDEADLK: ::c_int = 35; pub const EDEADLOCK: ::c_int = EDEADLK; @@ -905,52 +898,6 @@ pub const IEXTEN: ::tcflag_t = 0x00008000; pub const TOSTOP: ::tcflag_t = 0x00000100; pub const FLUSHO: ::tcflag_t = 0x00001000; -pub const TCGETS: ::c_int = 0x5401; -pub const TCSETS: ::c_int = 0x5402; -pub const TCSETSW: ::c_int = 0x5403; -pub const TCSETSF: ::c_int = 0x5404; -pub const TCGETA: ::c_int = 0x5405; -pub const TCSETA: ::c_int = 0x5406; -pub const TCSETAW: ::c_int = 0x5407; -pub const TCSETAF: ::c_int = 0x5408; -pub const TCSBRK: ::c_int = 0x5409; -pub const TCXONC: ::c_int = 0x540A; -pub const TCFLSH: ::c_int = 0x540B; -pub const TIOCGSOFTCAR: ::c_int = 0x5419; -pub const TIOCSSOFTCAR: ::c_int = 0x541A; -pub const TIOCLINUX: ::c_int = 0x541C; -pub const TIOCGSERIAL: ::c_int = 0x541E; -pub const TIOCEXCL: ::c_int = 0x540C; -pub const TIOCNXCL: ::c_int = 0x540D; -pub const TIOCSCTTY: ::c_int = 0x540E; -pub const TIOCGPGRP: ::c_int = 0x540F; -pub const TIOCSPGRP: ::c_int = 0x5410; -pub const TIOCOUTQ: ::c_int = 0x5411; -pub const TIOCSTI: ::c_int = 0x5412; -pub const TIOCGWINSZ: ::c_int = 0x5413; -pub const TIOCSWINSZ: ::c_int = 0x5414; -pub const TIOCMGET: ::c_int = 0x5415; -pub const TIOCMBIS: ::c_int = 0x5416; -pub const TIOCMBIC: ::c_int = 0x5417; -pub const TIOCMSET: ::c_int = 0x5418; -pub const FIONREAD: ::c_int = 0x541B; -pub const TIOCCONS: ::c_int = 0x541D; - -pub const TIOCM_LE: ::c_int = 0x001; -pub const TIOCM_DTR: ::c_int = 0x002; -pub const TIOCM_RTS: ::c_int = 0x004; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_DSR: ::c_int = 0x100; -pub const TIOCM_CD: ::c_int = TIOCM_CAR; -pub const TIOCM_RI: ::c_int = TIOCM_RNG; - -extern "C" { - pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; -} cfg_if! { if #[cfg(libc_align)] { diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/musl/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/musl/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -24,6 +24,16 @@ pub type flock64 = flock; +cfg_if! { + if #[cfg(doc)] { + // Used in `linux::arch` to define ioctl constants. + pub(crate) type Ioctl = ::c_int; + } else { + #[doc(hidden)] + pub type Ioctl = ::c_int; + } +} + impl siginfo_t { pub unsafe fn si_addr(&self) -> *mut ::c_void { #[repr(C)] @@ -628,9 +638,6 @@ pub const REG_OK: ::c_int = 0; -pub const TIOCSBRK: ::c_int = 0x5427; -pub const TIOCCBRK: ::c_int = 0x5428; - pub const PRIO_PROCESS: ::c_int = 0; pub const PRIO_PGRP: ::c_int = 1; pub const PRIO_USER: ::c_int = 2; @@ -735,6 +742,7 @@ old_limit: *mut ::rlimit64, ) -> ::c_int; + pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; pub fn ptrace(request: ::c_int, ...) -> ::c_long; pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; @@ -758,6 +766,11 @@ pub fn adjtimex(buf: *mut ::timex) -> ::c_int; pub fn clock_adjtime(clk_id: ::clockid_t, buf: *mut ::timex) -> ::c_int; + + pub fn ctermid(s: *mut ::c_char) -> *mut ::c_char; + + pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int; + pub fn mlock2(addr: *const ::c_void, len: ::size_t, flags: ::c_uint) -> ::c_int; } cfg_if! { @@ -765,7 +778,8 @@ target_arch = "aarch64", target_arch = "mips64", target_arch = "powerpc64", - target_arch = "s390x"))] { + target_arch = "s390x", + target_arch = "riscv64"))] { mod b64; pub use self::b64::*; } else if #[cfg(any(target_arch = "x86", diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/non_exhaustive.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/non_exhaustive.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/non_exhaustive.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/non_exhaustive.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,9 @@ +s! { + // linux/openat2.h + #[non_exhaustive] + pub struct open_how { + pub flags: ::__u64, + pub mode: ::__u64, + pub resolve: ::__u64, + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/uclibc/arm/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/arm/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/uclibc/arm/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/arm/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -44,14 +44,14 @@ pub struct stat { pub st_dev: ::c_ulonglong, - pub __pad1: ::c_ushort, + __pad1: ::c_ushort, pub st_ino: ::ino_t, pub st_mode: ::mode_t, pub st_nlink: ::nlink_t, pub st_uid: ::uid_t, pub st_gid: ::gid_t, pub st_rdev: ::c_ulonglong, - pub __pad2: ::c_ushort, + __pad2: ::c_ushort, pub st_size: ::off_t, pub st_blksize: ::blksize_t, pub st_blocks: ::blkcnt_t, @@ -61,8 +61,8 @@ pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, - pub __unused4: ::c_ulong, - pub __unused5: ::c_ulong, + __unused4: ::c_ulong, + __unused5: ::c_ulong, } pub struct stat64 @@ -202,44 +202,44 @@ pub cuid: ::uid_t, pub cgid: ::gid_t, pub mode: ::c_ushort, - pub __pad1: ::c_ushort, + __pad1: ::c_ushort, pub __seq: ::c_ushort, - pub __pad2: ::c_ushort, - pub __unused1: ::c_ulong, - pub __unused2: ::c_ulong, + __pad2: ::c_ushort, + __unused1: ::c_ulong, + __unused2: ::c_ulong, } pub struct msqid_ds { pub msg_perm: ::ipc_perm, pub msg_stime: ::time_t, - pub __unused1: ::c_ulong, + __unused1: ::c_ulong, pub msg_rtime: ::time_t, - pub __unused2: ::c_ulong, + __unused2: ::c_ulong, pub msg_ctime: ::time_t, - pub __unused3: ::c_ulong, - pub __msg_cbytes: ::c_ulong, + __unused3: ::c_ulong, + __msg_cbytes: ::c_ulong, pub msg_qnum: ::msgqnum_t, pub msg_qbytes: ::msglen_t, pub msg_lspid: ::pid_t, pub msg_lrpid: ::pid_t, - pub __unused4: ::c_ulong, - pub __unused5: ::c_ulong, + __unused4: ::c_ulong, + __unused5: ::c_ulong, } pub struct shmid_ds { pub shm_perm: ::ipc_perm, pub shm_segsz: ::size_t, pub shm_atime: ::time_t, - pub __unused1: ::c_ulong, + __unused1: ::c_ulong, pub shm_dtime: ::time_t, - pub __unused2: ::c_ulong, + __unused2: ::c_ulong, pub shm_ctime: ::time_t, - pub __unused3: ::c_ulong, + __unused3: ::c_ulong, pub shm_cpid: ::pid_t, pub shm_lpid: ::pid_t, pub shm_nattch: ::shmatt_t, - pub __unused4: ::c_ulong, - pub __unused5: ::c_ulong, + __unused4: ::c_ulong, + __unused5: ::c_ulong, } } @@ -417,9 +417,6 @@ pub const EXFULL: ::c_int = 0x36; pub const FF1: ::c_int = 0x8000; pub const FFDLY: ::c_int = 0x8000; -pub const FIONBIO: ::c_ulong = 0x5421; -pub const FIOCLEX: ::c_ulong = 0x5451; -pub const FIONCLEX: ::c_ulong = 0x5450; pub const FLUSHO: ::tcflag_t = 0x1000; pub const F_GETLK: ::c_int = 0x5; pub const F_SETLK: ::c_int = 0x6; @@ -517,8 +514,6 @@ pub const TCSADRAIN: ::c_int = 0x1; pub const TCSAFLUSH: ::c_int = 0x2; pub const TCSANOW: ::c_int = 0; -pub const TIOCGWINSZ: ::c_int = 0x5413; -pub const TIOCSWINSZ: ::c_int = 0x5414; pub const TOSTOP: ::tcflag_t = 0x100; pub const VDISCARD: usize = 0xd; pub const VEOF: usize = 0x4; @@ -893,10 +888,6 @@ pub const SYS_pidfd_open: ::c_long = 434; pub const SYS_clone3: ::c_long = 435; -extern "C" { - pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; -} - cfg_if! { if #[cfg(libc_align)] { mod align; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -637,7 +637,6 @@ newp: *mut ::c_void, newlen: ::size_t, ) -> ::c_int; - pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; pub fn glob64( pattern: *const ::c_char, flags: ::c_int, diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -197,11 +197,6 @@ pub const SYS_gettid: ::c_long = 5178; // Valid for n64 -#[link(name = "util")] -extern "C" { - pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; -} - cfg_if! { if #[cfg(libc_align)] { mod align; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -154,10 +154,6 @@ pub const SOCK_DGRAM: ::c_int = 1; pub const SOCK_SEQPACKET: ::c_int = 5; -pub const FIOCLEX: ::c_ulong = 0x6601; -pub const FIONCLEX: ::c_ulong = 0x6602; -pub const FIONBIO: ::c_ulong = 0x667e; - pub const SA_ONSTACK: ::c_uint = 0x08000000; pub const SA_SIGINFO: ::c_uint = 0x00000008; pub const SA_NOCLDWAIT: ::c_int = 0x00010000; @@ -210,9 +206,6 @@ pub const SFD_NONBLOCK: ::c_int = 0x80; -pub const TIOCGWINSZ: ::c_ulong = 0x40087468; -pub const TIOCSWINSZ: ::c_ulong = 0x80087467; - pub const RTLD_GLOBAL: ::c_int = 0x4; pub const SIGSTKSZ: ::size_t = 8192; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/uclibc/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/linux/uclibc/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/linux/uclibc/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -5,6 +5,16 @@ pub type __rlimit_resource_t = ::c_uint; pub type __priority_which_t = ::c_uint; +cfg_if! { + if #[cfg(doc)] { + // Used in `linux::arch` to define ioctl constants. + pub(crate) type Ioctl = ::c_ulong; + } else { + #[doc(hidden)] + pub type Ioctl = ::c_ulong; + } +} + s! { pub struct statvfs { // Different than GNU! pub f_bsize: ::c_ulong, @@ -62,6 +72,12 @@ pub e_termination: ::c_short, pub e_exit: ::c_short, } + + pub struct ptrace_peeksiginfo_args { + pub off: ::__u64, + pub flags: ::__u32, + pub nr: ::__s32, + } } pub const MCL_CURRENT: ::c_int = 0x0001; @@ -150,7 +166,6 @@ pub const PTRACE_SEIZE: ::c_int = 0x4206; pub const PTRACE_INTERRUPT: ::c_int = 0x4207; pub const PTRACE_LISTEN: ::c_int = 0x4208; -pub const PTRACE_O_MASK: ::c_int = 0x000000ff; pub const POSIX_FADV_DONTNEED: ::c_int = 4; pub const POSIX_FADV_NOREUSE: ::c_int = 5; @@ -256,11 +271,10 @@ pub const EDEADLOCK: ::c_int = EDEADLK; pub const EXTA: ::c_uint = B19200; pub const EXTB: ::c_uint = B38400; -pub const EXTPROC: ::c_int = 0200000; +pub const EXTPROC: ::tcflag_t = 0200000; pub const FAN_MARK_FILESYSTEM: ::c_int = 0x00000100; pub const FAN_MARK_INODE: ::c_int = 0x00000000; pub const FAN_MARK_MOUNT: ::c_int = 0x10; -pub const FIONREAD: ::c_int = 0x541B; pub const FOPEN_MAX: ::c_int = 16; pub const F_GETOWN: ::c_int = 9; pub const F_OFD_GETLK: ::c_int = 36; @@ -289,7 +303,7 @@ pub const MINSIGSTKSZ: ::c_int = 2048; pub const MSG_COPY: ::c_int = 040000; pub const NI_MAXHOST: ::socklen_t = 1025; -pub const O_TMPFILE: ::c_int = 020000000 | O_DIRECTORY; +pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY; pub const PACKET_MR_UNICAST: ::c_int = 3; pub const PF_NFC: ::c_int = 39; pub const PF_VSOCK: ::c_int = 40; @@ -309,51 +323,13 @@ pub const SIGPOLL: ::c_int = SIGIO; pub const SOCK_DCCP: ::c_int = 6; pub const SOCK_PACKET: ::c_int = 10; -pub const TCFLSH: ::c_int = 0x540B; -pub const TCGETA: ::c_int = 0x5405; -pub const TCGETS: ::c_int = 0x5401; pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; -pub const TCSBRK: ::c_int = 0x5409; -pub const TCSETA: ::c_int = 0x5406; -pub const TCSETAF: ::c_int = 0x5408; -pub const TCSETAW: ::c_int = 0x5407; -pub const TCSETS: ::c_int = 0x5402; -pub const TCSETSF: ::c_int = 0x5404; -pub const TCSETSW: ::c_int = 0x5403; -pub const TCXONC: ::c_int = 0x540A; -pub const TIOCCONS: ::c_int = 0x541D; -pub const TIOCEXCL: ::c_int = 0x540C; -pub const TIOCGPGRP: ::c_int = 0x540F; -pub const TIOCGSERIAL: ::c_int = 0x541E; -pub const TIOCGSOFTCAR: ::c_int = 0x5419; -pub const TIOCINQ: ::c_int = FIONREAD; -pub const TIOCLINUX: ::c_int = 0x541C; -pub const TIOCMBIC: ::c_int = 0x5417; -pub const TIOCMGET: ::c_int = 0x5415; -pub const TIOCMBIS: ::c_int = 0x5416; -pub const TIOCMSET: ::c_int = 0x5418; -pub const TIOCM_CAR: ::c_int = 0x040; -pub const TIOCM_CD: ::c_int = TIOCM_CAR; -pub const TIOCM_CTS: ::c_int = 0x020; -pub const TIOCM_DSR: ::c_int = 0x100; -pub const TIOCM_DTR: ::c_int = 0x002; -pub const TIOCM_LE: ::c_int = 0x001; -pub const TIOCM_RI: ::c_int = TIOCM_RNG; -pub const TIOCM_RNG: ::c_int = 0x080; -pub const TIOCM_RTS: ::c_int = 0x004; -pub const TIOCM_SR: ::c_int = 0x010; -pub const TIOCM_ST: ::c_int = 0x008; -pub const TIOCNXCL: ::c_int = 0x540D; -pub const TIOCOUTQ: ::c_int = 0x5411; -pub const TIOCSCTTY: ::c_int = 0x540E; -pub const TIOCSPGRP: ::c_int = 0x5410; -pub const TIOCSSOFTCAR: ::c_int = 0x541A; -pub const TIOCSTI: ::c_int = 0x5412; pub const UDP_GRO: ::c_int = 104; pub const UDP_SEGMENT: ::c_int = 103; pub const YESEXPR: ::c_int = ((5) << 8) | (0); extern "C" { + pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int; pub fn pthread_rwlockattr_getkind_np( diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/mod.rs cargo-0.58.0/vendor/libc/src/unix/linux_like/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/linux_like/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/linux_like/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1045,8 +1045,10 @@ pub const EPOLL_CTL_MOD: ::c_int = 3; pub const EPOLL_CTL_DEL: ::c_int = 2; +pub const MNT_FORCE: ::c_int = 0x1; pub const MNT_DETACH: ::c_int = 0x2; pub const MNT_EXPIRE: ::c_int = 0x4; +pub const UMOUNT_NOFOLLOW: ::c_int = 0x8; pub const Q_GETFMT: ::c_int = 0x800004; pub const Q_GETINFO: ::c_int = 0x800005; @@ -1062,8 +1064,6 @@ pub const QIF_TIMES: u32 = 48; pub const QIF_ALL: u32 = 63; -pub const MNT_FORCE: ::c_int = 0x1; - pub const Q_SYNC: ::c_int = 0x800001; pub const Q_QUOTAON: ::c_int = 0x800002; pub const Q_QUOTAOFF: ::c_int = 0x800003; @@ -1163,6 +1163,7 @@ pub const PTRACE_O_TRACESECCOMP: ::c_int = 0x00000080; pub const PTRACE_O_SUSPEND_SECCOMP: ::c_int = 0x00200000; pub const PTRACE_O_EXITKILL: ::c_int = 0x00100000; +pub const PTRACE_O_MASK: ::c_int = 0x003000ff; // Wait extended result codes for the above trace options. pub const PTRACE_EVENT_FORK: ::c_int = 1; @@ -1237,6 +1238,10 @@ pub const POLLNVAL: ::c_short = 0x20; pub const POLLRDNORM: ::c_short = 0x040; pub const POLLRDBAND: ::c_short = 0x080; +#[cfg(not(any(target_arch = "sparc", target_arch = "sparc64")))] +pub const POLLRDHUP: ::c_short = 0x2000; +#[cfg(any(target_arch = "sparc", target_arch = "sparc64"))] +pub const POLLRDHUP: ::c_short = 0x800; pub const IPTOS_LOWDELAY: u8 = 0x10; pub const IPTOS_THROUGHPUT: u8 = 0x08; @@ -1360,12 +1365,6 @@ pub const ARPHRD_VOID: u16 = 0xFFFF; pub const ARPHRD_NONE: u16 = 0xFFFE; -cfg_if! { - if #[cfg(not(target_env = "uclibc"))] { - pub const PTRACE_O_MASK: ::c_int = 0x003000ff; - } -} - const_fn! { {const} fn CMSG_ALIGN(len: usize) -> usize { len + ::mem::size_of::() - 1 & !(::mem::size_of::() - 1) diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/mod.rs cargo-0.58.0/vendor/libc/src/unix/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -305,21 +305,21 @@ } else if #[cfg(all(target_os = "linux", any(target_env = "gnu", target_env = "uclibc"), feature = "rustc-dep-of-std"))] { - #[link(name = "util", kind = "static-nobundle", + #[link(name = "util", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] - #[link(name = "rt", kind = "static-nobundle", + #[link(name = "rt", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] - #[link(name = "pthread", kind = "static-nobundle", + #[link(name = "pthread", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] - #[link(name = "m", kind = "static-nobundle", + #[link(name = "m", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] - #[link(name = "dl", kind = "static-nobundle", + #[link(name = "dl", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] - #[link(name = "c", kind = "static-nobundle", + #[link(name = "c", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] - #[link(name = "gcc_eh", kind = "static-nobundle", + #[link(name = "gcc_eh", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] - #[link(name = "gcc", kind = "static-nobundle", + #[link(name = "gcc", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] #[link(name = "util", cfg(not(target_feature = "crt-static")))] #[link(name = "rt", cfg(not(target_feature = "crt-static")))] @@ -330,7 +330,7 @@ extern {} } else if #[cfg(target_env = "musl")] { #[cfg_attr(feature = "rustc-dep-of-std", - link(name = "c", kind = "static", + link(name = "c", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static")))] #[cfg_attr(feature = "rustc-dep-of-std", link(name = "c", cfg(not(target_feature = "crt-static"))))] @@ -372,7 +372,7 @@ extern {} } else if #[cfg(target_os = "redox")] { #[cfg_attr(feature = "rustc-dep-of-std", - link(name = "c", kind = "static-nobundle", + link(name = "c", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static")))] #[cfg_attr(feature = "rustc-dep-of-std", link(name = "c", cfg(not(target_feature = "crt-static"))))] diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/solarish/illumos.rs cargo-0.58.0/vendor/libc/src/unix/solarish/illumos.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/solarish/illumos.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/solarish/illumos.rs 2022-01-21 02:47:39.000000000 +0000 @@ -13,6 +13,12 @@ pub shm_ctime: ::time_t, pub shm_pad4: [i64; 4], } + + pub struct fil_info { + pub fi_flags: ::c_int, + pub fi_pos: ::c_int, + pub fi_name: [::c_char; ::FILNAME_MAX as usize], + } } pub const AF_LOCAL: ::c_int = 1; // AF_UNIX @@ -33,6 +39,17 @@ pub const F_FLOCK: ::c_int = 55; pub const F_FLOCKW: ::c_int = 56; +pub const FIL_ATTACH: ::c_int = 0x1; +pub const FIL_DETACH: ::c_int = 0x2; +pub const FIL_LIST: ::c_int = 0x3; +pub const FILNAME_MAX: ::c_int = 32; +pub const FILF_PROG: ::c_int = 0x1; +pub const FILF_AUTO: ::c_int = 0x2; +pub const FILF_BYPASS: ::c_int = 0x4; +pub const SOL_FILTER: ::c_int = 0xfffc; + +pub const MR_HDR_AOUT: ::c_uint = 0x3; + extern "C" { pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; @@ -49,4 +66,5 @@ pub fn preadv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -> ::ssize_t; pub fn pwritev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -> ::ssize_t; + pub fn getpagesizes2(pagesize: *mut ::size_t, nelem: ::c_int) -> ::c_int; } diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/unix/solarish/mod.rs cargo-0.58.0/vendor/libc/src/unix/solarish/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/unix/solarish/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/unix/solarish/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -267,6 +267,13 @@ pub f_fstr: [::c_char; 32] } + pub struct sendfilevec_t { + pub sfv_fd: ::c_int, + pub sfv_flag: ::c_uint, + pub sfv_off: ::off_t, + pub sfv_len: ::size_t, + } + pub struct sched_param { pub sched_priority: ::c_int, sched_pad: [::c_int; 8] @@ -418,6 +425,15 @@ pub maxerror: i32, pub esterror: i32, } + + pub struct mmapobj_result_t { + pub mr_addr: ::caddr_t, + pub mr_msize: ::size_t, + pub mr_fize: ::size_t, + pub mr_offset: ::size_t, + pub mr_prot: ::c_uint, + pub mr_flags: ::c_uint, + } } s_no_extra_traits! { @@ -1233,6 +1249,11 @@ pub const MS_ASYNC: ::c_int = 0x0001; pub const MS_INVALIDATE: ::c_int = 0x0002; +pub const MMOBJ_PADDING: ::c_uint = 0x10000; +pub const MMOBJ_INTERPRET: ::c_uint = 0x20000; +pub const MR_PADDING: ::c_uint = 0x1; +pub const MR_HDR_ELF: ::c_uint = 0x2; + pub const EPERM: ::c_int = 1; pub const ENOENT: ::c_int = 2; pub const ESRCH: ::c_int = 3; @@ -1974,6 +1995,18 @@ pub const TIOCREMOTE: ::c_int = tIOC | 30; pub const TIOCSIGNAL: ::c_int = tIOC | 31; +pub const TIOCM_LE: ::c_int = 0o0001; +pub const TIOCM_DTR: ::c_int = 0o0002; +pub const TIOCM_RTS: ::c_int = 0o0004; +pub const TIOCM_ST: ::c_int = 0o0010; +pub const TIOCM_SR: ::c_int = 0o0020; +pub const TIOCM_CTS: ::c_int = 0o0040; +pub const TIOCM_CAR: ::c_int = 0o0100; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_RNG: ::c_int = 0o0200; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; +pub const TIOCM_DSR: ::c_int = 0o0400; + pub const EPOLLIN: ::c_int = 0x1; pub const EPOLLPRI: ::c_int = 0x2; pub const EPOLLOUT: ::c_int = 0x4; @@ -2192,6 +2225,15 @@ pub const SCHED_FSS: ::c_int = 5; pub const SCHED_FX: ::c_int = 6; +// sys/priv.h +pub const PRIV_DEBUG: ::c_uint = 0x0001; +pub const PRIV_AWARE: ::c_uint = 0x0002; +pub const PRIV_AWARE_INHERIT: ::c_uint = 0x0004; +pub const __PROC_PROTECT: ::c_uint = 0x0008; +pub const NET_MAC_AWARE: ::c_uint = 0x0010; +pub const NET_MAC_AWARE_INHERIT: ::c_uint = 0x0020; +pub const PRIV_AWARE_RESET: ::c_uint = 0x0040; + // As per sys/socket.h, header alignment must be 8 bytes on SPARC // and 4 bytes everywhere else: #[cfg(target_arch = "sparc64")] @@ -2310,6 +2352,10 @@ pub {const} fn WCOREDUMP(status: ::c_int) -> bool { (status & 0x80) != 0 } + + pub {const} fn MR_GET_TYPE(flags: ::c_uint) -> ::c_uint { + flags & 0x0000ffff + } } extern "C" { @@ -2760,6 +2806,44 @@ pub fn gethostid() -> ::c_long; pub fn sethostid(hostid: ::c_long) -> ::c_int; + + pub fn getpflags(flags: ::c_uint) -> ::c_uint; + pub fn setpflags(flags: ::c_uint, value: ::c_uint) -> ::c_int; + + pub fn sendfile(out_fd: ::c_int, in_fd: ::c_int, off: *mut ::off_t, len: ::size_t) + -> ::ssize_t; + pub fn sendfilev( + fildes: ::c_int, + vec: *const sendfilevec_t, + sfvcnt: ::c_int, + xferred: *mut ::size_t, + ) -> ::ssize_t; + pub fn getpagesize() -> ::c_int; + pub fn getpagesizes(pagesize: *mut ::size_t, nelem: ::c_int) -> ::c_int; + pub fn mmapobj( + fd: ::c_int, + flags: ::c_uint, + storage: *mut mmapobj_result_t, + elements: *mut ::c_uint, + arg: *mut ::c_void, + ) -> ::c_int; + pub fn meminfo( + inaddr: *const u64, + addr_count: ::c_int, + info_req: *const ::c_uint, + info_count: ::c_int, + outdata: *mut u64, + validity: *mut ::c_uint, + ) -> ::c_int; + + pub fn strcasecmp_l(s1: *const ::c_char, s2: *const ::c_char, loc: ::locale_t) -> ::c_int; + pub fn strncasecmp_l( + s1: *const ::c_char, + s2: *const ::c_char, + n: ::size_t, + loc: ::locale_t, + ) -> ::c_int; + pub fn strsep(string: *mut *mut ::c_char, delim: *const ::c_char) -> *mut ::c_char; } mod compat; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/wasi.rs cargo-0.58.0/vendor/libc/src/wasi.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/wasi.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/wasi.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,3 +1,5 @@ +use super::{Send, Sync}; + pub use ffi::c_void; pub type c_char = i8; @@ -37,6 +39,14 @@ pub type nfds_t = c_ulong; pub type wchar_t = i32; +s_no_extra_traits! { + #[repr(align(16))] + #[allow(missing_debug_implementations)] + pub struct max_align_t { + priv_: [f64; 4] + } +} + pub type __wasi_rights_t = u64; #[allow(missing_copy_implementations)] @@ -51,6 +61,16 @@ pub type locale_t = *mut __locale_struct; +s_paren! { + // in wasi-libc clockid_t is const struct __clockid* (where __clockid is an opaque struct), + // but that's an implementation detail that we don't want to have to deal with + #[repr(transparent)] + pub struct clockid_t(*const u8); +} + +unsafe impl Send for clockid_t {} +unsafe impl Sync for clockid_t {} + s! { #[repr(align(8))] pub struct fpos_t { @@ -342,9 +362,21 @@ pub const _SC_IOV_MAX: c_int = 60; pub const _SC_SYMLOOP_MAX: c_int = 173; +pub static CLOCK_MONOTONIC: clockid_t = unsafe { clockid_t(ptr_addr_of!(_CLOCK_MONOTONIC)) }; +pub static CLOCK_PROCESS_CPUTIME_ID: clockid_t = + unsafe { clockid_t(ptr_addr_of!(_CLOCK_PROCESS_CPUTIME_ID)) }; +pub static CLOCK_REALTIME: clockid_t = unsafe { clockid_t(ptr_addr_of!(_CLOCK_REALTIME)) }; +pub static CLOCK_THREAD_CPUTIME_ID: clockid_t = + unsafe { clockid_t(ptr_addr_of!(_CLOCK_THREAD_CPUTIME_ID)) }; + #[cfg_attr( feature = "rustc-dep-of-std", - link(name = "c", kind = "static", cfg(target_feature = "crt-static")) + link( + name = "c", + kind = "static", + modifiers = "-bundle", + cfg(target_feature = "crt-static") + ) )] #[cfg_attr( feature = "rustc-dep-of-std", @@ -417,15 +449,14 @@ pub fn asctime_r(a: *const tm, b: *mut c_char) -> *mut c_char; pub fn ctime_r(a: *const time_t, b: *mut c_char) -> *mut c_char; + static _CLOCK_MONOTONIC: u8; + static _CLOCK_PROCESS_CPUTIME_ID: u8; + static _CLOCK_REALTIME: u8; + static _CLOCK_THREAD_CPUTIME_ID: u8; pub fn nanosleep(a: *const timespec, b: *mut timespec) -> c_int; - // pub fn clock_getres(a: clockid_t, b: *mut timespec) -> c_int; - // pub fn clock_gettime(a: clockid_t, b: *mut timespec) -> c_int; - // pub fn clock_nanosleep( - // a: clockid_t, - // a2: c_int, - // b: *const timespec, - // c: *mut timespec, - // ) -> c_int; + pub fn clock_getres(a: clockid_t, b: *mut timespec) -> c_int; + pub fn clock_gettime(a: clockid_t, b: *mut timespec) -> c_int; + pub fn clock_nanosleep(a: clockid_t, a2: c_int, b: *const timespec, c: *mut timespec) -> c_int; pub fn isalnum(c: c_int) -> c_int; pub fn isalpha(c: c_int) -> c_int; @@ -623,6 +654,8 @@ pub fn newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t; pub fn uselocale(loc: ::locale_t) -> ::locale_t; pub fn sched_yield() -> ::c_int; + pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char; + pub fn chdir(dir: *const c_char) -> ::c_int; pub fn __wasilibc_register_preopened_fd(fd: c_int, path: *const c_char) -> c_int; pub fn __wasilibc_fd_renumber(fd: c_int, newfd: c_int) -> c_int; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/windows/mod.rs cargo-0.58.0/vendor/libc/src/windows/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/windows/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/windows/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -319,6 +319,8 @@ pub fn feof(stream: *mut FILE) -> c_int; pub fn ferror(stream: *mut FILE) -> c_int; pub fn perror(s: *const c_char); + pub fn printf(format: *const c_char, ...) -> ::c_int; + pub fn fprintf(stream: *mut FILE, format: *const c_char, ...) -> ::c_int; pub fn atoi(s: *const c_char) -> c_int; pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float; diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/windows/msvc/mod.rs cargo-0.58.0/vendor/libc/src/windows/msvc/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/windows/msvc/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/windows/msvc/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -18,12 +18,3 @@ count: ::size_t, ) -> *mut ::c_void; } - -cfg_if! { - if #[cfg(target_arch = "x86_64")] { - mod x86_64; - pub use self::x86_64::*; - } else { - // Unknown target_arch - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/windows/msvc/x86_64/align.rs cargo-0.58.0/vendor/libc/src/windows/msvc/x86_64/align.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/windows/msvc/x86_64/align.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/windows/msvc/x86_64/align.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,150 +0,0 @@ -#[allow(deprecated)] -pub type XMM_SAVE_AREA32 = XSAVE_FORMAT; - -s_no_extra_traits! { - #[repr(align(16))] - pub union __c_anonymous_CONTEXT_FP { - pub FltSave: ::XMM_SAVE_AREA32, - pub Xmm: __c_anonymous_CONTEXT_XMM, - } -} - -cfg_if! { - if #[cfg(feature = "extra_traits")] { - impl PartialEq for __c_anonymous_CONTEXT_FP { - fn eq(&self, other: &__c_anonymous_CONTEXT_FP) -> bool { - unsafe { - self.FltSave == other.FltSave || - self.Xmm == other.Xmm - } - } - } - impl Eq for __c_anonymous_CONTEXT_FP {} - impl ::fmt::Debug for __c_anonymous_CONTEXT_FP { - fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { - unsafe { - f.debug_struct("__c_anonymous_CONTEXT_FP") - .field("FltSave", &self.FltSave) - .finish() - } - } - } - impl ::hash::Hash for __c_anonymous_CONTEXT_FP { - fn hash(&self, state: &mut H) { - unsafe { - self.FltSave.hash(state); - self.Xmm.hash(state); - } - } - } - } -} - -s! { - #[doc(hidden)] - #[deprecated(since = "0.2.104", note = "use the `winapi` crate instead; we're going to -remove it in a future release")] - #[repr(align(16))] - pub struct M128A { - pub Low: ::c_ulonglong, - pub High: ::c_longlong, - } - - #[doc(hidden)] - #[deprecated(since = "0.2.104", note = "use the `winapi` crate instead; we're going to -remove it in a future release")] - #[repr(align(16))] - pub struct XSAVE_FORMAT { - pub ControlWord: ::c_ushort, - pub StatusWord: ::c_ushort, - pub TagWord: ::c_uchar, - _Reserved1: ::c_uchar, - pub ErrorOpcode: ::c_ushort, - pub ErrorOffset: ::c_ulong, - pub ErrorSelector: ::c_ushort, - _Reserved2: ::c_ushort, - pub DataOffset: ::c_ulong, - pub DataSelector: ::c_ushort, - _Reserved3: ::c_ushort, - pub MxCsr: ::c_ulong, - pub MxCsr_Mask: ::c_ulong, - pub FloatRegisters: [M128A; 8], - pub XmmRegisters: [M128A; 16], - _Reserved4: [[::c_uchar; 16]; 6], - } - - #[repr(align(16))] - pub struct __c_anonymous_CONTEXT_XMM { - pub Header: [M128A; 2], - pub Legacy: [M128A; 8], - pub Xmm0: M128A, - pub Xmm1: M128A, - pub Xmm2: M128A, - pub Xmm3: M128A, - pub Xmm4: M128A, - pub Xmm5: M128A, - pub Xmm6: M128A, - pub Xmm7: M128A, - pub Xmm8: M128A, - pub Xmm9: M128A, - pub Xmm10: M128A, - pub Xmm11: M128A, - pub Xmm12: M128A, - pub Xmm13: M128A, - pub Xmm14: M128A, - pub Xmm15: M128A, - } - - #[doc(hidden)] - #[deprecated(since = "0.2.104", note = "use the `winapi` crate instead; we're going to -remove it in a future release")] - #[repr(align(16))] - pub struct CONTEXT { - pub P1Home: u64, - pub P2Home: u64, - pub P3Home: u64, - pub P4Home: u64, - pub P5Home: u64, - pub P6Home: u64, - pub ContextFlags: ::c_ulong, - pub MxCsr: ::c_ulong, - pub SegCs: ::c_ushort, - pub SegDs: ::c_ushort, - pub SegEs: ::c_ushort, - pub SegFs: ::c_ushort, - pub SegGs: ::c_ushort, - pub SegSs: ::c_ushort, - pub EFlags: ::c_ulong, - pub Dr0: u64, - pub Dr1: u64, - pub Dr2: u64, - pub Dr3: u64, - pub Dr6: u64, - pub Dr7: u64, - pub Rax: u64, - pub Rcx: u64, - pub Rdx: u64, - pub Rbx: u64, - pub Rsp: u64, - pub Rbp: u64, - pub Rsi: u64, - pub Rdi: u64, - pub R8: u64, - pub R9: u64, - pub R10: u64, - pub R11: u64, - pub R12: u64, - pub R13: u64, - pub R14: u64, - pub R15: u64, - pub Rip: u64, - pub Fp: __c_anonymous_CONTEXT_FP, - pub VectorRegister: [M128A; 26], - pub VectorControl: u64, - pub DebugControl: u64, - pub LastBranchToRip: u64, - pub LastBranchFromRip: u64, - pub LastExceptionToRip: u64, - pub LastExceptionFromRip: u64, - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/libc/src/windows/msvc/x86_64/mod.rs cargo-0.58.0/vendor/libc/src/windows/msvc/x86_64/mod.rs --- cargo-0.57.0+ubuntu/vendor/libc/src/windows/msvc/x86_64/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/libc/src/windows/msvc/x86_64/mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -cfg_if! { - if #[cfg(libc_align)] { - mod align; - pub use self::align::*; - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/libgit2-sys/.cargo-checksum.json cargo-0.58.0/vendor/libgit2-sys/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/libgit2-sys/.cargo-checksum.json 2021-12-13 00:49:42.000000000 +0000 +++ cargo-0.58.0/vendor/libgit2-sys/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{"Cargo.toml":"35a195b40d928ad075ca0164463561a241eafc8d373f3791a819119766598697","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"378f5840b258e2779c39418f3f2d7b2ba96f1c7917dd6be0713f88305dbda397","build.rs":"4674350814337370182fc49dacd2c4a0b26787a3882c6ccd94cfede513183c6d","lib.rs":"026a64e02c02dae67768e3bfcc9d4e8c225560b45762110e923f4a3efdbec781","libgit2/AUTHORS":"d7d4f16a8e4303cc515fd4410b2c64b7ded924b1e8784a125d15195555e986b2","libgit2/CMakeLists.txt":"e8c80c4a3eedd64a24f3459c118248f96b2794700ca19a3cdbcb456bfeb7a38f","libgit2/COPYING":"8b7e4f54f8bf210c8fe010a49571a1ee57463ef020cc43f051d4d3fbb74942af","libgit2/README.md":"23f9c7ce9ceb2d8635ebf3853a7de96b8ff1fcfb43995354c0916a7525c6d36f","libgit2/SECURITY.md":"566da5b3e26904232486c2b7107a1ebb0dc90e8eb2f32b9468d0da41e1cd5543","libgit2/api.docurium":"c77dc54504945864b3270877a9ddcabe85d6d1a742c07232f6faf847958c0dd2","libgit2/cmake/AddCFlagIfSupported.cmake":"6c2fa4ffebe595428f06d8332330e832c7c7352a006705ac811621b9b4d50f73","libgit2/cmake/EnableWarnings.cmake":"e98c7d862caf629dbefdd2a2911b636cfcd1e3a08902fef01a87335b87328fc1","libgit2/cmake/FindCoreFoundation.cmake":"bc7de34062253d9bc4dbd7d777e70c6ed18122ef174a64e8f23bad58ddb2595b","libgit2/cmake/FindGSSAPI.cmake":"eda9f076dc7aaed50ab81734110c3a15c80b1ed15cbf8d4ab742af166e136410","libgit2/cmake/FindGSSFramework.cmake":"c8d8e3039802835f88af3724e5f91b21cfc9ca62b4ce70a6d1d3dbf4f2625b38","libgit2/cmake/FindHTTP_Parser.cmake":"ae7c457f673470a1e20397667555778515e5b5dd4263d3ed8816c7ac5e67d5a5","libgit2/cmake/FindIconv.cmake":"3ab0b707bb56daf770d74231d0530883296b28c61e8a99444c928db47478f929","libgit2/cmake/FindLibSSH2.cmake":"d34237065925414af114047ed7c1345e730a16cd0786eb07ba7ffc6b5e53dbf7","libgit2/cmake/FindPCRE.cmake":"b94df6fd44724b5d8cd968d4f4353adc5eb035e5dfcc46b698d7d6bbab059b69","libgit2/cmake/FindPCRE2.cmake":"91d2305b37211f31ec5986515ac7440a9fb5483751cfebb910f5f312c2bca76f","libgit2/cmake/FindPkgLibraries.cmake":"9132bb80cb6d9f7925be275c4a267f91fef82b383e9f0f1214b5e4726c76567b","libgit2/cmake/FindSecurity.cmake":"f2cf50ef8d1a95e5a8777a26b09edf857ff5e685aa5bc221d8f04bca8311a173","libgit2/cmake/FindStatNsec.cmake":"92dd6a058ecb45ce0fe294031f592383100baaeed6d84050734baf396cac4f47","libgit2/cmake/Findfutimens.cmake":"060dab43690b7696cfe4d01aa80e6ecf3e835f370a9e412bc08ebea96ad241c2","libgit2/cmake/FindmbedTLS.cmake":"dddc209a1d02b7599d4bb6a49cd4315fabe32c816190fdb0abfd5c214a470362","libgit2/cmake/IdeSplitSources.cmake":"0fd931f46f32392f2507ff0ffbdc66c51dc415fe00b72ef44ae3c4776fab1074","libgit2/cmake/PkgBuildConfig.cmake":"e00fced7e197262d03b41919961d829994693904f563f38c69564a5716723aa0","libgit2/cmake/SanitizeBool.cmake":"2cfdec6d742ed97aebf123c6ec9e087417d568912da0fc9bf7f6319470908ead","libgit2/cmake/SelectGSSAPI.cmake":"8abdf3c8d7a553c44e358ca3f7119b8bdcbafe7d78afc6901d7b85c7504c0f43","libgit2/cmake/SelectHTTPSBackend.cmake":"18f78221115cee2b8d0ca960d8f9db65a20cd38bb368667b5f24d9bda2079a01","libgit2/cmake/SelectHashes.cmake":"8b077ae79df3b0de53d827ba53753de4f65e59feadec103a73d61ff2a1cf1c2d","libgit2/deps/chromium-zlib/CMakeLists.txt":"9e89e537ebf74c166d337f6f9af25bd07300d40bcaf7a4556cc3b897e3af956b","libgit2/deps/http-parser/CMakeLists.txt":"f3fb5bb432aa7267ce9f6aee3780346ee6d0899154a3f05a1e57eb13bc5a1822","libgit2/deps/http-parser/COPYING":"2996a1c43ee757f9c997a829d82bdd584052323e73cf02ff8126c6fbd95c2d87","libgit2/deps/http-parser/http_parser.c":"80930f8b6c15827a3ae571e77ddbdccca366e8f6c98874062cb8c0c6dc877ee2","libgit2/deps/http-parser/http_parser.h":"d3fd211486e4352f57a47e856a5a10dfce06c46211119d0f6d9935713d2ad08a","libgit2/deps/ntlmclient/CMakeLists.txt":"34cf4a22a9c358fe6e66a66915efffde28279141b5ad231db8cc63a8be93683f","libgit2/deps/ntlmclient/compat.h":"f27a8e91c75ed75a71140c597548b43fae19b28eda1a09ab28e367a196bdad84","libgit2/deps/ntlmclient/crypt.h":"38647af40b21a8baf2c2e73e80ff631718b7fb0db51b0c2079d4bc85793a2032","libgit2/deps/ntlmclient/crypt_commoncrypto.c":"445b2f9d8f2cc820515d0bdf262d699e635061c81c2d617d7e3da9780817f7a9","libgit2/deps/ntlmclient/crypt_commoncrypto.h":"55a6fe82280421e5fd61f20be1938cc92efef1a211147072790eecc91eb87e6f","libgit2/deps/ntlmclient/crypt_mbedtls.c":"162fa2759c1073ce61a6bc2e7898a8c8557b8b4cda1191fca8af75200d971cc0","libgit2/deps/ntlmclient/crypt_mbedtls.h":"d10c8dee39844ad68a6f408d4134300b984279da9dfb9c7ff070a7065e5ecc26","libgit2/deps/ntlmclient/crypt_openssl.c":"e701e6d7758ca718825594939879e018a0bbf9977c55693437444f1e926c3941","libgit2/deps/ntlmclient/crypt_openssl.h":"8c87194b5fd0220f4b40ec5ddaed151c8a189a157ed3b3ab3595f5358cf4a62d","libgit2/deps/ntlmclient/ntlm.c":"cb08e24a47dd33d08d52db6bdcf83f8f56e2d30cfb3b91208e6e00c921042f14","libgit2/deps/ntlmclient/ntlm.h":"da9dcb20e629eb05a8c6e56c17a2011df41093d8b8b2d1985adeb6fa8e44c3db","libgit2/deps/ntlmclient/ntlmclient.h":"6de91838294651f7d491e3a211f1238d61833c3e72ca321e258ac55f52283964","libgit2/deps/ntlmclient/unicode.h":"ddb0cbb25cca1a2f413865070fd47c354f87caf66f868022dd288b90fe93711d","libgit2/deps/ntlmclient/unicode_builtin.c":"3bafcf95dd5c6b3ea3d54d7b24e7333c4af13f6051922d6f27cb6497f9962329","libgit2/deps/ntlmclient/unicode_builtin.h":"fb1674d49fc240f33d8120fea10504021a61f69967d933ed386d57d0b267127a","libgit2/deps/ntlmclient/unicode_iconv.c":"45f30469fa188781f5b61a645368d9fd9249f5c9d8aa8512708e98b242259f5a","libgit2/deps/ntlmclient/unicode_iconv.h":"7dd5cfe97dbbbcec94f3e1dcd6edf51785f6eb5510ef96607fce45ce1cc818a3","libgit2/deps/ntlmclient/utf8.h":"0b57540746cfe500009216ba3bb7bcbd1555c158648ec82fe26f16bef75adb97","libgit2/deps/ntlmclient/util.c":"94ec747cd810c90ccc966688d89ef8dbfb91e41aea2f665a13db5fa18ac26443","libgit2/deps/ntlmclient/util.h":"3b15e99337fa1555fd99b2434894cdef7c0ea96167f7b4ff4ae772a1d0982bb8","libgit2/deps/pcre/CMakeLists.txt":"f6c89cc6c4b33e2dd24e1ee33b5af92eb89ffe52075d089eef439c9d6be8c9cf","libgit2/deps/pcre/COPYING":"17abe1dbb92b21ab173cf9757dd57b0b15cd8d863b2ccdef635fdbef03077fb0","libgit2/deps/pcre/LICENCE":"0dd9c13864dbb9ee4d77a1557e96be29b2d719fb6584192ee36611aae264c4a3","libgit2/deps/pcre/cmake/COPYING-CMAKE-SCRIPTS":"46cde7dc11e64c78d650b4851b88f6704b4665ff60f22a1caf68ceb15e217e5b","libgit2/deps/pcre/cmake/FindEditline.cmake":"44788ac3e7c8c4b4da3e5e0f467c7ee49de7ba9e1c13024dcf1e2501f8fe9684","libgit2/deps/pcre/cmake/FindPackageHandleStandardArgs.cmake":"aa3ef1f1c8742da54813aab0ac58c71edd1e58cd3b6b157b856bfd525adc2e5d","libgit2/deps/pcre/cmake/FindReadline.cmake":"055e1df8bd29e6837d8ebb8c15dd5dcb28c88e23aabda8538b76a249dff829b0","libgit2/deps/pcre/config.h.in":"480e3e1a1eea810516e59f19375575e83f62980d20b9cfc990ecf8e8cb17f79f","libgit2/deps/pcre/pcre.h":"885609063157d6eb0e3c74af413b608dcd60a94efa023319648a7a8a6e4daa20","libgit2/deps/pcre/pcre_byte_order.c":"4030a1156da8690352226b5de2c9c5f52cc6955409e4a7ab9ba4d6b223e74b3c","libgit2/deps/pcre/pcre_chartables.c":"3386fd60b4a4175a7baf474223522540abd6e006e8507a04d3485f84973424ae","libgit2/deps/pcre/pcre_compile.c":"74526b16f6683efd56742a6cacf31ec1d55dfd8a9fc04f66df59e5e1fbb4354b","libgit2/deps/pcre/pcre_config.c":"fb9e1e766291b2b4b3066ecfd0795db398762b9597fb2af23cc784617984609e","libgit2/deps/pcre/pcre_dfa_exec.c":"1cbf3a680388110bddff833983d3653630eedf6e6e9d9e656a737e3b85de9dd0","libgit2/deps/pcre/pcre_exec.c":"2a6871b9a56de682ce28a467d26b42caf71f4323e44b555db720cd51c0f2c505","libgit2/deps/pcre/pcre_fullinfo.c":"a84fc4cb4d22b2ddfcd4d0f0a0ff333cc9f623e1fbf2a7c90623a212e0bde54d","libgit2/deps/pcre/pcre_get.c":"c93ded768f96cc392f911776e6d993b565114936e08247dfa79080b35dada4e7","libgit2/deps/pcre/pcre_globals.c":"8b2fda23b42715eff2f01188c4911dd8453868ff77fccfe34b99126aa775fa5d","libgit2/deps/pcre/pcre_internal.h":"f713de1fa2c20b5414f6746c80d10878ab48c9186462b074c5bb6a74a822fa80","libgit2/deps/pcre/pcre_jit_compile.c":"76ed39027b25f2bdab581c0bb12b95fa3659baa53c81e10f8f17819d6255199b","libgit2/deps/pcre/pcre_maketables.c":"8564fab861c7eb4037ffcd53fda789a747a30c4a462f460a5ef824f534fb06dc","libgit2/deps/pcre/pcre_newline.c":"3163ed2193fa74d8cc9e1db2bba672bcebf8efe85c2465cc0aefda51966bd929","libgit2/deps/pcre/pcre_ord2utf8.c":"fa926e32ae8d6e5610c500e7b6971a5149765a1881f798b18904a0a88bf549de","libgit2/deps/pcre/pcre_printint.c":"71751d151efbe935e9d8bbf58bbe143d617b34acd13d1bf237330c7c7736c422","libgit2/deps/pcre/pcre_refcount.c":"0dd8b7273243545fdafab585890fa12e210cf526030eb6b877325ce89250fa39","libgit2/deps/pcre/pcre_string_utils.c":"b83225f9cf2658654d6a0af01199050f6fb36d903041b33cd4d0c06e762b66df","libgit2/deps/pcre/pcre_study.c":"f5285714b59af9503dacff268cb37ab4944fbdf74a78c5a7b9bc49043a00ba40","libgit2/deps/pcre/pcre_tables.c":"fcdd9f705a7a1640ae5e5e5b7148761fc5e82896d84b1a287dd7e55b8b87eb15","libgit2/deps/pcre/pcre_ucd.c":"b35ad7e532f52c5fb1f4ab1d48f5d80618abff2a115099220d95cd13ac64c346","libgit2/deps/pcre/pcre_valid_utf8.c":"4265abf04c03acba9ea90351da662eb89aaed79e7eef03329ccf030ef28ef907","libgit2/deps/pcre/pcre_version.c":"5bb67c3373a934a2d9263ba9f9fe3cd79e381e6aed8507e5319202330bc5275e","libgit2/deps/pcre/pcre_xclass.c":"b2c3b2c7600e18e562a333df017ee35c69233e9427b866726d944122a9560e28","libgit2/deps/pcre/pcreposix.c":"49e996bbf43cb2d4acec350410ab40f811a9fefe21fc68004c6182a8da884aba","libgit2/deps/pcre/pcreposix.h":"85a6a09b806d8506e5710e9862b6716b2b88761abe0d05aeda5071257537d9c3","libgit2/deps/pcre/ucp.h":"ea98e4eb999d8e777f2ba709e68b5aff7108a4eaa169f4eefa4510056551b724","libgit2/deps/winhttp/CMakeLists.txt":"6c641c08d2cb1719c533ac20577f317bfc5ecf27e4ffdd0ea940e26e25dfbf2c","libgit2/deps/winhttp/COPYING.GPL":"d9a8038088df84fde493fa33a0f1e537252eeb9642122aa4b862690197152813","libgit2/deps/winhttp/COPYING.LGPL":"dc626520dcd53a22f727af3ee42c770e56c97a64fe3adb063799d8ab032fe551","libgit2/deps/winhttp/urlmon.h":"6cdb0f5ce5f0aea2daefc44c4806697ed31ad759f8baa18fb38a5b220ddc7d7f","libgit2/deps/winhttp/winhttp.def":"89601b95ac2515619426ea52ca093fac1a16ef0bfb5586c1385a028947ab6513","libgit2/deps/winhttp/winhttp.h":"a51828d65b1b260a727f596c41cf3257cac2ef6cfebb11726234fd7ccb1537f6","libgit2/deps/winhttp/winhttp64.def":"7cd0bc8dd2c06d288c241d175da06146e940c28d7201fb63de8a75730d09fcd4","libgit2/deps/zlib/CMakeLists.txt":"5d583227eeecfe65a9b59742e128b7bf33f0bcbd8749a17f551ef8b7a4b2671c","libgit2/deps/zlib/COPYING":"864943392878a2479350e12a04f6e8e0ae434b5573bae350823c4d6c4474c755","libgit2/deps/zlib/adler32.c":"47a05d4213c9694e821027225aa8ccf5975b58d7ecfd2877008b44dc8f53983e","libgit2/deps/zlib/crc32.c":"0e842875b2822122efbf822a15483ccbf0cf2d1a39f21f70a78492738f7f2fe5","libgit2/deps/zlib/crc32.h":"407af59d0abfea84a6507c603eb29809411797f98249614fe76a661def783ce1","libgit2/deps/zlib/deflate.c":"4ce6ad864c9c59c2eab54af193360afbe5b6641d63f425ab51463b2318f74bda","libgit2/deps/zlib/deflate.h":"0ca7fb0cf1dd63001c6e9e4ff93c8dbff2fe521199be51a4dda38a11b44919f6","libgit2/deps/zlib/gzguts.h":"1ef4741cf10441feeca5c8dde2b6c754f0cbd96fcae697d54a604757289a5e9b","libgit2/deps/zlib/infback.c":"abe44873b5af2ea68ea1d281d915b2800f1832f846d2c05442a4711adbe6f269","libgit2/deps/zlib/inffast.c":"4d496ab2a3d29df5fadc3dbff6067e039806aaceae6cfcd09ea77d46c2b848fd","libgit2/deps/zlib/inffast.h":"7d8c1c873ce9bc346ad6005bb9d75cce5c6352aaf7395385be216a9452a34908","libgit2/deps/zlib/inffixed.h":"237ba710f090e432b62ebf963bee8b302867e9691406b2d3f8ee89ee7bfef9b0","libgit2/deps/zlib/inflate.c":"8b6c599c3563c14c447c47db0d7dc9a16e8c246a078ec95a169ddcebaaebd811","libgit2/deps/zlib/inflate.h":"8ec9ac297790276f7e46a961d4c6f9f944fb1dec92401339ec2666973cc5983c","libgit2/deps/zlib/inftrees.c":"1960ca67384376f65b6ce8c08fdb501f8eb33923e11ef5f61a855708c6cb0a8a","libgit2/deps/zlib/inftrees.h":"c510b36402784b1f898be3b049b923469aa92701de2d9195aed19f6b65c0dce2","libgit2/deps/zlib/trees.c":"f2a5f949ea70dde7c23a54c793aeed630a03df4bb72417cd3aa008000c44699b","libgit2/deps/zlib/trees.h":"bb0a9d3ca88ee00c81adb7c636e73b97085f6ef1b52d6d58edbe2b6dc3adeb4d","libgit2/deps/zlib/zconf.h":"9c0087f31cd45fe4bfa0ca79b51df2c69d67c44f2fbb2223d7cf9ab8d971c360","libgit2/deps/zlib/zlib.h":"4ddc82b4af931ab55f44d977bde81bfbc4151b5dcdccc03142831a301b5ec3c8","libgit2/deps/zlib/zutil.c":"f7fdc9ef326a2683eb33c794face54e83c751ec17f3d1ba581847a62af36ddcd","libgit2/deps/zlib/zutil.h":"9a63f6690fac1620aa3cecee5752af618806da438a256b4a047fbcd289cac159","libgit2/git.git-authors":"807ee76d5d1f87f87bb4deff8196b7854530521ebe52bde5d52b9e2bb82a75e4","libgit2/include/git2.h":"3cc2ff96db345c2dae88c2168a9e4f0d23da336d9e0391a096320e0f08ef2c24","libgit2/include/git2/annotated_commit.h":"b416a1418b38c638cfd331022cf0fd059ec693090ffd29df3e649fbf502605a2","libgit2/include/git2/apply.h":"3712984fb5e82d9cbf5f75fa415262390f5091b150034aacc1aff67fb452dbee","libgit2/include/git2/attr.h":"80766ce5770fdd5a91bf8a84ec042e370c16f7fa7ab5320d4cc4f1f35351ec93","libgit2/include/git2/blame.h":"b1539196da49e1e76da4de260539902c4969355ccc91dfb065adcfd6d02a75ee","libgit2/include/git2/blob.h":"00c5939fade9aeb45a69677deb6b2928f3e99a7e51a0c3246211d9dc85da2c40","libgit2/include/git2/branch.h":"69cbee1443d56973c537331ac5be0287fff810d61a6ab43b4a5fc24350b07c49","libgit2/include/git2/buffer.h":"6123f50ce96972ed89c1a4316ee1b91d4e319002bccb16d79b460f59c0a4524e","libgit2/include/git2/cert.h":"75ea7a0790601e3456c6770647151189e0a3943e4164fcbff9941f2c476b2eb5","libgit2/include/git2/checkout.h":"2f2831794285b6e949f8f1dc044771a6ea92c863f36a5f0e288402f7b7ac54bc","libgit2/include/git2/cherrypick.h":"9d55b4dcf4a3db3cc432d9ab60bb6788c5a0a22525f3d2c5c071e6e693df3824","libgit2/include/git2/clone.h":"49a5dbb63c14ccb5d5a81bda47b3e30b523b6386ecafac2982360805b4dac64f","libgit2/include/git2/commit.h":"2f322d964a508288931ed3bfb0a569e730120c12f6750c8673c373dc89cb31e9","libgit2/include/git2/common.h":"523baeb99b95c5362ee056e45b38ebdf1cbb06b15f08862e38bbd140a0e29512","libgit2/include/git2/config.h":"dbd486ab9a111f8469d4c2bf59f731c15c06d973b4dd8d699ca9cd71cc9ea445","libgit2/include/git2/cred_helpers.h":"4478aa5e3f82cd754333311939c3c0d5deeff7be636f68e03a7f5b1c5f4bf73b","libgit2/include/git2/credential.h":"9b4623b90cb05d83bcd33330deab55c21efc7c3ee9fae960b20c0dd6f78158da","libgit2/include/git2/credential_helpers.h":"165864b7b39478e15804ccc95a03362a88fcb6bfd21b32b4fce660f50fbf479a","libgit2/include/git2/deprecated.h":"84c1d1a993e94f129fe0abbdcbcdb16e246b5717e2b7f743a120e20b151f1590","libgit2/include/git2/describe.h":"08b3280fbb5c38c5b261e317380bd602948ad5c0c94c6073329fdb222c110700","libgit2/include/git2/diff.h":"1f8d9506ee03fbf80fee7a1a3cd1699e310b202cf67e38519a74f7faa06ad8d5","libgit2/include/git2/email.h":"fd749d0c994e7375be2a0ca1c961aa3d15c631990b485eb8f639762a9ad7a123","libgit2/include/git2/errors.h":"9d4dba14a9a99ac94b212009bd773f5edce1e7d90842ffc80a4e8279dfa8f25e","libgit2/include/git2/filter.h":"d9709d99580043e4f944a69c9d031a1119aa293947bc13c234e82e4f81259d7c","libgit2/include/git2/global.h":"88e49fa7593012aa9575df08755b907b5b613f43278f477e9ca8e4feedbe6786","libgit2/include/git2/graph.h":"3c1c582f911a638d58543f2cdde8422aac6b25d8ef69bff3519981785f8ea814","libgit2/include/git2/ignore.h":"266b8bbef564bec63b4fe7d1d3042ffd273f252f151bdec23cc4f77c0febb883","libgit2/include/git2/index.h":"37b297f676018e2f707df240cc37a87a7ee0432bae0a4c5adb38cc9f78b71227","libgit2/include/git2/indexer.h":"f34bb2e002a72a1653a8987d3f74cb7faaa460a8147906fc1b41eeed1167edc1","libgit2/include/git2/mailmap.h":"4f0d18eb0ab5ffdacdd716a9649319683fb84a33627bb4dfa6fed8aedff55d73","libgit2/include/git2/merge.h":"f7b481f59efd4e533e57012f5694940d13edbcb2d5010dd6b29f85ab2e3ee6d6","libgit2/include/git2/message.h":"dd9a84083afa7835e4445e444d85756458133ad34c96f8529c2ab942e8ade5a7","libgit2/include/git2/net.h":"aa6ce5cde1a1c0dc586b3ac22bfd68689505d05fd91ee4c128c0225fdc7676ca","libgit2/include/git2/notes.h":"59256cc18452a945e1712c210a957685501448225f57f3ade0a839cb9124fe12","libgit2/include/git2/object.h":"16d24acf810ad90168283d05911d516c526f8a3a1760e762540441e8473244b2","libgit2/include/git2/odb.h":"e824b70b655bd6a7f72c34fee9f88773d8e7bb7458e3ddea6de2f1f205741545","libgit2/include/git2/odb_backend.h":"b80a063e8f7d521f8c5b1fc6c3329273b2b0b6a8e3308b145ee7045621cb4bef","libgit2/include/git2/oid.h":"a2510249c32905b3f4d8e149341f81d4f56c1481be3fe2ee21edb49e1ac2ec72","libgit2/include/git2/oidarray.h":"aaf8e8102afe1f35429c8738976ae1f886c5d831fc2d19737ec3577c901741bb","libgit2/include/git2/pack.h":"834e38d09ec0759a618484c271a996ce738dcb52e03954c8e2744e3e0887e9ad","libgit2/include/git2/patch.h":"eb9e7dbafa666d927cda8b39d4a0f8948990136461c9bf6bc5b8299e02c51c64","libgit2/include/git2/pathspec.h":"5b482e78f28b084ba7b399b1f4612e58c7b8077e56403d5cb8f2cbec8798eb0c","libgit2/include/git2/proxy.h":"5b15bc3add05b2051432653ec20d6132a5798ccf1d1acec205d37208086b0e92","libgit2/include/git2/rebase.h":"9d54c9fee343ff6a7ad1cef094a26c465aa0630a25cd3511f796e46d9b7446bd","libgit2/include/git2/refdb.h":"77a1b09f4ea49607e7dbaadec51680316e67fc574f822e7f5c92e6e0594c3905","libgit2/include/git2/reflog.h":"c3239c314b3d7bdcb056dcaf7fe31834fdc5905bf98f3e6682d11ad7817bcd4b","libgit2/include/git2/refs.h":"f63eae1f0bbc19d211f27df81779576dc2f61e99c67ad05f441cb799327171a6","libgit2/include/git2/refspec.h":"3fac2002e7bcc36fba7e353e728846423c121520e8caf00836d232493eda2db0","libgit2/include/git2/remote.h":"bed6678893c24aa94c33ad2188b2ec48033e8728883ad998df4406285ab12160","libgit2/include/git2/repository.h":"794fb09e96a2694d2b8db813991dabd07180935e7440d58aee39ba7e6fa39ea1","libgit2/include/git2/reset.h":"303c3b9ac582a59000be80c3c2acec5eaa50c207112fd42efae77e6f3a308909","libgit2/include/git2/revert.h":"fdc9b2a8106191b36edac31d586375f82257614050b1d75fdcd0066e36da2243","libgit2/include/git2/revparse.h":"c917020e414e3324d963af61871f045bfd765e2b950fc1a4a67fd6eec1e0216b","libgit2/include/git2/revwalk.h":"7ddcfc8e95a35c0b60511a899fddd806a587f690277ff765a5fb2d01a6a8065e","libgit2/include/git2/signature.h":"c4562eb9a73f0f58fe575f040bf4a81fb9228eff91a8d4e22bcbb74007ff23af","libgit2/include/git2/stash.h":"d1a14e7d6a1bf7cc39ac94c3d1d20cdeedb672db9ae313b3d1d2d96fde33014a","libgit2/include/git2/status.h":"07adf481a94f382de9379edc755661ebaab49e567854928c3b23325c9361b1fa","libgit2/include/git2/stdint.h":"ff41f7b6917b7c4955a685a28072e2dc141f626f5f09068e33fbb2e05b866bf1","libgit2/include/git2/strarray.h":"9a1133c71aa242661c684f78f5028e00d2c520a4a833906b125c05038448658a","libgit2/include/git2/submodule.h":"65b0b68878f493d2c8643e23393a495a5c7a7fe7df259f5f41433d52ab78a0c5","libgit2/include/git2/sys/alloc.h":"9a19fb88e2c70146520d63e01778e22938976a4b754e4bb9e487c4d5a2ca486b","libgit2/include/git2/sys/commit.h":"3d1b2220325a82983ecb271c2eb8383a8db134dfc0da96b1f050f3664871252a","libgit2/include/git2/sys/commit_graph.h":"6dd6b43318d8f526ac723da45302f34df3dcd5c527802dc5e9a5d76d4165cb89","libgit2/include/git2/sys/config.h":"7888b5265f18640820d43f8ffc31e3e6b3153398ee2851d657ae8b28bdcd10a4","libgit2/include/git2/sys/cred.h":"b2ea956401c5554f26cec0f428dd9d0d9661d1ef3d9368769b415193df98ed1a","libgit2/include/git2/sys/credential.h":"8cfe0a41b027f8196f43fd2e81c15bbe1a26ed7c15468711f900dfaad0a3705f","libgit2/include/git2/sys/diff.h":"e341f693acb25645f6ed47c041fc4eda8996a6f1d42905ae4f87fffba22520f3","libgit2/include/git2/sys/email.h":"c90da62e7696a61eed3f21ecb7c9feb39569130746a6bd317e3e82e18c070bcd","libgit2/include/git2/sys/filter.h":"84830316c546511631506cb7b833a1cd39fb9deb76249e2ce6b02c524d00db19","libgit2/include/git2/sys/hashsig.h":"5677f86c02e557c7897e98d395e83d8168c532916ecfb7f9ca5bf7b4057141f4","libgit2/include/git2/sys/index.h":"bc6a371ea47773019e17e5ed5951dbb5b9d773c437d6d49e79e20fa175993c87","libgit2/include/git2/sys/mempack.h":"677bbdd7c613d82cc07966318f133c6ef4101b1a1dbfc0f3b1979a925ae50810","libgit2/include/git2/sys/merge.h":"48bd0d3a80046712287e5c396ca7dd6d81af5cd2e765f96ee89fb298d17a79db","libgit2/include/git2/sys/midx.h":"d191831dd85832e62c3a940370e355dff7e7432fb8d11c27d6698a7e8c4555f6","libgit2/include/git2/sys/odb_backend.h":"b6adefbb29aac9cf13fe3ab732b9965d1efb7d45b83641a4e6911f33d62d1161","libgit2/include/git2/sys/openssl.h":"011d45d1991a7d4467b5de5c574718af5b16198fb1581639845fd8d07bef7758","libgit2/include/git2/sys/path.h":"97adf0e0751e456546c7c0119743e50aa428fad8a29184fcc637db1eaae08b67","libgit2/include/git2/sys/refdb_backend.h":"6be92a5c1b660e4adf99f4604fefc9e93d2e639ae53295b722a1364723d036bb","libgit2/include/git2/sys/reflog.h":"c307ce8e9c8b0483ec45ce34a200f74e1ee73bfea9c4c7b0cc3923e3881360ca","libgit2/include/git2/sys/refs.h":"ee98c1aa0596b1cb409795a94de4891392e1675c42e8877a1e38bd0a5c3fd2d0","libgit2/include/git2/sys/repository.h":"63a142623683376fe11f498685525ba33d3cd184708338f2461067b7aa5b92c1","libgit2/include/git2/sys/stream.h":"6bd6609f2dd2acaf7206c9542a02abad5439a6516f1ff160f1df040da33ad829","libgit2/include/git2/sys/transport.h":"45598f66c72c23acb35b3dcb98ecd39899017493089e04c9f1a375f9a6f0be51","libgit2/include/git2/tag.h":"0af6f620d427c03341cfdf4e482b98d892c1f49e7e850903ffe22064d5574acb","libgit2/include/git2/trace.h":"f9aaff56cd6e6ea2dc5f7e221f198016f7d4a947829340a45c12714bf32f6738","libgit2/include/git2/transaction.h":"4c7969130a952134c597e84a06f38ca4b19e0b372df88085cb4f846292681c5b","libgit2/include/git2/transport.h":"7272a0f8cc321ac012a3fbb8cf4d1be0bc6d34fc266a09b72d604a30ad0a91c5","libgit2/include/git2/tree.h":"6660dced76f176b3af23fa669cf046a85f5eb4b73a1a9f4aecc652468db4b6cf","libgit2/include/git2/types.h":"a626c586d1890cda86beecba1249b5fa1324bc8fc9a67cd5ddbf02f24138cb5e","libgit2/include/git2/version.h":"fe572a156e444c7c51aa531e08a580b646b673edbb39f29b42d5f24a132d24f4","libgit2/include/git2/worktree.h":"6b9a107dafb2494a615370fd2d55edb807830a219f3d7684f1841c8ae550bd9c","libgit2/package.json":"0c4937f6400849ff8e4bd811bcc7bf4bc7429cbd71dd02633765e717993b84fb","libgit2/script/backport.sh":"6ef93a8c4a15ef74d2639638db3b24d20a76fc31faa53b1c34b07e3759c78fe6","libgit2/script/leaks.sh":"62532838555750cfdbff91709c40b1c1356e399238fc29379a45802922530a51","libgit2/script/release.py":"28a113a377422d7aebab4ce25c672f134ccb8a81cbbcece4d6af4354c44c4711","libgit2/script/sanitizers.supp":"8ac23fc907490c5ba1dd641f97201878e195c3bec0c1f224a9a4dda1fbd1f5b9","libgit2/script/thread-sanitizer.supp":"6497c98a2c0c83d867b0d88c36095a609731e7f6f4ad5a73dfe5287d6f2ba0d2","libgit2/script/user_model.c":"073e0b631f2d50af9c326dc009c626dfb9d31707d36bc61396ad9960160652bf","libgit2/script/user_nodefs.h":"4287333a6d7484a5a5796e6deadea53ec1ef587e4c571351e3fab61cf8badb45","libgit2/script/valgrind.sh":"13d1e34010c351992ac5950dbadf35928eaabfc9ba3acad336e7677fbda0946c","libgit2/script/valgrind.supp":"f959d829f41bd3cdf663a3ec0861ebf98f5c69b4b46005d754d748d7b90d1734","libgit2/src/CMakeLists.txt":"1edf13d521d176adc79840fe98accb09b8562f50e00ea217dc24cec4f3101298","libgit2/src/alloc.c":"a203aa1aa433888642043576c031fdd01b230405d143511123dc8ef4b831356e","libgit2/src/alloc.h":"0897973a8dd43caeedf3806771930d163db62554af8efc61b1c536e7daeb4052","libgit2/src/allocators/failalloc.c":"60b00ca09e75ca103e15bff16533a46fece76962c9a5e2c0ebc5f18918240474","libgit2/src/allocators/failalloc.h":"3d039fddfc851c594030b1dc024b9fddc8e9ec02d7f40709167379261f090dec","libgit2/src/allocators/stdalloc.c":"e100fa204d60a0977c0334207aa8bf77d7787525a6bf2ed097138cbcd62d7605","libgit2/src/allocators/stdalloc.h":"fe632f78c5cb6a079cc5f5dab9e7381aa504dc6937a0222f8de996c4f1f74e9c","libgit2/src/allocators/win32_leakcheck.c":"e9817c98d0dfdf97846a24f9c0d5d25a038f26507ac2ca21b887fef3bc193f31","libgit2/src/allocators/win32_leakcheck.h":"a19c1c859175753319a4c9a7b6a0d622c64a6c702c2e80e2ac4c530cf77a3974","libgit2/src/annotated_commit.c":"224e3bbd567ca961522cafb78c717d29f1710f2d2bea5c40305674b58b56f73c","libgit2/src/annotated_commit.h":"0c685dee827676a1d9548cb57d017fbdd20bade9ea78da62a1403e078b1e2fe2","libgit2/src/apply.c":"237ac74be2d25d967f87f594d12bbf42771482bd43831f64f7b9cddbd723de3c","libgit2/src/apply.h":"f506155358417b3d3b9b56599228e28bd757a23713e74cd049c393f4ce9d1a03","libgit2/src/array.h":"3e2aabb5691419ff362bb79d8ed4496e4254fa24785e96eda0ee0d61cde6a198","libgit2/src/assert_safe.h":"b8d5af4449d7aab6c29eff56b8f3992bdc3b4dc10d9016cf82af70179d7dd5f0","libgit2/src/attr.c":"2a73674ba223d9eb2a7e9d266d4c916fa507eec0c85e196443016fa385f6c4e5","libgit2/src/attr.h":"c940426d88f00d1510d2698897d5fd1b9270d91ec0c86a7df10b9d07f598171e","libgit2/src/attr_file.c":"4ed99209485f6f2e2514f43cfbd578e16d24795e216895e11331cf809440d720","libgit2/src/attr_file.h":"0b6593a60b73add7ec5f6182962b7ef047dfc0d6e4748fbb8c83d164f63a0c55","libgit2/src/attrcache.c":"3b639da3319ed69e72a74a42be483835a50546606384cb65ccaca25a6cb33686","libgit2/src/attrcache.h":"a47b509e5862731889fd1bda172f6dd2e3f9dff50b7296d4e2cee86daf508769","libgit2/src/bitvec.h":"281444c865be87104cff9c1b3998877a67bfd92af4b0e5b9b034fd48f6569f7a","libgit2/src/blame.c":"7e6a4a9cfd1382da134121d3b7b7677257e2ccbc692fa75e212b3495c0aaecb4","libgit2/src/blame.h":"5cd24ffc72a646e373d5d0b850aaa86316fd83b6fb886b0aacfe57ef4fd9b760","libgit2/src/blame_git.c":"8e55f2ffec06bb99eea9c9531402c43799b0e937a6c831d614627b9405fcf98e","libgit2/src/blame_git.h":"9b813f16b93512d27d93648e53d1438d5b931024701273b5976c1da41868e286","libgit2/src/blob.c":"218cdcafc8eff3357693ba09588107d6b64d87bc3f9098fd09e5f7e5e45b2181","libgit2/src/blob.h":"754e2c4c41761314ff9bc369b7b796945ce98c2afc0826aa419e0707b497a82d","libgit2/src/branch.c":"176836ee9632da43fdfa17566e94442784c0a3899dd85691a7a98568b2c93dd1","libgit2/src/branch.h":"c73beffe8a3a21390d49f5cc99601accb3e03d82c150be70da823548e031b6d3","libgit2/src/buffer.c":"1404f2e0d16d1653fe54afb65f3d80973e2616bd677c9424d2689b0e159f99a3","libgit2/src/buffer.h":"39718f430d6b8dfe6357ad884f5aed7992ecda09e8d59161e1759c82383080a0","libgit2/src/cache.c":"46385411ee06769a97c6d3f72568fcc34f0873444b27c8c1ba0c1f3e1255730a","libgit2/src/cache.h":"7fb0a0a0898367f1489b0430c35ccbca440cf7119c45382ec67adeff443f83ac","libgit2/src/cc-compat.h":"3388d4c811baba598ba23821252b31c134ba6404b125689991b776f544c9e77b","libgit2/src/checkout.c":"4f3e3f29e42d6081d54f90ec25d5d1d5a71272971c2736fa1394be58cbaab0df","libgit2/src/checkout.h":"deeaae59fbd6f4cb3d6c5b67133df66832ad3e49bc9585b6ce9c5d0aa4aa6ef0","libgit2/src/cherrypick.c":"fa605bf34387e3ee8362123932b092828d2312e295f8d633c20d3697bd4bed95","libgit2/src/clone.c":"c7ddad6dca59d9c6820b1193ab8170005075dcffc3973b7c22bb0690c5f308a0","libgit2/src/clone.h":"1820fe915f31a5346b28cf06c29e60cf7fa5dea92d521ed2bf2aa51d0eec3c18","libgit2/src/commit.c":"95b55623df96c54e4fa8ba65c7f3b00b0d06cb32b861acbb223d36191603d20f","libgit2/src/commit.h":"6bb1d7b467ffabe7cbcc73a316255c59a78ff37a68d9d4ce4226ac694ef9cdcb","libgit2/src/commit_graph.c":"9cc8a29c4c37db52e17f50d0921c74eed08befa9504dc97485330f53a5b1870b","libgit2/src/commit_graph.h":"853efb87db91d8a6cfe4c0dd8f3100d2ae5dab43e5bc94711b13ca62a7b40bcb","libgit2/src/commit_list.c":"0286f785f881f3c75b7462dd719ce95fc3757839ac05f7017c984fbf0ecb70a0","libgit2/src/commit_list.h":"0ca7bb97dd4d33c49420c9b7eb5689ee0b3ec01f39be08bcbbfacd695820e249","libgit2/src/common.h":"8c448d310bb794a96ec2a94d005f8349709251532c8db402530e2e7f7e38d180","libgit2/src/config.c":"e7fe25431adb0b83918630425fde4a1bf5e219f87bdeee1a8a2adb79a14939c0","libgit2/src/config.h":"c37e78949ab85b1b4694cc39d494c9990e3b7e21f98eee79325645a1382ecc5b","libgit2/src/config_backend.h":"8a368a7b9235aca7a6fc70e6192b1dc9ca85c881faabb69ce612c011a53cdaa2","libgit2/src/config_cache.c":"46fec2adc322b57a2a85a1963aa4702893228a3ba90c1a156e127552a0a1a854","libgit2/src/config_entries.c":"a938c81fce685b07aab19a30ee163bd1cdbb8a019aefcf704d1a97373f5f8da8","libgit2/src/config_entries.h":"932abf82f5103fef5c6e991a6e50effeb33cb6ce90eb1b15f6606d9f370feb66","libgit2/src/config_file.c":"ba0cb07c20e8cc5ad609f4635b5d8389e293a2fe83bad42eceb531669c8531b9","libgit2/src/config_mem.c":"c643aa86947d1155d6cc66088b95172788bc5b0bf7badbeb39b4ef82b830dbbe","libgit2/src/config_parse.c":"649519e96fdd9a63f51114826980269d7501976a74deb56b7e1859142e7d9aac","libgit2/src/config_parse.h":"ed2e0138e13fc0115fba047c80687eb20778984bb2ee13c261ae69893e11e5a9","libgit2/src/config_snapshot.c":"ff6771e940ebc78bfcdb12b7dac205629e8e88732b44b10a35962e3289cd660b","libgit2/src/crlf.c":"d66bb90e34b7a90002df6e2a4abd29e0814f643b86c3c73e5f3a3135c70b16a8","libgit2/src/date.c":"1cd211512fa14dc55baab4ddc60f703f35f986086be8174e7b1d7ff6410dbdfb","libgit2/src/delta.c":"3e5d84b81f8fa3b752f75e0853a548ec3863ac3f1070bf99a9367bf6ae8ab87c","libgit2/src/delta.h":"c757526292144083a0e96e7ab259080e83158e28c4819c4fa8bc2523aec12a59","libgit2/src/describe.c":"bcaf3b1c843b46477e3f5f8782dbb864cbeff40135c72c03e362a8f6efe1f521","libgit2/src/diff.c":"5fc798e667b06dc2e0702def1ed8e8c7d80f1d1320f2cd208b70bd29bbb048d0","libgit2/src/diff.h":"baaa3143e54a9b298159482b97a397cc0dc79bd937dc9e2f490c303202fe89a6","libgit2/src/diff_driver.c":"7e02470cf2c54342986baabc88df278f4e313277deb3be2d21ff5c117401fc7a","libgit2/src/diff_driver.h":"a59c56162e5ee30af5a831b45fcf60833a5a622c05a97b6ac052186a507ded01","libgit2/src/diff_file.c":"cbebacdcaeba04ec1796b7ffc67a5bef74d11c6d71cbb56f9efee231f6fa6df1","libgit2/src/diff_file.h":"f19e2a17d089591596325cfede708846c8df05a711e349ff84394db4af560c1c","libgit2/src/diff_generate.c":"ceaa1b17a00fccd7a23d71a78a7c339ccc3ee718befa142bec9a0f1df22656d8","libgit2/src/diff_generate.h":"1fd38c67babe08d6aaaf58edbdda577897103db0265c75fa337156237d121549","libgit2/src/diff_parse.c":"107d11e188e054538c29275f6755bde45523a4f04bbdbf30fcfaf18c54a88a1c","libgit2/src/diff_parse.h":"8902d9ba9102f10898c14d0a41a8d5823450527266908cbbb06e676309e23f56","libgit2/src/diff_print.c":"5c834789e5dd8ec88205edbf045a02fcb66a44737c43b1faa68b0beea8096230","libgit2/src/diff_stats.c":"0b50e3a72148f441aaa965ea3b66ed122a051b5c67191fe3b894565bf4f6b16b","libgit2/src/diff_tform.c":"45f8f00fc9e6db9efd932722d9014feccb52b1184b8f73f502c2f5599acbf5e2","libgit2/src/diff_tform.h":"a4a7433036cefffaa9d968ff45244afb4957313cd9c28980cc102f172f9eaf5a","libgit2/src/diff_xdiff.c":"9745218c619d3a579a170a1a8ad8cd6012885a554071b4222dc2f0cec62fbc5e","libgit2/src/diff_xdiff.h":"f027a95aadb84a42fcc349b082ad50c0b6ce3a3c439fbdf90ffbb04f48968e81","libgit2/src/email.c":"8f62ac3d962168188b31ef16fa704f011b2e10eb754de09fe569f444a04f2a4d","libgit2/src/email.h":"88891f37f71b8e526cb3501896a24d591024a6ceba6c732adcf5ed362c0e357c","libgit2/src/errors.c":"bce0dac402c9cf29a49205f82de11da55aa698b1d999d6bae3faf40794d93751","libgit2/src/errors.h":"218c25d91201b34e3d8fc9d945837a607f7cd4d90b895155f83548bd5a32723d","libgit2/src/features.h.in":"2e6f5ede61aaf7838012d8042fa356e01eca330b7fcb1ae0ba3d646b5041e27f","libgit2/src/fetch.c":"b5eb97e32762372d48286096115d8128d186c96d1482035176fc2a047b6b3567","libgit2/src/fetch.h":"93669dbc5007dfe99856c76d35ca82fd25bcc59f3b5308cd0ca15a14d9fa865d","libgit2/src/fetchhead.c":"706e16f254f22e854e8c8157c50caaa9d598115df212f0df2ce85d8ec3382014","libgit2/src/fetchhead.h":"65681769629f670afcf739d582bb7ae90f702f0c6085de3f26b79fb3293d1dc7","libgit2/src/filebuf.c":"189893ab7b2154fc2821dd8d6a285f9267e78c6e9d70da1683867e6c37b58171","libgit2/src/filebuf.h":"f20fdf1c20401c0e6b544394bc7cdff043624c4f3bc1412cf5f58c5363b45c76","libgit2/src/filter.c":"bf1da751516495d0aa187382fd9dea181ddc235aa41979233c11000d1659e980","libgit2/src/filter.h":"82778dd93b24df117f3b01890742f123694ec27388c6b0e1018b023e2895c7b5","libgit2/src/futils.c":"7e3c242e8749930dee727898f7252e6ed01668736516c89cfbd10a11917570dc","libgit2/src/futils.h":"aaa38e1b1947bcddcc517e86fd16f104659eb4d2762b36deab05eee1bca4df17","libgit2/src/graph.c":"babca47e94066357799c0ab823c9b3e454187202f7ab14068a6cf0fba28bdf41","libgit2/src/hash.c":"6ea788aa642167e800b3a77e4786976ece92056c8da57c443a71cec99040580e","libgit2/src/hash.h":"4d61f9e71675a22ffa244771dda691b4bb5d9b5802daa448b4381cd5296b0923","libgit2/src/hash/sha1.h":"9349e5886a08c37d57d32e73b83470f9da658a36f06b6bdb79a43d15fbb51093","libgit2/src/hash/sha1/collisiondetect.c":"af31802bab96c3f20622f71fe35d820d9b630daeba7908d5fc7943d8c3572fff","libgit2/src/hash/sha1/collisiondetect.h":"5a1a2a35d0fe5a9e61f4c65fa07e68a923601ad12e0bc14de0d64b634dc1270c","libgit2/src/hash/sha1/common_crypto.c":"cdfeaf3bf758d0a7ce8927a510a71cef316909459d7497119452c43d77d38c4b","libgit2/src/hash/sha1/common_crypto.h":"bde45e520496280b52c9fc7eae9c987f9f0f2a29a0d4c42cc0a451df3907897b","libgit2/src/hash/sha1/generic.c":"4bab2be3f32eebdf1ba71c71b32d1762eed40e1be4b1e012fe7900a88789e00c","libgit2/src/hash/sha1/generic.h":"ca6c77582636773941c569bafbc792769880a4e4d3fe6ed15144dea2f9d8bea7","libgit2/src/hash/sha1/mbedtls.c":"bc5fb30bb5aaec4425dfc9d996c7aa7eabbc7ed439e21ef8c7743dae7af10477","libgit2/src/hash/sha1/mbedtls.h":"be359c3f5006ce661cdf344c857f2725c8a5722bf15e300f5bd30a532f0e900b","libgit2/src/hash/sha1/openssl.c":"14d06a69f6a7ca2b9b2c3c7f7ee9f003315c94f3403e91be0cdf63ad616d6b28","libgit2/src/hash/sha1/openssl.h":"ee9d4c8091b780c475b1342e2bb7d7934d2948a2938caac197cab7464a67819b","libgit2/src/hash/sha1/sha1dc/sha1.c":"6fd7bc736a53c3477e319aa09307308533883f73817f8d49a79a0a038fb70373","libgit2/src/hash/sha1/sha1dc/sha1.h":"78f97f092c20329d1fa8d9a8cbb3d53bb90be19cbc49f1917605a9ddf520de83","libgit2/src/hash/sha1/sha1dc/ubc_check.c":"7b0db83569ba82965dc0d16e51e9ad85167cdfdab343f9a02c2c475bfdd93956","libgit2/src/hash/sha1/sha1dc/ubc_check.h":"4a140693701da167b4709c4c1b330800a0c29f2a065d0d819567a27b3171a09f","libgit2/src/hash/sha1/win32.c":"145660f7c463c4c3b149fa86963d5bac90986faa2b4b71ec779e4b0a3c72e19e","libgit2/src/hash/sha1/win32.h":"e63dbd03dc247e5673c106a9036cd515efe2e9300f55d324070dbeb8824c7fdc","libgit2/src/hashsig.c":"fbe29bf41024a9bf9b556756a23bea451d1ca2aced680fe666d24b651a719a7a","libgit2/src/ident.c":"f39195dd181b03170df42026c56d0f0bcdb93eae7ca6b24b2c99a2d0c7ae3d45","libgit2/src/idxmap.c":"015ba3e2f290fd817152f034208a55aa94b8ebd29fc8c80b3d053847d66de605","libgit2/src/idxmap.h":"162a477b8faa3d37e83fd413bd53f6ba2801c1cf64a03c29513601058a6ed40b","libgit2/src/ignore.c":"4cd2358d6ed543a9ff46a157f32f9bf9cbc067483bed36649e4ed671eba2b915","libgit2/src/ignore.h":"8189ffe01ffe66489fa19f26c960823ba781e5eb35d93f8ee655b06da26ea96b","libgit2/src/index.c":"1bcb76080582f2ae9ac5fea419a2c40d7c89421eeaa6b7f98a1d4dbe2b542887","libgit2/src/index.h":"a634d752e2c8fdfeb05ed7c327a71b1ccf8cdd49598ec974bbbfc6e9097a69f3","libgit2/src/indexer.c":"dc2b84263075698f6fd039af0a03c79542edaa4fe7ac6eb74ec3ab2db3ba0e54","libgit2/src/indexer.h":"bd32fd65a3a7c6014e3e9846477b060033102c8c7baeb097506074f99c50a434","libgit2/src/integer.h":"2581341c6fbc03f9403e6184a40b0aa6d67d8dc1b127e1f4e003edc867e21226","libgit2/src/iterator.c":"d0d8936e332ae486ca270b2e493a9585c5073838252d71fbe730ed32d0caed63","libgit2/src/iterator.h":"54beccce28e1adef2580ba24bfae492cd19242c0e8b1dec12eced62199f07c9e","libgit2/src/khash.h":"56a62732cfd1ae8b994ee4d37c0f7290442b4fb933f34e9ab0b4d26019c45fc0","libgit2/src/libgit2.c":"89eeab7ad72673f6023f42d226c49e5d8bcf2d5236694fb66390355d3cdbc686","libgit2/src/libgit2.h":"4cc280df2f469e2c0dfedef5f895e95ff0b4eda3710b93fc10c9b0cc97f1207c","libgit2/src/mailmap.c":"69f06d59627dd8d1c003aeee54ab5a583455347f46bea46dec1a55bbd664baba","libgit2/src/mailmap.h":"edd8723b4c861c855708f2d7f9ed5e37cbb7523534349b0f69258a3557b93b36","libgit2/src/map.h":"57816a28b029f0ac87964a86fb0c31e7cc9f047a304f52bcd4042891ded30d32","libgit2/src/merge.c":"5c7bb72ea06589c587fe931d5455b7765d88c6cadfac6cc6448c89f7f99362c8","libgit2/src/merge.h":"defe4f6abef4c03927f0f89468140e486335f0be06593dc6ef5325f9a74e6f8c","libgit2/src/merge_driver.c":"69faba54835e888da0c30a808762e7d7912951d18e3c2e4696d315d71a1ed16d","libgit2/src/merge_driver.h":"4f56c2965330a5cb08b9f26d6b83dc4e15fced9419540d2d793f2e75049bc121","libgit2/src/merge_file.c":"b0b3b7ee0f6ee004ead88fce60468bdae002e5620650d18bf5313d7f4fcfbaa8","libgit2/src/message.c":"369bbba0abbaebba98cac86426dc42591f42729fd4360d4bcf7855654043bf05","libgit2/src/message.h":"7cabd6fb3da32197a5564061b2f4461551263c207810add923250d9127e3e537","libgit2/src/midx.c":"b95104858ae1f1737c43b323226df3ee2ab9fd4c70eed6efbc3ac27f2a63d210","libgit2/src/midx.h":"6328f785b9b1ffda427b0fb870354e40adbf54452399b2ebd37e3463bf6033e1","libgit2/src/mwindow.c":"1cf194b60f2e1fd590645cfbcf516d2d94cb9cf27214067f74deb56144687657","libgit2/src/mwindow.h":"fb8d6136edcac8ac33535c3b209510041a922960800b9e6143edddc00c952ada","libgit2/src/net.c":"c2e8f1224a26cd0987e0b9456bc60f909e200136fb761f7c2955fdc7c978524a","libgit2/src/net.h":"99850b1781d5e93062a00d2bc94aea379e49b623f30f61f900f85221459a1a4a","libgit2/src/netops.c":"464441d78b35e8be325935134ad8af5da1fe10896b139d176c2dc5de37a22a4f","libgit2/src/netops.h":"54789b7a4de20fd400cb0530e8a96c32bd497aa577ed9f14b2a84175fdd255dc","libgit2/src/notes.c":"4e639e675197f510acd86e5740d39a1a78ed2eaa96ec3c1e71f6e4c975b67a77","libgit2/src/notes.h":"650f92bbf875ab194b9e1d041f06fb8332bf5f402ea49cde528a81d2eac05694","libgit2/src/object.c":"de1ca0f99734559f53f85fed3798aef84d23a14382ddfe056bc2ff611a16ea2d","libgit2/src/object.h":"0fe112515dc59a3faea70637cfb37d6d6b538adac3dcea9ca0fc05d222b0374e","libgit2/src/object_api.c":"ac963762a903ea36adb20f0d4317388159c23828a6e26e9a1b1333b7a9fa1317","libgit2/src/odb.c":"a2f4993945cc478a2e26221c030dba9d150d3c1405978772bdb7819c0e7faeff","libgit2/src/odb.h":"35fc6e5124a2ee9253efcc5593dd68eaca4f15c9da3d05126588cfd990f42344","libgit2/src/odb_loose.c":"417133facd6b635fb3894eb2131fc79a6d0e89c4d0f2e87fd58f5795a0c7e35e","libgit2/src/odb_mempack.c":"83c554256d99195f3c7aa261cff85c796f47275b0ee86eb9867e1ece40f5e0a6","libgit2/src/odb_pack.c":"c6d7feb53bb2cdcf354cebc608789f0558ce217ecc50f9f1dd8f209287fca50f","libgit2/src/offmap.c":"0185030081a9d7df6ca8abea2e0b2c367278172ccd5ca5eb3601555a3ac1f665","libgit2/src/offmap.h":"e902482f4727d30f786f48fbc143d7324ace0fa60877212f7ab3e982b0d46318","libgit2/src/oid.c":"331f27859d5c57594a458a9f70a4735156e1fe8c58826e12e65e41b0fd398048","libgit2/src/oid.h":"322eef4b2dd9b1f78f25b59034491f3547353655d9fcc9b6fe5a1ab348cb1eca","libgit2/src/oidarray.c":"5919ea8d7a0138d9a4323a650c2ef9f2cd52da5d6c8922ce307a6ac6fa131a8d","libgit2/src/oidarray.h":"17a745a4d1f2c464b91080279fb4a3163bb39456be5c7e9d6c8195724cc3cba4","libgit2/src/oidmap.c":"72ee7bfcb30cc05e73e49962aa1d09b78060272666420bc2b31083e18cdc2384","libgit2/src/oidmap.h":"7aff6a1568632f38f2acea1a526e11e24b42fffa7b05b75ac53ce18b9dd70e42","libgit2/src/pack-objects.c":"b81393cef517797b5b80ac35232be4e4578cd8f30d6994ddb424ae73aba42dfc","libgit2/src/pack-objects.h":"d6f1847b389cbf39c756341b64cabc2a12bd01f7def2d14bb18406feac19fd2d","libgit2/src/pack.c":"1ebe15d9bf5d0e88e5cab83b199a18d787961bd7213541781afb07f42e2980b9","libgit2/src/pack.h":"114150d7e4528ff2ea25e27ff9308b3026590ad4c547a4822007fbf78d69fac2","libgit2/src/parse.c":"34410522f13568a6d061ed723ddd7049f21d1f054e530bd5d3c262a1105e1f74","libgit2/src/parse.h":"d5f25a7d63d004bd3abe86255b2877f5c6415939338202c32fc78e218c9554fc","libgit2/src/patch.c":"bf8a4eb0504e21c9515c75959cce25217c3ec6793f6672e6fc748e1e7aaf51e8","libgit2/src/patch.h":"b6e844a48af7a8729c37f9bab8dc794907534ff723543260781491c133930120","libgit2/src/patch_generate.c":"437f7cf9b0bf406bbb139a26c6bd804419b710ac32eb954b7c4ebead8ede5977","libgit2/src/patch_generate.h":"396a726fd8546630bfc85fb4b1a1fcb3e085aca4b7263f0042aea1b12ff02e35","libgit2/src/patch_parse.c":"d06965a193f61a37c92ff832cd0de5b4db44ba5ac8debdc4a059ed03f65d643a","libgit2/src/patch_parse.h":"6883a184830f4c59427177eba5462d27737706a1be899db35423c5ad9d6c8c4a","libgit2/src/path.c":"ab081d6e1dcacfc36c632cf025371b5a67bc820bb4027d233713d62109020470","libgit2/src/path.h":"4dd10e891b565df2713db6f386b389c681f77f9ac22a6962553bcb129ce04393","libgit2/src/pathspec.c":"bfb5408efe5812112a050cb53106c0f9d09c198ff912cf7a45a746ade6676a18","libgit2/src/pathspec.h":"405f9c8598735d84951b8adc40e66617dcaf20f5141e5caa187cb638936041c4","libgit2/src/pool.c":"9a84fc9208d8cfeb4537d6e8575a43ed6ff56689f23b4b48ef61381c7b5f4303","libgit2/src/pool.h":"af966aeaee12823f34136e607156e7e64f03f34a0041d0e74aa71fe7245e9d34","libgit2/src/posix.c":"f092a25aadec65445c80899a33bd34b48c17bb6b5e6dd2297581194749155854","libgit2/src/posix.h":"dc452141efa29d919226043135a9300762470de0f20cbf2c2bace92a20c661ab","libgit2/src/pqueue.c":"d5cd8f6c5639b50898fe0f9354dbb29de1a0be1d20c879242c8423907466c7c2","libgit2/src/pqueue.h":"c4c98b6e99fdc1ab33906a1d659ba113a2048890928f158e9031caa35e385991","libgit2/src/proxy.c":"9078a1231c675e70369448d9d7f6548f4f1922e5703074a4d7f4f670f8004fe8","libgit2/src/proxy.h":"e195b1b88c11f9d02aa8f02925fd7f11cd68c0361d0e7a6a477f4a3a5cceb896","libgit2/src/push.c":"ce8fc35067e4d1f93ca656af625bb447493ac8ca99e5a95ed208228b0bf3c1a4","libgit2/src/push.h":"aa327d0a24e838330230c10b4b67431e0ea0fd7913c3bb8fbd24441bf72fb8be","libgit2/src/reader.c":"45a1b838d7f13530d570720fbc9ee05f98f6b37610d2f30f3bd6d550b9ca5c08","libgit2/src/reader.h":"7c5c2aa3805bcf813d2ef84373fa55d06c7c675b79854c4fa82e77724a5d575b","libgit2/src/rebase.c":"583485b207cffcb73ddfed1c94915425b925c7b8fe609033ae00ab60a5fe2c89","libgit2/src/refdb.c":"40cd4c55b0d0296bfa674541fb16936cb7c5a785be9afdbfca5e96b54adb7424","libgit2/src/refdb.h":"ad8127049a89e43f49ffed64e82ee343e7c8acee31f7cb900b555193667cb99a","libgit2/src/refdb_fs.c":"6c779aab0f15954d109d9642dabbe84b434d5d2cc1332eefb9ec6a8df1803414","libgit2/src/reflog.c":"becf9c66068585bd1e93a1328db2529199a322cc212d60b6738183495f326327","libgit2/src/reflog.h":"898ae0bf378c465673fef1a4221baa2cf6165a0700949952971f743ca73075da","libgit2/src/refs.c":"7f229f323b081dd7769bbdd391c7a0bbd82cb3e347bbab19876358a7573f7dcc","libgit2/src/refs.h":"48d9a8164377eacf3ab34aba0e7c64ad14d77be1d5605b7df959948955cb82a5","libgit2/src/refspec.c":"65978f805a46117a448d1a27cc09ce8b288765f300e049cb6d23a08313417710","libgit2/src/refspec.h":"6ebd69454d6f9942c531cd7dfb976a2a8f7474e4f12eabbc33f741c0f9632d04","libgit2/src/regexp.c":"2dbafc10e44384cf82fa5ffc7ac9d434150ec648871a8adaa1a20e1a3dd10d65","libgit2/src/regexp.h":"3861d1cb9e9435a07acbdc94d2b1b68ddc46ab0f33cf9fba4815f5d74ba3a88f","libgit2/src/remote.c":"4f04989ea3bc550979905fe30358613800212dc766512de85daf6313eba0a5f9","libgit2/src/remote.h":"86d49794834fd490e5bb5b714effb1c0ca80667a18947cfbe27909e7a6a1b9e1","libgit2/src/repo_template.h":"bec227c595d193802723f81765487da76beaffafae40ec05b76a4db7de153c01","libgit2/src/repository.c":"fba4f8b55129007bd31bc56e0dabcf75cb893dff184a23db01d71e06adcaa7d0","libgit2/src/repository.h":"baaf5dba2c1786c452520e9a288bfd8a361c9a9f9a1c9a9272810fca4ba3b89a","libgit2/src/reset.c":"4d03f947bcbb8f057d76443e032f382b77e68e083af5b45e85cf89b6561d074b","libgit2/src/revert.c":"54772299d5394f02236a36942eec342db80c50f4ff5dc3f7b019c9eb73bdf97d","libgit2/src/revparse.c":"7be8f4576c4346a113b665a3c2b51bccde70887362d4d881efe287ed049d43fb","libgit2/src/revwalk.c":"2fb0cb8afb81bf4e420836395e9ad08a6ca76cc3b456673c3d29d9f75d574663","libgit2/src/revwalk.h":"d341454f2b0f22e69f1c890fb9f3a2d8ef327797dc8f1dab5cb2b2734b57bebb","libgit2/src/runtime.c":"1eedad58ec93e1b34a3c636769fa94bbd8f26b175a7e001ffcd92b754483f416","libgit2/src/runtime.h":"523451d56b175f285e8cfd691b5f3c2522413b83dfffa53b6e35d4669572201e","libgit2/src/settings.h":"9addfd18452820405a0309f944f01bfb63b6918f740f8dd6e6e4f889cac51537","libgit2/src/signature.c":"450d6189ba5925a28fdcd9503ef4f2d8b73d725e6c57647deeaa47bccaa832dd","libgit2/src/signature.h":"766717ad4c2fdaad4b32f5dc5710f14edcda06ac2f98d98c24cf21a6620e6ff9","libgit2/src/sortedcache.c":"967ab6a718a9e61fc02b99498c9ef6a066b2ceba137c8b20af62968d2bf9a856","libgit2/src/sortedcache.h":"a2ada486c90e39a5f8b00c93c70a08b8d452c7136cf4b153562e498614407b8f","libgit2/src/stash.c":"a4238729ebcce245c9486d0ef159b170c5afb2adb984bbd6b6256aa50a38a07c","libgit2/src/status.c":"1449a9192fbb392e027833de43c7b0bb1f3e957f53c27e6967a49f35f5df46a6","libgit2/src/status.h":"68ed612f65430563ad5b3f50973b360f583c5865e54c9b9298eb082d441c4e79","libgit2/src/strarray.c":"8beb44371f7dfdbe492fdc6bece0569c0732f11664aa735b6842df990ed2ed3e","libgit2/src/stream.h":"a7755d211e19ea4a29d7d6151f71efd92bb92906d1668960e076ced663961784","libgit2/src/streams/mbedtls.c":"2f694fccd4dcfead1e18fe34cc19863cff37a3c3e3d3e8e7e69b67c26a7f5bcd","libgit2/src/streams/mbedtls.h":"4aab96dac336790b4b172a7f355eb3fa6db35d31765edfa6524c581c10896ec3","libgit2/src/streams/openssl.c":"a119df581f475c3a31e89ff6a3685818c973e5ecdde2dd7373caa8d3edc71c29","libgit2/src/streams/openssl.h":"693e5d00ba86f206170630f3a23771cec7824017b26d6c6436620b6812a03833","libgit2/src/streams/openssl_dynamic.c":"938d853510017e1fbe84322359c5b65b8cd2737bd3fe6bfd0cde85ea2b17d29e","libgit2/src/streams/openssl_dynamic.h":"07293341a32877f2a1fdd69d4e6e9943e52012b0ac7d9d22f56ee03683f9c703","libgit2/src/streams/openssl_legacy.c":"1c0643b0ea8cdd9d2f37dda38d777dc6aa6d3af8c631671f413da53b62470066","libgit2/src/streams/openssl_legacy.h":"5a0f3da348dd5fb0cf4ddf7b9f65234bb5cf7017dfb084e5aad48e8d33d818a3","libgit2/src/streams/registry.c":"079e2c8807d0cab10ab4363599e8a82e31042ba5ba2802cb52cdca0afad8222c","libgit2/src/streams/registry.h":"42a887dd1fff029efa00a04a4e8716905149d3639a6881dc53254170cb8e18be","libgit2/src/streams/socket.c":"7505512da233f7a37b2fbb9c7c5b1afd7fd41db6bef7542a2d2c6c9773f59951","libgit2/src/streams/socket.h":"6ed5745f368fb167f24b8a733be0c2272f5bceb9fc40b5c550463428533c26f9","libgit2/src/streams/stransport.c":"99085a58bd8a2f1cd5e37896a45b27268b7fe4a26fc137d98f5e16c7866def92","libgit2/src/streams/stransport.h":"01c4555417713c415de10ea16222d44cd9c0c0db4ad5d7e3d5e9863d62f49eb4","libgit2/src/streams/tls.c":"807146d607993810ad1b09362605596c067043aa78f7f062c5e92eb3b20789c8","libgit2/src/streams/tls.h":"c989f0a996ba7a11f8732336da77266905ebbc371e5e5969955d096ae16b64ad","libgit2/src/strmap.c":"02ee770dfbcc95f15bfe6755853f1c2795782f906d883d3102a904fedb2cda23","libgit2/src/strmap.h":"66e8c5a84d36cd1e3f3b6693d8c0601824d709f9fd3e27a48f235ae06f71cc39","libgit2/src/strnlen.h":"27e73ccbe8be7c5bac1d022bf59f2458cc2998d0222e7658a687e02f89fcfd17","libgit2/src/submodule.c":"b1b20aa17f1eeaf4b318a4cfe4bf3405ebfd438eaea71cf40d6ea06e12d107bb","libgit2/src/submodule.h":"fbd4ddc9e32939d9f2c7f049e452f9c75a2c0b96f7cb6b2d9137f58a3914bc34","libgit2/src/sysdir.c":"c848be4a53d37baabae68568b5f23e2441cff4b31869aea2e0a98a676f19d8d8","libgit2/src/sysdir.h":"fff528468f7c9fa3258f47a0405e190ac191e9f290aab7e2a8a8b2dbb1b9fff8","libgit2/src/tag.c":"492c06a3618409a0d88358ae79f3f454ea777ed5a77fac1642938caabce4025d","libgit2/src/tag.h":"e14485eafab3d4925bb6652158fb2f6abd211dbefe0655607a561b8bc6826ba9","libgit2/src/thread.c":"a6ec2a0f77637ecd8d29834a8c60f3329cfa532ec1d85f3be3920de07564ad1d","libgit2/src/thread.h":"6af008c48539f73a89a7130e059cc62aff2cd367848ea1cf1f1fad03c9a5cb60","libgit2/src/threadstate.c":"412ef19ecbd1d10edced57c858554549cfab2ae2271c3ff84c19b7d5ee500a02","libgit2/src/threadstate.h":"522d3a4c7779649510a18f378f963a23de05ed3a5e492b00c1a9d62a9b7f8324","libgit2/src/trace.c":"bce0652cda2c922d8a83272b35a704313868ff8d3121f92790a96eb948d53f86","libgit2/src/trace.h":"3c13e2ad631d60c79a233195d5ab1f87e4d6c1a72e56dde3a2b3241d2855f068","libgit2/src/trailer.c":"0c7ef868fe2d991de8c3e87f298b7e4ad4fed6caf9b08e42f46184f2bdaa6725","libgit2/src/transaction.c":"b3c07ef995c0325323a959b6c01fecc32a2a21df5cb7ed73f2eed6fd605e18d5","libgit2/src/transaction.h":"42e4b38d1fc7a8d57513da8230fff2f11ea4e1c2907130f99d77fdd2f099fc62","libgit2/src/transport.c":"7dfaf8b9af066c5cee8e254411483bd8189b48c57b5f9af151b1595de6b27e6f","libgit2/src/transports/auth.c":"bee50c17961564ce984947ef0dfffa4347e3dbd95d2b69d62747d25c792a448b","libgit2/src/transports/auth.h":"a92b6cbb2df72d5daad28e04987f4316a1635021f9ab0dbeb625eafb783c03a9","libgit2/src/transports/auth_negotiate.c":"cb7efb669ad0850e13feaa0d744d17f751fda71b016f96664d50fc97383da444","libgit2/src/transports/auth_negotiate.h":"1125aec36ee74214a6a159027f6babd4299dbbc31d663202656cd12b6e83a245","libgit2/src/transports/auth_ntlm.c":"9d12b7446c747fef671ca71c8122552e96b3b3806e2de60f24ae486f1fb888a9","libgit2/src/transports/auth_ntlm.h":"b5c953351d00c7fd0773eb9038a8fd72c731b96b8f8372cc5bac4920db90e691","libgit2/src/transports/credential.c":"058451ea233e7cf2d65f00b281a28caab16a84c9c83306e0ddc41479e7f93339","libgit2/src/transports/credential_helpers.c":"e6ce81166b05d5f66c74c24086ec2025758ced7d8b85b041e190c2dab57e181b","libgit2/src/transports/git.c":"1e9128ff40a44d478dae98937fb381ad89cdee60b1ae58c605720c48dc96328e","libgit2/src/transports/http.c":"4bfff6ef16834cdb7356969b9318be10b14bda9551195f528ab0a0ee8ce8814a","libgit2/src/transports/http.h":"78c2c02b6644db04cffc64d83efac8335734ae9582ccc8c9121bb90050c47aa6","libgit2/src/transports/httpclient.c":"388fbfed5d5e5c14dc835e332faf7a4436469aa8401a3bcf9383fa4a206e5fea","libgit2/src/transports/httpclient.h":"58815a04492f73224f3bfc72b370c059279e76de1ffe0ac8829c12fe96f3f942","libgit2/src/transports/local.c":"e468156159a50202d2e3ec2aa368d6952878acc9ee6f0972b9fc090e18ce2197","libgit2/src/transports/smart.c":"f04871015030b94c4c934e67fb2765ecf432ac29324748dcf2f729fe07ef128e","libgit2/src/transports/smart.h":"a00f197ebde4ea581f7659b9c4208b27479d0e7e3da2f8706878e411155c9d01","libgit2/src/transports/smart_pkt.c":"22721460a60fd2c990d3f86b5aa02cd4b4992e40b23c6d9dc943ba9e39ed9f25","libgit2/src/transports/smart_protocol.c":"d35bf7fb2b5d096b2ee8999f56297711a8f1eaa2b7294df04614f2178e5375f1","libgit2/src/transports/ssh.c":"6be05611e0a1632c90ec87bb98f6e99c92aa4803c96e9b2e9035b763ad6595b3","libgit2/src/transports/ssh.h":"a4f6279848362d54f6ba4e9338443d6a3402c1ddb9eb85e2e3befb937cbea2ff","libgit2/src/transports/winhttp.c":"3f7c36ef3a06225728a600e1b2b5c597e59361820538dd39d30403ac20a4f94f","libgit2/src/tree-cache.c":"8300f36285dba6d1980b10f30c95a353789c37f079e2e1868c81df64b21ca3ac","libgit2/src/tree-cache.h":"f7fac0fe438958415ccd256e0bf9cbe30aa20aa125e60f3812a7fa0521ddb12a","libgit2/src/tree.c":"cecac07a9b403b16603a1f23a407f506ec6915ff834fe6cd18064e0144ad6e4c","libgit2/src/tree.h":"8aff774d2ee17d8d19e23a059955956d2457b52172a6b4f0ae7b8b08de5462e2","libgit2/src/tsort.c":"4c5a1ec08d13148e230fd72592d74346d35a2c219643d52ba8600eadf63f01a9","libgit2/src/unix/map.c":"2e1aa0c66090f410f6dcee0a22fb6075275ccc968c7270ea1e944a3287d1f4e2","libgit2/src/unix/posix.h":"35d31249fe4945bc57da60a5b2b800493c92950bcce44f545afdbdf3fda60c20","libgit2/src/unix/pthread.h":"c716daa88e2e7ef2a2df23591a6061965dc11d77ed5fe1863d367a2b738a9fb0","libgit2/src/unix/realpath.c":"e3ed89d4139d62b8a8f37579edb1f262fa02972834603f7b00596cc88240ad2b","libgit2/src/userdiff.h":"f623acbe67ce809a21541d0d665536f68df9e0ed8a4aa4556cbffd070960fc88","libgit2/src/utf8.c":"f15639b96595f71d7ae311a05360a64c3fd6c7214290ec5dab41685051d2a045","libgit2/src/utf8.h":"71462f2cd84decedc57df1b22f2998134d6f4ae62dd1ff102204d18c502614e9","libgit2/src/util.c":"aed722b75b012923b04e9f048490d9e8fcf06529b2f83fe156784c71467ef85c","libgit2/src/util.h":"7607d01f940e1d20c8029150f450c65cc2d7b6c2f71c3ceded905ca9d7a12a2a","libgit2/src/varint.c":"f93c5ba3498ac04d98ba13d3a320263892452356f797c4091411e5833dfe82f2","libgit2/src/varint.h":"db8ed46f6049f12058d4b624cb0a5ea9d0b0f1317b6378c8817d6e632b6436cd","libgit2/src/vector.c":"03cfd9059ffac7ada3c208379eea8ba9bb3b47e33e11d944ea333d3760ff08e8","libgit2/src/vector.h":"25f1cc4a3b52145761be8f3fab9668949b6bcccdaf895973fedc127ee3312a69","libgit2/src/wildmatch.c":"0102685757a40046a5fdee4be5be784989a84d3b4be9160d48120c4485c37133","libgit2/src/wildmatch.h":"c33e23b44b8989a91614563ddc5b6c69ad6f76a91abc081bfbc985d8a7dc4976","libgit2/src/win32/dir.c":"a0490ab8fe3be9213093afca1923a0fc472d368f2907ab23a86bb392520359cc","libgit2/src/win32/dir.h":"8e520dd28e37c333aeb10f745efce8ba48a4db414b1605027787b1a52b75a222","libgit2/src/win32/error.c":"f1d2bcb2b6e60ca76c1ee0ca0f236e928331aa9755afc16926a5dab5de26d255","libgit2/src/win32/error.h":"47faa526d448f222c9ed0cf7c3f1ed2c4f14c166610524c76eeb6f0f83938a63","libgit2/src/win32/findfile.c":"88c89b4c402908f2d15ee1b56716a3edb7962d20ed901561356f1799d7adaf3b","libgit2/src/win32/findfile.h":"47842451768d01dec2b7965669ccbc9da6be26449e3b4ebf93caa1ff3f08ab3e","libgit2/src/win32/git2.rc":"da3c8f58e8b133c52ce5184dfd9afa88801ec3e09ed76f2547a7851a25d3199d","libgit2/src/win32/map.c":"c002138fe669544a03a4363cd6fc25e53ccf1d045abec59f4633b6be9d022baa","libgit2/src/win32/mingw-compat.h":"f7b0c7e9dd7147e8930782cdf54ce4be385172966dd1e27435446f38cd2f6d68","libgit2/src/win32/msvc-compat.h":"36e4c9515a8d53e70f78794826700c4a5472235aef703ac439308dd005e31454","libgit2/src/win32/path_w32.c":"b1df028f86d538818acae31d60a45aa90098f36732784e311d2ab6f39d350d07","libgit2/src/win32/path_w32.h":"57515fa93c352fe37ff20819308b171e85e52b18f20a3afe465370f9d26fb845","libgit2/src/win32/posix.h":"b305d9c04f62134b93a03d4b5ba76699800abaa54bb538b07dc18b1dfe536952","libgit2/src/win32/posix_w32.c":"1e5dd32c1ddb7211bcd6f8ada01d75b9016f715ae076c02170721109858445c5","libgit2/src/win32/precompiled.c":"4dff04101bd64b95c8f708d1accd1bedc39e95a263444290f796c63f4734d4cd","libgit2/src/win32/precompiled.h":"e3fb71360ca11082e3e1a66042bef0361c05b962179775010d48a821edfbcb74","libgit2/src/win32/reparse.h":"ba254a97aba283930306f39f73e297d5eb30350276b3dd86deecbf10b4094c97","libgit2/src/win32/thread.c":"bce98dd6a635b66d811fab98b943ec448751a8b55c7261732277ca2804862fb9","libgit2/src/win32/thread.h":"ebfbf037e0096cbccc625240ebe95ddce23af7d9a8ea24e73bcfd035b69f4333","libgit2/src/win32/utf-conv.c":"fce8f7998d93fcd4f043d4d643f466a854b9611389487250e65fbc987a455bca","libgit2/src/win32/utf-conv.h":"46473448949ef66faf32be710f48d3a925e3db1aee27c4cfc4fcd36d344a5404","libgit2/src/win32/version.h":"d9d9546728ee78923ba7ea1c16c000d44450ca80f8c0c3268bf58fa9966ba38f","libgit2/src/win32/w32_buffer.c":"de172fe5493ff2d4d6ff65c3c96fc82169f1e0bb2e4e3a4cf637ef518636db44","libgit2/src/win32/w32_buffer.h":"f50a4d06e54710e5f0c5a3eca13690d71875339ae7e696455062651e265b6ae5","libgit2/src/win32/w32_common.h":"214cd67bcbdf89bb7effb78ee50c60b0504319117984c1a990f8301cffd78e0d","libgit2/src/win32/w32_leakcheck.c":"b185b87779ff34d46aa679ed4da8ae116dd2173a7f339c8a3cf5f3b266d3fd76","libgit2/src/win32/w32_leakcheck.h":"76fe2642298d62d83d7e80bf41eac67dc5b9edec41445da70bf7f42177b1827f","libgit2/src/win32/w32_util.c":"fbe85eac432d4d1462ba659726557f782e811353170df8838ea1f967950d8711","libgit2/src/win32/w32_util.h":"acd149fd9f4683085b6c33671c49ff12be7ed316767fca0490c567b04b9328d9","libgit2/src/win32/win32-compat.h":"5ea7b1837a159d66a89365ee2bf3724b32579a6a78d94b0b205d44c8697a8e6f","libgit2/src/worktree.c":"4d500b5b4aab3c645fae9382629c93f5e4d551f81e4c118e4e32a1977a7d6805","libgit2/src/worktree.h":"8f2e10b231590962e1d43b4dd51085da343f09f3e74245141720de9ff8a8e4c5","libgit2/src/xdiff/xdiff.h":"63fb0e162716c6c30364d24f5be1192a3724e527864e462d2163a904222d0b91","libgit2/src/xdiff/xdiffi.c":"17f4fd29d3e6c5a45fb3e4942d95abfab96e470c5f5bfc6ea16ec14bda318b0c","libgit2/src/xdiff/xdiffi.h":"3429a12de1a8c990005268801706fc2ced0f935813e12493c2dee68ba28dc94e","libgit2/src/xdiff/xemit.c":"588f9867c656b7311006e63ac1c1fc57cfd5f1f2ba5890bc60946d9f638afcb7","libgit2/src/xdiff/xemit.h":"0a8c569eec74bb4d6e8b7b9a50b457532550800e0566cbba6d185974613a2e6c","libgit2/src/xdiff/xhistogram.c":"141e5d993bb0c609de7828a4c3e1e1b26deebb05b0995f1ef4601cbf609050f7","libgit2/src/xdiff/xinclude.h":"26f9a54fefdc2635e31801febb7d44afa8d039d078414d6cd26463e67e5346b5","libgit2/src/xdiff/xmacros.h":"d9cc54bfc6c0f9e6eef68f9d03594a8bd10f6243a2137776527bb5c849cc9de2","libgit2/src/xdiff/xmerge.c":"198275cee963f086086fce7ca5d6c62d31c956701db15a38220a92ebc281a8ee","libgit2/src/xdiff/xpatience.c":"9b62a3438207aaac20e76bf6c7842037182ee5fb492129f2a3a34e7b1b87f4e2","libgit2/src/xdiff/xprepare.c":"a99e59dfd2adff23a5f3f2b3920ee384eb6665cfbc40eddde11b87dfb0c51bc7","libgit2/src/xdiff/xprepare.h":"4945e8fffe620cd4d687c12618d1a4b2aa95a7a8097abf3e5e341abf96c76e1b","libgit2/src/xdiff/xtypes.h":"3336d046bf60e0dc99f3686dfe9ecf098456f0aebe96486be5d1cd64b5d9cefa","libgit2/src/xdiff/xutils.c":"6928247d6adee0f64a63c6ba103a47abe3a83dca12577552d23094f53d4a55f7","libgit2/src/xdiff/xutils.h":"78e2813f0d604d4deaf29583f6709111d8368b4bbd71cfdc55d56769570abe3e","libgit2/src/zstream.c":"80563757d22d87b8e0b1fff4f7beb71e1cab9cffcd29ce55a978381164983de9","libgit2/src/zstream.h":"9011f92af1f8462795fe19d2b179743209c1d5168812f86e3bda5e7352a63314"},"package":"ddbd6021eef06fb289a8f54b3c2acfdd85ff2a585dfbb24b8576325373d2152c"} \ No newline at end of file +{"files":{},"package":"ddbd6021eef06fb289a8f54b3c2acfdd85ff2a585dfbb24b8576325373d2152c"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/libgit2-sys/Cargo.lock cargo-0.58.0/vendor/libgit2-sys/Cargo.lock --- cargo-0.57.0+ubuntu/vendor/libgit2-sys/Cargo.lock 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/libgit2-sys/Cargo.lock 2022-01-21 03:14:44.000000000 +0000 @@ -0,0 +1,116 @@ +# This file is automatically @generated by Cargo. +# 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 = "cc" +version = "1.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +dependencies = [ + "jobserver", +] + +[[package]] +name = "cmake" +version = "0.1.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8ad8cef104ac57b68b89df3208164d228503abbdce70f6880ffa3d970e7443a" +dependencies = [ + "cc", +] + +[[package]] +name = "jobserver" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" +dependencies = [ + "libc", +] + +[[package]] +name = "libc" +version = "0.2.113" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eef78b64d87775463c549fbd80e19249ef436ea3bf1de2a1eb7e717ec7fab1e9" + +[[package]] +name = "libgit2-sys" +version = "0.12.24+1.3.0" +dependencies = [ + "cc", + "libc", + "libssh2-sys", + "libz-sys", + "openssl-sys", + "pkg-config", +] + +[[package]] +name = "libssh2-sys" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b094a36eb4b8b8c8a7b4b8ae43b2944502be3e59cd87687595cf6b0a71b3f4ca" +dependencies = [ + "cc", + "libc", + "libz-sys", + "openssl-sys", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "libz-sys" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66" +dependencies = [ + "cc", + "cmake", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "openssl-src" +version = "111.17.0+1.1.1m" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05d6a336abd10814198f66e2a91ccd7336611f30334119ca8ce300536666fcf4" +dependencies = [ + "cc", +] + +[[package]] +name = "openssl-sys" +version = "0.9.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb" +dependencies = [ + "autocfg", + "cc", + "libc", + "openssl-src", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "pkg-config" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" diff -Nru cargo-0.57.0+ubuntu/vendor/once_cell/.cargo-checksum.json cargo-0.58.0/vendor/once_cell/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/once_cell/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/once_cell/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"} \ No newline at end of file +{"files":{},"package":"da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/once_cell/Cargo.lock cargo-0.58.0/vendor/once_cell/Cargo.lock --- cargo-0.57.0+ubuntu/vendor/once_cell/Cargo.lock 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/once_cell/Cargo.lock 2022-01-21 02:47:39.000000000 +0000 @@ -9,13 +9,45 @@ ] [[package]] +name = "atomic-polyfill" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "critical-section 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "riscv-target 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "autocfg" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "bare-metal" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bare-metal" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "bit_field" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "bitfield" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -29,6 +61,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "cortex-m" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bare-metal 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "bitfield 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", + "embedded-hal 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "volatile-register 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "critical-section" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bare-metal 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cortex-m 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "riscv 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "crossbeam-utils" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -39,8 +93,17 @@ ] [[package]] +name = "embedded-hal" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "nb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "instant" -version = "0.1.9" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -53,12 +116,12 @@ [[package]] name = "libc" -version = "0.2.97" +version = "0.2.112" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lock_api" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -70,44 +133,58 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "nb" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "nb 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "nb" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "once_cell" -version = "1.8.0" +version = "1.9.0" dependencies = [ + "atomic-polyfill 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "parking_lot" -version = "0.11.1" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "instant 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "lock_api 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)", + "instant 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "lock_api 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "parking_lot_core" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "instant 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.97 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "instant 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.112 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", + "smallvec 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "redox_syscall" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -131,13 +208,53 @@ ] [[package]] +name = "riscv" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bare-metal 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bit_field 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", + "riscv-target 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "riscv-target" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "smallvec" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -159,6 +276,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "vcell" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "volatile-register" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "vcell 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -179,26 +314,44 @@ [metadata] "checksum aho-corasick 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "36b7aa1ccb7d7ea3f437cf025a2ab1c47cc6c1bc9fc84918ff449def12f5e282" +"checksum atomic-polyfill 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e686d748538a32325b28d6411dd8a939e7ad5128e5d0023cc4fd3573db456042" "checksum autocfg 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" -"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +"checksum bare-metal 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "5deb64efa5bd81e31fcd1938615a6d98c82eafcbcd787162b6f63b91d6bac5b3" +"checksum bare-metal 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603" +"checksum bit_field 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4" +"checksum bitfield 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)" = "46afbd2983a5d5a7bd740ccb198caf5b82f45c40c09c0eed36052d91cb92e719" +"checksum bitflags 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" "checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3" "checksum cfg-if 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +"checksum cortex-m 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ac919ef424449ec8c08d515590ce15d9262c0ca5f0da5b0c901e971a3b783b3" +"checksum critical-section 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "01e191a5a6f6edad9b679777ef6b6c0f2bdd4a333f2ecb8f61c3e28109a03d70" "checksum crossbeam-utils 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" -"checksum instant 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" +"checksum embedded-hal 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "e36cfb62ff156596c892272f3015ef952fe1525e85261fa3a7f327bd6b384ab9" +"checksum instant 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.97 (registry+https://github.com/rust-lang/crates.io-index)" = "12b8adadd720df158f4d70dfe7ccc6adb0472d7c55ca83445f6a5ab3e36f8fb6" -"checksum lock_api 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" +"checksum libc 0.2.112 (registry+https://github.com/rust-lang/crates.io-index)" = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" +"checksum lock_api 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "712a4d093c9976e24e7dbca41db895dabcbac38eb5f4045393d17a95bdfb1109" "checksum memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "88579771288728879b57485cc7d6b07d648c9f0141eb955f8ab7f9d45394468e" -"checksum parking_lot 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" -"checksum parking_lot_core 0.8.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" -"checksum redox_syscall 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "742739e41cd49414de871ea5e549afb7e2a3ac77b589bcbebe8c82fab37147fc" +"checksum nb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" +"checksum nb 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" +"checksum parking_lot 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +"checksum parking_lot_core 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +"checksum redox_syscall 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" "checksum regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6b23da8dfd98a84bd7e08700190a5d9f7d2d38abd4369dd1dae651bc40bfd2cc" "checksum regex-syntax 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bfaca88e749e19dffb60f77b55e5d87a872fac7e9e48598f7cf93b2d8c047b0a" +"checksum riscv 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6907ccdd7a31012b70faf2af85cd9e5ba97657cc3987c4f13f8e4d2c2a088aba" +"checksum riscv-target 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "88aa938cda42a0cf62a20cfe8d139ff1af20c2e681212b5b34adb5a58333f222" +"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" -"checksum smallvec 1.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" +"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +"checksum smallvec 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" "checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" "checksum ucd-util 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f3bf5cdf1df6b578c0947a94d4740bbb2b2afd1b898e33df1ff07b555a335e4" "checksum utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd70f467df6810094968e2fce0ee1bd0e87157aceb026a8c083bcf5e25b9efe4" +"checksum vcell 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "77439c1b53d2303b20d9459b1ade71a83c716e3f9c34f3228c00e6f185d6c002" +"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +"checksum volatile-register 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9ee8f19f9d74293faf70901bc20ad067dc1ad390d2cbf1e3f75f721ffee908b6" "checksum winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff -Nru cargo-0.57.0+ubuntu/vendor/once_cell/Cargo.toml cargo-0.58.0/vendor/once_cell/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/once_cell/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/once_cell/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -3,17 +3,16 @@ # 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 = "once_cell" -version = "1.8.0" +version = "1.9.0" authors = ["Aleksey Kladov "] exclude = ["*.png", "*.svg", "/Cargo.lock.msrv", "/.travis.yml", "/run-miri-tests.sh", "rustfmt.toml"] description = "Single assignment cells and lazy values." @@ -53,6 +52,10 @@ [[example]] name = "test_synchronization" required-features = ["std"] +[dependencies.atomic-polyfill] +version = "0.1" +optional = true + [dependencies.parking_lot] version = "0.10" optional = true diff -Nru cargo-0.57.0+ubuntu/vendor/once_cell/CHANGELOG.md cargo-0.58.0/vendor/once_cell/CHANGELOG.md --- cargo-0.57.0+ubuntu/vendor/once_cell/CHANGELOG.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/once_cell/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 @@ -1,5 +1,9 @@ # Changelog +## 1.9 + +- Added an `atomic-polyfill` optional dependency to compile `race` on platforms without atomics + ## 1.8.0 - Add `try_insert` API -- a version of `set` that returns a reference. diff -Nru cargo-0.57.0+ubuntu/vendor/once_cell/src/lib.rs cargo-0.58.0/vendor/once_cell/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/once_cell/src/lib.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/once_cell/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -441,6 +441,18 @@ /// Gets a mutable reference to the underlying value. /// /// Returns `None` if the cell is empty. + /// + /// This method is allowed to violate the invariant of writing to a `OnceCell` + /// at most once because it requires `&mut` access to `self`. As with all + /// interior mutability, `&mut` access permits arbitrary modification: + /// + /// ``` + /// use once_cell::unsync::OnceCell; + /// + /// let mut cell: OnceCell = OnceCell::new(); + /// cell.set(92).unwrap(); + /// cell = OnceCell::new(); + /// ``` pub fn get_mut(&mut self) -> Option<&mut T> { // Safe because we have unique access unsafe { &mut *self.inner.get() }.as_mut() @@ -590,6 +602,18 @@ /// assert_eq!(cell.take(), Some("hello".to_string())); /// assert_eq!(cell.get(), None); /// ``` + /// + /// This method is allowed to violate the invariant of writing to a `OnceCell` + /// at most once because it requires `&mut` access to `self`. As with all + /// interior mutability, `&mut` access permits arbitrary modification: + /// + /// ``` + /// use once_cell::unsync::OnceCell; + /// + /// let mut cell: OnceCell = OnceCell::new(); + /// cell.set(92).unwrap(); + /// cell = OnceCell::new(); + /// ``` pub fn take(&mut self) -> Option { mem::replace(self, Self::default()).into_inner() } @@ -737,7 +761,7 @@ panic::RefUnwindSafe, }; - use crate::imp::OnceCell as Imp; + use crate::{imp::OnceCell as Imp, take_unchecked}; /// A thread-safe cell which can be written to only once. /// @@ -835,6 +859,18 @@ /// Gets the mutable reference to the underlying value. /// /// Returns `None` if the cell is empty. + /// + /// This method is allowed to violate the invariant of writing to a `OnceCell` + /// at most once because it requires `&mut` access to `self`. As with all + /// interior mutability, `&mut` access permits arbitrary modification: + /// + /// ``` + /// use once_cell::sync::OnceCell; + /// + /// let mut cell: OnceCell = OnceCell::new(); + /// cell.set(92).unwrap(); + /// cell = OnceCell::new(); + /// ``` pub fn get_mut(&mut self) -> Option<&mut T> { self.0.get_mut() } @@ -897,7 +933,7 @@ /// ``` pub fn try_insert(&self, value: T) -> Result<&T, (&T, T)> { let mut value = Some(value); - let res = self.get_or_init(|| value.take().unwrap()); + let res = self.get_or_init(|| unsafe { take_unchecked(&mut value) }); match value { None => Ok(res), Some(value) => Err((res, value)), @@ -999,6 +1035,18 @@ /// assert_eq!(cell.take(), Some("hello".to_string())); /// assert_eq!(cell.get(), None); /// ``` + /// + /// This method is allowed to violate the invariant of writing to a `OnceCell` + /// at most once because it requires `&mut` access to `self`. As with all + /// interior mutability, `&mut` access permits arbitrary modification: + /// + /// ``` + /// use once_cell::sync::OnceCell; + /// + /// let mut cell: OnceCell = OnceCell::new(); + /// cell.set(92).unwrap(); + /// cell = OnceCell::new(); + /// ``` pub fn take(&mut self) -> Option { mem::replace(self, Self::default()).into_inner() } diff -Nru cargo-0.57.0+ubuntu/vendor/once_cell/src/race.rs cargo-0.58.0/vendor/once_cell/src/race.rs --- cargo-0.57.0+ubuntu/vendor/once_cell/src/race.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/once_cell/src/race.rs 2022-01-21 02:47:39.000000000 +0000 @@ -6,10 +6,13 @@ //! //! This module does not require `std` feature. -use core::{ - num::NonZeroUsize, - sync::atomic::{AtomicUsize, Ordering}, -}; +#[cfg(feature = "atomic-polyfill")] +use atomic_polyfill as atomic; +#[cfg(not(feature = "atomic-polyfill"))] +use core::sync::atomic; + +use atomic::{AtomicUsize, Ordering}; +use core::num::NonZeroUsize; /// A thread-safe cell which can be written to only once. #[derive(Default, Debug)] @@ -160,21 +163,23 @@ #[cfg(feature = "alloc")] mod once_box { - use core::{ - marker::PhantomData, - ptr, - sync::atomic::{AtomicPtr, Ordering}, - }; + use super::atomic::{AtomicPtr, Ordering}; + use core::{marker::PhantomData, ptr}; use alloc::boxed::Box; /// A thread-safe cell which can be written to only once. - #[derive(Debug)] pub struct OnceBox { inner: AtomicPtr, ghost: PhantomData>>, } + impl core::fmt::Debug for OnceBox { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "OnceBox({:?})", self.inner.load(Ordering::Relaxed)) + } + } + impl Default for OnceBox { fn default() -> Self { Self::new() diff -Nru cargo-0.57.0+ubuntu/vendor/openssl/build.rs cargo-0.58.0/vendor/openssl/build.rs --- cargo-0.57.0+ubuntu/vendor/openssl/build.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl/build.rs 2022-01-21 02:47:39.000000000 +0000 @@ -74,5 +74,9 @@ if version >= 0x3_03_02_00_0 { println!("cargo:rustc-cfg=libressl332"); } + + if version >= 0x3_04_00_00_0 { + println!("cargo:rustc-cfg=libressl340"); + } } } diff -Nru cargo-0.57.0+ubuntu/vendor/openssl/.cargo-checksum.json cargo-0.58.0/vendor/openssl/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/openssl/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"8d9facdb76fec0b73c406f125d44d86fdad818d66fef0531eec9233ca425ff4a"} \ No newline at end of file +{"files":{},"package":"0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/openssl/Cargo.lock cargo-0.58.0/vendor/openssl/Cargo.lock --- cargo-0.57.0+ubuntu/vendor/openssl/Cargo.lock 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl/Cargo.lock 2022-01-21 02:47:39.000000000 +0000 @@ -16,9 +16,9 @@ [[package]] name = "cc" -version = "1.0.69" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" +checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd" [[package]] name = "cfg-if" @@ -55,9 +55,9 @@ [[package]] name = "libc" -version = "0.2.99" +version = "0.2.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765" +checksum = "a60553f9a9e039a333b4e9b20573b9e9b9c0bb3a11e201ccc48ef4283456d673" [[package]] name = "once_cell" @@ -67,7 +67,7 @@ [[package]] name = "openssl" -version = "0.10.36" +version = "0.10.38" dependencies = [ "bitflags", "cfg-if", @@ -81,18 +81,18 @@ [[package]] name = "openssl-src" -version = "111.15.0+1.1.1k" +version = "300.0.2+3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a5f6ae2ac04393b217ea9f700cd04fa9bf3d93fae2872069f3d15d908af70a" +checksum = "14a760a11390b1a5daf72074d4f6ff1a6e772534ae191f999f57e9ee8146d1fb" dependencies = [ "cc", ] [[package]] name = "openssl-sys" -version = "0.9.66" +version = "0.9.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1996d2d305e561b70d1ee0c53f1542833f4e1ac6ce9a6708b6ff2738ca67dc82" +checksum = "14276c7942cb12d5ffab976d5b69789b0510d052576b230fcde58d8c581b8d1d" dependencies = [ "autocfg", "cc", @@ -104,9 +104,9 @@ [[package]] name = "pkg-config" -version = "0.3.19" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" +checksum = "12295df4f294471248581bc09bef3c38a5e46f1e36d6a37353621a0c6c357e1f" [[package]] name = "rand" diff -Nru cargo-0.57.0+ubuntu/vendor/openssl/Cargo.toml cargo-0.58.0/vendor/openssl/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/openssl/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -3,17 +3,16 @@ # 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 = "openssl" -version = "0.10.36" +version = "0.10.38" authors = ["Steven Fackler "] description = "OpenSSL bindings" readme = "README.md" @@ -28,7 +27,7 @@ version = "1.0" [dependencies.ffi] -version = "0.9.66" +version = "0.9.69" package = "openssl-sys" [dependencies.foreign-types] diff -Nru cargo-0.57.0+ubuntu/vendor/openssl/CHANGELOG.md cargo-0.58.0/vendor/openssl/CHANGELOG.md --- cargo-0.57.0+ubuntu/vendor/openssl/CHANGELOG.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 @@ -2,6 +2,24 @@ ## [Unreleased] +## [v0.10.38] - 2021-10-31 + +### Added + +* Added `Pkey::ec_gen`. + +## [v0.10.37] - 2021-10-27 + +### Fixed + +* Fixed linkage against OpenSSL distributions built with `no-chacha`. + +### Added + +* Added `BigNumRef::to_vec_padded`. +* Added `X509Name::from_der` and `X509NameRef::to_der`. +* Added `BigNum::new_secure`, `BigNumReef::set_const_time`, `BigNumref::is_const_time`, and `BigNumRef::is_secure`. + ## [v0.10.36] - 2021-08-17 ### Added @@ -556,7 +574,9 @@ Look at the [release tags] for information about older releases. -[Unreleased]: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.36...master +[Unreleased]: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.38...master +[v0.10.38]: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.37...openssl-v0.10.38 +[v0.10.37]: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.36...openssl-v0.10.37 [v0.10.36]: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.35...openssl-v0.10.36 [v0.10.35]: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.34...openssl-v0.10.35 [v0.10.34]: https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.33...openssl-v0.10.34 diff -Nru cargo-0.57.0+ubuntu/vendor/openssl/src/bn.rs cargo-0.58.0/vendor/openssl/src/bn.rs --- cargo-0.57.0+ubuntu/vendor/openssl/src/bn.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl/src/bn.rs 2022-01-21 02:47:39.000000000 +0000 @@ -108,6 +108,19 @@ cvt_p(ffi::BN_CTX_new()).map(BigNumContext) } } + + /// Returns a new secure `BigNumContext`. + /// + /// See OpenSSL documentation at [`BN_CTX_secure_new`]. + /// + /// [`BN_CTX_secure_new`]: https://www.openssl.org/docs/man1.1.0/crypto/BN_CTX_secure_new.html + #[cfg(ossl110)] + pub fn new_secure() -> Result { + unsafe { + ffi::init(); + cvt_p(ffi::BN_CTX_secure_new()).map(BigNumContext) + } + } } foreign_type_and_impl_send_sync! { @@ -885,6 +898,37 @@ v } + /// Returns a big-endian byte vector representation of the absolute value of `self` padded + /// to `pad_to` bytes. + /// + /// If `pad_to` is less than `self.num_bytes()` then an error is returned. + /// + /// `self` can be recreated by using `from_slice`. + /// + /// ``` + /// # use openssl::bn::BigNum; + /// let bn = BigNum::from_u32(0x4543).unwrap(); + /// + /// let bn_vec = bn.to_vec_padded(4).unwrap(); + /// assert_eq!(&bn_vec, &[0, 0, 0x45, 0x43]); + /// + /// let r = bn.to_vec_padded(1); + /// assert!(r.is_err()); + /// + /// let bn = -BigNum::from_u32(0x4543).unwrap(); + /// let bn_vec = bn.to_vec_padded(4).unwrap(); + /// assert_eq!(&bn_vec, &[0, 0, 0x45, 0x43]); + /// ``` + #[cfg(ossl110)] + pub fn to_vec_padded(&self, pad_to: i32) -> Result, ErrorStack> { + let mut v = Vec::with_capacity(pad_to as usize); + unsafe { + cvt(ffi::BN_bn2binpad(self.as_ptr(), v.as_mut_ptr(), pad_to))?; + v.set_len(pad_to as usize); + } + Ok(v) + } + /// Returns a decimal string representation of `self`. /// /// ``` @@ -922,6 +966,30 @@ .map(|p| Asn1Integer::from_ptr(p)) } } + + /// Force constant time computation on this value. + #[cfg(ossl110)] + pub fn set_const_time(&mut self) { + unsafe { ffi::BN_set_flags(self.as_ptr(), ffi::BN_FLG_CONSTTIME) } + } + + /// Returns true if `self` is in const time mode. + #[cfg(ossl110)] + pub fn is_const_time(&self) -> bool { + unsafe { + let ret = ffi::BN_get_flags(self.as_ptr(), ffi::BN_FLG_CONSTTIME); + ret == ffi::BN_FLG_CONSTTIME + } + } + + /// Returns true if `self` was created with [`BigNum::new_secure`]. + #[cfg(ossl110)] + pub fn is_secure(&self) -> bool { + unsafe { + let ret = ffi::BN_get_flags(self.as_ptr(), ffi::BN_FLG_SECURE); + ret == ffi::BN_FLG_SECURE + } + } } impl BigNum { @@ -934,6 +1002,20 @@ } } + /// Returns a new secure `BigNum`. + /// + /// See OpenSSL documentation at [`BN_secure_new`]. + /// + /// [`BN_secure_new`]: https://www.openssl.org/docs/man1.1.0/crypto/BN_secure_new.html + #[cfg(ossl110)] + pub fn new_secure() -> Result { + unsafe { + ffi::init(); + let v = cvt_p(ffi::BN_secure_new())?; + Ok(BigNum::from_ptr(v)) + } + } + /// Creates a new `BigNum` with the given value. /// /// OpenSSL documentation at [`BN_set_word`] @@ -1428,4 +1510,38 @@ assert!(p.is_prime(100, &mut ctx).unwrap()); assert!(p.is_prime_fasttest(100, &mut ctx, true).unwrap()); } + + #[cfg(ossl110)] + #[test] + fn test_secure_bn_ctx() { + let mut cxt = BigNumContext::new_secure().unwrap(); + let a = BigNum::from_u32(8).unwrap(); + let b = BigNum::from_u32(3).unwrap(); + + let mut remainder = BigNum::new().unwrap(); + remainder.nnmod(&a, &b, &mut cxt).unwrap(); + + assert!(remainder.eq(&BigNum::from_u32(2).unwrap())); + } + + #[cfg(ossl110)] + #[test] + fn test_secure_bn() { + let a = BigNum::new().unwrap(); + assert!(!a.is_secure()); + + let b = BigNum::new_secure().unwrap(); + assert!(b.is_secure()) + } + + #[cfg(ossl110)] + #[test] + fn test_const_time_bn() { + let a = BigNum::new().unwrap(); + assert!(!a.is_const_time()); + + let mut b = BigNum::new().unwrap(); + b.set_const_time(); + assert!(b.is_const_time()) + } } diff -Nru cargo-0.57.0+ubuntu/vendor/openssl/src/lib.rs cargo-0.58.0/vendor/openssl/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/openssl/src/lib.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,7 +1,7 @@ //! Bindings to OpenSSL //! //! This crate provides a safe interface to the popular OpenSSL cryptography library. OpenSSL versions 1.0.1 through -//! 1.1.1 and LibreSSL versions 2.5 through 3.3.x are supported. +//! 1.1.1 and LibreSSL versions 2.5 through 3.4.0 are supported. //! //! # Building //! diff -Nru cargo-0.57.0+ubuntu/vendor/openssl/src/pkey.rs cargo-0.58.0/vendor/openssl/src/pkey.rs --- cargo-0.57.0+ubuntu/vendor/openssl/src/pkey.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl/src/pkey.rs 2022-01-21 02:47:39.000000000 +0000 @@ -602,6 +602,22 @@ PKey::generate_eddsa(ffi::EVP_PKEY_ED448) } + /// Generates a new EC key using the provided curve. + /// + /// This corresponds to [`EVP_EC_gen`]. + /// + /// Requires OpenSSL 3.0.0 or newer. + /// + /// [`EVP_EC_gen`]: https://www.openssl.org/docs/manmaster/man3/EVP_EC_gen.html + #[cfg(ossl300)] + pub fn ec_gen(curve: &str) -> Result, ErrorStack> { + let curve = CString::new(curve).unwrap(); + unsafe { + let ptr = cvt_p(ffi::EVP_EC_gen(curve.as_ptr()))?; + Ok(PKey::from_ptr(ptr)) + } + } + private_key_from_pem! { /// Deserializes a private key from a PEM-encoded key type specific format. /// @@ -1128,4 +1144,11 @@ assert!(pkey.raw_private_key().is_err()); assert!(pkey.raw_public_key().is_err()); } + + #[cfg(ossl300)] + #[test] + fn test_ec_gen() { + let key = PKey::ec_gen("prime256v1").unwrap(); + assert!(key.ec_key().is_ok()); + } } diff -Nru cargo-0.57.0+ubuntu/vendor/openssl/src/srtp.rs cargo-0.58.0/vendor/openssl/src/srtp.rs --- cargo-0.57.0+ubuntu/vendor/openssl/src/srtp.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl/src/srtp.rs 2022-01-21 02:47:39.000000000 +0000 @@ -7,7 +7,6 @@ /// fake free method, since SRTP_PROTECTION_PROFILE is static unsafe fn free(_profile: *mut ffi::SRTP_PROTECTION_PROFILE) {} -#[allow(unused_unsafe)] foreign_type_and_impl_send_sync! { type CType = ffi::SRTP_PROTECTION_PROFILE; fn drop = free; diff -Nru cargo-0.57.0+ubuntu/vendor/openssl/src/ssl/test/mod.rs cargo-0.58.0/vendor/openssl/src/ssl/test/mod.rs --- cargo-0.57.0+ubuntu/vendor/openssl/src/ssl/test/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl/src/ssl/test/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -295,7 +295,7 @@ let server = Server::builder().build(); let s = server.client().connect(); - assert_eq!(s.ssl().state_string(), "SSLOK "); + assert_eq!(s.ssl().state_string().trim(), "SSLOK"); assert_eq!( s.ssl().state_string_long(), "SSL negotiation finished successfully" diff -Nru cargo-0.57.0+ubuntu/vendor/openssl/src/symm.rs cargo-0.58.0/vendor/openssl/src/symm.rs --- cargo-0.57.0+ubuntu/vendor/openssl/src/symm.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl/src/symm.rs 2022-01-21 02:47:39.000000000 +0000 @@ -279,13 +279,13 @@ } /// Requires OpenSSL 1.1.0 or newer. - #[cfg(any(ossl110))] + #[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_CHACHA")))] pub fn chacha20() -> Cipher { unsafe { Cipher(ffi::EVP_chacha20()) } } /// Requires OpenSSL 1.1.0 or newer. - #[cfg(any(ossl110))] + #[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_CHACHA")))] pub fn chacha20_poly1305() -> Cipher { unsafe { Cipher(ffi::EVP_chacha20_poly1305()) } } diff -Nru cargo-0.57.0+ubuntu/vendor/openssl/src/version.rs cargo-0.58.0/vendor/openssl/src/version.rs --- cargo-0.57.0+ubuntu/vendor/openssl/src/version.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl/src/version.rs 2022-01-21 02:47:39.000000000 +0000 @@ -127,6 +127,9 @@ assert!(number() > 0); assert!(version().starts_with(expected_name())); assert!(c_flags().starts_with("compiler:")); - assert!(built_on().starts_with("built on:")); + // some distributions patch out dates out of openssl so that the builds are reproducible + if !built_on().is_empty() { + assert!(built_on().starts_with("built on:")); + } assert!(dir().starts_with("OPENSSLDIR:")); } diff -Nru cargo-0.57.0+ubuntu/vendor/openssl/src/x509/mod.rs cargo-0.58.0/vendor/openssl/src/x509/mod.rs --- cargo-0.57.0+ubuntu/vendor/openssl/src/x509/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl/src/x509/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -947,6 +947,17 @@ let file = CString::new(file.as_ref().as_os_str().to_str().unwrap()).unwrap(); unsafe { cvt_p(ffi::SSL_load_client_CA_file(file.as_ptr())).map(|p| Stack::from_ptr(p)) } } + + from_der! { + /// Deserializes a DER-encoded X509 name structure. + /// + /// This corresponds to [`d2i_X509_NAME`]. + /// + /// [`d2i_X509_NAME`]: https://www.openssl.org/docs/manmaster/man3/d2i_X509_NAME.html + from_der, + X509Name, + ffi::d2i_X509_NAME + } } impl Stackable for X509Name { @@ -971,6 +982,16 @@ loc: -1, } } + + to_der! { + /// Serializes the certificate into a DER-encoded X509 name structure. + /// + /// This corresponds to [`i2d_X509_NAME`]. + /// + /// [`i2d_X509_NAME`]: https://www.openssl.org/docs/man1.1.0/crypto/i2d_X509_NAME.html + to_der, + ffi::i2d_X509_NAME + } } impl fmt::Debug for X509NameRef { diff -Nru cargo-0.57.0+ubuntu/vendor/openssl/src/x509/tests.rs cargo-0.58.0/vendor/openssl/src/x509/tests.rs --- cargo-0.57.0+ubuntu/vendor/openssl/src/x509/tests.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl/src/x509/tests.rs 2022-01-21 02:47:39.000000000 +0000 @@ -453,3 +453,26 @@ "Default certificate version is incorrect", ); } + +#[test] +fn test_save_subject_der() { + let cert = include_bytes!("../../test/cert.pem"); + let cert = X509::from_pem(cert).unwrap(); + + let der = cert.subject_name().to_der().unwrap(); + println!("der: {:?}", der); + assert!(!der.is_empty()); +} + +#[test] +fn test_load_subject_der() { + // The subject from ../../test/cert.pem + const SUBJECT_DER: &[u8] = &[ + 48, 90, 49, 11, 48, 9, 6, 3, 85, 4, 6, 19, 2, 65, 85, 49, 19, 48, 17, 6, 3, 85, 4, 8, 12, + 10, 83, 111, 109, 101, 45, 83, 116, 97, 116, 101, 49, 33, 48, 31, 6, 3, 85, 4, 10, 12, 24, + 73, 110, 116, 101, 114, 110, 101, 116, 32, 87, 105, 100, 103, 105, 116, 115, 32, 80, 116, + 121, 32, 76, 116, 100, 49, 19, 48, 17, 6, 3, 85, 4, 3, 12, 10, 102, 111, 111, 98, 97, 114, + 46, 99, 111, 109, + ]; + X509Name::from_der(SUBJECT_DER).unwrap(); +} diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-probe/.cargo-checksum.json cargo-0.58.0/vendor/openssl-probe/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/openssl-probe/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-probe/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a"} \ No newline at end of file +{"files":{},"package":"ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-probe/Cargo.lock cargo-0.58.0/vendor/openssl-probe/Cargo.lock --- cargo-0.57.0+ubuntu/vendor/openssl-probe/Cargo.lock 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-probe/Cargo.lock 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "openssl-probe" +version = "0.1.5" diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-probe/Cargo.toml cargo-0.58.0/vendor/openssl-probe/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/openssl-probe/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-probe/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -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 = "openssl-probe" -version = "0.1.4" +version = "0.1.5" authors = ["Alex Crichton "] description = "Tool for helping to find SSL certificate locations on the system for OpenSSL\n" homepage = "https://github.com/alexcrichton/openssl-probe" diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-probe/examples/probe.rs cargo-0.58.0/vendor/openssl-probe/examples/probe.rs --- cargo-0.57.0+ubuntu/vendor/openssl-probe/examples/probe.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-probe/examples/probe.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,6 @@ +fn main() { + let r = openssl_probe::probe(); + + println!("cert_dir: {:?}", r.cert_dir); + println!("cert_file: {:?}", r.cert_file); +} diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-probe/src/lib.rs cargo-0.58.0/vendor/openssl-probe/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/openssl-probe/src/lib.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-probe/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -36,6 +36,8 @@ "/etc/pki/ca-trust/extracted/pem", "/etc/pki/tls", "/etc/ssl", + "/etc/certs", + "/opt/etc/ssl", // Entware "/data/data/com.termux/files/usr/etc/tls", "/boot/system/data/ssl", ] @@ -106,6 +108,8 @@ "cert.pem", "certs.pem", "ca-bundle.pem", + "cacert.pem", + "ca-certificates.crt", "certs/ca-certificates.crt", "certs/ca-root-nss.crt", "certs/ca-bundle.crt", diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-sys/build/expando.c cargo-0.58.0/vendor/openssl-sys/build/expando.c --- cargo-0.57.0+ubuntu/vendor/openssl-sys/build/expando.c 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-sys/build/expando.c 2022-01-21 02:47:39.000000000 +0000 @@ -23,6 +23,10 @@ RUST_CONF_OPENSSL_NO_BUF_FREELISTS #endif +#ifdef OPENSSL_NO_CHACHA +RUST_CONF_OPENSSL_NO_CHACHA +#endif + #ifdef OPENSSL_NO_CMS RUST_CONF_OPENSSL_NO_CMS #endif diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-sys/build/find_normal.rs cargo-0.58.0/vendor/openssl-sys/build/find_normal.rs --- cargo-0.57.0+ubuntu/vendor/openssl-sys/build/find_normal.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-sys/build/find_normal.rs 2022-01-21 02:47:39.000000000 +0000 @@ -22,21 +22,27 @@ } fn resolve_with_wellknown_homebrew_location(dir: &str) -> Option { + let versions = ["openssl@3", "openssl@1.1"]; + // Check up default aarch 64 Homebrew installation location first // for quick resolution if possible. // `pkg-config` on brew doesn't necessarily contain settings for openssl apparently. - let homebrew = Path::new(dir).join("opt/openssl@1.1"); - if homebrew.exists() { - return Some(homebrew); + for version in &versions { + let homebrew = Path::new(dir).join(format!("opt/{}", version)); + if homebrew.exists() { + return Some(homebrew); + } } - // Calling `brew --prefix ` command usually slow and - // takes seconds, and will be used only as a last resort. - let output = execute_command_and_get_output("brew", &["--prefix", "openssl@1.1"]); - if let Some(ref output) = output { - let homebrew = Path::new(&output); - if homebrew.exists() { - return Some(homebrew.to_path_buf()); + for version in &versions { + // Calling `brew --prefix ` command usually slow and + // takes seconds, and will be used only as a last resort. + let output = execute_command_and_get_output("brew", &["--prefix", version]); + if let Some(ref output) = output { + let homebrew = Path::new(&output); + if homebrew.exists() { + return Some(homebrew.to_path_buf()); + } } } diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-sys/build/main.rs cargo-0.58.0/vendor/openssl-sys/build/main.rs --- cargo-0.57.0+ubuntu/vendor/openssl-sys/build/main.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-sys/build/main.rs 2022-01-21 02:47:39.000000000 +0000 @@ -19,7 +19,9 @@ #[cfg(feature = "vendored_debian_disabled")] mod find_vendored; +#[derive(PartialEq)] enum Version { + Openssl3xx, Openssl11x, Openssl10x, Libressl, @@ -94,7 +96,9 @@ } None => match version { Version::Openssl10x if target.contains("windows") => vec!["ssleay32", "libeay32"], - Version::Openssl11x if target.contains("windows-msvc") => vec!["libssl", "libcrypto"], + Version::Openssl3xx | Version::Openssl11x if target.contains("windows-msvc") => { + vec!["libssl", "libcrypto"] + } _ => vec!["ssl", "crypto"], }, }; @@ -104,6 +108,16 @@ println!("cargo:rustc-link-lib={}={}", kind, lib); } + // https://github.com/openssl/openssl/pull/15086 + if version == Version::Openssl3xx + && kind == "static" + && (env::var("CARGO_CFG_TARGET_OS").unwrap() == "linux" + || env::var("CARGO_CFG_TARGET_OS").unwrap() == "android") + && env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "32" + { + println!("cargo:rustc-link-lib=dylib=atomic"); + } + if kind == "static" && target.contains("windows") { println!("cargo:rustc-link-lib=dylib=gdi32"); println!("cargo:rustc-link-lib=dylib=user32"); @@ -125,8 +139,8 @@ /// version string of OpenSSL. #[allow(clippy::manual_strip)] // we need to support pre-1.45.0 fn validate_headers(include_dirs: &[PathBuf]) -> Version { - // This `*-sys` crate only works with OpenSSL 1.0.1, 1.0.2, and 1.1.0. To - // correctly expose the right API from this crate, take a look at + // This `*-sys` crate only works with OpenSSL 1.0.1, 1.0.2, 1.1.0, 1.1.1 and 3.0.0. + // To correctly expose the right API from this crate, take a look at // `opensslv.h` to see what version OpenSSL claims to be. // // OpenSSL has a number of build-time configuration options which affect @@ -137,6 +151,7 @@ // file of OpenSSL, `opensslconf.h`, and then dump out everything it defines // as our own #[cfg] directives. That way the `ossl10x.rs` bindings can // account for compile differences and such. + println!("cargo:rerun-if-changed=build/expando.c"); let mut gcc = cc::Build::new(); for include_dir in include_dirs { gcc.include(include_dir); @@ -238,6 +253,7 @@ (3, 3, 1) => ('3', '3', '1'), (3, 3, _) => ('3', '3', 'x'), (3, 4, 0) => ('3', '4', '0'), + (3, 4, _) => ('3', '4', 'x'), _ => version_error(), }; @@ -252,7 +268,7 @@ if openssl_version >= 0x4_00_00_00_0 { version_error() } else if openssl_version >= 0x3_00_00_00_0 { - Version::Openssl11x + Version::Openssl3xx } else if openssl_version >= 0x1_01_01_00_0 { println!("cargo:version=111"); Version::Openssl11x @@ -279,8 +295,8 @@ panic!( " -This crate is only compatible with OpenSSL 1.0.1 through 1.1.1, or LibreSSL 2.5 -through 3.4.0, but a different version of OpenSSL was found. The build is now aborting +This crate is only compatible with OpenSSL (version 1.0.1 through 1.1.1, or 3.0.0), or LibreSSL 2.5 +through 3.4.1, but a different version of OpenSSL was found. The build is now aborting due to this version mismatch. " diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-sys/.cargo-checksum.json cargo-0.58.0/vendor/openssl-sys/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/openssl-sys/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-sys/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"69df2d8dfc6ce3aaf44b40dec6f487d5a886516cf6879c49e98e0710f310a058"} \ No newline at end of file +{"files":{},"package":"7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-sys/Cargo.toml cargo-0.58.0/vendor/openssl-sys/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/openssl-sys/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-sys/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -11,7 +11,7 @@ [package] name = "openssl-sys" -version = "0.9.67" +version = "0.9.72" authors = ["Alex Crichton ", "Steven Fackler "] build = "build/main.rs" links = "openssl" diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-sys/Cargo.toml.rej cargo-0.58.0/vendor/openssl-sys/Cargo.toml.rej --- cargo-0.57.0+ubuntu/vendor/openssl-sys/Cargo.toml.rej 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-sys/Cargo.toml.rej 2022-01-21 03:07:38.000000000 +0000 @@ -0,0 +1,18 @@ +--- Cargo.toml ++++ Cargo.toml +@@ -30,14 +30,11 @@ + [build-dependencies.cc] + version = "1.0" + +-[build-dependencies.openssl-src] +-version = "111.0.1" +-optional = true +- + [build-dependencies.pkg-config] + version = "0.3.9" + + [features] + vendored = ["openssl-src"] ++openssl-src = [] + [target."cfg(target_env = \"msvc\")".build-dependencies.vcpkg] + version = "0.2.8" diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-sys/CHANGELOG.md cargo-0.58.0/vendor/openssl-sys/CHANGELOG.md --- cargo-0.57.0+ubuntu/vendor/openssl-sys/CHANGELOG.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-sys/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 @@ -2,6 +2,66 @@ ## [Unreleased] +## [v0.9.72] + +### Changed + +* Temporarily downgraded the vendored OpenSSL back to 1.1.1 due to significant performance regressions. We will move + back to 3.0.0 when a future release resolves those issues. + +### Added + +* Added `PKCS12_set_mac`. +* Added `EVP_PKEY_sign_init`, `EVP_PKEY_sign`, `EVP_PKEY_verify_init`, and `EVP_PKEY_verify`. +* Added support for LibreSSL 3.4.x. + +## [v0.9.71] + +### Fixed + +* Fixed linkage to static OpenSSL 3.0.0 libraries on some 32 bit Android targets. + +### Added + +* Added support for LibreSSL 3.4.1. +* Added `SSL_get_extms_support` and `SSL_CTRL_GET_EXTMS_SUPPORT`. +* Added `OBJ_create`. +* Added `EVP_CIPHER_CTX_get0_cipher`, `EVP_CIPHER_CTX_get_block_size`, `EVP_CIPHER_CTX_get_key_length`, + `EVP_CIPHER_CTX_get_iv_length`, and `EVP_CIPHER_CTX_get_tag_length`. +* Added `EVP_CIPHER_free`. +* Added `EVP_CIPHER_CTX_rand_key`. +* Added `OSSL_LIB_CTX_new` and `OSSL_LIB_CTX_free`. +* Added `EVP_CIPHER_fetch`. +* Added `EVP_MD_fetch` and `EVP_MD_free`. +* Added `OPENSSL_malloc` and `OPENSSL_free`. +* Added `EVP_DigestSignUpdate` and `EVP_DigestVerifyUpdate`. + +## [v0.9.70] - 2021-10-31 + +### Fixed + +* Fixed linkage to static 3.0.0 OpenSSL libraries on some 32 bit architectures. + +## [v0.9.69] - 2021-10-31 + +### Changed + +* Upgraded the vendored OpenSSL to 3.0.0. + +### Added + +* Added support for automatic detection of Homebrew `openssl@3` installs. +* Added `EVP_PKEY_Q_keygen` and `EVP_EC_gen`. + +## [v0.9.68] - 2021-10-27 + +### Added + +* Added `BN_bn2binpad`. +* Added `i2d_X509_NAME` and `d2i_X509_NAME`. +* Added `BN_FLG_MALLOCED`, `BN_FLG_STATIC_DATA`, `BN_FLG_CONSTTIME`, and `BN_FLG_SECURE`. +* Added `BN_CTX_secure_new`, `BN_secure_new`, `BN_set_flags`, and `BN_get_flags`. + ## [v0.9.67] - 2021-09-21 ### Added @@ -227,7 +287,12 @@ * Added `X509_verify` and `X509_REQ_verify`. * Added `EVP_MD_type` and `EVP_GROUP_get_curve_name`. -[Unreleased]: https://github.com/sfackler/rust-openssl/compare/openssl-sys-v0.9.67...master +[Unreleased]: https://github.com/sfackler/rust-openssl/compare/openssl-sys-v0.9.72..master +[v0.9.72]: https://github.com/sfackler/rust-openssl/compare/openssl-sys-v0.9.71...openssl-sys-v0.9.72 +[v0.9.71]: https://github.com/sfackler/rust-openssl/compare/openssl-sys-v0.9.70...openssl-sys-v0.9.71 +[v0.9.70]: https://github.com/sfackler/rust-openssl/compare/openssl-sys-v0.9.69...openssl-sys-v0.9.70 +[v0.9.69]: https://github.com/sfackler/rust-openssl/compare/openssl-sys-v0.9.68...openssl-sys-v0.9.69 +[v0.9.68]: https://github.com/sfackler/rust-openssl/compare/openssl-sys-v0.9.67...openssl-sys-v0.9.68 [v0.9.67]: https://github.com/sfackler/rust-openssl/compare/openssl-sys-v0.9.66...openssl-sys-v0.9.67 [v0.9.66]: https://github.com/sfackler/rust-openssl/compare/openssl-sys-v0.9.65...openssl-sys-v0.9.66 [v0.9.65]: https://github.com/sfackler/rust-openssl/compare/openssl-sys-v0.9.64...openssl-sys-v0.9.65 diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-sys/debian/patches/disable-vendor.patch cargo-0.58.0/vendor/openssl-sys/debian/patches/disable-vendor.patch --- cargo-0.57.0+ubuntu/vendor/openssl-sys/debian/patches/disable-vendor.patch 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-sys/debian/patches/disable-vendor.patch 2022-01-21 02:47:39.000000000 +0000 @@ -5,7 +5,7 @@ version = "1.0" -[build-dependencies.openssl-src] --version = "111.0.1" +-version = "111" -optional = true - [build-dependencies.pkg-config] @@ -35,8 +35,8 @@ +#[cfg(feature = "vendored_debian_disabled")] mod find_vendored; - enum Version { -@@ -44,7 +44,7 @@ + #[derive(PartialEq)] +@@ -46,7 +46,7 @@ } fn find_openssl(target: &str) -> (PathBuf, PathBuf) { diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-sys/src/bn.rs cargo-0.58.0/vendor/openssl-sys/src/bn.rs --- cargo-0.57.0+ubuntu/vendor/openssl-sys/src/bn.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-sys/src/bn.rs 2022-01-21 02:47:39.000000000 +0000 @@ -7,18 +7,37 @@ #[cfg(target_pointer_width = "32")] pub type BN_ULONG = c_uint; +#[cfg(ossl110)] +pub const BN_FLG_MALLOCED: c_int = 0x01; +#[cfg(ossl110)] +pub const BN_FLG_STATIC_DATA: c_int = 0x02; +#[cfg(ossl110)] +pub const BN_FLG_CONSTTIME: c_int = 0x04; +#[cfg(ossl110)] +pub const BN_FLG_SECURE: c_int = 0x08; + extern "C" { pub fn BN_CTX_new() -> *mut BN_CTX; + #[cfg(ossl110)] + pub fn BN_CTX_secure_new() -> *mut BN_CTX; pub fn BN_CTX_free(ctx: *mut BN_CTX); pub fn BN_rand(r: *mut BIGNUM, bits: c_int, top: c_int, bottom: c_int) -> c_int; pub fn BN_pseudo_rand(r: *mut BIGNUM, bits: c_int, top: c_int, bottom: c_int) -> c_int; pub fn BN_rand_range(r: *mut BIGNUM, range: *const BIGNUM) -> c_int; pub fn BN_pseudo_rand_range(r: *mut BIGNUM, range: *const BIGNUM) -> c_int; pub fn BN_new() -> *mut BIGNUM; + #[cfg(ossl110)] + pub fn BN_secure_new() -> *mut BIGNUM; + #[cfg(ossl110)] + pub fn BN_set_flags(b: *mut BIGNUM, n: c_int); + #[cfg(ossl110)] + pub fn BN_get_flags(b: *const BIGNUM, n: c_int) -> c_int; pub fn BN_num_bits(bn: *const BIGNUM) -> c_int; pub fn BN_clear_free(bn: *mut BIGNUM); pub fn BN_bin2bn(s: *const u8, size: c_int, ret: *mut BIGNUM) -> *mut BIGNUM; pub fn BN_bn2bin(a: *const BIGNUM, to: *mut u8) -> c_int; + #[cfg(ossl110)] + pub fn BN_bn2binpad(a: *const BIGNUM, to: *mut u8, tolen: c_int) -> c_int; pub fn BN_sub(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM) -> c_int; pub fn BN_add(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM) -> c_int; pub fn BN_mul(r: *mut BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX) -> c_int; diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-sys/src/crypto.rs cargo-0.58.0/vendor/openssl-sys/src/crypto.rs --- cargo-0.57.0+ubuntu/vendor/openssl-sys/src/crypto.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-sys/src/crypto.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,7 +1,45 @@ use libc::*; - use *; +#[cfg(ossl110)] +#[inline] +#[track_caller] +pub unsafe fn OPENSSL_malloc(num: usize) -> *mut c_void { + CRYPTO_malloc( + num, + concat!(file!(), "\0").as_ptr() as *const _, + line!() as _, + ) +} + +#[cfg(not(ossl110))] +#[inline] +#[track_caller] +pub unsafe fn OPENSSL_malloc(num: c_int) -> *mut c_void { + CRYPTO_malloc( + num, + concat!(file!(), "\0").as_ptr() as *const _, + line!() as _, + ) +} + +#[cfg(ossl110)] +#[inline] +#[track_caller] +pub unsafe fn OPENSSL_free(addr: *mut c_void) { + CRYPTO_free( + addr, + concat!(file!(), "\0").as_ptr() as *const _, + line!() as _, + ) +} + +#[cfg(not(ossl110))] +#[inline] +pub unsafe fn OPENSSL_free(addr: *mut c_void) { + CRYPTO_free(addr) +} + #[cfg(not(ossl110))] pub const CRYPTO_LOCK_X509: c_int = 3; #[cfg(not(ossl110))] @@ -127,4 +165,9 @@ pub fn FIPS_mode_set(onoff: c_int) -> c_int; pub fn CRYPTO_memcmp(a: *const c_void, b: *const c_void, len: size_t) -> c_int; + + #[cfg(ossl300)] + pub fn OSSL_LIB_CTX_new() -> *mut OSSL_LIB_CTX; + #[cfg(ossl300)] + pub fn OSSL_LIB_CTX_free(libcts: *mut OSSL_LIB_CTX); } diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-sys/src/ec.rs cargo-0.58.0/vendor/openssl-sys/src/ec.rs --- cargo-0.57.0+ubuntu/vendor/openssl-sys/src/ec.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-sys/src/ec.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,4 +1,5 @@ use libc::*; +use std::ptr; use *; @@ -241,3 +242,13 @@ pub fn i2d_ECDSA_SIG(sig: *const ECDSA_SIG, out: *mut *mut c_uchar) -> c_int; } + +#[cfg(ossl300)] +pub unsafe fn EVP_EC_gen(curve: *const c_char) -> *mut EVP_PKEY { + EVP_PKEY_Q_keygen( + ptr::null_mut(), + ptr::null_mut(), + "EC\0".as_ptr().cast(), + curve, + ) +} diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-sys/src/evp.rs cargo-0.58.0/vendor/openssl-sys/src/evp.rs --- cargo-0.57.0+ubuntu/vendor/openssl-sys/src/evp.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-sys/src/evp.rs 2022-01-21 02:47:39.000000000 +0000 @@ -20,6 +20,8 @@ pub const EVP_PKEY_ED448: c_int = NID_ED448; pub const EVP_PKEY_HMAC: c_int = NID_hmac; pub const EVP_PKEY_CMAC: c_int = NID_cmac; +#[cfg(ossl110)] +pub const EVP_PKEY_HKDF: c_int = NID_hkdf; pub const EVP_CTRL_GCM_SET_IVLEN: c_int = 0x9; pub const EVP_CTRL_GCM_GET_TAG: c_int = 0x10; @@ -39,6 +41,18 @@ pub fn EVP_CIPHER_get_block_size(cipher: *const EVP_CIPHER) -> c_int; pub fn EVP_CIPHER_get_iv_length(cipher: *const EVP_CIPHER) -> c_int; pub fn EVP_CIPHER_get_nid(cipher: *const EVP_CIPHER) -> c_int; + pub fn EVP_CIPHER_fetch( + ctx: *mut OSSL_LIB_CTX, + algorithm: *const c_char, + properties: *const c_char, + ) -> *mut EVP_CIPHER; + pub fn EVP_CIPHER_free(cipher: *mut EVP_CIPHER); + + pub fn EVP_CIPHER_CTX_get0_cipher(ctx: *const EVP_CIPHER_CTX) -> *const EVP_CIPHER; + pub fn EVP_CIPHER_CTX_get_block_size(ctx: *const EVP_CIPHER_CTX) -> c_int; + pub fn EVP_CIPHER_CTX_get_key_length(ctx: *const EVP_CIPHER_CTX) -> c_int; + pub fn EVP_CIPHER_CTX_get_iv_length(ctx: *const EVP_CIPHER_CTX) -> c_int; + pub fn EVP_CIPHER_CTX_get_tag_length(ctx: *const EVP_CIPHER_CTX) -> c_int; } #[inline] @@ -70,6 +84,21 @@ pub unsafe fn EVP_CIPHER_nid(cipher: *const EVP_CIPHER) -> c_int { EVP_CIPHER_get_nid(cipher) } + + #[inline] + pub unsafe fn EVP_CIPHER_CTX_block_size(ctx: *const EVP_CIPHER_CTX) -> c_int { + EVP_CIPHER_CTX_get_block_size(ctx) + } + + #[inline] + pub unsafe fn EVP_CIPHER_CTX_key_length(ctx: *const EVP_CIPHER_CTX) -> c_int { + EVP_CIPHER_CTX_get_key_length(ctx) + } + + #[inline] + pub unsafe fn EVP_CIPHER_CTX_iv_length(ctx: *const EVP_CIPHER_CTX) -> c_int { + EVP_CIPHER_CTX_get_iv_length(ctx) + } } else { extern "C" { pub fn EVP_MD_size(md: *const EVP_MD) -> c_int; @@ -79,10 +108,14 @@ pub fn EVP_CIPHER_block_size(cipher: *const EVP_CIPHER) -> c_int; pub fn EVP_CIPHER_iv_length(cipher: *const EVP_CIPHER) -> c_int; pub fn EVP_CIPHER_nid(cipher: *const EVP_CIPHER) -> c_int; + + pub fn EVP_CIPHER_CTX_cipher(ctx: *const EVP_CIPHER_CTX) -> *const EVP_CIPHER; + pub fn EVP_CIPHER_CTX_block_size(ctx: *const EVP_CIPHER_CTX) -> c_int; + pub fn EVP_CIPHER_CTX_key_length(ctx: *const EVP_CIPHER_CTX) -> c_int; + pub fn EVP_CIPHER_CTX_iv_length(ctx: *const EVP_CIPHER_CTX) -> c_int; } } } -extern "C" {} cfg_if! { if #[cfg(ossl110)] { @@ -118,6 +151,16 @@ #[cfg(ossl111)] pub fn EVP_DigestFinalXOF(ctx: *mut EVP_MD_CTX, res: *mut u8, len: usize) -> c_int; + #[cfg(ossl300)] + pub fn EVP_MD_fetch( + ctx: *mut OSSL_LIB_CTX, + algorithm: *const c_char, + properties: *const c_char, + ) -> *mut EVP_MD; + + #[cfg(ossl300)] + pub fn EVP_MD_free(md: *mut EVP_MD); + pub fn EVP_BytesToKey( typ: *const EVP_CIPHER, md: *const EVP_MD, @@ -160,6 +203,28 @@ e: *mut ENGINE, pkey: *mut EVP_PKEY, ) -> c_int; +} +cfg_if! { + if #[cfg(ossl300)] { + extern "C" { + pub fn EVP_DigestSignUpdate( + ctx: *mut EVP_MD_CTX, + data: *const c_void, + dsize: size_t, + ) -> c_int; + } + } else { + #[inline] + pub unsafe fn EVP_DigestSignUpdate( + ctx: *mut EVP_MD_CTX, + data: *const c_void, + dsize: size_t, + ) -> c_int { + EVP_DigestUpdate(ctx, data, dsize) + } + } +} +extern "C" { pub fn EVP_DigestSignFinal( ctx: *mut EVP_MD_CTX, sig: *mut c_uchar, @@ -172,6 +237,28 @@ e: *mut ENGINE, pkey: *mut EVP_PKEY, ) -> c_int; +} +cfg_if! { + if #[cfg(ossl300)] { + extern "C" { + pub fn EVP_DigestVerifyUpdate( + ctx: *mut EVP_MD_CTX, + data: *const c_void, + dsize: size_t, + ) -> c_int; + } + } else { + #[inline] + pub unsafe fn EVP_DigestVerifyUpdate( + ctx: *mut EVP_MD_CTX, + data: *const c_void, + dsize: size_t, + ) -> c_int { + EVP_DigestUpdate(ctx, data, dsize) + } + } +} +extern "C" { pub fn EVP_SealInit( ctx: *mut EVP_CIPHER_CTX, type_: *const EVP_CIPHER, @@ -291,6 +378,7 @@ arg: c_int, ptr: *mut c_void, ) -> c_int; + pub fn EVP_CIPHER_CTX_rand_key(ctx: *mut EVP_CIPHER_CTX, key: *mut c_uchar) -> c_int; pub fn EVP_md_null() -> *const EVP_MD; pub fn EVP_md5() -> *const EVP_MD; @@ -359,9 +447,9 @@ pub fn EVP_aes_256_ofb() -> *const EVP_CIPHER; #[cfg(ossl110)] pub fn EVP_aes_256_ocb() -> *const EVP_CIPHER; - #[cfg(ossl110)] + #[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_CHACHA")))] pub fn EVP_chacha20() -> *const ::EVP_CIPHER; - #[cfg(ossl110)] + #[cfg(all(ossl110, not(osslconf = "OPENSSL_NO_CHACHA")))] pub fn EVP_chacha20_poly1305() -> *const ::EVP_CIPHER; #[cfg(not(osslconf = "OPENSSL_NO_SEED"))] pub fn EVP_seed_cbc() -> *const EVP_CIPHER; @@ -475,6 +563,7 @@ pub const EVP_PKEY_OP_VERIFYCTX: c_int = 1 << 8; pub const EVP_PKEY_OP_ENCRYPT: c_int = 1 << 9; pub const EVP_PKEY_OP_DECRYPT: c_int = 1 << 10; + pub const EVP_PKEY_OP_DERIVE: c_int = 1 << 11; } else { pub const EVP_PKEY_OP_SIGN: c_int = 1 << 3; pub const EVP_PKEY_OP_VERIFY: c_int = 1 << 4; @@ -483,6 +572,7 @@ pub const EVP_PKEY_OP_VERIFYCTX: c_int = 1 << 7; pub const EVP_PKEY_OP_ENCRYPT: c_int = 1 << 8; pub const EVP_PKEY_OP_DECRYPT: c_int = 1 << 9; + pub const EVP_PKEY_OP_DERIVE: c_int = 1 << 10; } } @@ -500,6 +590,30 @@ pub const EVP_PKEY_ALG_CTRL: c_int = 0x1000; +#[cfg(ossl111)] +pub const EVP_PKEY_HKDEF_MODE_EXTRACT_AND_EXPAND: c_int = 0; + +#[cfg(ossl111)] +pub const EVP_PKEY_HKDEF_MODE_EXTRACT_ONLY: c_int = 1; + +#[cfg(ossl111)] +pub const EVP_PKEY_HKDEF_MODE_EXPAND_ONLY: c_int = 2; + +#[cfg(ossl110)] +pub const EVP_PKEY_CTRL_HKDF_MD: c_int = EVP_PKEY_ALG_CTRL + 3; + +#[cfg(ossl110)] +pub const EVP_PKEY_CTRL_HKDF_SALT: c_int = EVP_PKEY_ALG_CTRL + 4; + +#[cfg(ossl110)] +pub const EVP_PKEY_CTRL_HKDF_KEY: c_int = EVP_PKEY_ALG_CTRL + 5; + +#[cfg(ossl110)] +pub const EVP_PKEY_CTRL_HKDF_INFO: c_int = EVP_PKEY_ALG_CTRL + 6; + +#[cfg(ossl111)] +pub const EVP_PKEY_CTRL_HKDF_MODE: c_int = EVP_PKEY_ALG_CTRL + 7; + extern "C" { pub fn EVP_PKEY_CTX_new(k: *mut EVP_PKEY, e: *mut ENGINE) -> *mut EVP_PKEY_CTX; pub fn EVP_PKEY_CTX_new_id(id: c_int, e: *mut ENGINE) -> *mut EVP_PKEY_CTX; @@ -525,9 +639,32 @@ pub fn EVP_PKEY_derive_set_peer(ctx: *mut EVP_PKEY_CTX, peer: *mut EVP_PKEY) -> c_int; pub fn EVP_PKEY_derive(ctx: *mut EVP_PKEY_CTX, key: *mut c_uchar, size: *mut size_t) -> c_int; + #[cfg(ossl300)] + pub fn EVP_PKEY_Q_keygen( + libctx: *mut OSSL_LIB_CTX, + propq: *const c_char, + type_: *const c_char, + ... + ) -> *mut EVP_PKEY; pub fn EVP_PKEY_keygen_init(ctx: *mut EVP_PKEY_CTX) -> c_int; pub fn EVP_PKEY_keygen(ctx: *mut EVP_PKEY_CTX, key: *mut *mut EVP_PKEY) -> c_int; + pub fn EVP_PKEY_sign_init(ctx: *mut EVP_PKEY_CTX) -> c_int; + pub fn EVP_PKEY_sign( + ctx: *mut EVP_PKEY_CTX, + sig: *mut c_uchar, + siglen: *mut size_t, + tbs: *const c_uchar, + tbslen: size_t, + ) -> c_int; + pub fn EVP_PKEY_verify_init(ctx: *mut EVP_PKEY_CTX) -> c_int; + pub fn EVP_PKEY_verify( + ctx: *mut EVP_PKEY_CTX, + sig: *const c_uchar, + siglen: size_t, + tbs: *const c_uchar, + tbslen: size_t, + ) -> c_int; pub fn EVP_PKEY_encrypt_init(ctx: *mut EVP_PKEY_CTX) -> c_int; pub fn EVP_PKEY_encrypt( ctx: *mut EVP_PKEY_CTX, @@ -546,6 +683,102 @@ ) -> c_int; } +// HKDF Functions +cfg_if! { + if #[cfg(ossl300)] { + extern "C" { + pub fn EVP_PKEY_CTX_set_hkdf_mode(ctx: *mut EVP_PKEY_CTX, mode: c_int) -> c_int; + pub fn EVP_PKEY_CTX_set_hkdf_md(ctx: *mut EVP_PKEY_CTX, md: *const EVP_MD) -> c_int; + pub fn EVP_PKEY_CTX_set1_hkdf_salt( + ctx: *mut EVP_PKEY_CTX, + salt: *const u8, + saltlen: c_int, + ) -> c_int; + pub fn EVP_PKEY_CTX_set1_hkdf_key( + ctx: *mut EVP_PKEY_CTX, + key: *const u8, + keylen: c_int, + ) -> c_int; + pub fn EVP_PKEY_CTX_add1_hkdf_info( + ctx: *mut EVP_PKEY_CTX, + info: *const u8, + infolen: c_int, + ) -> c_int; + } + } else { + #[cfg(ossl111)] + pub unsafe fn EVP_PKEY_CTX_set_hkdf_mode(ctx: *mut EVP_PKEY_CTX, mode: c_int) -> c_int { + EVP_PKEY_CTX_ctrl( + ctx, + -1, + EVP_PKEY_OP_DERIVE, + EVP_PKEY_CTRL_HKDF_MODE, + mode, std::ptr::null_mut(), + ) + } + + #[cfg(ossl110)] + pub unsafe fn EVP_PKEY_CTX_set_hkdf_md(ctx: *mut EVP_PKEY_CTX, md: *const EVP_MD) -> c_int { + EVP_PKEY_CTX_ctrl( + ctx, + -1, + EVP_PKEY_OP_DERIVE, + EVP_PKEY_CTRL_HKDF_MD, + 0, + md as *mut c_void, + ) + } + + #[cfg(ossl110)] + pub unsafe fn EVP_PKEY_CTX_set1_hkdf_salt( + ctx: *mut EVP_PKEY_CTX, + salt: *const u8, + saltlen: c_int, + ) -> c_int { + EVP_PKEY_CTX_ctrl( + ctx, + -1, + EVP_PKEY_OP_DERIVE, + EVP_PKEY_CTRL_HKDF_SALT, + saltlen, + salt as *mut c_void, + ) + } + + #[cfg(ossl110)] + pub unsafe fn EVP_PKEY_CTX_set1_hkdf_key( + ctx: *mut EVP_PKEY_CTX, + key: *const u8, + keylen: c_int, + ) -> c_int { + EVP_PKEY_CTX_ctrl( + ctx, + -1, + EVP_PKEY_OP_DERIVE, + EVP_PKEY_CTRL_HKDF_KEY, + keylen, + key as *mut c_void, + ) + } + + #[cfg(ossl110)] + pub unsafe fn EVP_PKEY_CTX_add1_hkdf_info( + ctx: *mut EVP_PKEY_CTX, + info: *const u8, + infolen: c_int, + ) -> c_int { + EVP_PKEY_CTX_ctrl( + ctx, + -1, + EVP_PKEY_OP_DERIVE, + EVP_PKEY_CTRL_HKDF_INFO, + infolen, + info as *mut c_void, + ) + } + } +} + const_ptr_api! { extern "C" { pub fn EVP_PKCS82PKEY(p8: #[const_ptr_if(any(ossl110, libressl280))] PKCS8_PRIV_KEY_INFO) -> *mut EVP_PKEY; diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-sys/src/object.rs cargo-0.58.0/vendor/openssl-sys/src/object.rs --- cargo-0.57.0+ubuntu/vendor/openssl-sys/src/object.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-sys/src/object.rs 2022-01-21 02:47:39.000000000 +0000 @@ -18,6 +18,11 @@ -> c_int; pub fn OBJ_sn2nid(sn: *const libc::c_char) -> libc::c_int; pub fn OBJ_txt2obj(s: *const libc::c_char, no_name: libc::c_int) -> *mut ASN1_OBJECT; + pub fn OBJ_create( + oid: *const libc::c_char, + sn: *const libc::c_char, + ln: *const libc::c_char, + ) -> c_int; #[cfg(ossl111)] pub fn OBJ_length(obj: *const ASN1_OBJECT) -> libc::size_t; #[cfg(ossl111)] diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-sys/src/obj_mac.rs cargo-0.58.0/vendor/openssl-sys/src/obj_mac.rs --- cargo-0.57.0+ubuntu/vendor/openssl-sys/src/obj_mac.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-sys/src/obj_mac.rs 2022-01-21 02:47:39.000000000 +0000 @@ -916,6 +916,8 @@ pub const NID_X25519: c_int = 1034; #[cfg(ossl111)] pub const NID_X448: c_int = 1035; +#[cfg(ossl110)] +pub const NID_hkdf: c_int = 1036; #[cfg(ossl111)] pub const NID_ED25519: c_int = 1087; #[cfg(ossl111)] diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-sys/src/pkcs12.rs cargo-0.58.0/vendor/openssl-sys/src/pkcs12.rs --- cargo-0.57.0+ubuntu/vendor/openssl-sys/src/pkcs12.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-sys/src/pkcs12.rs 2022-01-21 02:47:39.000000000 +0000 @@ -22,6 +22,16 @@ cert: *mut *mut X509, ca: *mut *mut stack_st_X509, ) -> c_int; + + pub fn PKCS12_set_mac( + p12: *mut PKCS12, + pass: *const c_char, + passlen: c_int, + salt: *mut c_uchar, + saltlen: c_int, + iter: c_int, + md_type: *const EVP_MD, + ) -> c_int; } const_ptr_api! { extern "C" { diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-sys/src/ssl.rs cargo-0.58.0/vendor/openssl-sys/src/ssl.rs --- cargo-0.57.0+ubuntu/vendor/openssl-sys/src/ssl.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-sys/src/ssl.rs 2022-01-21 02:47:39.000000000 +0000 @@ -482,6 +482,11 @@ SSL_ctrl(ssl, SSL_CTRL_SET_MTU, mtu, ptr::null_mut()) } +#[cfg(ossl110)] +pub unsafe fn SSL_get_extms_support(ssl: *mut SSL) -> c_long { + SSL_ctrl(ssl, SSL_CTRL_GET_EXTMS_SUPPORT, 0, ptr::null_mut()) +} + pub type GEN_SESSION_CB = Option c_int>; @@ -768,6 +773,8 @@ #[cfg(ossl102)] pub const SSL_CTRL_SET_VERIFY_CERT_STORE: c_int = 106; #[cfg(ossl110)] +pub const SSL_CTRL_GET_EXTMS_SUPPORT: c_int = 122; +#[cfg(ossl110)] pub const SSL_CTRL_SET_MIN_PROTO_VERSION: c_int = 123; #[cfg(ossl110)] pub const SSL_CTRL_SET_MAX_PROTO_VERSION: c_int = 124; diff -Nru cargo-0.57.0+ubuntu/vendor/openssl-sys/src/x509.rs cargo-0.58.0/vendor/openssl-sys/src/x509.rs --- cargo-0.57.0+ubuntu/vendor/openssl-sys/src/x509.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/openssl-sys/src/x509.rs 2022-01-21 02:47:39.000000000 +0000 @@ -478,6 +478,7 @@ loc: c_int, set: c_int, ) -> c_int; + pub fn i2d_X509_NAME(n: #[const_ptr_if(ossl300)] X509_NAME, buf: *mut *mut u8) -> c_int; pub fn X509_NAME_ENTRY_get_object(ne: #[const_ptr_if(any(ossl110, libressl280))] X509_NAME_ENTRY) -> *mut ASN1_OBJECT; pub fn X509_NAME_ENTRY_get_data(ne: #[const_ptr_if(any(ossl110, libressl280))] X509_NAME_ENTRY) -> *mut ASN1_STRING; } @@ -492,6 +493,11 @@ loc: c_int, set: c_int, ) -> c_int; + pub fn d2i_X509_NAME( + n: *mut *mut X509_NAME, + pp: *mut *const c_uchar, + length: c_long, + ) -> *mut X509_NAME; } // "raw" X509_EXTENSION related functions diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/.cargo-checksum.json cargo-0.58.0/vendor/os_info/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/os_info/.cargo-checksum.json 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1 @@ +{"files":{},"package":"198e392be7e882f0c2836f425e430f81d9a0e99651e4646311347417cddbfd43"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/Cargo.lock cargo-0.58.0/vendor/os_info/Cargo.lock --- cargo-0.57.0+ubuntu/vendor/os_info/Cargo.lock 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/Cargo.lock 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,158 @@ +# This file is automatically @generated by Cargo. +# 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 = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "ctor" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccc0a48a9b826acdf4028595adc9db92caea352f7af011a3034acd172a52a0aa" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "diff" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499" + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "os_info" +version = "3.1.0" +dependencies = [ + "doc-comment", + "log", + "pretty_assertions", + "serde", + "winapi", +] + +[[package]] +name = "output_vt100" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53cdc5b785b7a58c5aad8216b3dfa114df64b0b06ae6e1501cef91df2fbdf8f9" +dependencies = [ + "winapi", +] + +[[package]] +name = "pretty_assertions" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0cfe1b2403f172ba0f234e500906ee0a3e493fb81092dac23ebefe129301cc" +dependencies = [ + "ansi_term", + "ctor", + "diff", + "output_vt100", +] + +[[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 = "serde" +version = "1.0.133" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.133" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[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 = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/Cargo.toml cargo-0.58.0/vendor/os_info/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/os_info/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,42 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# 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. +# +# 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 = "os_info" +version = "3.1.0" +authors = ["Jan Schulte ", "Stanislav Tkach "] +description = "Detect the operating system type and version." +homepage = "https://github.com/stanislav-tkach/os_info" +documentation = "https://docs.rs/os_info" +readme = "README.md" +keywords = ["os", "os_type", "os_version", "os_info"] +categories = ["os"] +license = "MIT" +repository = "https://github.com/stanislav-tkach/os_info" +[dependencies.log] +version = "0.4.5" + +[dependencies.serde] +version = "1.0.0" +features = ["derive"] +optional = true +[dev-dependencies.doc-comment] +version = "0.3.1" + +[dev-dependencies.pretty_assertions] +version = "1.0.0" + +[features] +default = ["serde"] +[target."cfg(windows)".dependencies.winapi] +version = "0.3.8" +features = ["minwindef", "ntdef", "ntstatus", "sysinfoapi", "winnt", "winuser", "libloaderapi", "processthreadsapi", "winerror", "winreg"] diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/examples/print_version.rs cargo-0.58.0/vendor/os_info/examples/print_version.rs --- cargo-0.57.0+ubuntu/vendor/os_info/examples/print_version.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/examples/print_version.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,13 @@ +fn main() { + let info = os_info::get(); + + // Print full information: + println!("OS information: {}", info); + + // Print information separately: + println!("Type: {}", info.os_type()); + println!("Version: {}", info.version()); + println!("Edition: {:?}", info.edition()); + println!("Codename: {:?}", info.codename()); + println!("Bitness: {}", info.bitness()); +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/LICENSE cargo-0.58.0/vendor/os_info/LICENSE --- cargo-0.57.0+ubuntu/vendor/os_info/LICENSE 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/LICENSE 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2017 Stanislav Tkach + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/README.md cargo-0.58.0/vendor/os_info/README.md --- cargo-0.57.0+ubuntu/vendor/os_info/README.md 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/README.md 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,119 @@ +# os_info + +**Status:** +[![CI](https://github.com/stanislav-tkach/os_info/workflows/CI/badge.svg)](https://github.com/stanislav-tkach/os_info/actions) +[![Coverage](https://codecov.io/gh/stanislav-tkach/os_info/branch/master/graph/badge.svg)](https://codecov.io/gh/stanislav-tkach/os_info) +[![Dependency status](https://deps.rs/repo/github/stanislav-tkach/os_info/status.svg)](https://deps.rs/repo/github/stanislav-tkach/os_info) + +**Project info:** +[![Docs.rs](https://docs.rs/os_info/badge.svg)](https://docs.rs/os_info) +[![Latest version](https://img.shields.io/crates/v/os_info.svg)](https://crates.io/crates/os_info) +[![License](https://img.shields.io/github/license/stanislav-tkach/os_info.svg)](https://github.com/stanislav-tkach/os_info/blob/master/LICENSE) + +**Project details:** +[![LoC](https://tokei.rs/b1/github/stanislav-tkach/os_info)](https://github.com/stanislav-tkach/os_info) +![Rust 1.41+ required](https://img.shields.io/badge/rust-1.41+-blue.svg?label=Required%20Rust) + +## Overview + +This project consists of two parts: the library that can be used to detect the +operating system type (including version and bitness) and the command line tool +that uses the library. + +### Library (`os_info`) + +#### `os_info` usage + +To use this crate, add `os_info` as a dependency to your project's Cargo.toml: + +```toml +[dependencies] +os_info = "3" +``` + +This project has `serde` as an optional dependency, so if you don't need it, then +you can speed up compilation disabling it: + +```toml +[dependencies] +os_info = { version = "3", default-features = false } +``` + +#### Example + +```rust +let info = os_info::get(); + +// Print full information: +println!("OS information: {}", info); + +// Print information separately: +println!("Type: {}", info.os_type()); +println!("Version: {}", info.version()); +println!("Bitness: {}", info.bitness()); +``` + +### Command line tool (`os_info_cli`) + +A simple wrapper around the `os_info` library. + +#### Installation + +This tool can be installed using the following cargo command: + +```console +cargo install os_info_cli +``` + +#### `os_info_cli` usage + +Despite being named `os_info_cli` during installation, it is actually named +`os_info`. You can use the `--help` flag to see available options: + +```console +os_info --help +``` + +## Supported operating systems + +Right now, the following operating system types can be returned: + +- Alpine Linux +- Amazon Linux AMI +- Android +- Arch Linux +- CentOS +- Debian +- DragonFly BSD +- Emscripten +- EndeavourOS +- Fedora +- FreeBSD +- Linux +- Linux Mint +- macOS (Mac OS X or OS X) +- Manjaro +- NetBSD +- NixOS +- OpenBSD +- openSUSE +- Oracle Linux +- Pop!_OS +- Raspberry OS +- Red Hat Linux +- Red Hat Enterprise Linux +- Redox +- Solus +- SUSE Linux Enterprise Server +- Ubuntu +- Unknown +- Windows + +If you need support for more OS types, I am looking forward to your Pull Request. + +## License + +`os_info` is licensed under the MIT license. See [LICENSE] for the details. + +[lsb_release]: http://refspecs.linuxbase.org/LSB_2.0.1/LSB-PDA/LSB-PDA/lsbrelease.html +[LICENSE]: https://github.com/stanislav-tkach/os_info/blob/master/LICENSE diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/android/mod.rs cargo-0.58.0/vendor/os_info/src/android/mod.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/android/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/android/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,23 @@ +use log::trace; + +use crate::{Bitness, Info, Type}; + +pub fn current_platform() -> Info { + trace!("android::current_platform is called"); + + let info = Info::with_type(Type::Android); + trace!("Returning {:?}", info); + info +} + +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::assert_eq; + + #[test] + fn os_type() { + let version = current_platform(); + assert_eq!(Type::Android, version.os_type()); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/bitness.rs cargo-0.58.0/vendor/os_info/src/bitness.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/bitness.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/bitness.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,112 @@ +// spell-checker:ignore getconf + +use std::fmt::{self, Display, Formatter}; +#[cfg(any( + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd" +))] +use std::process::{Command, Output}; + +/// Operating system architecture in terms of how many bits compose the basic values it can deal with. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[non_exhaustive] +pub enum Bitness { + /// Unknown bitness (unable to determine). + Unknown, + /// 32-bit. + X32, + /// 64-bit. + X64, +} + +impl Display for Bitness { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + match *self { + Bitness::Unknown => write!(f, "unknown bitness"), + Bitness::X32 => write!(f, "32-bit"), + Bitness::X64 => write!(f, "64-bit"), + } + } +} + +#[cfg(any( + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "macos", +))] +pub fn get() -> Bitness { + match &Command::new("getconf").arg("LONG_BIT").output() { + Ok(Output { stdout, .. }) if stdout == b"32\n" => Bitness::X32, + Ok(Output { stdout, .. }) if stdout == b"64\n" => Bitness::X64, + _ => Bitness::Unknown, + } +} + +#[cfg(target_os = "netbsd")] +pub fn get() -> Bitness { + match &Command::new("sysctl") + .arg("-n") + .arg("hw.machine_arch") + .output() + { + Ok(Output { stdout, .. }) if stdout == b"amd64\n" => Bitness::X64, + Ok(Output { stdout, .. }) if stdout == b"x86_64\n" => Bitness::X64, + Ok(Output { stdout, .. }) if stdout == b"i386\n" => Bitness::X32, + Ok(Output { stdout, .. }) if stdout == b"aarch64\n" => Bitness::X64, + Ok(Output { stdout, .. }) if stdout == b"earmv7hf\n" => Bitness::X32, + _ => Bitness::Unknown, + } +} + +#[cfg(target_os = "openbsd")] +pub fn get() -> Bitness { + match &Command::new("sysctl").arg("-n").arg("hw.machine").output() { + Ok(Output { stdout, .. }) if stdout == b"amd64\n" => Bitness::X64, + Ok(Output { stdout, .. }) if stdout == b"x86_64\n" => Bitness::X64, + Ok(Output { stdout, .. }) if stdout == b"i386\n" => Bitness::X32, + Ok(Output { stdout, .. }) if stdout == b"aarch64\n" => Bitness::X64, + Ok(Output { stdout, .. }) if stdout == b"earmv7hf\n" => Bitness::X32, + _ => Bitness::Unknown, + } +} + +#[cfg(all( + test, + any( + target_os = "dragonfly", + target_os = "freebsd", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd" + ) +))] +mod tests { + use super::*; + use pretty_assertions::assert_ne; + + #[test] + fn get_bitness() { + let b = get(); + assert_ne!(b, Bitness::Unknown); + } + + #[test] + fn display() { + let data = [ + (Bitness::Unknown, "unknown bitness"), + (Bitness::X32, "32-bit"), + (Bitness::X64, "64-bit"), + ]; + + for (bitness, expected) in &data { + assert_eq!(&bitness.to_string(), expected); + } + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/dragonfly/mod.rs cargo-0.58.0/vendor/os_info/src/dragonfly/mod.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/dragonfly/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/dragonfly/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,35 @@ +use std::process::Command; + +use log::trace; + +use crate::{bitness, uname::uname, Bitness, Info, Type, Version}; + +pub fn current_platform() -> Info { + trace!("dragonfly::current_platform is called"); + + let version = uname() + .map(Version::from_string) + .unwrap_or_else(|| Version::Unknown); + + let info = Info { + os_type: Type::DragonFly, + version, + bitness: bitness::get(), + ..Default::default() + }; + + trace!("Returning {:?}", info); + info +} + +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::assert_eq; + + #[test] + fn os_type() { + let version = current_platform(); + assert_eq!(Type::DragonFly, version.os_type()); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/emscripten/mod.rs cargo-0.58.0/vendor/os_info/src/emscripten/mod.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/emscripten/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/emscripten/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,24 @@ +use log::trace; + +use crate::{Bitness, Info, Type}; + +// TODO: Somehow get the real OS version? +pub fn current_platform() -> Info { + trace!("emscripten::current_platform is called"); + + let info = Info::with_type(Type::Emscripten); + trace!("Returning {:?}", info); + info +} + +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::assert_eq; + + #[test] + fn os_type() { + let version = current_platform(); + assert_eq!(Type::Emscripten, version.os_type()); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/freebsd/mod.rs cargo-0.58.0/vendor/os_info/src/freebsd/mod.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/freebsd/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/freebsd/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,35 @@ +use std::process::Command; + +use log::{error, trace}; + +use crate::{bitness, uname::uname, Info, Type, Version}; + +pub fn current_platform() -> Info { + trace!("freebsd::current_platform is called"); + + let version = uname() + .map(Version::from_string) + .unwrap_or_else(|| Version::Unknown); + + let info = Info { + os_type: Type::FreeBSD, + version, + bitness: bitness::get(), + ..Default::default() + }; + + trace!("Returning {:?}", info); + info +} + +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::assert_eq; + + #[test] + fn os_type() { + let version = current_platform(); + assert_eq!(Type::FreeBSD, version.os_type()); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/info.rs cargo-0.58.0/vendor/os_info/src/info.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/info.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/info.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,309 @@ +// spell-checker:ignore itertools, iproduct, bitnesses + +use std::fmt::{self, Display, Formatter}; + +use super::{Bitness, Type, Version}; + +/// Holds information about operating system (type, version, etc.). +/// +/// The best way to get string representation of the operation system information is to use its +/// `Display` implementation. +/// +/// # Examples +/// +/// ``` +/// use os_info; +/// +/// let info = os_info::get(); +/// println!("OS information: {}", info); +/// ``` +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct Info { + /// Operating system type. See `Type` for details. + pub(crate) os_type: Type, + /// Operating system version. See `Version` for details. + pub(crate) version: Version, + /// Operating system edition. + pub(crate) edition: Option, + /// Operating system edition. + pub(crate) codename: Option, + /// Operating system architecture in terms of how many bits compose the basic values it can deal + /// with. See `Bitness` for details. + pub(crate) bitness: Bitness, +} + +impl Info { + /// Constructs a new `Info` instance with unknown type, version and bitness. + /// + /// # Examples + /// + /// ``` + /// use os_info::{Info, Type, Version, Bitness}; + /// + /// let info = Info::unknown(); + /// assert_eq!(Type::Unknown, info.os_type()); + /// assert_eq!(&Version::Unknown, info.version()); + /// assert_eq!(None, info.edition()); + /// assert_eq!(None, info.codename()); + /// assert_eq!(Bitness::Unknown, info.bitness()); + /// ``` + pub fn unknown() -> Self { + Self { + os_type: Type::Unknown, + version: Version::Unknown, + edition: None, + codename: None, + bitness: Bitness::Unknown, + } + } + + /// Constructs a new `Info` instance with the specified operating system type. + /// + /// # Examples + /// + /// ``` + /// use os_info::{Info, Type, Version, Bitness}; + /// + /// let os_type = Type::Linux; + /// let info = Info::with_type(os_type); + /// assert_eq!(os_type, info.os_type()); + /// assert_eq!(&Version::Unknown, info.version()); + /// assert_eq!(None, info.edition()); + /// assert_eq!(None, info.codename()); + /// assert_eq!(Bitness::Unknown, info.bitness()); + /// ``` + pub fn with_type(os_type: Type) -> Self { + Self { + os_type, + ..Default::default() + } + } + + /// Returns operating system type. See `Type` for details. + /// + /// # Examples + /// + /// ``` + /// use os_info::{Info, Type}; + /// + /// let info = Info::unknown(); + /// assert_eq!(Type::Unknown, info.os_type()); + /// ``` + pub fn os_type(&self) -> Type { + self.os_type + } + + /// Returns operating system version. See `Version` for details. + /// + /// # Examples + /// + /// ``` + /// use os_info::{Info, Version}; + /// + /// let info = Info::unknown(); + /// assert_eq!(&Version::Unknown, info.version()); + /// ``` + pub fn version(&self) -> &Version { + &self.version + } + + /// Returns optional operation system edition. + /// + /// # Examples + /// + /// ``` + /// use os_info::Info; + /// + /// let info = Info::unknown(); + /// assert_eq!(None, info.edition()); + pub fn edition(&self) -> Option<&str> { + self.edition.as_ref().map(String::as_ref) + } + + /// Returns optional operation system 'codename'. + /// + /// # Examples + /// + /// ``` + /// use os_info::Info; + /// + /// let info = Info::unknown(); + /// assert_eq!(None, info.codename()); + pub fn codename(&self) -> Option<&str> { + self.codename.as_ref().map(String::as_ref) + } + + /// Returns operating system bitness. See `Bitness` for details. + /// + /// # Examples + /// + /// ``` + /// use os_info::{Info, Bitness}; + /// + /// let info = Info::unknown(); + /// assert_eq!(Bitness::Unknown, info.bitness()); + /// ``` + pub fn bitness(&self) -> Bitness { + self.bitness + } +} + +impl Default for Info { + fn default() -> Self { + Self::unknown() + } +} + +impl Display for Info { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + write!(f, "{}", self.os_type)?; + if self.version != Version::Unknown { + write!(f, " {}", self.version)?; + } + if let Some(ref edition) = self.edition { + write!(f, " ({})", edition)?; + } + if let Some(ref codename) = self.codename { + write!(f, " ({})", codename)?; + } + write!(f, " [{}]", self.bitness) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::assert_eq; + + #[test] + fn unknown() { + let info = Info::unknown(); + assert_eq!(Type::Unknown, info.os_type()); + assert_eq!(&Version::Unknown, info.version()); + assert_eq!(None, info.edition()); + assert_eq!(None, info.codename()); + assert_eq!(Bitness::Unknown, info.bitness()); + } + + #[test] + fn with_type() { + let types = [ + Type::Redox, + Type::Alpine, + Type::Amazon, + Type::Android, + Type::Arch, + Type::CentOS, + Type::Debian, + Type::Emscripten, + Type::EndeavourOS, + Type::Fedora, + Type::Linux, + Type::Macos, + Type::Manjaro, + Type::NixOS, + Type::openSUSE, + Type::OracleLinux, + Type::Pop, + Type::Redhat, + Type::RedHatEnterprise, + Type::Redox, + Type::Solus, + Type::SUSE, + Type::Ubuntu, + Type::Mint, + Type::Unknown, + Type::Windows, + ]; + + for t in &types { + let info = Info::with_type(*t); + assert_eq!(t, &info.os_type()); + } + } + + #[test] + fn default() { + assert_eq!(Info::default(), Info::unknown()); + } + + #[test] + fn display() { + let data = [ + // All unknown. + (Info::unknown(), "Unknown [unknown bitness]"), + // Type. + ( + Info { + os_type: Type::Redox, + ..Default::default() + }, + "Redox [unknown bitness]", + ), + // Type and version. + ( + Info { + os_type: Type::Linux, + version: Version::Semantic(2, 3, 4), + ..Default::default() + }, + "Linux 2.3.4 [unknown bitness]", + ), + ( + Info { + os_type: Type::Arch, + version: Version::Rolling(None), + ..Default::default() + }, + "Arch Linux Rolling Release [unknown bitness]", + ), + ( + Info { + os_type: Type::Manjaro, + version: Version::Rolling(Some("2020.05.24".to_owned())), + ..Default::default() + }, + "Manjaro Rolling Release (2020.05.24) [unknown bitness]", + ), + ( + Info { + os_type: Type::Windows, + version: Version::Custom("Special Version".to_owned()), + ..Default::default() + }, + "Windows Special Version [unknown bitness]", + ), + // Bitness. + ( + Info { + bitness: Bitness::X32, + ..Default::default() + }, + "Unknown [32-bit]", + ), + ( + Info { + bitness: Bitness::X64, + ..Default::default() + }, + "Unknown [64-bit]", + ), + // All info. + ( + Info { + os_type: Type::Macos, + version: Version::Semantic(10, 2, 0), + edition: Some("edition".to_owned()), + codename: Some("codename".to_owned()), + bitness: Bitness::X64, + }, + "Mac OS 10.2.0 (edition) (codename) [64-bit]", + ), + ]; + + for (info, expected) in &data { + assert_eq!(expected, &info.to_string()); + } + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/lib.rs cargo-0.58.0/vendor/os_info/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,105 @@ +//! `os_info` +//! +//! Provides interfaces for getting information about the current operating system, such as type, +//! version, edition and bitness. + +#![deny( + missing_debug_implementations, + missing_docs, + unsafe_code, + missing_doc_code_examples +)] + +#[cfg(target_os = "android")] +#[path = "android/mod.rs"] +mod imp; + +#[cfg(target_os = "dragonfly")] +#[path = "dragonfly/mod.rs"] +mod imp; + +#[cfg(target_os = "emscripten")] +#[path = "emscripten/mod.rs"] +mod imp; + +#[cfg(target_os = "freebsd")] +#[path = "freebsd/mod.rs"] +mod imp; + +#[cfg(target_os = "linux")] +#[path = "linux/mod.rs"] +mod imp; + +#[cfg(target_os = "macos")] +#[path = "macos/mod.rs"] +mod imp; + +#[cfg(target_os = "netbsd")] +#[path = "netbsd/mod.rs"] +mod imp; + +#[cfg(target_os = "openbsd")] +#[path = "openbsd/mod.rs"] +mod imp; + +#[cfg(target_os = "redox")] +#[path = "redox/mod.rs"] +mod imp; + +#[cfg(windows)] +#[path = "windows/mod.rs"] +mod imp; + +#[cfg(not(any( + target_os = "android", + target_os = "dragonfly", + target_os = "emscripten", + target_os = "freebsd", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "openbsd", + target_os = "redox", + target_os = "windows" +)))] +#[path = "unknown/mod.rs"] +mod imp; + +mod bitness; +mod info; +#[cfg(not(windows))] +mod matcher; +mod os_type; +#[cfg(any( + target_os = "dragonfly", + target_os = "freebsd", + target_os = "netbsd", + target_os = "openbsd" +))] +mod uname; +mod version; + +pub use crate::{bitness::Bitness, info::Info, os_type::Type, version::Version}; + +/// Returns information about the current operating system (type, version, edition, etc.). +/// +/// # Examples +/// +/// ``` +/// use os_info; +/// +/// let info = os_info::get(); +/// +/// // Print full information: +/// println!("OS information: {}", info); +/// +/// // Print information separately: +/// println!("Type: {}", info.os_type()); +/// println!("Version: {}", info.version()); +/// println!("Edition: {:?}", info.edition()); +/// println!("Codename: {:?}", info.codename()); +/// println!("Bitness: {}", info.bitness()); +/// ``` +pub fn get() -> Info { + imp::current_platform() +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/file_release.rs cargo-0.58.0/vendor/os_info/src/linux/file_release.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/file_release.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/file_release.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,327 @@ +// spell-checker:ignore sles + +use std::{fs::File, io::Read, path::Path}; + +use log::{trace, warn}; + +use crate::{matcher::Matcher, Bitness, Info, Type, Version}; + +pub fn get() -> Option { + retrieve(&DISTRIBUTIONS) +} + +fn retrieve(distributions: &[ReleaseInfo]) -> Option { + for release_info in distributions { + if !Path::new(release_info.path).exists() { + trace!("Path '{}' doesn't exist", release_info.path); + continue; + } + + let mut file = match File::open(&release_info.path) { + Ok(val) => val, + Err(e) => { + warn!("Unable to open {:?} file: {:?}", release_info.path, e); + continue; + } + }; + + let mut file_content = String::new(); + if let Err(e) = file.read_to_string(&mut file_content) { + warn!("Unable to read {:?} file: {:?}", release_info.path, e); + continue; + } + + let os_type = Matcher::KeyValue { key: "NAME" } + .find(&file_content) + .and_then(|name| get_type(&name)) + .unwrap_or(release_info.os_type); + + let version = release_info + .version_matcher + .find(&file_content) + .map(Version::from_string) + .unwrap_or_else(|| Version::Unknown); + + return Some(Info { + os_type, + version, + bitness: Bitness::Unknown, + ..Default::default() + }); + } + + None +} + +fn get_type(name: &str) -> Option { + match name.to_lowercase().as_ref() { + "alpine linux" => Some(Type::Alpine), + "amazon linux" => Some(Type::Amazon), + "amazon linux ami" => Some(Type::Amazon), + "arch linux" => Some(Type::Arch), + "centos linux" => Some(Type::CentOS), + "centos stream" => Some(Type::CentOS), + "fedora" => Some(Type::Fedora), + "linux mint" => Some(Type::Mint), + "nixos" => Some(Type::NixOS), + "red hat enterprise linux" => Some(Type::Redhat), + "sles" => Some(Type::SUSE), + "ubuntu" => Some(Type::Ubuntu), + _ => None, + } +} + +#[derive(Debug, Clone)] +struct ReleaseInfo<'a> { + os_type: Type, + path: &'a str, + version_matcher: Matcher, +} + +/// List of all supported distributions and the information on how to parse their version from the +/// release file. +const DISTRIBUTIONS: [ReleaseInfo; 5] = [ + // Due to shenanigans with Oracle Linux including an /etc/redhat-release file that states + // that the OS is Red Hat Enterprise Linux, this /etc/os-release file MUST be checked + // before this code checks /etc/redhat-release. If it does not get run first, + // it will unintentionally report that the operating system is Red Hat Enterprise Linux + // instead of Oracle Linux. + ReleaseInfo { + os_type: Type::OracleLinux, + path: "/etc/os-release", + version_matcher: Matcher::KeyValue { key: "VERSION_ID" }, + }, + ReleaseInfo { + os_type: Type::CentOS, + path: "/etc/centos-release", + version_matcher: Matcher::PrefixedVersion { prefix: "release" }, + }, + ReleaseInfo { + os_type: Type::Fedora, + path: "/etc/fedora-release", + version_matcher: Matcher::PrefixedVersion { prefix: "release" }, + }, + ReleaseInfo { + os_type: Type::Redhat, + path: "/etc/redhat-release", + version_matcher: Matcher::PrefixedVersion { prefix: "release" }, + }, + ReleaseInfo { + os_type: Type::Alpine, + path: "/etc/alpine-release", + version_matcher: Matcher::AllTrimmed, + }, +]; + +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::assert_eq; + + #[test] + fn oracle_linux() { + let mut distributions = [DISTRIBUTIONS[0].clone()]; + distributions[0].path = "src/linux/tests/os-release"; + + let info = retrieve(&distributions).unwrap(); + assert_eq!(info.os_type(), Type::OracleLinux); + assert_eq!(info.version, Version::Semantic(8, 1, 0)); + assert_eq!(info.edition, None); + assert_eq!(info.codename, None); + } + + #[test] + fn os_release_alpine_3_12() { + let mut distributions = [DISTRIBUTIONS[0].clone()]; + distributions[0].path = "src/linux/tests/os-release-alpine-3-12"; + + let info = retrieve(&distributions).unwrap(); + assert_eq!(info.os_type(), Type::Alpine); + assert_eq!(info.version, Version::Semantic(3, 12, 0)); + assert_eq!(info.edition, None); + assert_eq!(info.codename, None); + } + + #[test] + fn os_release_amazon_1() { + let mut distributions = [DISTRIBUTIONS[0].clone()]; + distributions[0].path = "src/linux/tests/os-release-amazon-1"; + + let info = retrieve(&distributions).unwrap(); + assert_eq!(info.os_type(), Type::Amazon); + assert_eq!(info.version, Version::Semantic(2018, 3, 0)); + assert_eq!(info.edition, None); + assert_eq!(info.codename, None); + } + + #[test] + fn os_release_amazon_2() { + let mut distributions = [DISTRIBUTIONS[0].clone()]; + distributions[0].path = "src/linux/tests/os-release-amazon-2"; + + let info = retrieve(&distributions).unwrap(); + assert_eq!(info.os_type(), Type::Amazon); + assert_eq!(info.version, Version::Semantic(2, 0, 0)); + assert_eq!(info.edition, None); + assert_eq!(info.codename, None); + } + + #[test] + fn os_release_centos() { + let mut distributions = [DISTRIBUTIONS[0].clone()]; + distributions[0].path = "src/linux/tests/os-release-centos"; + + let info = retrieve(&distributions).unwrap(); + assert_eq!(info.os_type(), Type::CentOS); + assert_eq!(info.version, Version::Semantic(7, 0, 0)); + assert_eq!(info.edition, None); + assert_eq!(info.codename, None); + } + + #[test] + fn os_release_centos_stream() { + let mut distributions = [DISTRIBUTIONS[0].clone()]; + distributions[0].path = "src/linux/tests/os-release-centos-stream"; + + let info = retrieve(&distributions).unwrap(); + assert_eq!(info.os_type(), Type::CentOS); + assert_eq!(info.version, Version::Semantic(8, 0, 0)); + assert_eq!(info.edition, None); + assert_eq!(info.codename, None); + } + + #[test] + fn os_release_fedora() { + let mut distributions = [DISTRIBUTIONS[0].clone()]; + distributions[0].path = "src/linux/tests/os-release-fedora-32"; + + let info = retrieve(&distributions).unwrap(); + assert_eq!(info.os_type(), Type::Fedora); + assert_eq!(info.version, Version::Semantic(32, 0, 0)); + assert_eq!(info.edition, None); + assert_eq!(info.codename, None); + } + + #[test] + fn os_release_nixos() { + let mut distributions = [DISTRIBUTIONS[0].clone()]; + distributions[0].path = "src/linux/tests/os-release-nixos"; + + let info = retrieve(&distributions).unwrap(); + assert_eq!(info.os_type(), Type::NixOS); + assert_eq!( + info.version, + Version::Custom("21.05pre275822.916ee862e87".to_string()) + ); + assert_eq!(info.edition, None); + assert_eq!(info.codename, None); + } + + #[test] + fn os_release_rhel() { + let mut distributions = [DISTRIBUTIONS[0].clone()]; + distributions[0].path = "src/linux/tests/os-release-rhel"; + + let info = retrieve(&distributions).unwrap(); + assert_eq!(info.os_type(), Type::Redhat); + assert_eq!(info.version, Version::Semantic(8, 2, 0)); + assert_eq!(info.edition, None); + assert_eq!(info.codename, None); + } + + #[test] + fn os_release_suse_12() { + let mut distributions = [DISTRIBUTIONS[0].clone()]; + distributions[0].path = "src/linux/tests/os-release-suse-12"; + + let info = retrieve(&distributions).unwrap(); + assert_eq!(info.os_type(), Type::SUSE); + assert_eq!(info.version, Version::Semantic(12, 5, 0)); + assert_eq!(info.edition, None); + assert_eq!(info.codename, None); + } + + #[test] + fn os_release_suse_15() { + let mut distributions = [DISTRIBUTIONS[0].clone()]; + distributions[0].path = "src/linux/tests/os-release-suse-15"; + + let info = retrieve(&distributions).unwrap(); + assert_eq!(info.os_type(), Type::SUSE); + assert_eq!(info.version, Version::Semantic(15, 2, 0)); + assert_eq!(info.edition, None); + assert_eq!(info.codename, None); + } + + #[test] + fn os_release_ubuntu() { + let mut distributions = [DISTRIBUTIONS[0].clone()]; + distributions[0].path = "src/linux/tests/os-release-ubuntu"; + + let info = retrieve(&distributions).unwrap(); + assert_eq!(info.os_type(), Type::Ubuntu); + assert_eq!(info.version, Version::Semantic(18, 10, 0)); + assert_eq!(info.edition, None); + assert_eq!(info.codename, None); + } + + #[test] + fn os_release_mint() { + let mut distributions = [DISTRIBUTIONS[0].clone()]; + distributions[0].path = "src/linux/tests/os-release-mint"; + + let info = retrieve(&distributions).unwrap(); + assert_eq!(info.os_type(), Type::Mint); + assert_eq!(info.version, Version::Semantic(20, 0, 0)); + assert_eq!(info.edition, None); + assert_eq!(info.codename, None); + } + + #[test] + fn centos() { + let mut distributions = [DISTRIBUTIONS[1].clone()]; + distributions[0].path = "src/linux/tests/centos-release"; + + let info = retrieve(&distributions).unwrap(); + assert_eq!(info.os_type(), Type::CentOS); + assert_eq!(info.version, Version::Custom("XX".to_owned())); + assert_eq!(info.edition, None); + assert_eq!(info.codename, None); + } + + #[test] + fn fedora() { + let mut distributions = [DISTRIBUTIONS[2].clone()]; + distributions[0].path = "src/linux/tests/fedora-release"; + + let info = retrieve(&distributions).unwrap(); + assert_eq!(info.os_type(), Type::Fedora); + assert_eq!(info.version, Version::Semantic(26, 0, 0)); + assert_eq!(info.edition, None); + assert_eq!(info.codename, None); + } + + #[test] + fn redhat() { + let mut distributions = [DISTRIBUTIONS[3].clone()]; + distributions[0].path = "src/linux/tests/redhat-release"; + + let info = retrieve(&distributions).unwrap(); + assert_eq!(info.os_type(), Type::Redhat); + assert_eq!(info.version, Version::Custom("XX".to_owned())); + assert_eq!(info.edition, None); + assert_eq!(info.codename, None); + } + + #[test] + fn alpine() { + let mut distributions = [DISTRIBUTIONS[4].clone()]; + distributions[0].path = "src/linux/tests/alpine-release"; + + let info = retrieve(&distributions).unwrap(); + assert_eq!(info.os_type(), Type::Alpine); + assert_eq!(info.version, Version::Custom("A.B.C".to_owned())); + assert_eq!(info.edition, None); + assert_eq!(info.codename, None); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/lsb_release.rs cargo-0.58.0/vendor/os_info/src/linux/lsb_release.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/lsb_release.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/lsb_release.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,462 @@ +// spell-checker:ignore codename, noarch, rhel, ootpa, maipo + +use std::process::Command; + +use log::{debug, trace}; + +use crate::{matcher::Matcher, Info, Type, Version}; + +pub fn get() -> Option { + let release = retrieve()?; + + let version = match release.version.as_deref() { + Some("rolling") => Version::Rolling(None), + Some(v) => Version::Custom(v.to_owned()), + None => Version::Unknown, + }; + + let os_type = match release.distribution.as_ref().map(String::as_ref) { + Some("Amazon") | Some("AmazonAMI") => Type::Amazon, + Some("Arch") => Type::Arch, + Some("CentOS") => Type::CentOS, + Some("Debian") => Type::Debian, + Some("EndeavourOS") => Type::EndeavourOS, + Some("Fedora") | Some("Fedora Linux") => Type::Fedora, + Some("Linuxmint") => Type::Mint, + Some("ManjaroLinux") => Type::Manjaro, + Some("NixOS") => Type::NixOS, + Some("openSUSE") => Type::openSUSE, + Some("OracleServer") => Type::OracleLinux, + Some("Pop") => Type::Pop, + Some("Raspbian") => Type::Raspbian, + Some("RedHatEnterprise") | Some("RedHatEnterpriseServer") => Type::RedHatEnterprise, + Some("Solus") => Type::Solus, + Some("SUSE") => Type::SUSE, + Some("Ubuntu") => Type::Ubuntu, + _ => Type::Linux, + }; + + Some(Info { + os_type, + version, + codename: release.codename, + ..Default::default() + }) +} + +struct LsbRelease { + pub distribution: Option, + pub version: Option, + pub codename: Option, +} + +fn retrieve() -> Option { + match Command::new("lsb_release").arg("-a").output() { + Ok(output) => { + trace!("lsb_release command returned {:?}", output); + Some(parse(&String::from_utf8_lossy(&output.stdout))) + } + Err(e) => { + debug!("lsb_release command failed with {:?}", e); + None + } + } +} + +fn parse(output: &str) -> LsbRelease { + trace!("Trying to parse {:?}", output); + + let distribution = Matcher::PrefixedWord { + prefix: "Distributor ID:", + } + .find(output); + + let codename = Matcher::PrefixedWord { + prefix: "Codename:", + } + .find(output) + .filter(|c| c != "n/a"); + + let version = Matcher::PrefixedVersion { prefix: "Release:" }.find(output); + + trace!( + "Parsed as '{:?}' distribution and '{:?}' version", + distribution, + version + ); + + LsbRelease { + distribution, + version, + codename, + } +} + +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::assert_eq; + + #[test] + fn debian() { + let parse_results = parse(file()); + assert_eq!(parse_results.distribution, Some("Debian".to_string())); + assert_eq!(parse_results.version, Some("7.8".to_string())); + assert_eq!(parse_results.codename, Some("wheezy".to_string())); + } + + #[test] + fn arch() { + let parse_results = parse(arch_file()); + assert_eq!(parse_results.distribution, Some("Arch".to_string())); + assert_eq!(parse_results.version, Some("rolling".to_string())); + assert_eq!(parse_results.codename, None); + } + + #[test] + fn fedora() { + let parse_results = parse(fedora_file()); + assert_eq!(parse_results.distribution, Some("Fedora".to_string())); + assert_eq!(parse_results.version, Some("26".to_string())); + assert_eq!(parse_results.codename, Some("TwentySix".to_string())); + } + + #[test] + fn ubuntu() { + let parse_results = parse(ubuntu_file()); + assert_eq!(parse_results.distribution, Some("Ubuntu".to_string())); + assert_eq!(parse_results.version, Some("16.04".to_string())); + assert_eq!(parse_results.codename, Some("xenial".to_string())); + } + + #[test] + fn mint() { + let parse_results = parse(mint_file()); + assert_eq!(parse_results.distribution, Some("Linuxmint".to_string())); + assert_eq!(parse_results.version, Some("20".to_string())); + assert_eq!(parse_results.codename, Some("ulyana".to_string())); + } + + #[test] + fn nixos() { + let parse_results = parse(nixos_file()); + assert_eq!(parse_results.distribution, Some("NixOS".to_string())); + assert_eq!( + parse_results.version, + Some("21.05pre275822.916ee862e87".to_string()) + ); + assert_eq!(parse_results.codename, Some("okapi".to_string())); + } + + #[test] + fn amazon1() { + let parse_results = parse(amazon1_file()); + assert_eq!(parse_results.distribution, Some("AmazonAMI".to_string())); + assert_eq!(parse_results.version, Some("2018.03".to_string())); + assert_eq!(parse_results.codename, None); + } + + #[test] + fn amazon2() { + let parse_results = parse(amazon2_file()); + assert_eq!(parse_results.distribution, Some("Amazon".to_string())); + assert_eq!(parse_results.version, Some("2".to_string())); + assert_eq!(parse_results.codename, Some("Karoo".to_string())); + } + + #[test] + fn redhat_enterprise_8() { + let parse_results = parse(rhel8_file()); + assert_eq!( + parse_results.distribution, + Some("RedHatEnterprise".to_string()) + ); + assert_eq!(parse_results.version, Some("8.1".to_string())); + assert_eq!(parse_results.codename, Some("Ootpa".to_string())); + } + + #[test] + fn redhat_enterprise_7() { + let parse_results = parse(rhel7_file()); + assert_eq!( + parse_results.distribution, + Some("RedHatEnterpriseServer".to_string()) + ); + assert_eq!(parse_results.version, Some("7.7".to_string())); + assert_eq!(parse_results.codename, Some("Maipo".to_string())); + } + + #[test] + fn redhat_enterprise_6() { + let parse_results = parse(rhel6_file()); + assert_eq!( + parse_results.distribution, + Some("RedHatEnterpriseServer".to_string()) + ); + assert_eq!(parse_results.version, Some("6.10".to_string())); + assert_eq!(parse_results.codename, Some("Santiago".to_string())); + } + + #[test] + fn suse_enterprise_15_1() { + let parse_results = parse(suse_enterprise15_1_file()); + assert_eq!(parse_results.distribution, Some("SUSE".to_string())); + assert_eq!(parse_results.version, Some("15.1".to_string())); + assert_eq!(parse_results.codename, None); + } + + #[test] + fn suse_enterprise_12_5() { + let parse_results = parse(suse_enterprise12_5_file()); + assert_eq!(parse_results.distribution, Some("SUSE".to_string())); + assert_eq!(parse_results.version, Some("12.5".to_string())); + assert_eq!(parse_results.codename, None); + } + + #[test] + fn open_suse_15_1() { + let parse_results = parse(open_suse_15_1_file()); + assert_eq!(parse_results.distribution, Some("openSUSE".to_string())); + assert_eq!(parse_results.version, Some("15.1".to_string())); + assert_eq!(parse_results.codename, None); + } + + #[test] + fn oracle_linux_7_5() { + let parse_results = parse(oracle_server_linux_7_5_file()); + assert_eq!(parse_results.distribution, Some("OracleServer".to_string())); + assert_eq!(parse_results.version, Some("7.5".to_string())); + assert_eq!(parse_results.codename, None); + } + + #[test] + fn oracle_linux_8_1() { + let parse_results = parse(oracle_server_linux_8_1_file()); + assert_eq!(parse_results.distribution, Some("OracleServer".to_string())); + assert_eq!(parse_results.version, Some("8.1".to_string())); + assert_eq!(parse_results.codename, None); + } + + #[test] + fn pop_os_20_04_lts() { + let parse_results = parse(pop_os_20_04_lts_file()); + assert_eq!(parse_results.distribution, Some("Pop".to_string())); + assert_eq!(parse_results.version, Some("20.04".to_string())); + assert_eq!(parse_results.codename, Some("focal".to_string())); + } + + #[test] + fn solus_4_1() { + let parse_results = parse(solus_4_1_file()); + assert_eq!(parse_results.distribution, Some("Solus".to_string())); + assert_eq!(parse_results.version, Some("4.1".to_string())); + assert_eq!(parse_results.codename, Some("fortitude".to_string())); + } + + #[test] + fn manjaro() { + let parse_results = parse(manjaro_19_0_2_file()); + assert_eq!(parse_results.distribution, Some("ManjaroLinux".to_string())); + assert_eq!(parse_results.version, Some("19.0.2".to_string())); + assert_eq!(parse_results.codename, None); + } + + #[test] + fn endeavouros() { + let parse_results = parse(endeavouros_file()); + assert_eq!(parse_results.distribution, Some("EndeavourOS".to_string())); + assert_eq!(parse_results.version, Some("rolling".to_string())); + assert_eq!(parse_results.codename, None); + } + + #[test] + fn raspbian() { + let parse_results = parse(raspberry_os_file()); + assert_eq!(parse_results.distribution, Some("Raspbian".to_string())); + assert_eq!(parse_results.version, Some("10".to_string())); + assert_eq!(parse_results.codename, None); + } + + fn file() -> &'static str { + "\nDistributor ID: Debian\n\ + Description: Debian GNU/Linux 7.8 (wheezy)\n\ + Release: 7.8\n\ + Codename: wheezy\n\ + " + } + + fn arch_file() -> &'static str { + "\nLSB Version: 1.4\n\ + Distributor ID: Arch\n\ + Description: Arch Linux\n\ + Release: rolling\n\ + Codename: n/a" + } + + fn fedora_file() -> &'static str { + "\nLSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch\n\ + Distributor ID: Fedora\n\ + Description: Fedora release 26 (Twenty Six)\n\ + Release: 26\n\ + Codename: TwentySix\n\ + " + } + + fn ubuntu_file() -> &'static str { + "Distributor ID: Ubuntu\n\ + Description: Ubuntu 16.04.5 LTS\n\ + Release: 16.04\n\ + Codename: xenial" + } + + fn mint_file() -> &'static str { + "Distributor ID: Linuxmint\n\ + Description: Linux Mint 20\n\ + Release: 20\n\ + Codename: ulyana" + } + + fn nixos_file() -> &'static str { + "Distributor ID: NixOS\n\ + Description: NixOS 21.05 (Okapi)\n\ + Release: 21.05pre275822.916ee862e87\n\ + Codename: okapi" + } + + // Amazon Linux 1 uses a separate Distributor ID and Release format from Amazon Linux 2 + fn amazon1_file() -> &'static str { + "LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch\n\ + Distributor ID: AmazonAMI\n\ + Description: Amazon Linux AMI release 2018.03\n\ + Release: 2018.03\n\ + Codename: n/a\n\ + " + } + + // Amazon Linux 2 uses a separate Distributor ID and Release format from Amazon Linux 1 + fn amazon2_file() -> &'static str { + "LSB Version: :core-4.1-amd64:core-4.1-noarch\n\ + Distributor ID: Amazon\n\ + Description: Amazon Linux release 2 (Karoo)\n\ + Release: 2\n\ + Codename: Karoo\n\ + " + } + + fn rhel8_file() -> &'static str { + "LSB Version: :core-4.1-amd64:core-4.1-noarch\n\ + Distributor ID: RedHatEnterprise\n\ + Description: Red Hat Enterprise Linux release 8.1 (Ootpa)\n\ + Release: 8.1\n\ + Codename: Ootpa\n\ + " + } + + fn rhel7_file() -> &'static str { + "LSB Version: :core-4.1-amd64:core-4.1-noarch\n\ + Distributor ID: RedHatEnterpriseServer\n\ + Description: Red Hat Enterprise Linux Server release 7.7 (Maipo)\n\ + Release: 7.7\n\ + Codename: Maipo\n\ + " + } + + fn rhel6_file() -> &'static str { + "LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch\n\ + Distributor ID: RedHatEnterpriseServer\n\ + Description: Red Hat Enterprise Linux Server release 6.10 (Santiago)\n\ + Release: 6.10\n\ + Codename: Santiago\n\ + " + } + + fn suse_enterprise15_1_file() -> &'static str { + "LSB Version: n/a\n\ + Distributor ID: SUSE\n\ + Description: SUSE Linux Enterprise Server 15 SP1\n\ + Release: 15.1\n\ + Codename: n/a\n\ + " + } + + fn suse_enterprise12_5_file() -> &'static str { + "LSB Version: n/a\n\ + Distributor ID: SUSE\n\ + Description: SUSE Linux Enterprise Server 12 SP5\n\ + Release: 12.5\n\ + Codename: n/a\n\ + " + } + + fn raspberry_os_file() -> &'static str { + "LSB Version: n/a\n\ + Distributor ID: Raspbian\n\ + Description: Raspbian GNU/Linux 10 (buster)\n\ + Release: 10\n\ + Codename: n/a\n\ + " + } + + fn open_suse_15_1_file() -> &'static str { + "LSB Version: n/a\n\ + Distributor ID: openSUSE\n\ + Description: openSUSE Leap 15.1\n\ + Release: 15.1\n\ + Codename: n/a\n\ + " + } + + fn oracle_server_linux_7_5_file() -> &'static str { + "LSB Version: :core-4.1-amd64:core-4.1-noarch\n\ + Distributor ID: OracleServer\n\ + Description: Oracle Linux Server release 7.5\n\ + Release: 7.5\n\ + Codename: n/a\n\ + " + } + + fn oracle_server_linux_8_1_file() -> &'static str { + "LSB Version: :core-4.1-amd64:core-4.1-noarch\n\ + Distributor ID: OracleServer\n\ + Description: Oracle Linux Server release 8.1\n\ + Release: 8.1\n\ + Codename: n/a\n\ + " + } + + fn pop_os_20_04_lts_file() -> &'static str { + "No LSB modules are available.\n\ + Distributor ID: Pop\n\ + Description: Pop!_OS 20.04 LTS\n\ + Release: 20.04\n\ + Codename: focal\n\ + " + } + + fn solus_4_1_file() -> &'static str { + "LSB Version: 1.4\n\ + Distributor ID: Solus\n\ + Description: Solus\n\ + Release: 4.1\n\ + Codename: fortitude\n\ + " + } + + fn manjaro_19_0_2_file() -> &'static str { + "LSB Version: n/a\n\ + Distributor ID: ManjaroLinux\n\ + Description: Manjaro Linux\n\ + Release: 19.0.2\n\ + Codename: n/a\n\ + " + } + + fn endeavouros_file() -> &'static str { + "LSB Version: 1.4\n\ + Distributor ID: EndeavourOS\n\ + Description: EndeavourOS Linux\n\ + Release: rolling\n\ + Codename: n/a\n\ + " + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/mod.rs cargo-0.58.0/vendor/os_info/src/linux/mod.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,53 @@ +mod file_release; +mod lsb_release; + +use log::trace; + +use crate::{bitness, Info, Type}; + +pub fn current_platform() -> Info { + trace!("linux::current_platform is called"); + + let mut info = lsb_release::get() + .or_else(file_release::get) + .unwrap_or_else(|| Info::with_type(Type::Linux)); + info.bitness = bitness::get(); + + trace!("Returning {:?}", info); + info +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn os_type() { + let version = current_platform(); + match version.os_type() { + Type::Alpine + | Type::Amazon + | Type::Arch + | Type::CentOS + | Type::Debian + | Type::EndeavourOS + | Type::Fedora + | Type::Linux + | Type::Manjaro + | Type::NixOS + | Type::openSUSE + | Type::OracleLinux + | Type::Pop + | Type::Raspbian + | Type::Redhat + | Type::RedHatEnterprise + | Type::Solus + | Type::SUSE + | Type::Ubuntu + | Type::Mint => (), + os_type => { + panic!("Unexpected OS type: {}", os_type); + } + } + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/alpine-release cargo-0.58.0/vendor/os_info/src/linux/tests/alpine-release --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/alpine-release 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/tests/alpine-release 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1 @@ +A.B.C diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/centos-release cargo-0.58.0/vendor/os_info/src/linux/tests/centos-release --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/centos-release 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/tests/centos-release 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1 @@ +Centos Linux release XX diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/fedora-release cargo-0.58.0/vendor/os_info/src/linux/tests/fedora-release --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/fedora-release 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/tests/fedora-release 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1 @@ +Fedora release 26 (Twenty Six) diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release cargo-0.58.0/vendor/os_info/src/linux/tests/os-release --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/tests/os-release 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,18 @@ +NAME="Oracle Linux Server" +VERSION="8.1" +ID="ol" +ID_LIKE="fedora" +VARIANT="Server" +VARIANT_ID="server" +VERSION_ID="8.1" +PLATFORM_ID="platform:el8" +PRETTY_NAME="Oracle Linux Server 8.1" +ANSI_COLOR="0;31" +CPE_NAME="cpe:/o:oracle:linux:8:1:server" +HOME_URL="https://linux.oracle.com/" +BUG_REPORT_URL="https://bugzilla.oracle.com/" + +ORACLE_BUGZILLA_PRODUCT="Oracle Linux 8" +ORACLE_BUGZILLA_PRODUCT_VERSION=8.1 +ORACLE_SUPPORT_PRODUCT="Oracle Linux" +ORACLE_SUPPORT_PRODUCT_VERSION=8.1 diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-alpine-3-12 cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-alpine-3-12 --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-alpine-3-12 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-alpine-3-12 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,6 @@ +NAME="Alpine Linux" +ID=alpine +VERSION_ID=3.12.0 +PRETTY_NAME="Alpine Linux v3.12" +HOME_URL="https://alpinelinux.org/" +BUG_REPORT_URL="https://bugs.alpinelinux.org/" diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-amazon-1 cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-amazon-1 --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-amazon-1 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-amazon-1 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,9 @@ +NAME="Amazon Linux AMI" +VERSION="2018.03" +ID="amzn" +ID_LIKE="rhel fedora" +VERSION_ID="2018.03" +PRETTY_NAME="Amazon Linux AMI 2018.03" +ANSI_COLOR="0;33" +CPE_NAME="cpe:/o:amazon:linux:2018.03:ga" +HOME_URL="http://aws.amazon.com/amazon-linux-ami/" diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-amazon-2 cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-amazon-2 --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-amazon-2 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-amazon-2 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,9 @@ +NAME="Amazon Linux" +VERSION="2" +ID="amzn" +ID_LIKE="centos rhel fedora" +VERSION_ID="2" +PRETTY_NAME="Amazon Linux 2" +ANSI_COLOR="0;33" +CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2" +HOME_URL="https://amazonlinux.com/" diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-centos cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-centos --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-centos 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-centos 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,15 @@ +NAME="CentOS Linux" +VERSION="7 (Core)" +ID="centos" +ID_LIKE="rhel fedora" +VERSION_ID="7" +PRETTY_NAME="CentOS Linux 7 (Core)" +ANSI_COLOR="0;31" +CPE_NAME="cpe:/o:centos:centos:7" +HOME_URL="https://www.centos.org/" +BUG_REPORT_URL="https://bugs.centos.org/" + +CENTOS_MANTISBT_PROJECT="CentOS-7" +CENTOS_MANTISBT_PROJECT_VERSION="7" +REDHAT_SUPPORT_PRODUCT="centos" +REDHAT_SUPPORT_PRODUCT_VERSION="7" diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-centos-stream cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-centos-stream --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-centos-stream 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-centos-stream 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,13 @@ +NAME="CentOS Stream" +VERSION="8" +ID="centos" +ID_LIKE="rhel fedora" +VERSION_ID="8" +PLATFORM_ID="platform:el8" +PRETTY_NAME="CentOS Stream 8" +ANSI_COLOR="0;31" +CPE_NAME="cpe:/o:centos:centos:8" +HOME_URL="https://centos.org/" +BUG_REPORT_URL="https://bugzilla.redhat.com/" +REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 8" +REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream" diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-fedora-32 cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-fedora-32 --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-fedora-32 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-fedora-32 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,21 @@ +NAME=Fedora +VERSION="32 (Cloud Edition)" +ID=fedora +VERSION_ID=32 +VERSION_CODENAME="" +PLATFORM_ID="platform:f32" +PRETTY_NAME="Fedora 32 (Cloud Edition)" +ANSI_COLOR="0;34" +LOGO=fedora-logo-icon +CPE_NAME="cpe:/o:fedoraproject:fedora:32" +HOME_URL="https://fedoraproject.org/" +DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f32/system-administrators-guide/" +SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help" +BUG_REPORT_URL="https://bugzilla.redhat.com/" +REDHAT_BUGZILLA_PRODUCT="Fedora" +REDHAT_BUGZILLA_PRODUCT_VERSION=32 +REDHAT_SUPPORT_PRODUCT="Fedora" +REDHAT_SUPPORT_PRODUCT_VERSION=32 +PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy" +VARIANT="Cloud Edition" +VARIANT_ID=cloud diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-mint cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-mint --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-mint 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-mint 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,12 @@ +NAME="Linux Mint" +VERSION="20 (Ulyana)" +ID=linuxmint +ID_LIKE=ubuntu +PRETTY_NAME="Linux Mint 20" +VERSION_ID="20" +HOME_URL="https://www.linuxmint.com/" +SUPPORT_URL="https://forums.linuxmint.com/" +BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/" +PRIVACY_POLICY_URL="https://www.linuxmint.com/" +VERSION_CODENAME=ulyana +UBUNTU_CODENAME=focal diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-nixos cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-nixos --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-nixos 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-nixos 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,11 @@ +NAME=NixOS +ID=nixos +VERSION="21.05pre275822.916ee862e87 (Okapi)" +VERSION_CODENAME=okapi +VERSION_ID="21.05pre275822.916ee862e87" +PRETTY_NAME="NixOS 21.05 (Okapi)" +LOGO="nix-snowflake" +HOME_URL="https://nixos.org/" +DOCUMENTATION_URL="https://nixos.org/learn.html" +SUPPORT_URL="https://nixos.org/community.html" +BUG_REPORT_URL="https://github.com/NixOS/nixpkgs/issues" diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-rhel cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-rhel --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-rhel 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-rhel 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,16 @@ +NAME="Red Hat Enterprise Linux" +VERSION="8.2 (Ootpa)" +ID="rhel" +ID_LIKE="fedora" +VERSION_ID="8.2" +PLATFORM_ID="platform:el8" +PRETTY_NAME="Red Hat Enterprise Linux 8.2 (Ootpa)" +ANSI_COLOR="0;31" +CPE_NAME="cpe:/o:redhat:enterprise_linux:8.2:GA" +HOME_URL="https://www.redhat.com/" +BUG_REPORT_URL="https://bugzilla.redhat.com/" + +REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8" +REDHAT_BUGZILLA_PRODUCT_VERSION=8.2 +REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux" +REDHAT_SUPPORT_PRODUCT_VERSION="8.2" diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-suse-12 cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-suse-12 --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-suse-12 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-suse-12 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,7 @@ +NAME="SLES" +VERSION="12-SP5" +VERSION_ID="12.5" +PRETTY_NAME="SUSE Linux Enterprise Server 12 SP5" +ID="sles" +ANSI_COLOR="0;32" +CPE_NAME="cpe:/o:suse:sles:12:sp5" diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-suse-15 cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-suse-15 --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-suse-15 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-suse-15 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,8 @@ +NAME="SLES" +VERSION="15-SP2" +VERSION_ID="15.2" +PRETTY_NAME="SUSE Linux Enterprise Server 15 SP2" +ID="sles" +ID_LIKE="suse" +ANSI_COLOR="0;32" +CPE_NAME="cpe:/o:suse:sles:15:sp2" diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-ubuntu cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-ubuntu --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/os-release-ubuntu 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/tests/os-release-ubuntu 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,12 @@ +NAME="Ubuntu" +VERSION="18.10 (Cosmic Cuttlefish)" +ID=ubuntu +ID_LIKE=debian +PRETTY_NAME="Ubuntu 18.10" +VERSION_ID="18.10" +HOME_URL="https://www.ubuntu.com/" +SUPPORT_URL="https://help.ubuntu.com/" +BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" +PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" +VERSION_CODENAME=cosmic +UBUNTU_CODENAME=cosmic diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/redhat-release cargo-0.58.0/vendor/os_info/src/linux/tests/redhat-release --- cargo-0.57.0+ubuntu/vendor/os_info/src/linux/tests/redhat-release 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/linux/tests/redhat-release 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1 @@ +Redhat Linux release XX diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/macos/mod.rs cargo-0.58.0/vendor/os_info/src/macos/mod.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/macos/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/macos/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,106 @@ +use std::process::Command; + +use log::{trace, warn}; + +use crate::{bitness, matcher::Matcher, Info, Type, Version}; + +pub fn current_platform() -> Info { + trace!("macos::current_platform is called"); + + let info = Info { + os_type: Type::Macos, + version: version(), + bitness: bitness::get(), + ..Default::default() + }; + trace!("Returning {:?}", info); + info +} + +fn version() -> Version { + match product_version() { + None => Version::Unknown, + Some(val) => Version::from_string(val), + } +} + +fn product_version() -> Option { + match Command::new("sw_vers").output() { + Ok(val) => { + let output = String::from_utf8_lossy(&val.stdout); + trace!("sw_vers command returned {:?}", output); + parse(&output) + } + Err(e) => { + warn!("sw_vers command failed with {:?}", e); + None + } + } +} + +fn parse(sw_vers_output: &str) -> Option { + Matcher::PrefixedVersion { + prefix: "ProductVersion:", + } + .find(sw_vers_output) +} + +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::{assert_eq, assert_ne}; + + #[test] + fn os_type() { + let version = current_platform(); + assert_eq!(Type::Macos, version.os_type()); + } + + #[test] + fn os_version() { + let version = version(); + assert_ne!(Version::Unknown, version); + } + + #[test] + fn string_product_version() { + let version = product_version(); + assert!(version.is_some()); + } + + #[test] + fn parse_version() { + let parse_output = parse(sw_vers_output()); + assert_eq!(parse_output, Some("10.10.5".to_string())); + } + + fn sw_vers_output() -> &'static str { + "ProductName: Mac OS X\n\ + ProductVersion: 10.10.5\n\ + BuildVersion: 14F27" + } + + #[test] + fn parse_beta_version() { + let parse_output = parse(sw_vers_output_beta()); + assert_eq!(parse_output, Some("10.15".to_string())); + } + + fn sw_vers_output_beta() -> &'static str { + "ProductName: Mac OS X\n\ + ProductVersion: 10.15\n\ + BuildVersion: 19A546d" + } + + #[test] + fn parse_double_digit_patch_version() { + let parse_output = parse(sw_vers_output_double_digit_patch_version()); + assert_eq!(parse_output, Some("10.15.21".to_string())); + } + + fn sw_vers_output_double_digit_patch_version() -> &'static str { + "ProductName: Mac OS X\n\ + ProductVersion: 10.15.21\n\ + BuildVersion: ABCD123" + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/matcher.rs cargo-0.58.0/vendor/os_info/src/matcher.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/matcher.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/matcher.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,150 @@ +/// An implementation to match on simple strings. +#[derive(Debug, Clone)] +#[allow(dead_code)] +pub enum Matcher { + /// Considers the entire string (trimmed) to be the match. + AllTrimmed, + + /// After finding the `prefix` followed by one or more spaces, returns the following word. + PrefixedWord { prefix: &'static str }, + + /// Similar to `PrefixedWord`, but only if the word is a valid version. + PrefixedVersion { prefix: &'static str }, + + /// Takes a set of lines (separated by `\n`) and searches for the value in a key/value pair + /// separated by the `=` character. For example `VERSION_ID="8.1"`. + KeyValue { key: &'static str }, +} + +impl Matcher { + /// Find the match on the input `string`. + pub fn find(&self, string: &str) -> Option { + match *self { + Self::AllTrimmed => Some(string.trim().to_string()), + Self::PrefixedWord { prefix } => find_prefixed_word(string, prefix).map(str::to_owned), + Self::PrefixedVersion { prefix } => find_prefixed_word(string, prefix) + .filter(|&v| is_valid_version(v)) + .map(str::to_owned), + Self::KeyValue { key } => find_by_key(string, key).map(str::to_owned), + } + } +} + +fn find_by_key<'a>(string: &'a str, key: &str) -> Option<&'a str> { + let key = [key, "="].concat(); + for line in string.lines() { + if let Some(key_start) = line.find(&key) { + return Some( + line[key_start + key.len()..].trim_matches(|c: char| c == '"' || c.is_whitespace()), + ); + } + } + + None +} + +fn find_prefixed_word<'a>(string: &'a str, prefix: &str) -> Option<&'a str> { + if let Some(prefix_start) = string.find(prefix) { + // Ignore prefix and leading whitespace + let string = &string[prefix_start + prefix.len()..].trim_start(); + + // Find where the word boundary ends + let word_end = string + .find(|c: char| c.is_whitespace()) + .unwrap_or_else(|| string.len()); + let string = &string[..word_end]; + + Some(string) + } else { + None + } +} + +fn is_valid_version(word: &str) -> bool { + !word.starts_with('.') && !word.ends_with('.') +} + +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::assert_eq; + + #[test] + fn trimmed() { + let data = [ + ("", Some("")), + ("test", Some("test")), + (" test", Some("test")), + ("test ", Some("test")), + (" test ", Some("test")), + ]; + + let matcher = Matcher::AllTrimmed; + + for (input, expected) in &data { + let result = matcher.find(input); + assert_eq!(result.as_deref(), *expected); + } + } + + #[test] + fn prefixed_word() { + let data = [ + ("", None), + ("test", Some("")), + ("test1", Some("1")), + ("test 1", Some("1")), + (" test 1", Some("1")), + ("test 1.2.3", Some("1.2.3")), + (" test 1.2.3", Some("1.2.3")), + ]; + + let matcher = Matcher::PrefixedWord { prefix: "test" }; + + for (input, expected) in &data { + let result = matcher.find(input); + assert_eq!(result.as_deref(), *expected); + } + } + + #[test] + fn prefixed_version() { + let data = [ + ("", None), + ("test", Some("")), + ("test 1", Some("1")), + ("test .1", None), + ("test 1.", None), + ("test .1.", None), + (" test 1", Some("1")), + ("test 1.2.3", Some("1.2.3")), + (" test 1.2.3", Some("1.2.3")), + ]; + + let matcher = Matcher::PrefixedVersion { prefix: "test" }; + + for (input, expected) in &data { + let result = matcher.find(input); + assert_eq!(result.as_deref(), *expected); + } + } + + #[test] + fn key_value() { + let data = [ + ("", None), + ("key", None), + ("key=value", Some("value")), + ("key=1", Some("1")), + ("key=\"1\"", Some("1")), + ("key=\"CentOS Linux\"", Some("CentOS Linux")), + ]; + + let matcher = Matcher::KeyValue { key: "key" }; + + for (input, expected) in &data { + let result = matcher.find(input); + assert_eq!(result.as_deref(), *expected); + } + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/netbsd/mod.rs cargo-0.58.0/vendor/os_info/src/netbsd/mod.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/netbsd/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/netbsd/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,35 @@ +use std::process::Command; + +use log::{error, trace}; + +use crate::{bitness, uname::uname, Info, Type, Version}; + +pub fn current_platform() -> Info { + trace!("netbsd::current_platform is called"); + + let version = uname() + .map(Version::from_string) + .unwrap_or_else(|| Version::Unknown); + + let info = Info { + os_type: Type::NetBSD, + version, + bitness: bitness::get(), + ..Default::default() + }; + + trace!("Returning {:?}", info); + info +} + +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::assert_eq; + + #[test] + fn os_type() { + let version = current_platform(); + assert_eq!(Type::NetBSD, version.os_type()); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/openbsd/mod.rs cargo-0.58.0/vendor/os_info/src/openbsd/mod.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/openbsd/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/openbsd/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,35 @@ +use std::process::Command; + +use log::{error, trace}; + +use crate::{bitness, uname::uname, Info, Type, Version}; + +pub fn current_platform() -> Info { + trace!("openbsd::current_platform is called"); + + let version = uname() + .map(Version::from_string) + .unwrap_or_else(|| Version::Unknown); + + let info = Info { + os_type: Type::OpenBSD, + version, + bitness: bitness::get(), + ..Default::default() + }; + + trace!("Returning {:?}", info); + info +} + +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::assert_eq; + + #[test] + fn os_type() { + let version = current_platform(); + assert_eq!(Type::OpenBSD, version.os_type()); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/os_type.rs cargo-0.58.0/vendor/os_info/src/os_type.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/os_type.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/os_type.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,144 @@ +use std::fmt::{self, Display, Formatter}; + +/// A list of supported operating system types. +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[allow(non_camel_case_types, clippy::upper_case_acronyms)] +#[non_exhaustive] +pub enum Type { + /// Alpine Linux (). + Alpine, + /// Amazon Linux AMI (). + Amazon, + /// Android (). + Android, + /// Arch Linux (). + Arch, + /// CentOS (). + CentOS, + /// Debian (). + Debian, + /// DragonFly BSD (). + DragonFly, + /// Emscripten (). + Emscripten, + /// EndeavourOS (). + EndeavourOS, + /// Fedora (). + Fedora, + /// FreeBSD (). + FreeBSD, + /// Linux based operating system (). + Linux, + /// Mac OS X/OS X/macOS (). + Macos, + /// Manjaro (). + Manjaro, + /// Mint (). + Mint, + /// NetBSD (). + NetBSD, + /// NixOS (). + NixOS, + /// OpenBSD (). + OpenBSD, + /// openSUSE (). + openSUSE, + /// Oracle Linux (). + OracleLinux, + /// Pop!_OS () + Pop, + /// Raspberry Pi OS (). + Raspbian, + /// Red Hat Linux (). + Redhat, + /// Red Hat Enterprise Linux (). + RedHatEnterprise, + /// Redox (). + Redox, + /// Solus (). + Solus, + /// SUSE Linux Enterprise Server (). + SUSE, + /// Ubuntu (). + Ubuntu, + /// Unknown operating system. + Unknown, + /// Windows (). + Windows, +} + +impl Default for Type { + fn default() -> Self { + Type::Unknown + } +} + +impl Display for Type { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + match *self { + Type::Alpine => write!(f, "Alpine Linux"), + Type::Amazon => write!(f, "Amazon Linux AMI"), + Type::Arch => write!(f, "Arch Linux"), + Type::DragonFly => write!(f, "DragonFly BSD"), + Type::Macos => write!(f, "Mac OS"), + Type::Mint => write!(f, "Linux Mint"), + Type::Pop => write!(f, "Pop!_OS"), + Type::Raspbian => write!(f, "Raspberry Pi OS"), + Type::Redhat => write!(f, "Red Hat Linux"), + Type::RedHatEnterprise => write!(f, "Red Hat Enterprise Linux"), + Type::SUSE => write!(f, "SUSE Linux Enterprise Server"), + _ => write!(f, "{:?}", self), + } + } +} +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::assert_eq; + + #[test] + fn default() { + assert_eq!(Type::Unknown, Type::default()); + } + + #[test] + fn display() { + let data = [ + (Type::Alpine, "Alpine Linux"), + (Type::Amazon, "Amazon Linux AMI"), + (Type::Android, "Android"), + (Type::Arch, "Arch Linux"), + (Type::CentOS, "CentOS"), + (Type::Debian, "Debian"), + (Type::DragonFly, "DragonFly BSD"), + (Type::Emscripten, "Emscripten"), + (Type::EndeavourOS, "EndeavourOS"), + (Type::Fedora, "Fedora"), + (Type::FreeBSD, "FreeBSD"), + (Type::Linux, "Linux"), + (Type::Macos, "Mac OS"), + (Type::Manjaro, "Manjaro"), + (Type::Mint, "Linux Mint"), + (Type::NetBSD, "NetBSD"), + (Type::NixOS, "NixOS"), + (Type::OpenBSD, "OpenBSD"), + (Type::openSUSE, "openSUSE"), + (Type::OracleLinux, "OracleLinux"), + (Type::Pop, "Pop!_OS"), + (Type::Raspbian, "Raspberry Pi OS"), + (Type::Redhat, "Red Hat Linux"), + (Type::RedHatEnterprise, "Red Hat Enterprise Linux"), + (Type::Redox, "Redox"), + (Type::Solus, "Solus"), + (Type::SUSE, "SUSE Linux Enterprise Server"), + (Type::Ubuntu, "Ubuntu"), + (Type::Unknown, "Unknown"), + (Type::Windows, "Windows"), + ]; + + for (t, expected) in &data { + assert_eq!(&t.to_string(), expected); + } + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/redox/mod.rs cargo-0.58.0/vendor/os_info/src/redox/mod.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/redox/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/redox/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,54 @@ +// spell-checker:ignore uname + +use std::{fs::File, io::Read}; + +use log::{error, trace}; + +use crate::{Bitness, Info, Type, Version}; + +const UNAME_FILE: &str = "sys:uname"; + +pub fn current_platform() -> Info { + trace!("redox::current_platform is called"); + + let version = get_version() + .map(Version::from_string) + .unwrap_or_else(|| Version::Unknown); + let info = Info { + os_type: Type::Redox, + version, + bitness: Bitness::Unknown, + ..Default::default() + }; + trace!("Returning {:?}", info); + info +} + +fn get_version() -> Option { + let mut file = match File::open(UNAME_FILE) { + Ok(file) => file, + Err(e) => { + error!("Unable to open {} file: {:?}", UNAME_FILE, e); + return None; + } + }; + + let mut version = String::new(); + if let Err(e) = file.read_to_string(&mut version) { + error!("Unable to read {} file: {:?}", UNAME_FILE, e); + return None; + } + Some(version) +} + +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::assert_eq; + + #[test] + fn os_type() { + let version = current_platform(); + assert_eq!(Type::Redox, version.os_type()); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/uname.rs cargo-0.58.0/vendor/os_info/src/uname.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/uname.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/uname.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,32 @@ +use std::process::Command; + +use log::error; + +pub fn uname() -> Option { + Command::new("uname") + .arg("-r") + .output() + .map_err(|e| { + error!("Failed to invoke 'uname': {:?}", e); + }) + .ok() + .and_then(|out| { + if out.status.success() { + Some(String::from_utf8_lossy(&out.stdout).trim_end().to_owned()) + } else { + log::error!("'uname' invocation error: {:?}", out); + None + } + }) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn uname_nonempty() { + let val = uname().expect("uname failed"); + assert!(!val.is_empty()); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/unknown/mod.rs cargo-0.58.0/vendor/os_info/src/unknown/mod.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/unknown/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/unknown/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,20 @@ +use log::trace; + +use crate::{Info, Type}; + +pub fn current_platform() -> Info { + trace!("unknown::current_platform is called"); + Info::unknown() +} + +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::assert_eq; + + #[test] + fn os_type() { + let version = current_platform(); + assert_eq!(Type::Unknown, version.os_type()); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/version.rs cargo-0.58.0/vendor/os_info/src/version.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/version.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/version.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,150 @@ +use std::fmt::{self, Display, Formatter}; + +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; + +/// Operating system version. +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum Version { + /// Unknown version. + Unknown, + /// Semantic version (major.minor.patch). + Semantic(u64, u64, u64), + /// Rolling version. Optionally contains the release date in the string format. + Rolling(Option), + /// Custom version format. + Custom(String), +} + +impl Version { + /// Constructs `VersionType` from the given string. + /// + /// Returns `VersionType::Unknown` if the string is empty. If it can be parsed as a semantic + /// version, then `VersionType::Semantic`, otherwise `VersionType::Custom`. + /// + /// # Examples + /// + /// ``` + /// use os_info::Version; + /// + /// let v = Version::from_string("custom"); + /// assert_eq!(Version::Custom("custom".to_owned()), v); + /// + /// let v = Version::from_string("1.2.3"); + /// assert_eq!(Version::Semantic(1, 2, 3), v); + /// ``` + pub fn from_string + AsRef>(s: S) -> Self { + if s.as_ref().is_empty() { + Self::Unknown + } else if let Some((major, minor, patch)) = parse_version(s.as_ref()) { + Self::Semantic(major, minor, patch) + } else { + Self::Custom(s.into()) + } + } +} + +impl Default for Version { + fn default() -> Self { + Version::Unknown + } +} + +impl Display for Version { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + match *self { + Self::Unknown => f.write_str("Unknown"), + Self::Semantic(major, minor, patch) => write!(f, "{}.{}.{}", major, minor, patch), + Self::Rolling(ref date) => { + let date = match date { + Some(date) => format!(" ({})", date), + None => "".to_owned(), + }; + write!(f, "Rolling Release{}", date) + } + Self::Custom(ref version) => write!(f, "{}", version), + } + } +} + +fn parse_version(s: &str) -> Option<(u64, u64, u64)> { + let mut iter = s.trim().split_terminator('.').fuse(); + + let major = iter.next().and_then(|s| s.parse().ok())?; + let minor = iter.next().unwrap_or("0").parse().ok()?; + let patch = iter.next().unwrap_or("0").parse().ok()?; + + if iter.next().is_some() { + return None; + } + + Some((major, minor, patch)) +} + +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::assert_eq; + + #[test] + fn parse_semantic_version() { + let data = [ + ("", None), + ("version", None), + ("1", Some((1, 0, 0))), + ("1.", Some((1, 0, 0))), + ("1.2", Some((1, 2, 0))), + ("1.2.", Some((1, 2, 0))), + ("1.2.3", Some((1, 2, 3))), + ("1.2.3.", Some((1, 2, 3))), + ("1.2.3. ", Some((1, 2, 3))), + (" 1.2.3.", Some((1, 2, 3))), + (" 1.2.3. ", Some((1, 2, 3))), + ("1.2.3.4", None), + ("1.2.3.4.5.6.7.8.9", None), + ]; + + for (s, expected) in &data { + let result = parse_version(s); + assert_eq!(expected, &result); + } + } + + #[test] + fn from_string() { + let custom_version = "some version"; + let data = [ + ("", Version::Unknown), + ("1.2.3", Version::Semantic(1, 2, 3)), + (custom_version, Version::Custom(custom_version.to_owned())), + ]; + + for (s, expected) in &data { + let version = Version::from_string(*s); + assert_eq!(expected, &version); + } + } + + #[test] + fn default() { + assert_eq!(Version::Unknown, Version::default()); + } + + #[test] + fn display() { + let data = [ + (Version::Unknown, "Unknown"), + (Version::Semantic(1, 5, 0), "1.5.0"), + (Version::Rolling(None), "Rolling Release"), + ( + Version::Rolling(Some("date".to_owned())), + "Rolling Release (date)", + ), + ]; + + for (version, expected) in &data { + assert_eq!(expected, &version.to_string()); + } + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/windows/mod.rs cargo-0.58.0/vendor/os_info/src/windows/mod.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/windows/mod.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/windows/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,26 @@ +mod winapi; + +use log::trace; + +use crate::Info; + +pub fn current_platform() -> Info { + trace!("windows::current_platform is called"); + let info = winapi::get(); + trace!("Returning {:?}", info); + info +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::Type; + use pretty_assertions::assert_eq; + + #[test] + fn os_type() { + let version = current_platform(); + assert_eq!(Type::Windows, version.os_type()); + assert!(version.edition().is_some()); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/src/windows/winapi.rs cargo-0.58.0/vendor/os_info/src/windows/winapi.rs --- cargo-0.57.0+ubuntu/vendor/os_info/src/windows/winapi.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/src/windows/winapi.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,371 @@ +// spell-checker:ignore dword, minwindef, ntdef, ntdll, ntstatus, osversioninfoex, osversioninfoexa +// spell-checker:ignore osversioninfoexw, serverr, sysinfoapi, winnt, winuser, pbool, libloaderapi +// spell-checker:ignore lpcstr, processthreadsapi, farproc, lstatus, wchar, lpbyte, hkey, winerror +// spell-checker:ignore osstr, winreg + +#![allow(unsafe_code)] + +use std::{ + ffi::{OsStr, OsString}, + mem, + os::windows::ffi::{OsStrExt, OsStringExt}, + ptr, +}; + +use winapi::{ + shared::{ + minwindef::{DWORD, FARPROC, LPBYTE}, + ntdef::{LPCSTR, NTSTATUS}, + ntstatus::STATUS_SUCCESS, + winerror::ERROR_SUCCESS, + }, + um::{ + libloaderapi::{GetModuleHandleA, GetProcAddress}, + sysinfoapi::{GetSystemInfo, SYSTEM_INFO}, + winnt::{ + KEY_READ, PROCESSOR_ARCHITECTURE_AMD64, REG_SZ, VER_NT_WORKSTATION, + VER_SUITE_WH_SERVER, WCHAR, + }, + winreg::{RegOpenKeyExW, RegQueryValueExW, HKEY_LOCAL_MACHINE, LSTATUS}, + winuser::{GetSystemMetrics, SM_SERVERR2}, + }, +}; + +use crate::{Bitness, Info, Type, Version}; + +#[cfg(target_arch = "x86")] +type OSVERSIONINFOEX = winapi::um::winnt::OSVERSIONINFOEXA; + +#[cfg(not(target_arch = "x86"))] +type OSVERSIONINFOEX = winapi::um::winnt::OSVERSIONINFOEXW; + +pub fn get() -> Info { + let (version, edition) = version(); + Info { + os_type: Type::Windows, + version, + edition, + bitness: bitness(), + ..Default::default() + } +} + +fn version() -> (Version, Option) { + match version_info() { + None => (Version::Unknown, None), + Some(v) => ( + Version::Semantic( + v.dwMajorVersion as u64, + v.dwMinorVersion as u64, + v.dwBuildNumber as u64, + ), + product_name().or_else(|| edition(&v)), + ), + } +} + +#[cfg(target_pointer_width = "64")] +fn bitness() -> Bitness { + // x64 program can only run on x64 Windows. + Bitness::X64 +} + +#[cfg(target_pointer_width = "32")] +fn bitness() -> Bitness { + use winapi::{ + shared::{ + minwindef::{BOOL, FALSE, PBOOL}, + ntdef::HANDLE, + }, + um::processthreadsapi::GetCurrentProcess, + }; + + // IsWow64Process is not available on all supported versions of Windows. Use GetModuleHandle to + // get a handle to the DLL that contains the function and GetProcAddress to get a pointer to the + // function if available. + let is_wow_64 = match get_proc_address(b"kernel32\0", b"IsWow64Process\0") { + None => return Bitness::Unknown, + Some(val) => val, + }; + + type IsWow64 = unsafe extern "system" fn(HANDLE, PBOOL) -> BOOL; + let is_wow_64: IsWow64 = unsafe { mem::transmute(is_wow_64) }; + + let mut result = FALSE; + if unsafe { is_wow_64(GetCurrentProcess(), &mut result) } == 0 { + log::error!("IsWow64Process failed"); + return Bitness::Unknown; + } + + if result == FALSE { + Bitness::X32 + } else { + Bitness::X64 + } +} + +// Calls the Win32 API function RtlGetVersion to get the OS version information: +// https://msdn.microsoft.com/en-us/library/mt723418(v=vs.85).aspx +fn version_info() -> Option { + let rtl_get_version = match get_proc_address(b"ntdll\0", b"RtlGetVersion\0") { + None => return None, + Some(val) => val, + }; + + type RtlGetVersion = unsafe extern "system" fn(&mut OSVERSIONINFOEX) -> NTSTATUS; + let rtl_get_version: RtlGetVersion = unsafe { mem::transmute(rtl_get_version) }; + + let mut info: OSVERSIONINFOEX = unsafe { mem::zeroed() }; + info.dwOSVersionInfoSize = mem::size_of::() as DWORD; + + if unsafe { rtl_get_version(&mut info) } == STATUS_SUCCESS { + Some(info) + } else { + None + } +} + +fn product_name() -> Option { + const REG_SUCCESS: LSTATUS = ERROR_SUCCESS as LSTATUS; + + let sub_key = to_wide("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"); + let mut key = ptr::null_mut(); + if unsafe { RegOpenKeyExW(HKEY_LOCAL_MACHINE, sub_key.as_ptr(), 0, KEY_READ, &mut key) } + != REG_SUCCESS + || key.is_null() + { + log::error!("RegOpenKeyExW(HKEY_LOCAL_MACHINE, ...) failed"); + return None; + } + + // Get size of the data. + let name = to_wide("ProductName"); + let mut data_type: DWORD = 0; + let mut data_size: DWORD = 0; + if unsafe { + RegQueryValueExW( + key, + name.as_ptr(), + ptr::null_mut(), + &mut data_type, + ptr::null_mut(), + &mut data_size, + ) + } != REG_SUCCESS + || data_type != REG_SZ + || data_size == 0 + || data_size % 2 != 0 + { + log::error!("RegQueryValueExW failed"); + return None; + } + + // Get the data. + let mut data = vec![0u16; data_size as usize / 2]; + if unsafe { + RegQueryValueExW( + key, + name.as_ptr(), + ptr::null_mut(), + ptr::null_mut(), + data.as_mut_ptr() as LPBYTE, + &mut data_size, + ) + } != REG_SUCCESS + || data_size as usize != data.len() * 2 + { + return None; + } + + // If the data has the REG_SZ, REG_MULTI_SZ or REG_EXPAND_SZ type, the string may not have been + // stored with the proper terminating null characters. + match data.last() { + Some(0) => { + data.pop(); + } + _ => {} + } + + Some( + OsString::from_wide(data.as_slice()) + .to_string_lossy() + .into_owned(), + ) +} + +fn to_wide(value: &str) -> Vec { + OsStr::new(value).encode_wide().chain(Some(0)).collect() +} + +// Examines data in the OSVERSIONINFOEX structure to determine the Windows edition: +// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724833(v=vs.85).aspx +fn edition(version_info: &OSVERSIONINFOEX) -> Option { + match ( + version_info.dwMajorVersion, + version_info.dwMinorVersion, + version_info.wProductType, + ) { + // Windows 10. + (10, 0, VER_NT_WORKSTATION) => Some("Windows 10"), + (10, 0, _) => Some("Windows Server 2016"), + // Windows Vista, 7, 8 and 8.1. + (6, 3, VER_NT_WORKSTATION) => Some("Windows 8.1"), + (6, 3, _) => Some("Windows Server 2012 R2"), + (6, 2, VER_NT_WORKSTATION) => Some("Windows 8"), + (6, 2, _) => Some("Windows Server 2012"), + (6, 1, VER_NT_WORKSTATION) => Some("Windows 7"), + (6, 1, _) => Some("Windows Server 2008 R2"), + (6, 0, VER_NT_WORKSTATION) => Some("Windows Vista"), + (6, 0, _) => Some("Windows Server 2008"), + // Windows 2000, Home Server, 2003 Server, 2003 R2 Server, XP and XP Professional x64. + (5, 1, _) => Some("Windows XP"), + (5, 0, _) => Some("Windows 2000"), + (5, 2, _) if unsafe { GetSystemMetrics(SM_SERVERR2) } == 0 => { + let mut info: SYSTEM_INFO = unsafe { mem::zeroed() }; + unsafe { GetSystemInfo(&mut info) }; + + if Into::::into(version_info.wSuiteMask) & VER_SUITE_WH_SERVER + == VER_SUITE_WH_SERVER + { + Some("Windows Home Server") + } else if version_info.wProductType == VER_NT_WORKSTATION + && unsafe { info.u.s().wProcessorArchitecture } == PROCESSOR_ARCHITECTURE_AMD64 + { + Some("Windows XP Professional x64 Edition") + } else { + Some("Windows Server 2003") + } + } + _ => None, + } + .map(str::to_string) +} + +fn get_proc_address(module: &[u8], proc: &[u8]) -> Option { + assert!( + *module.last().expect("Empty module name") == 0, + "Module name should be zero-terminated" + ); + assert!( + *proc.last().expect("Empty procedure name") == 0, + "Procedure name should be zero-terminated" + ); + + let handle = unsafe { GetModuleHandleA(module.as_ptr() as LPCSTR) }; + if handle.is_null() { + log::error!( + "GetModuleHandleA({}) failed", + String::from_utf8_lossy(module) + ); + return None; + } + + unsafe { Some(GetProcAddress(handle, proc.as_ptr() as LPCSTR)) } +} + +#[cfg(test)] +mod tests { + use super::*; + use pretty_assertions::{assert_eq, assert_ne}; + + #[test] + fn version() { + let info = get(); + assert_eq!(Type::Windows, info.os_type()); + } + + #[test] + fn get_version_info() { + let version = version_info(); + assert!(version.is_some()); + } + + #[test] + fn get_edition() { + let test_data = [ + (10, 0, VER_NT_WORKSTATION, "Windows 10"), + (10, 0, 0, "Windows Server 2016"), + (6, 3, VER_NT_WORKSTATION, "Windows 8.1"), + (6, 3, 0, "Windows Server 2012 R2"), + (6, 2, VER_NT_WORKSTATION, "Windows 8"), + (6, 2, 0, "Windows Server 2012"), + (6, 1, VER_NT_WORKSTATION, "Windows 7"), + (6, 1, 0, "Windows Server 2008 R2"), + (6, 0, VER_NT_WORKSTATION, "Windows Vista"), + (6, 0, 0, "Windows Server 2008"), + (5, 1, 0, "Windows XP"), + (5, 1, 1, "Windows XP"), + (5, 1, 100, "Windows XP"), + (5, 0, 0, "Windows 2000"), + (5, 0, 1, "Windows 2000"), + (5, 0, 100, "Windows 2000"), + ]; + + let mut info = version_info().unwrap(); + + for &(major, minor, product_type, expected_edition) in &test_data { + info.dwMajorVersion = major; + info.dwMinorVersion = minor; + info.wProductType = product_type; + + let edition = edition(&info).unwrap(); + assert_eq!(edition, expected_edition); + } + } + + #[test] + fn get_bitness() { + let b = bitness(); + assert_ne!(b, Bitness::Unknown); + } + + #[test] + #[should_panic(expected = "Empty module name")] + fn empty_module_name() { + get_proc_address(b"", b"RtlGetVersion\0"); + } + + #[test] + #[should_panic(expected = "Module name should be zero-terminated")] + fn non_zero_terminated_module_name() { + get_proc_address(b"ntdll", b"RtlGetVersion\0"); + } + + #[test] + #[should_panic(expected = "Empty procedure name")] + fn empty_proc_name() { + get_proc_address(b"ntdll\0", b""); + } + + #[test] + #[should_panic(expected = "Procedure name should be zero-terminated")] + fn non_zero_terminated_proc_name() { + get_proc_address(b"ntdll\0", b"RtlGetVersion"); + } + + #[test] + fn proc_address() { + let address = get_proc_address(b"ntdll\0", b"RtlGetVersion\0"); + assert!(address.is_some()); + } + + #[test] + fn get_product_name() { + let edition = product_name().expect("edition() failed"); + assert!(!edition.is_empty()); + } + + #[test] + fn to_wide_str() { + let data = [ + ("", [0x0000].as_ref()), + ("U", &[0x0055, 0x0000]), + ("你好", &[0x4F60, 0x597D, 0x0000]), + ]; + + for (s, expected) in &data { + let wide = to_wide(s); + assert_eq!(&wide, expected); + } + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/tests/basic.rs cargo-0.58.0/vendor/os_info/tests/basic.rs --- cargo-0.57.0+ubuntu/vendor/os_info/tests/basic.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/tests/basic.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,4 @@ +#[test] +fn get() { + let _ = os_info::get(); +} diff -Nru cargo-0.57.0+ubuntu/vendor/os_info/tests/md_doc.rs cargo-0.58.0/vendor/os_info/tests/md_doc.rs --- cargo-0.57.0+ubuntu/vendor/os_info/tests/md_doc.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/os_info/tests/md_doc.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,3 @@ +// spell-checker:ignore doctest + +doc_comment::doctest!("../README.md"); diff -Nru cargo-0.57.0+ubuntu/vendor/pkg-config/.cargo-checksum.json cargo-0.58.0/vendor/pkg-config/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/pkg-config/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/pkg-config/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"10e2fcbb64ecbe64c8e040a386c3104d384583af58b956d870aaaf229df6e66d"} \ No newline at end of file +{"files":{},"package":"58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/pkg-config/Cargo.toml cargo-0.58.0/vendor/pkg-config/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/pkg-config/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/pkg-config/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -11,7 +11,7 @@ [package] name = "pkg-config" -version = "0.3.21" +version = "0.3.24" authors = ["Alex Crichton "] description = "A library to run the pkg-config system tool at build time in order to be used in\nCargo build scripts.\n" documentation = "https://docs.rs/pkg-config" diff -Nru cargo-0.57.0+ubuntu/vendor/pkg-config/CHANGELOG.md cargo-0.58.0/vendor/pkg-config/CHANGELOG.md --- cargo-0.57.0+ubuntu/vendor/pkg-config/CHANGELOG.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/pkg-config/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 @@ -5,6 +5,30 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.3.24] - 2021-12-11 + +### Fixed + +- Re-add `target_supported()`, which was accidentally removed in 0.3.15 (#128). + +## [0.3.23] - 2021-12-06 + +### Changed + +- Improve error messages when a `pkg-config` package can't be found (#127). + +## [0.3.22] - 2021-10-24 + +### Fixed + +- `pkg-config` compiles again with Rust 1.30 or newer. 0.3.21 accidentally + made use of API only available since 1.40 (#124, #125). + +### Changed + +- Switched from Travis to GitHub Actions for the CI. Travis is dysfunctional + since quite some time (#126). + ## [0.3.21] - 2021-10-22 ### Fixed diff -Nru cargo-0.57.0+ubuntu/vendor/pkg-config/README.md cargo-0.58.0/vendor/pkg-config/README.md --- cargo-0.57.0+ubuntu/vendor/pkg-config/README.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/pkg-config/README.md 2022-01-21 02:47:39.000000000 +0000 @@ -1,6 +1,6 @@ # pkg-config-rs -[![Build Status](https://travis-ci.com/rust-lang/pkg-config-rs.svg?branch=master)](https://travis-ci.com/rust-lang/pkg-config-rs) +[![Build Status](https://github.com/rust-lang/pkg-config-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/rust-lang/pkg-config-rs/actions) [![Rust](https://img.shields.io/badge/rust-1.30%2B-blue.svg?maxAge=3600)](https://github.com/rust-lang/pkg-config-rs/) [Documentation](https://docs.rs/pkg-config) @@ -10,7 +10,7 @@ library is located. You can use this crate directly to probe for specific libraries, or use -[metadeps](https://github.com/joshtriplett/metadeps) to declare all your +[system-deps](https://github.com/gdesmott/system-deps) to declare all your `pkg-config` dependencies in `Cargo.toml`. This library requires Rust 1.30+. diff -Nru cargo-0.57.0+ubuntu/vendor/pkg-config/src/lib.rs cargo-0.58.0/vendor/pkg-config/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/pkg-config/src/lib.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/pkg-config/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -112,11 +112,20 @@ /// Contains the command and the cause. Command { command: String, cause: io::Error }, - /// `pkg-config` did not exit sucessfully. + /// `pkg-config` did not exit sucessfully after probing a library. /// /// Contains the command and output. Failure { command: String, output: Output }, + /// `pkg-config` did not exit sucessfully on the first attempt to probe a library. + /// + /// Contains the command and output. + ProbeFailure { + name: String, + command: String, + output: Output, + }, + #[doc(hidden)] // please don't match on this, we're likely to add more variants over time __Nonexhaustive, @@ -141,8 +150,8 @@ } => { match cause.kind() { io::ErrorKind::NotFound => { - let crate_name = std::env::var("CARGO_PKG_NAME"); - let crate_name = crate_name.as_deref().unwrap_or("sys"); + let crate_name = + std::env::var("CARGO_PKG_NAME").unwrap_or_else(|_| "sys".to_owned()); let instructions = if cfg!(target_os = "macos") || cfg!(target_os = "ios") { "Try `brew install pkg-config` if you have Homebrew.\n" } else if cfg!(unix) { @@ -168,30 +177,46 @@ _ => write!(f, "Failed to run command `{}`, because: {}", command, cause), } } + Error::ProbeFailure { + ref name, + ref command, + ref output, + } => { + write!( + f, + "`{}` did not exit successfully: {}\nerror: could not find system library '{}' required by the '{}' crate\n", + command, output.status, name, env::var("CARGO_PKG_NAME").unwrap_or_default(), + )?; + format_output(output, f) + } Error::Failure { ref command, ref output, } => { - let stdout = str::from_utf8(&output.stdout).unwrap(); - let stderr = str::from_utf8(&output.stderr).unwrap(); write!( f, "`{}` did not exit successfully: {}", command, output.status )?; - if !stdout.is_empty() { - write!(f, "\n--- stdout\n{}", stdout)?; - } - if !stderr.is_empty() { - write!(f, "\n--- stderr\n{}", stderr)?; - } - Ok(()) + format_output(output, f) } Error::CrossCompilation | Error::__Nonexhaustive => panic!(), } } } +fn format_output(output: &Output, f: &mut fmt::Formatter) -> fmt::Result { + let stdout = String::from_utf8_lossy(&output.stdout); + if !stdout.is_empty() { + write!(f, "\n--- stdout\n{}", stdout)?; + } + let stderr = String::from_utf8_lossy(&output.stderr); + if !stderr.is_empty() { + write!(f, "\n--- stderr\n{}", stderr)?; + } + Ok(()) +} + /// Deprecated in favor of the probe_library function #[doc(hidden)] pub fn find_library(name: &str) -> Result { @@ -203,6 +228,12 @@ Config::new().probe(name) } +#[doc(hidden)] +#[deprecated(note = "use config.target_supported() instance method instead")] +pub fn target_supported() -> bool { + Config::new().target_supported() +} + /// Run `pkg-config` to get the value of a variable from a package using /// `--variable`. /// @@ -335,7 +366,14 @@ let mut library = Library::new(); - let output = run(self.command(name, &["--libs", "--cflags"]))?; + let output = run(self.command(name, &["--libs", "--cflags"])).map_err(|e| match e { + Error::Failure { command, output } => Error::ProbeFailure { + name: name.to_owned(), + command, + output, + }, + other => other, + })?; library.parse_libs_cflags(name, &output, self); let output = run(self.command(name, &["--modversion"]))?; @@ -344,6 +382,7 @@ Ok(library) } + /// True if pkg-config is used for the host system, or configured for cross-compilation pub fn target_supported(&self) -> bool { let target = env::var_os("TARGET").unwrap_or_default(); let host = env::var_os("HOST").unwrap_or_default(); diff -Nru cargo-0.57.0+ubuntu/vendor/ppv-lite86/.cargo-checksum.json cargo-0.58.0/vendor/ppv-lite86/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/ppv-lite86/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ppv-lite86/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"c3ca011bd0129ff4ae15cd04c4eef202cadf6c51c21e47aba319b4e0501db741"} \ No newline at end of file +{"files":{},"package":"eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/ppv-lite86/Cargo.toml cargo-0.58.0/vendor/ppv-lite86/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/ppv-lite86/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ppv-lite86/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -12,7 +12,7 @@ [package] edition = "2018" name = "ppv-lite86" -version = "0.2.14" +version = "0.2.16" authors = ["The CryptoCorrosion Contributors"] description = "Implementation of the crypto-simd API for x86" keywords = ["crypto", "simd", "x86"] diff -Nru cargo-0.57.0+ubuntu/vendor/ppv-lite86/CHANGELOG.md cargo-0.58.0/vendor/ppv-lite86/CHANGELOG.md --- cargo-0.57.0+ubuntu/vendor/ppv-lite86/CHANGELOG.md 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/ppv-lite86/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,10 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.2.16] +### Added +- add [u64; 4] conversion for generic vec256, to support BLAKE on non-x86. +- impl `From` (rather than just `Into`) for conversions between `*_storage` types and arrays. diff -Nru cargo-0.57.0+ubuntu/vendor/ppv-lite86/src/generic.rs cargo-0.58.0/vendor/ppv-lite86/src/generic.rs --- cargo-0.57.0+ubuntu/vendor/ppv-lite86/src/generic.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ppv-lite86/src/generic.rs 2022-01-21 02:47:39.000000000 +0000 @@ -69,6 +69,14 @@ [a, b, c, d] } } +impl From<[u64; 4]> for vec256_storage { + #[inline(always)] + fn from([a, b, c, d]: [u64; 4]) -> Self { + Self { + v128: [[a, b].into(), [c, d].into()], + } + } +} #[derive(Clone, Copy, PartialEq, Eq, Default)] pub struct vec512_storage { v128: [vec128_storage; 4], @@ -624,10 +632,10 @@ let c = c.0; let d = d.0; [ - a[0], a[1], a[2], a[3], - b[0], b[1], b[2], b[3], - c[0], c[1], c[2], c[3], - d[0], d[1], d[2], d[3], + a[0], a[1], a[2], a[3], // + b[0], b[1], b[2], b[3], // + c[0], c[1], c[2], c[3], // + d[0], d[1], d[2], d[3], // ] } } diff -Nru cargo-0.57.0+ubuntu/vendor/ppv-lite86/src/soft.rs cargo-0.58.0/vendor/ppv-lite86/src/soft.rs --- cargo-0.57.0+ubuntu/vendor/ppv-lite86/src/soft.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ppv-lite86/src/soft.rs 2022-01-21 02:47:39.000000000 +0000 @@ -175,26 +175,50 @@ impl StoreBytes for x2 { #[inline(always)] unsafe fn unsafe_read_le(input: &[u8]) -> Self { - let input = input.split_at(16); + let input = input.split_at(input.len() / 2); x2::new([W::unsafe_read_le(input.0), W::unsafe_read_le(input.1)]) } #[inline(always)] unsafe fn unsafe_read_be(input: &[u8]) -> Self { - x2::unsafe_read_le(input).bswap() + let input = input.split_at(input.len() / 2); + x2::new([W::unsafe_read_be(input.0), W::unsafe_read_be(input.1)]) } #[inline(always)] fn write_le(self, out: &mut [u8]) { - let out = out.split_at_mut(16); + let out = out.split_at_mut(out.len() / 2); self.0[0].write_le(out.0); self.0[1].write_le(out.1); } #[inline(always)] fn write_be(self, out: &mut [u8]) { - let out = out.split_at_mut(16); + let out = out.split_at_mut(out.len() / 2); self.0[0].write_be(out.0); self.0[1].write_be(out.1); } } +impl LaneWords4 for x2 { + #[inline(always)] + fn shuffle_lane_words2301(self) -> Self { + Self::new([ + self.0[0].shuffle_lane_words2301(), + self.0[1].shuffle_lane_words2301(), + ]) + } + #[inline(always)] + fn shuffle_lane_words1230(self) -> Self { + Self::new([ + self.0[0].shuffle_lane_words1230(), + self.0[1].shuffle_lane_words1230(), + ]) + } + #[inline(always)] + fn shuffle_lane_words3012(self) -> Self { + Self::new([ + self.0[0].shuffle_lane_words3012(), + self.0[1].shuffle_lane_words3012(), + ]) + } +} #[derive(Copy, Clone, Default)] #[allow(non_camel_case_types)] @@ -312,12 +336,15 @@ } impl Vec4Ext for x4 { #[inline(always)] - fn transpose4(a: Self, b: Self, c: Self, d: Self) -> (Self, Self, Self, Self) where Self: Sized { + fn transpose4(a: Self, b: Self, c: Self, d: Self) -> (Self, Self, Self, Self) + where + Self: Sized, + { ( x4([a.0[0], b.0[0], c.0[0], d.0[0]]), x4([a.0[1], b.0[1], c.0[1], d.0[1]]), x4([a.0[2], b.0[2], c.0[2], d.0[2]]), - x4([a.0[3], b.0[3], c.0[3], d.0[3]]) + x4([a.0[3], b.0[3], c.0[3], d.0[3]]), ) } } @@ -379,30 +406,39 @@ impl StoreBytes for x4 { #[inline(always)] unsafe fn unsafe_read_le(input: &[u8]) -> Self { + let n = input.len() / 4; x4([ - W::unsafe_read_le(&input[0..16]), - W::unsafe_read_le(&input[16..32]), - W::unsafe_read_le(&input[32..48]), - W::unsafe_read_le(&input[48..64]), + W::unsafe_read_le(&input[..n]), + W::unsafe_read_le(&input[n..n * 2]), + W::unsafe_read_le(&input[n * 2..n * 3]), + W::unsafe_read_le(&input[n * 3..]), ]) } #[inline(always)] unsafe fn unsafe_read_be(input: &[u8]) -> Self { - x4::unsafe_read_le(input).bswap() + let n = input.len() / 4; + x4([ + W::unsafe_read_be(&input[..n]), + W::unsafe_read_be(&input[n..n * 2]), + W::unsafe_read_be(&input[n * 2..n * 3]), + W::unsafe_read_be(&input[n * 3..]), + ]) } #[inline(always)] fn write_le(self, out: &mut [u8]) { - self.0[0].write_le(&mut out[0..16]); - self.0[1].write_le(&mut out[16..32]); - self.0[2].write_le(&mut out[32..48]); - self.0[3].write_le(&mut out[48..64]); + let n = out.len() / 4; + self.0[0].write_le(&mut out[..n]); + self.0[1].write_le(&mut out[n..n * 2]); + self.0[2].write_le(&mut out[n * 2..n * 3]); + self.0[3].write_le(&mut out[n * 3..]); } #[inline(always)] fn write_be(self, out: &mut [u8]) { - self.0[0].write_be(&mut out[0..16]); - self.0[1].write_be(&mut out[16..32]); - self.0[2].write_be(&mut out[32..48]); - self.0[3].write_be(&mut out[48..64]); + let n = out.len() / 4; + self.0[0].write_be(&mut out[..n]); + self.0[1].write_be(&mut out[n..n * 2]); + self.0[2].write_be(&mut out[n * 2..n * 3]); + self.0[3].write_be(&mut out[n * 3..]); } } impl LaneWords4 for x4 { diff -Nru cargo-0.57.0+ubuntu/vendor/ppv-lite86/src/types.rs cargo-0.58.0/vendor/ppv-lite86/src/types.rs --- cargo-0.57.0+ubuntu/vendor/ppv-lite86/src/types.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ppv-lite86/src/types.rs 2022-01-21 02:47:39.000000000 +0000 @@ -75,7 +75,9 @@ /// NOTE: functions in this trait may be moved to Vec4 in any patch release. To avoid breakage, /// import Vec4Ext only together with Vec4, and don't qualify its methods. pub trait Vec4Ext { - fn transpose4(a: Self, b: Self, c: Self, d: Self) -> (Self, Self, Self, Self) where Self: Sized; + fn transpose4(a: Self, b: Self, c: Self, d: Self) -> (Self, Self, Self, Self) + where + Self: Sized; } pub trait Vector { fn to_scalars(self) -> T; @@ -121,12 +123,7 @@ { } pub trait u64x2: - BitOps64 - + Store - + ArithOps - + Vec2 - + MultiLane<[u64; 2]> - + Into + BitOps64 + Store + ArithOps + Vec2 + MultiLane<[u64; 2]> + Into { } pub trait u128x1: @@ -141,6 +138,7 @@ + MultiLane<[M::u32x4; 2]> + ArithOps + Into + + StoreBytes { } pub trait u64x2x2: @@ -184,6 +182,7 @@ + ArithOps + LaneWords4 + Into + + StoreBytes { } pub trait u64x2x4: diff -Nru cargo-0.57.0+ubuntu/vendor/ppv-lite86/src/x86_64/mod.rs cargo-0.58.0/vendor/ppv-lite86/src/x86_64/mod.rs --- cargo-0.57.0+ubuntu/vendor/ppv-lite86/src/x86_64/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ppv-lite86/src/x86_64/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -79,7 +79,7 @@ type u64x2 = sse2::u64x2_sse2; type u128x1 = sse2::u128x1_sse2; - type u32x4x2 = sse2::u32x4x2_sse2; + type u32x4x2 = sse2::avx2::u32x4x2_avx2; type u64x2x2 = sse2::u64x2x2_sse2; type u64x4 = sse2::u64x4_sse2; type u128x2 = sse2::u128x2_sse2; @@ -119,16 +119,16 @@ p } } -impl<'a> Into<&'a [u32; 4]> for &'a vec128_storage { +impl<'a> From<&'a vec128_storage> for &'a [u32; 4] { #[inline(always)] - fn into(self) -> &'a [u32; 4] { - unsafe { &self.u32x4 } + fn from(x: &'a vec128_storage) -> Self { + unsafe { &x.u32x4 } } } -impl Into for [u32; 4] { +impl From<[u32; 4]> for vec128_storage { #[inline(always)] - fn into(self) -> vec128_storage { - vec128_storage { u32x4: self } + fn from(u32x4: [u32; 4]) -> Self { + vec128_storage { u32x4 } } } impl Default for vec128_storage { @@ -154,10 +154,10 @@ sse2: [vec128_storage; 2], avx: __m256i, } -impl Into for [u64; 4] { +impl From<[u64; 4]> for vec256_storage { #[inline(always)] - fn into(self) -> vec256_storage { - vec256_storage { u64x4: self } + fn from(u64x4: [u64; 4]) -> Self { + vec256_storage { u64x4 } } } impl Default for vec256_storage { @@ -221,10 +221,10 @@ macro_rules! impl_into { ($storage:ident, $array:ty, $name:ident) => { - impl Into<$array> for $storage { + impl From<$storage> for $array { #[inline(always)] - fn into(self) -> $array { - unsafe { self.$name } + fn from(vec: $storage) -> Self { + unsafe { vec.$name } } } }; diff -Nru cargo-0.57.0+ubuntu/vendor/ppv-lite86/src/x86_64/sse2.rs cargo-0.58.0/vendor/ppv-lite86/src/x86_64/sse2.rs --- cargo-0.57.0+ubuntu/vendor/ppv-lite86/src/x86_64/sse2.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/ppv-lite86/src/x86_64/sse2.rs 2022-01-21 02:47:39.000000000 +0000 @@ -189,21 +189,21 @@ rotr_32!(rotate_each_word_right7, 7); rotr_32_s3!( rotate_each_word_right8, - 0x0c0f0e0d_080b0a09, - 0x04070605_00030201 + 0x0c0f_0e0d_080b_0a09, + 0x0407_0605_0003_0201 ); rotr_32!(rotate_each_word_right11, 11); rotr_32!(rotate_each_word_right12, 12); rotr_32_s3!( rotate_each_word_right16, - 0x0d0c0f0e_09080b0a, - 0x05040706_01000302 + 0x0d0c_0f0e_0908_0b0a, + 0x0504_0706_0100_0302 ); rotr_32!(rotate_each_word_right20, 20); rotr_32_s3!( rotate_each_word_right24, - 0x0e0d0c0f_0a09080b, - 0x06050407_02010003 + 0x0e0d_0c0f_0a09_080b, + 0x0605_0407_0201_0003 ); rotr_32!(rotate_each_word_right25, 25); } @@ -883,9 +883,7 @@ impl Vector<[u32; 16]> for u32x4x4_sse2 { #[inline(always)] fn to_scalars(self) -> [u32; 16] { - unsafe { - core::mem::transmute(self) - } + unsafe { core::mem::transmute(self) } } } @@ -1015,16 +1013,6 @@ { } -impl u32x4x4> for u32x4x4_sse2 -where - u32x4_sse2: RotateEachWord32 + BSwap, - Avx2Machine: Machine, - u32x4x4_sse2: MultiLane<[ as Machine>::u32x4; 4]>, - u32x4x4_sse2: Vec4< as Machine>::u32x4>, - u32x4x4_sse2: Vec4Ext< as Machine>::u32x4>, - u32x4x4_sse2: Vector<[u32; 16]>, -{ -} impl u64x2x4> for u64x2x4_sse2 where u64x2_sse2: RotateEachWord64 + RotateEachWord32 + BSwap, @@ -1387,65 +1375,78 @@ pub mod avx2 { #![allow(non_camel_case_types)] - use crate::soft::x4; + use crate::soft::{x2, x4}; use crate::types::*; - use crate::x86_64::sse2::{u128x1_sse2, u32x4_sse2}; + use crate::x86_64::sse2::{u128x1_sse2, u32x4_sse2, G0}; use crate::x86_64::{vec256_storage, vec512_storage, Avx2Machine, YesS3, YesS4}; use core::arch::x86_64::*; use core::marker::PhantomData; use core::ops::*; #[derive(Copy, Clone)] - pub struct u32x4x4_avx2 { - x: [__m256i; 2], + pub struct u32x4x2_avx2 { + x: __m256i, ni: PhantomData, } - impl u32x4x4_avx2 { + impl u32x4x2_avx2 { #[inline(always)] - fn new(x: [__m256i; 2]) -> Self { + fn new(x: __m256i) -> Self { Self { x, ni: PhantomData } } } - impl u32x4x4> for u32x4x4_avx2 where NI: Copy {} - impl Store for u32x4x4_avx2 { + impl u32x4x2> for u32x4x2_avx2 where NI: Copy {} + impl Store for u32x4x2_avx2 { #[inline(always)] - unsafe fn unpack(p: vec512_storage) -> Self { - Self::new([p.avx[0].avx, p.avx[1].avx]) + unsafe fn unpack(p: vec256_storage) -> Self { + Self::new(p.avx) } } - impl MultiLane<[u32x4_sse2; 4]> for u32x4x4_avx2 { + impl StoreBytes for u32x4x2_avx2 { #[inline(always)] - fn to_lanes(self) -> [u32x4_sse2; 4] { + unsafe fn unsafe_read_le(input: &[u8]) -> Self { + assert_eq!(input.len(), 32); + Self::new(_mm256_loadu_si256(input.as_ptr() as *const _)) + } + #[inline(always)] + unsafe fn unsafe_read_be(input: &[u8]) -> Self { + Self::unsafe_read_le(input).bswap() + } + #[inline(always)] + fn write_le(self, out: &mut [u8]) { unsafe { - [ - u32x4_sse2::new(_mm256_extracti128_si256(self.x[0], 0)), - u32x4_sse2::new(_mm256_extracti128_si256(self.x[0], 1)), - u32x4_sse2::new(_mm256_extracti128_si256(self.x[1], 0)), - u32x4_sse2::new(_mm256_extracti128_si256(self.x[1], 1)), - ] + assert_eq!(out.len(), 32); + _mm256_storeu_si256(out.as_mut_ptr() as *mut _, self.x) } } #[inline(always)] - fn from_lanes(x: [u32x4_sse2; 4]) -> Self { - Self::new(unsafe { + fn write_be(self, out: &mut [u8]) { + self.bswap().write_le(out) + } + } + impl MultiLane<[u32x4_sse2; 2]> for u32x4x2_avx2 { + #[inline(always)] + fn to_lanes(self) -> [u32x4_sse2; 2] { + unsafe { [ - _mm256_setr_m128i(x[0].x, x[1].x), - _mm256_setr_m128i(x[2].x, x[3].x), + u32x4_sse2::new(_mm256_extracti128_si256(self.x, 0)), + u32x4_sse2::new(_mm256_extracti128_si256(self.x, 1)), ] - }) + } + } + #[inline(always)] + fn from_lanes(x: [u32x4_sse2; 2]) -> Self { + Self::new(unsafe { _mm256_setr_m128i(x[0].x, x[1].x) }) } } - impl Vec4> for u32x4x4_avx2 { + impl Vec2> for u32x4x2_avx2 { #[inline(always)] fn extract(self, i: u32) -> u32x4_sse2 { unsafe { match i { - 0 => u32x4_sse2::new(_mm256_extracti128_si256(self.x[0], 0)), - 1 => u32x4_sse2::new(_mm256_extracti128_si256(self.x[0], 1)), - 2 => u32x4_sse2::new(_mm256_extracti128_si256(self.x[1], 0)), - 3 => u32x4_sse2::new(_mm256_extracti128_si256(self.x[1], 1)), + 0 => u32x4_sse2::new(_mm256_extracti128_si256(self.x, 0)), + 1 => u32x4_sse2::new(_mm256_extracti128_si256(self.x, 1)), _ => panic!(), } } @@ -1454,95 +1455,21 @@ fn insert(self, w: u32x4_sse2, i: u32) -> Self { Self::new(unsafe { match i { - 0 => [_mm256_inserti128_si256(self.x[0], w.x, 0), self.x[1]], - 1 => [_mm256_inserti128_si256(self.x[0], w.x, 1), self.x[1]], - 2 => [self.x[0], _mm256_inserti128_si256(self.x[1], w.x, 0)], - 3 => [self.x[0], _mm256_inserti128_si256(self.x[1], w.x, 1)], + 0 => _mm256_inserti128_si256(self.x, w.x, 0), + 1 => _mm256_inserti128_si256(self.x, w.x, 1), _ => panic!(), } }) } } - impl Vec4Ext> for u32x4x4_avx2 { - #[inline(always)] - fn transpose4(a: Self, b: Self, c: Self, d: Self) -> (Self, Self, Self, Self) { - /* - * a00:a01 a10:a11 - * b00:b01 b10:b11 - * c00:c01 c10:c11 - * d00:d01 d10:d11 - * => - * a00:b00 c00:d00 - * a01:b01 c01:d01 - * a10:b10 c10:d10 - * a11:b11 c11:d11 - */ - unsafe { - let ab00 = _mm256_permute2x128_si256(a.x[0], b.x[0], 0x20); - let ab01 = _mm256_permute2x128_si256(a.x[0], b.x[0], 0x31); - let ab10 = _mm256_permute2x128_si256(a.x[1], b.x[1], 0x20); - let ab11 = _mm256_permute2x128_si256(a.x[1], b.x[1], 0x31); - let cd00 = _mm256_permute2x128_si256(c.x[0], d.x[0], 0x20); - let cd01 = _mm256_permute2x128_si256(c.x[0], d.x[0], 0x31); - let cd10 = _mm256_permute2x128_si256(c.x[1], d.x[1], 0x20); - let cd11 = _mm256_permute2x128_si256(c.x[1], d.x[1], 0x31); - ( - Self { x: [ab00, cd00], ni: a.ni }, - Self { x: [ab01, cd01], ni: a.ni }, - Self { x: [ab10, cd10], ni: a.ni }, - Self { x: [ab11, cd11], ni: a.ni }, - ) - } - } - } - impl Vector<[u32; 16]> for u32x4x4_avx2 { - #[inline(always)] - fn to_scalars(self) -> [u32; 16] { - unsafe { - core::mem::transmute(self) - } - } - } - impl LaneWords4 for u32x4x4_avx2 { - #[inline(always)] - fn shuffle_lane_words1230(self) -> Self { - Self::new(unsafe { - [ - _mm256_shuffle_epi32(self.x[0], 0b1001_0011), - _mm256_shuffle_epi32(self.x[1], 0b1001_0011), - ] - }) - } - #[inline(always)] - fn shuffle_lane_words2301(self) -> Self { - Self::new(unsafe { - [ - _mm256_shuffle_epi32(self.x[0], 0b0100_1110), - _mm256_shuffle_epi32(self.x[1], 0b0100_1110), - ] - }) - } - #[inline(always)] - fn shuffle_lane_words3012(self) -> Self { - Self::new(unsafe { - [ - _mm256_shuffle_epi32(self.x[0], 0b0011_1001), - _mm256_shuffle_epi32(self.x[1], 0b0011_1001), - ] - }) - } - } - impl BitOps32 for u32x4x4_avx2 where NI: Copy {} - impl ArithOps for u32x4x4_avx2 where NI: Copy {} + impl BitOps32 for u32x4x2_avx2 where NI: Copy {} + impl ArithOps for u32x4x2_avx2 where NI: Copy {} macro_rules! shuf_lane_bytes { ($name:ident, $k0:expr, $k1:expr) => { #[inline(always)] fn $name(self) -> Self { Self::new(unsafe { - [ - _mm256_shuffle_epi8(self.x[0], _mm256_set_epi64x($k0, $k1, $k0, $k1)), - _mm256_shuffle_epi8(self.x[1], _mm256_set_epi64x($k0, $k1, $k0, $k1)), - ] + _mm256_shuffle_epi8(self.x, _mm256_set_epi64x($k0, $k1, $k0, $k1)) }) } }; @@ -1552,52 +1479,41 @@ #[inline(always)] fn $name(self) -> Self { Self::new(unsafe { - [ - _mm256_or_si256( - _mm256_srli_epi32(self.x[0], $i as i32), - _mm256_slli_epi32(self.x[0], 32 - $i as i32), - ), - _mm256_or_si256( - _mm256_srli_epi32(self.x[1], $i as i32), - _mm256_slli_epi32(self.x[1], 32 - $i as i32), - ), - ] + _mm256_or_si256( + _mm256_srli_epi32(self.x, $i as i32), + _mm256_slli_epi32(self.x, 32 - $i as i32), + ) }) } }; } - impl RotateEachWord32 for u32x4x4_avx2 { + impl RotateEachWord32 for u32x4x2_avx2 { rotr_32!(rotate_each_word_right7, 7); shuf_lane_bytes!( rotate_each_word_right8, - 0x0c0f0e0d_080b0a09, - 0x04070605_00030201 + 0x0c0f_0e0d_080b_0a09, + 0x0407_0605_0003_0201 ); rotr_32!(rotate_each_word_right11, 11); rotr_32!(rotate_each_word_right12, 12); shuf_lane_bytes!( rotate_each_word_right16, - 0x0d0c0f0e_09080b0a, - 0x05040706_01000302 + 0x0d0c_0f0e_0908_0b0a, + 0x0504_0706_0100_0302 ); rotr_32!(rotate_each_word_right20, 20); shuf_lane_bytes!( rotate_each_word_right24, - 0x0e0d0c0f_0a09080b, - 0x06050407_02010003 + 0x0e0d_0c0f_0a09_080b, + 0x0605_0407_0201_0003 ); rotr_32!(rotate_each_word_right25, 25); } - impl BitOps0 for u32x4x4_avx2 where NI: Copy {} - impl From> for vec512_storage { + impl BitOps0 for u32x4x2_avx2 where NI: Copy {} + impl From> for vec256_storage { #[inline(always)] - fn from(x: u32x4x4_avx2) -> Self { - Self { - avx: [ - vec256_storage { avx: x.x[0] }, - vec256_storage { avx: x.x[1] }, - ], - } + fn from(x: u32x4x2_avx2) -> Self { + Self { avx: x.x } } } @@ -1614,55 +1530,172 @@ } }; } - impl_assign!(u32x4x4_avx2, BitXorAssign, bitxor_assign, bitxor); - impl_assign!(u32x4x4_avx2, BitOrAssign, bitor_assign, bitor); - impl_assign!(u32x4x4_avx2, BitAndAssign, bitand_assign, bitand); - impl_assign!(u32x4x4_avx2, AddAssign, add_assign, add); + impl_assign!(u32x4x2_avx2, BitXorAssign, bitxor_assign, bitxor); + impl_assign!(u32x4x2_avx2, BitOrAssign, bitor_assign, bitor); + impl_assign!(u32x4x2_avx2, BitAndAssign, bitand_assign, bitand); + impl_assign!(u32x4x2_avx2, AddAssign, add_assign, add); - macro_rules! impl_bitop_x2 { + macro_rules! impl_bitop { ($vec:ident, $Op:ident, $op_fn:ident, $impl_fn:ident) => { impl $Op for $vec { type Output = Self; #[inline(always)] fn $op_fn(self, rhs: Self) -> Self::Output { - Self::new(unsafe { - [$impl_fn(self.x[0], rhs.x[0]), $impl_fn(self.x[1], rhs.x[1])] - }) + Self::new(unsafe { $impl_fn(self.x, rhs.x) }) } } }; } - impl_bitop_x2!(u32x4x4_avx2, BitXor, bitxor, _mm256_xor_si256); - impl_bitop_x2!(u32x4x4_avx2, BitOr, bitor, _mm256_or_si256); - impl_bitop_x2!(u32x4x4_avx2, BitAnd, bitand, _mm256_and_si256); - impl_bitop_x2!(u32x4x4_avx2, AndNot, andnot, _mm256_andnot_si256); - impl_bitop_x2!(u32x4x4_avx2, Add, add, _mm256_add_epi32); + impl_bitop!(u32x4x2_avx2, BitXor, bitxor, _mm256_xor_si256); + impl_bitop!(u32x4x2_avx2, BitOr, bitor, _mm256_or_si256); + impl_bitop!(u32x4x2_avx2, BitAnd, bitand, _mm256_and_si256); + impl_bitop!(u32x4x2_avx2, AndNot, andnot, _mm256_andnot_si256); + impl_bitop!(u32x4x2_avx2, Add, add, _mm256_add_epi32); - impl Not for u32x4x4_avx2 { + impl Not for u32x4x2_avx2 { type Output = Self; #[inline(always)] fn not(self) -> Self::Output { unsafe { let f = _mm256_set1_epi8(-0x7f); - Self::new([f, f]) ^ self + Self::new(f) ^ self } } } - impl BSwap for u32x4x4_avx2 { + impl BSwap for u32x4x2_avx2 { shuf_lane_bytes!(bswap, 0x0c0d_0e0f_0809_0a0b, 0x0405_0607_0001_0203); } - impl From>> for u32x4x4_avx2 + impl From, G0>> for u32x4x2_avx2 where NI: Copy, { #[inline(always)] + fn from(x: x2, G0>) -> Self { + Self::new(unsafe { _mm256_setr_m128i(x.0[0].x, x.0[1].x) }) + } + } + + impl LaneWords4 for u32x4x2_avx2 { + #[inline(always)] + fn shuffle_lane_words1230(self) -> Self { + Self::new(unsafe { _mm256_shuffle_epi32(self.x, 0b1001_0011) }) + } + #[inline(always)] + fn shuffle_lane_words2301(self) -> Self { + Self::new(unsafe { _mm256_shuffle_epi32(self.x, 0b0100_1110) }) + } + #[inline(always)] + fn shuffle_lane_words3012(self) -> Self { + Self::new(unsafe { _mm256_shuffle_epi32(self.x, 0b0011_1001) }) + } + } + + /////////////////////////////////////////////////////////////////////////////////////////// + + pub type u32x4x4_avx2 = x2, G0>; + impl u32x4x4> for u32x4x4_avx2 {} + + impl Store for u32x4x4_avx2 { + #[inline(always)] + unsafe fn unpack(p: vec512_storage) -> Self { + Self::new([ + u32x4x2_avx2::unpack(p.avx[0]), + u32x4x2_avx2::unpack(p.avx[1]), + ]) + } + } + impl MultiLane<[u32x4_sse2; 4]> for u32x4x4_avx2 { + #[inline(always)] + fn to_lanes(self) -> [u32x4_sse2; 4] { + let [a, b] = self.0[0].to_lanes(); + let [c, d] = self.0[1].to_lanes(); + [a, b, c, d] + } + #[inline(always)] + fn from_lanes(x: [u32x4_sse2; 4]) -> Self { + let ab = u32x4x2_avx2::from_lanes([x[0], x[1]]); + let cd = u32x4x2_avx2::from_lanes([x[2], x[3]]); + Self::new([ab, cd]) + } + } + impl Vec4> for u32x4x4_avx2 { + #[inline(always)] + fn extract(self, i: u32) -> u32x4_sse2 { + match i { + 0 => self.0[0].extract(0), + 1 => self.0[0].extract(1), + 2 => self.0[1].extract(0), + 3 => self.0[1].extract(1), + _ => panic!(), + } + } + #[inline(always)] + fn insert(self, w: u32x4_sse2, i: u32) -> Self { + Self::new(match i { + 0 | 1 => [self.0[0].insert(w, i), self.0[1]], + 2 | 3 => [self.0[0], self.0[1].insert(w, i - 2)], + _ => panic!(), + }) + } + } + impl Vec4Ext> for u32x4x4_avx2 { + #[inline(always)] + fn transpose4(a: Self, b: Self, c: Self, d: Self) -> (Self, Self, Self, Self) { + /* + * a00:a01 a10:a11 + * b00:b01 b10:b11 + * c00:c01 c10:c11 + * d00:d01 d10:d11 + * => + * a00:b00 c00:d00 + * a01:b01 c01:d01 + * a10:b10 c10:d10 + * a11:b11 c11:d11 + */ + unsafe { + let ab00 = u32x4x2_avx2::new(_mm256_permute2x128_si256(a.0[0].x, b.0[0].x, 0x20)); + let ab01 = u32x4x2_avx2::new(_mm256_permute2x128_si256(a.0[0].x, b.0[0].x, 0x31)); + let ab10 = u32x4x2_avx2::new(_mm256_permute2x128_si256(a.0[1].x, b.0[1].x, 0x20)); + let ab11 = u32x4x2_avx2::new(_mm256_permute2x128_si256(a.0[1].x, b.0[1].x, 0x31)); + let cd00 = u32x4x2_avx2::new(_mm256_permute2x128_si256(c.0[0].x, d.0[0].x, 0x20)); + let cd01 = u32x4x2_avx2::new(_mm256_permute2x128_si256(c.0[0].x, d.0[0].x, 0x31)); + let cd10 = u32x4x2_avx2::new(_mm256_permute2x128_si256(c.0[1].x, d.0[1].x, 0x20)); + let cd11 = u32x4x2_avx2::new(_mm256_permute2x128_si256(c.0[1].x, d.0[1].x, 0x31)); + ( + Self::new([ab00, cd00]), + Self::new([ab01, cd01]), + Self::new([ab10, cd10]), + Self::new([ab11, cd11]), + ) + } + } + } + impl Vector<[u32; 16]> for u32x4x4_avx2 { + #[inline(always)] + fn to_scalars(self) -> [u32; 16] { + unsafe { core::mem::transmute(self) } + } + } + impl From> for vec512_storage { + #[inline(always)] + fn from(x: u32x4x4_avx2) -> Self { + Self { + avx: [ + vec256_storage { avx: x.0[0].x }, + vec256_storage { avx: x.0[1].x }, + ], + } + } + } + impl From>> for u32x4x4_avx2 { + #[inline(always)] fn from(x: x4>) -> Self { Self::new(unsafe { [ - _mm256_setr_m128i(x.0[0].x, x.0[1].x), - _mm256_setr_m128i(x.0[2].x, x.0[3].x), + u32x4x2_avx2::new(_mm256_setr_m128i(x.0[0].x, x.0[1].x)), + u32x4x2_avx2::new(_mm256_setr_m128i(x.0[2].x, x.0[3].x)), ] }) } diff -Nru cargo-0.57.0+ubuntu/vendor/proc-macro2/build.rs cargo-0.58.0/vendor/proc-macro2/build.rs --- cargo-0.57.0+ubuntu/vendor/proc-macro2/build.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/proc-macro2/build.rs 2022-01-21 02:47:39.000000000 +0000 @@ -58,9 +58,10 @@ process::exit(1); } - let semver_exempt = cfg!(procmacro2_semver_exempt); + let docs_rs = env::var_os("DOCS_RS").is_some(); + let semver_exempt = cfg!(procmacro2_semver_exempt) || docs_rs; if semver_exempt { - // https://github.com/alexcrichton/proc-macro2/issues/147 + // https://github.com/dtolnay/proc-macro2/issues/147 println!("cargo:rustc-cfg=procmacro2_semver_exempt"); } @@ -76,20 +77,24 @@ println!("cargo:rustc-cfg=no_bind_by_move_pattern_guard"); } - if version.minor >= 44 { - println!("cargo:rustc-cfg=lexerror_display"); + if version.minor < 44 { + println!("cargo:rustc-cfg=no_lexerror_display"); } - if version.minor >= 45 { - println!("cargo:rustc-cfg=hygiene"); + if version.minor < 45 { + println!("cargo:rustc-cfg=no_hygiene"); } - if version.minor >= 54 { - println!("cargo:rustc-cfg=literal_from_str"); + if version.minor < 54 { + println!("cargo:rustc-cfg=no_literal_from_str"); } - if version.minor >= 57 { - println!("cargo:rustc-cfg=is_available"); + if version.minor < 55 { + println!("cargo:rustc-cfg=no_group_open_close"); + } + + if version.minor < 57 { + println!("cargo:rustc-cfg=no_is_available"); } let target = env::var("TARGET").unwrap(); diff -Nru cargo-0.57.0+ubuntu/vendor/proc-macro2/.cargo-checksum.json cargo-0.58.0/vendor/proc-macro2/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/proc-macro2/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/proc-macro2/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"edc3358ebc67bc8b7fa0c007f945b0b18226f78437d61bec735a9eb96b61ee70"} \ No newline at end of file +{"files":{},"package":"c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/proc-macro2/Cargo.toml cargo-0.58.0/vendor/proc-macro2/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/proc-macro2/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/proc-macro2/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -13,15 +13,16 @@ edition = "2018" rust-version = "1.31" name = "proc-macro2" -version = "1.0.30" -authors = ["Alex Crichton ", "David Tolnay "] +version = "1.0.36" +authors = ["David Tolnay ", "Alex Crichton "] +autobenches = false description = "A substitute implementation of the compiler's `proc_macro` API to decouple\ntoken-based libraries from the procedural macro use case.\n" documentation = "https://docs.rs/proc-macro2" readme = "README.md" keywords = ["macros"] categories = ["development-tools::procedural-macro-helpers"] license = "MIT OR Apache-2.0" -repository = "https://github.com/alexcrichton/proc-macro2" +repository = "https://github.com/dtolnay/proc-macro2" [package.metadata.docs.rs] rustc-args = ["--cfg", "procmacro2_semver_exempt"] rustdoc-args = ["--cfg", "procmacro2_semver_exempt", "--cfg", "doc_cfg"] diff -Nru cargo-0.57.0+ubuntu/vendor/proc-macro2/README.md cargo-0.58.0/vendor/proc-macro2/README.md --- cargo-0.57.0+ubuntu/vendor/proc-macro2/README.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/proc-macro2/README.md 2022-01-21 02:47:39.000000000 +0000 @@ -1,8 +1,9 @@ # proc-macro2 -[![Build Status](https://img.shields.io/github/workflow/status/alexcrichton/proc-macro2/build%20and%20test)](https://github.com/alexcrichton/proc-macro2/actions) -[![Latest Version](https://img.shields.io/crates/v/proc-macro2.svg)](https://crates.io/crates/proc-macro2) -[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/proc-macro2) +[github](https://github.com/dtolnay/proc-macro2) +[crates.io](https://crates.io/crates/proc-macro2) +[docs.rs](https://docs.rs/proc-macro2) +[build status](https://github.com/dtolnay/proc-macro2/actions?query=branch%3Amaster) A wrapper around the procedural macro API of the compiler's `proc_macro` crate. This library serves two purposes: diff -Nru cargo-0.57.0+ubuntu/vendor/proc-macro2/src/detection.rs cargo-0.58.0/vendor/proc-macro2/src/detection.rs --- cargo-0.57.0+ubuntu/vendor/proc-macro2/src/detection.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/proc-macro2/src/detection.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,4 +1,3 @@ -use std::panic::{self, PanicInfo}; use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Once; @@ -6,7 +5,7 @@ static INIT: Once = Once::new(); pub(crate) fn inside_proc_macro() -> bool { - match WORKS.load(Ordering::SeqCst) { + match WORKS.load(Ordering::Relaxed) { 1 => return false, 2 => return true, _ => {} @@ -17,17 +16,17 @@ } pub(crate) fn force_fallback() { - WORKS.store(1, Ordering::SeqCst); + WORKS.store(1, Ordering::Relaxed); } pub(crate) fn unforce_fallback() { initialize(); } -#[cfg(feature = "is_available")] +#[cfg(not(no_is_available))] fn initialize() { let available = proc_macro::is_available(); - WORKS.store(available as usize + 1, Ordering::SeqCst); + WORKS.store(available as usize + 1, Ordering::Relaxed); } // Swap in a null panic hook to avoid printing "thread panicked" to stderr, @@ -54,8 +53,10 @@ // here. For now, if a user needs to guarantee that this failure mode does // not occur, they need to call e.g. `proc_macro2::Span::call_site()` from // the main thread before launching any other threads. -#[cfg(not(feature = "is_available"))] +#[cfg(no_is_available)] fn initialize() { + use std::panic::{self, PanicInfo}; + type PanicHook = dyn Fn(&PanicInfo) + Sync + Send + 'static; let null_hook: Box = Box::new(|_panic_info| { /* ignore */ }); @@ -64,7 +65,7 @@ panic::set_hook(null_hook); let works = panic::catch_unwind(proc_macro::Span::call_site).is_ok(); - WORKS.store(works as usize + 1, Ordering::SeqCst); + WORKS.store(works as usize + 1, Ordering::Relaxed); let hopefully_null_hook = panic::take_hook(); panic::set_hook(original_hook); diff -Nru cargo-0.57.0+ubuntu/vendor/proc-macro2/src/fallback.rs cargo-0.58.0/vendor/proc-macro2/src/fallback.rs --- cargo-0.57.0+ubuntu/vendor/proc-macro2/src/fallback.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/proc-macro2/src/fallback.rs 2022-01-21 02:47:39.000000000 +0000 @@ -31,7 +31,7 @@ #[derive(Clone)] pub(crate) struct TokenStream { - pub(crate) inner: Vec, + inner: Vec, } #[derive(Debug)] @@ -52,7 +52,7 @@ } impl TokenStream { - pub fn new() -> TokenStream { + pub fn new() -> Self { TokenStream { inner: Vec::new() } } @@ -65,7 +65,7 @@ } fn push_token(&mut self, token: TokenTree) { - // https://github.com/alexcrichton/proc-macro2/issues/235 + // https://github.com/dtolnay/proc-macro2/issues/235 match token { #[cfg(not(no_bind_by_move_pattern_guard))] TokenTree::Literal(crate::Literal { @@ -74,7 +74,7 @@ #[cfg(not(wrap_proc_macro))] inner: literal, .. - }) if literal.text.starts_with('-') => { + }) if literal.repr.starts_with('-') => { push_negative_literal(self, literal); } #[cfg(no_bind_by_move_pattern_guard)] @@ -85,7 +85,7 @@ inner: literal, .. }) => { - if literal.text.starts_with('-') { + if literal.repr.starts_with('-') { push_negative_literal(self, literal); } else { self.inner @@ -97,7 +97,7 @@ #[cold] fn push_negative_literal(stream: &mut TokenStream, mut literal: Literal) { - literal.text.remove(0); + literal.repr.remove(0); let mut punct = crate::Punct::new('-', Spacing::Alone); punct.set_span(crate::Span::_new_stable(literal.span)); stream.inner.push(TokenTree::Punct(punct)); @@ -108,6 +108,12 @@ } } +impl From> for TokenStream { + fn from(inner: Vec) -> Self { + TokenStream { inner } + } +} + // Nonrecursive to prevent stack overflow. impl Drop for TokenStream { fn drop(&mut self) { @@ -417,22 +423,22 @@ impl Span { #[cfg(not(span_locations))] - pub fn call_site() -> Span { + pub fn call_site() -> Self { Span {} } #[cfg(span_locations)] - pub fn call_site() -> Span { + pub fn call_site() -> Self { Span { lo: 0, hi: 0 } } - #[cfg(hygiene)] - pub fn mixed_site() -> Span { + #[cfg(not(no_hygiene))] + pub fn mixed_site() -> Self { Span::call_site() } #[cfg(procmacro2_semver_exempt)] - pub fn def_site() -> Span { + pub fn def_site() -> Self { Span::call_site() } @@ -554,7 +560,7 @@ } impl Group { - pub fn new(delimiter: Delimiter, stream: TokenStream) -> Group { + pub fn new(delimiter: Delimiter, stream: TokenStream) -> Self { Group { delimiter, stream, @@ -632,7 +638,7 @@ } impl Ident { - fn _new(string: &str, raw: bool, span: Span) -> Ident { + fn _new(string: &str, raw: bool, span: Span) -> Self { validate_ident(string); Ident { @@ -642,11 +648,11 @@ } } - pub fn new(string: &str, span: Span) -> Ident { + pub fn new(string: &str, span: Span) -> Self { Ident::_new(string, false, span) } - pub fn new_raw(string: &str, span: Span) -> Ident { + pub fn new_raw(string: &str, span: Span) -> Self { Ident::_new(string, true, span) } @@ -756,7 +762,7 @@ #[derive(Clone)] pub(crate) struct Literal { - text: String, + repr: String, span: Span, } @@ -777,13 +783,17 @@ } impl Literal { - pub(crate) fn _new(text: String) -> Literal { + pub(crate) fn _new(repr: String) -> Self { Literal { - text, + repr, span: Span::call_site(), } } + pub(crate) unsafe fn from_str_unchecked(repr: &str) -> Self { + Literal::_new(repr.to_owned()) + } + suffixed_numbers! { u8_suffixed => u8, u16_suffixed => u16, @@ -834,31 +844,31 @@ } pub fn string(t: &str) -> Literal { - let mut text = String::with_capacity(t.len() + 2); - text.push('"'); + let mut repr = String::with_capacity(t.len() + 2); + repr.push('"'); for c in t.chars() { if c == '\'' { // escape_debug turns this into "\'" which is unnecessary. - text.push(c); + repr.push(c); } else { - text.extend(c.escape_debug()); + repr.extend(c.escape_debug()); } } - text.push('"'); - Literal::_new(text) + repr.push('"'); + Literal::_new(repr) } pub fn character(t: char) -> Literal { - let mut text = String::new(); - text.push('\''); + let mut repr = String::new(); + repr.push('\''); if t == '"' { // escape_debug turns this into '\"' which is unnecessary. - text.push(t); + repr.push(t); } else { - text.extend(t.escape_debug()); + repr.extend(t.escape_debug()); } - text.push('\''); - Literal::_new(text) + repr.push('\''); + Literal::_new(repr) } pub fn byte_string(bytes: &[u8]) -> Literal { @@ -896,10 +906,20 @@ impl FromStr for Literal { type Err = LexError; - fn from_str(repr: &str) -> Result { + fn from_str(mut repr: &str) -> Result { + let negative = repr.starts_with('-'); + if negative { + repr = &repr[1..]; + if !repr.starts_with(|ch: char| ch.is_ascii_digit()) { + return Err(LexError::call_site()); + } + } let cursor = get_cursor(repr); - if let Ok((_rest, literal)) = parse::literal(cursor) { - if literal.text.len() == repr.len() { + if let Ok((_rest, mut literal)) = parse::literal(cursor) { + if literal.repr.len() == repr.len() { + if negative { + literal.repr.insert(0, '-'); + } return Ok(literal); } } @@ -909,14 +929,14 @@ impl Display for Literal { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - Display::fmt(&self.text, f) + Display::fmt(&self.repr, f) } } impl Debug for Literal { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { let mut debug = fmt.debug_struct("Literal"); - debug.field("lit", &format_args!("{}", self.text)); + debug.field("lit", &format_args!("{}", self.repr)); debug_span_field_if_nontrivial(&mut debug, self.span); debug.finish() } diff -Nru cargo-0.57.0+ubuntu/vendor/proc-macro2/src/lib.rs cargo-0.58.0/vendor/proc-macro2/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/proc-macro2/src/lib.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/proc-macro2/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,3 +1,11 @@ +//! [![github]](https://github.com/dtolnay/proc-macro2) [![crates-io]](https://crates.io/crates/proc-macro2) [![docs-rs]](crate) +//! +//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github +//! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust +//! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K +//! +//!
+//! //! A wrapper around the procedural macro API of the compiler's [`proc_macro`] //! crate. This library serves two purposes: //! @@ -78,7 +86,7 @@ //! a different thread. // Proc-macro2 types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.30")] +#![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.36")] #![cfg_attr(any(proc_macro_span, super_unstable), feature(proc_macro_span))] #![cfg_attr(super_unstable, feature(proc_macro_def_site))] #![cfg_attr(doc_cfg, feature(doc_cfg))] @@ -86,10 +94,11 @@ clippy::cast_lossless, clippy::cast_possible_truncation, clippy::doc_markdown, - clippy::if_then_panic, clippy::items_after_statements, + clippy::manual_assert, clippy::must_use_candidate, clippy::needless_doctest_main, + clippy::return_self_not_must_use, clippy::shadow_unrelated, clippy::trivially_copy_pass_by_ref, clippy::unnecessary_wraps, @@ -98,6 +107,14 @@ clippy::vec_init_then_push )] +#[cfg(all(procmacro2_semver_exempt, wrap_proc_macro, not(super_unstable)))] +compile_error! {"\ + Something is not right. If you've tried to turn on \ + procmacro2_semver_exempt, you need to ensure that it \ + is turned on for the compilation of the proc-macro2 \ + build script as well. +"} + #[cfg(use_proc_macro)] extern crate proc_macro; @@ -149,14 +166,14 @@ } impl TokenStream { - fn _new(inner: imp::TokenStream) -> TokenStream { + fn _new(inner: imp::TokenStream) -> Self { TokenStream { inner, _marker: Marker, } } - fn _new_stable(inner: fallback::TokenStream) -> TokenStream { + fn _new_stable(inner: fallback::TokenStream) -> Self { TokenStream { inner: inner.into(), _marker: Marker, @@ -164,7 +181,7 @@ } /// Returns an empty `TokenStream` containing no token trees. - pub fn new() -> TokenStream { + pub fn new() -> Self { TokenStream::_new(imp::TokenStream::new()) } @@ -287,7 +304,7 @@ /// The source file of a given `Span`. /// /// This type is semver exempt and not exposed by default. -#[cfg(procmacro2_semver_exempt)] +#[cfg(all(procmacro2_semver_exempt, any(not(wrap_proc_macro), super_unstable)))] #[cfg_attr(doc_cfg, doc(cfg(procmacro2_semver_exempt)))] #[derive(Clone, PartialEq, Eq)] pub struct SourceFile { @@ -295,7 +312,7 @@ _marker: Marker, } -#[cfg(procmacro2_semver_exempt)] +#[cfg(all(procmacro2_semver_exempt, any(not(wrap_proc_macro), super_unstable)))] impl SourceFile { fn _new(inner: imp::SourceFile) -> Self { SourceFile { @@ -328,7 +345,7 @@ } } -#[cfg(procmacro2_semver_exempt)] +#[cfg(all(procmacro2_semver_exempt, any(not(wrap_proc_macro), super_unstable)))] impl Debug for SourceFile { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { Debug::fmt(&self.inner, f) @@ -374,14 +391,14 @@ } impl Span { - fn _new(inner: imp::Span) -> Span { + fn _new(inner: imp::Span) -> Self { Span { inner, _marker: Marker, } } - fn _new_stable(inner: fallback::Span) -> Span { + fn _new_stable(inner: fallback::Span) -> Self { Span { inner: inner.into(), _marker: Marker, @@ -393,7 +410,7 @@ /// Identifiers created with this span will be resolved as if they were /// written directly at the macro call location (call-site hygiene) and /// other code at the macro call site will be able to refer to them as well. - pub fn call_site() -> Span { + pub fn call_site() -> Self { Span::_new(imp::Span::call_site()) } @@ -402,8 +419,8 @@ /// of the macro. This is the same hygiene behavior as `macro_rules`. /// /// This function requires Rust 1.45 or later. - #[cfg(hygiene)] - pub fn mixed_site() -> Span { + #[cfg(not(no_hygiene))] + pub fn mixed_site() -> Self { Span::_new(imp::Span::mixed_site()) } @@ -412,7 +429,7 @@ /// This method is semver exempt and not exposed by default. #[cfg(procmacro2_semver_exempt)] #[cfg_attr(doc_cfg, doc(cfg(procmacro2_semver_exempt)))] - pub fn def_site() -> Span { + pub fn def_site() -> Self { Span::_new(imp::Span::def_site()) } @@ -453,7 +470,7 @@ /// The original source file into which this span points. /// /// This method is semver exempt and not exposed by default. - #[cfg(procmacro2_semver_exempt)] + #[cfg(all(procmacro2_semver_exempt, any(not(wrap_proc_macro), super_unstable)))] #[cfg_attr(doc_cfg, doc(cfg(procmacro2_semver_exempt)))] pub fn source_file(&self) -> SourceFile { SourceFile::_new(self.inner.source_file()) @@ -663,7 +680,7 @@ /// This constructor will set the span for this group to /// `Span::call_site()`. To change the span you can use the `set_span` /// method below. - pub fn new(delimiter: Delimiter, stream: TokenStream) -> Group { + pub fn new(delimiter: Delimiter, stream: TokenStream) -> Self { Group { inner: imp::Group::new(delimiter, stream.inner), } @@ -771,7 +788,7 @@ /// /// The returned `Punct` will have the default span of `Span::call_site()` /// which can be further configured with the `set_span` method below. - pub fn new(ch: char, spacing: Spacing) -> Punct { + pub fn new(ch: char, spacing: Spacing) -> Self { Punct { ch, spacing, @@ -893,7 +910,7 @@ } impl Ident { - fn _new(inner: imp::Ident) -> Ident { + fn _new(inner: imp::Ident) -> Self { Ident { inner, _marker: Marker, @@ -931,7 +948,7 @@ /// style="padding-right:0;">syn::parse_str::<Ident> /// rather than `Ident::new`. - pub fn new(string: &str, span: Span) -> Ident { + pub fn new(string: &str, span: Span) -> Self { Ident::_new(imp::Ident::new(string, span.inner)) } @@ -940,11 +957,11 @@ /// This method is semver exempt and not exposed by default. #[cfg(procmacro2_semver_exempt)] #[cfg_attr(doc_cfg, doc(cfg(procmacro2_semver_exempt)))] - pub fn new_raw(string: &str, span: Span) -> Ident { + pub fn new_raw(string: &str, span: Span) -> Self { Ident::_new_raw(string, span) } - fn _new_raw(string: &str, span: Span) -> Ident { + fn _new_raw(string: &str, span: Span) -> Self { Ident::_new(imp::Ident::new_raw(string, span.inner)) } @@ -1062,14 +1079,14 @@ } impl Literal { - fn _new(inner: imp::Literal) -> Literal { + fn _new(inner: imp::Literal) -> Self { Literal { inner, _marker: Marker, } } - fn _new_stable(inner: fallback::Literal) -> Literal { + fn _new_stable(inner: fallback::Literal) -> Self { Literal { inner: inner.into(), _marker: Marker, @@ -1215,6 +1232,15 @@ pub fn subspan>(&self, range: R) -> Option { self.inner.subspan(range).map(Span::_new) } + + // Intended for the `quote!` macro to use when constructing a proc-macro2 + // token out of a macro_rules $:literal token, which is already known to be + // a valid literal. This avoids reparsing/validating the literal's string + // representation. This is not public API other than for quote. + #[doc(hidden)] + pub unsafe fn from_str_unchecked(repr: &str) -> Self { + Literal::_new(imp::Literal::from_str_unchecked(repr)) + } } impl FromStr for Literal { diff -Nru cargo-0.57.0+ubuntu/vendor/proc-macro2/src/parse.rs cargo-0.58.0/vendor/proc-macro2/src/parse.rs --- cargo-0.57.0+ubuntu/vendor/proc-macro2/src/parse.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/proc-macro2/src/parse.rs 2022-01-21 02:47:39.000000000 +0000 @@ -168,7 +168,7 @@ let first = match input.bytes().next() { Some(first) => first, None => match stack.last() { - None => return Ok(TokenStream { inner: trees }), + None => return Ok(TokenStream::from(trees)), #[cfg(span_locations)] Some((lo, _frame)) => { return Err(LexError { @@ -209,7 +209,7 @@ return Err(lex_error(input)); } input = input.advance(1); - let mut g = Group::new(open_delimiter, TokenStream { inner: trees }); + let mut g = Group::new(open_delimiter, TokenStream::from(trees)); g.set_span(Span { #[cfg(span_locations)] lo, @@ -819,7 +819,7 @@ for tt in &mut stream { tt.set_span(span); } - let group = Group::new(Delimiter::Bracket, stream.into_iter().collect()); + let group = Group::new(Delimiter::Bracket, TokenStream::from(stream)); trees.push(crate::Group::_new_stable(group).into()); for tt in &mut trees { tt.set_span(span); diff -Nru cargo-0.57.0+ubuntu/vendor/proc-macro2/src/wrapper.rs cargo-0.58.0/vendor/proc-macro2/src/wrapper.rs --- cargo-0.57.0+ubuntu/vendor/proc-macro2/src/wrapper.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/proc-macro2/src/wrapper.rs 2022-01-21 02:47:39.000000000 +0000 @@ -69,7 +69,7 @@ } impl TokenStream { - pub fn new() -> TokenStream { + pub fn new() -> Self { if inside_proc_macro() { TokenStream::Compiler(DeferredTokenStream::new(proc_macro::TokenStream::new())) } else { @@ -284,9 +284,9 @@ impl Display for LexError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - #[cfg(lexerror_display)] + #[cfg(not(no_lexerror_display))] LexError::Compiler(e) => Display::fmt(e, f), - #[cfg(not(lexerror_display))] + #[cfg(no_lexerror_display)] LexError::Compiler(_e) => Display::fmt( &fallback::LexError { span: fallback::Span::call_site(), @@ -408,7 +408,7 @@ } impl Span { - pub fn call_site() -> Span { + pub fn call_site() -> Self { if inside_proc_macro() { Span::Compiler(proc_macro::Span::call_site()) } else { @@ -416,8 +416,8 @@ } } - #[cfg(hygiene)] - pub fn mixed_site() -> Span { + #[cfg(not(no_hygiene))] + pub fn mixed_site() -> Self { if inside_proc_macro() { Span::Compiler(proc_macro::Span::mixed_site()) } else { @@ -426,7 +426,7 @@ } #[cfg(super_unstable)] - pub fn def_site() -> Span { + pub fn def_site() -> Self { if inside_proc_macro() { Span::Compiler(proc_macro::Span::def_site()) } else { @@ -436,11 +436,11 @@ pub fn resolved_at(&self, other: Span) -> Span { match (self, other) { - #[cfg(hygiene)] + #[cfg(not(no_hygiene))] (Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.resolved_at(b)), // Name resolution affects semantics, but location is only cosmetic - #[cfg(not(hygiene))] + #[cfg(no_hygiene)] (Span::Compiler(_), Span::Compiler(_)) => other, (Span::Fallback(a), Span::Fallback(b)) => Span::Fallback(a.resolved_at(b)), @@ -450,11 +450,11 @@ pub fn located_at(&self, other: Span) -> Span { match (self, other) { - #[cfg(hygiene)] + #[cfg(not(no_hygiene))] (Span::Compiler(a), Span::Compiler(b)) => Span::Compiler(a.located_at(b)), // Name resolution affects semantics, but location is only cosmetic - #[cfg(not(hygiene))] + #[cfg(no_hygiene)] (Span::Compiler(_), Span::Compiler(_)) => *self, (Span::Fallback(a), Span::Fallback(b)) => Span::Fallback(a.located_at(b)), @@ -575,7 +575,7 @@ } impl Group { - pub fn new(delimiter: Delimiter, stream: TokenStream) -> Group { + pub fn new(delimiter: Delimiter, stream: TokenStream) -> Self { match stream { TokenStream::Compiler(tts) => { let delimiter = match delimiter { @@ -620,9 +620,9 @@ pub fn span_open(&self) -> Span { match self { - #[cfg(proc_macro_span)] + #[cfg(not(no_group_open_close))] Group::Compiler(g) => Span::Compiler(g.span_open()), - #[cfg(not(proc_macro_span))] + #[cfg(no_group_open_close)] Group::Compiler(g) => Span::Compiler(g.span()), Group::Fallback(g) => Span::Fallback(g.span_open()), } @@ -630,9 +630,9 @@ pub fn span_close(&self) -> Span { match self { - #[cfg(proc_macro_span)] + #[cfg(not(no_group_open_close))] Group::Compiler(g) => Span::Compiler(g.span_close()), - #[cfg(not(proc_macro_span))] + #[cfg(no_group_open_close)] Group::Compiler(g) => Span::Compiler(g.span()), Group::Fallback(g) => Span::Fallback(g.span_close()), } @@ -685,14 +685,14 @@ } impl Ident { - pub fn new(string: &str, span: Span) -> Ident { + pub fn new(string: &str, span: Span) -> Self { match span { Span::Compiler(s) => Ident::Compiler(proc_macro::Ident::new(string, s)), Span::Fallback(s) => Ident::Fallback(fallback::Ident::new(string, s)), } } - pub fn new_raw(string: &str, span: Span) -> Ident { + pub fn new_raw(string: &str, span: Span) -> Self { match span { Span::Compiler(s) => { let p: proc_macro::TokenStream = string.parse().unwrap(); @@ -804,6 +804,14 @@ } impl Literal { + pub unsafe fn from_str_unchecked(repr: &str) -> Self { + if inside_proc_macro() { + Literal::Compiler(compiler_literal_from_str(repr).expect("invalid literal")) + } else { + Literal::Fallback(fallback::Literal::from_str_unchecked(repr)) + } + } + suffixed_numbers! { u8_suffixed => u8, u16_suffixed => u16, @@ -921,25 +929,7 @@ fn from_str(repr: &str) -> Result { if inside_proc_macro() { - #[cfg(literal_from_str)] - { - proc_macro::Literal::from_str(repr) - .map(Literal::Compiler) - .map_err(LexError::Compiler) - } - #[cfg(not(literal_from_str))] - { - let tokens = proc_macro_parse(repr)?; - let mut iter = tokens.into_iter(); - if let (Some(proc_macro::TokenTree::Literal(literal)), None) = - (iter.next(), iter.next()) - { - if literal.to_string().len() == repr.len() { - return Ok(Literal::Compiler(literal)); - } - } - Err(LexError::call_site()) - } + compiler_literal_from_str(repr).map(Literal::Compiler) } else { let literal = fallback::Literal::from_str(repr)?; Ok(Literal::Fallback(literal)) @@ -947,6 +937,24 @@ } } +fn compiler_literal_from_str(repr: &str) -> Result { + #[cfg(not(no_literal_from_str))] + { + proc_macro::Literal::from_str(repr).map_err(LexError::Compiler) + } + #[cfg(no_literal_from_str)] + { + let tokens = proc_macro_parse(repr)?; + let mut iter = tokens.into_iter(); + if let (Some(proc_macro::TokenTree::Literal(literal)), None) = (iter.next(), iter.next()) { + if literal.to_string().len() == repr.len() { + return Ok(literal); + } + } + Err(LexError::call_site()) + } +} + impl Display for Literal { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { diff -Nru cargo-0.57.0+ubuntu/vendor/proc-macro2/tests/test.rs cargo-0.58.0/vendor/proc-macro2/tests/test.rs --- cargo-0.57.0+ubuntu/vendor/proc-macro2/tests/test.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/proc-macro2/tests/test.rs 2022-01-21 02:47:39.000000000 +0000 @@ -168,7 +168,11 @@ #[test] fn literal_parse() { assert!("1".parse::().is_ok()); + assert!("-1".parse::().is_ok()); + assert!("-1u12".parse::().is_ok()); assert!("1.0".parse::().is_ok()); + assert!("-1.0".parse::().is_ok()); + assert!("-1.0f12".parse::().is_ok()); assert!("'a'".parse::().is_ok()); assert!("\"\n\"".parse::().is_ok()); assert!("0 1".parse::().is_err()); @@ -177,6 +181,9 @@ assert!("/* comment */0".parse::().is_err()); assert!("0/* comment */".parse::().is_err()); assert!("0// comment".parse::().is_err()); + assert!("- 1".parse::().is_err()); + assert!("- 1.0".parse::().is_err()); + assert!("-\"\"".parse::().is_err()); } #[test] diff -Nru cargo-0.57.0+ubuntu/vendor/quote/benches/bench.rs cargo-0.58.0/vendor/quote/benches/bench.rs --- cargo-0.57.0+ubuntu/vendor/quote/benches/bench.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/quote/benches/bench.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,192 +0,0 @@ -#![feature(test)] - -extern crate test; - -use quote::quote; -use test::Bencher; - -#[bench] -fn bench_impl(b: &mut Bencher) { - b.iter(|| { - quote! { - impl<'de> _serde::Deserialize<'de> for Response { - fn deserialize<__D>(__deserializer: __D) -> _serde::export::Result - where - __D: _serde::Deserializer<'de>, - { - #[allow(non_camel_case_types)] - enum __Field { - __field0, - __field1, - __ignore, - } - struct __FieldVisitor; - impl<'de> _serde::de::Visitor<'de> for __FieldVisitor { - type Value = __Field; - fn expecting( - &self, - __formatter: &mut _serde::export::Formatter, - ) -> _serde::export::fmt::Result { - _serde::export::Formatter::write_str(__formatter, "field identifier") - } - fn visit_u64<__E>(self, __value: u64) -> _serde::export::Result - where - __E: _serde::de::Error, - { - match __value { - 0u64 => _serde::export::Ok(__Field::__field0), - 1u64 => _serde::export::Ok(__Field::__field1), - _ => _serde::export::Err(_serde::de::Error::invalid_value( - _serde::de::Unexpected::Unsigned(__value), - &"field index 0 <= i < 2", - )), - } - } - fn visit_str<__E>(self, __value: &str) -> _serde::export::Result - where - __E: _serde::de::Error, - { - match __value { - "id" => _serde::export::Ok(__Field::__field0), - "s" => _serde::export::Ok(__Field::__field1), - _ => _serde::export::Ok(__Field::__ignore), - } - } - fn visit_bytes<__E>( - self, - __value: &[u8], - ) -> _serde::export::Result - where - __E: _serde::de::Error, - { - match __value { - b"id" => _serde::export::Ok(__Field::__field0), - b"s" => _serde::export::Ok(__Field::__field1), - _ => _serde::export::Ok(__Field::__ignore), - } - } - } - impl<'de> _serde::Deserialize<'de> for __Field { - #[inline] - fn deserialize<__D>(__deserializer: __D) -> _serde::export::Result - where - __D: _serde::Deserializer<'de>, - { - _serde::Deserializer::deserialize_identifier(__deserializer, __FieldVisitor) - } - } - struct __Visitor<'de> { - marker: _serde::export::PhantomData, - lifetime: _serde::export::PhantomData<&'de ()>, - } - impl<'de> _serde::de::Visitor<'de> for __Visitor<'de> { - type Value = Response; - fn expecting( - &self, - __formatter: &mut _serde::export::Formatter, - ) -> _serde::export::fmt::Result { - _serde::export::Formatter::write_str(__formatter, "struct Response") - } - #[inline] - fn visit_seq<__A>( - self, - mut __seq: __A, - ) -> _serde::export::Result - where - __A: _serde::de::SeqAccess<'de>, - { - let __field0 = - match try!(_serde::de::SeqAccess::next_element::(&mut __seq)) { - _serde::export::Some(__value) => __value, - _serde::export::None => { - return _serde::export::Err(_serde::de::Error::invalid_length( - 0usize, - &"struct Response with 2 elements", - )); - } - }; - let __field1 = - match try!(_serde::de::SeqAccess::next_element::(&mut __seq)) { - _serde::export::Some(__value) => __value, - _serde::export::None => { - return _serde::export::Err(_serde::de::Error::invalid_length( - 1usize, - &"struct Response with 2 elements", - )); - } - }; - _serde::export::Ok(Response { - id: __field0, - s: __field1, - }) - } - #[inline] - fn visit_map<__A>( - self, - mut __map: __A, - ) -> _serde::export::Result - where - __A: _serde::de::MapAccess<'de>, - { - let mut __field0: _serde::export::Option = _serde::export::None; - let mut __field1: _serde::export::Option = _serde::export::None; - while let _serde::export::Some(__key) = - try!(_serde::de::MapAccess::next_key::<__Field>(&mut __map)) - { - match __key { - __Field::__field0 => { - if _serde::export::Option::is_some(&__field0) { - return _serde::export::Err( - <__A::Error as _serde::de::Error>::duplicate_field("id"), - ); - } - __field0 = _serde::export::Some( - try!(_serde::de::MapAccess::next_value::(&mut __map)), - ); - } - __Field::__field1 => { - if _serde::export::Option::is_some(&__field1) { - return _serde::export::Err( - <__A::Error as _serde::de::Error>::duplicate_field("s"), - ); - } - __field1 = _serde::export::Some( - try!(_serde::de::MapAccess::next_value::(&mut __map)), - ); - } - _ => { - let _ = try!(_serde::de::MapAccess::next_value::< - _serde::de::IgnoredAny, - >(&mut __map)); - } - } - } - let __field0 = match __field0 { - _serde::export::Some(__field0) => __field0, - _serde::export::None => try!(_serde::private::de::missing_field("id")), - }; - let __field1 = match __field1 { - _serde::export::Some(__field1) => __field1, - _serde::export::None => try!(_serde::private::de::missing_field("s")), - }; - _serde::export::Ok(Response { - id: __field0, - s: __field1, - }) - } - } - const FIELDS: &'static [&'static str] = &["id", "s"]; - _serde::Deserializer::deserialize_struct( - __deserializer, - "Response", - FIELDS, - __Visitor { - marker: _serde::export::PhantomData::, - lifetime: _serde::export::PhantomData, - }, - ) - } - } - } - }); -} diff -Nru cargo-0.57.0+ubuntu/vendor/quote/.cargo-checksum.json cargo-0.58.0/vendor/quote/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/quote/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/quote/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05"} \ No newline at end of file +{"files":{},"package":"47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/quote/Cargo.toml cargo-0.58.0/vendor/quote/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/quote/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/quote/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -13,8 +13,9 @@ edition = "2018" rust-version = "1.31" name = "quote" -version = "1.0.10" +version = "1.0.14" authors = ["David Tolnay "] +autobenches = false description = "Quasi-quoting macro quote!(...)" documentation = "https://docs.rs/quote/" readme = "README.md" @@ -25,13 +26,13 @@ [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] [dependencies.proc-macro2] -version = "1.0.20" +version = "1.0.36" default-features = false [dev-dependencies.rustversion] version = "1.0" [dev-dependencies.trybuild] -version = "1.0.19" +version = "1.0.52" features = ["diff"] [features] diff -Nru cargo-0.57.0+ubuntu/vendor/quote/rust-toolchain.toml cargo-0.58.0/vendor/quote/rust-toolchain.toml --- cargo-0.57.0+ubuntu/vendor/quote/rust-toolchain.toml 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/quote/rust-toolchain.toml 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,2 @@ +[toolchain] +components = ["rust-src"] diff -Nru cargo-0.57.0+ubuntu/vendor/quote/src/format.rs cargo-0.58.0/vendor/quote/src/format.rs --- cargo-0.57.0+ubuntu/vendor/quote/src/format.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/quote/src/format.rs 2022-01-21 02:47:39.000000000 +0000 @@ -11,10 +11,10 @@ /// of format types to traits is: /// /// * `{}` ⇒ [`IdentFragment`] -/// * `{:o}` ⇒ [`Octal`](`std::fmt::Octal`) -/// * `{:x}` ⇒ [`LowerHex`](`std::fmt::LowerHex`) -/// * `{:X}` ⇒ [`UpperHex`](`std::fmt::UpperHex`) -/// * `{:b}` ⇒ [`Binary`](`std::fmt::Binary`) +/// * `{:o}` ⇒ [`Octal`](std::fmt::Octal) +/// * `{:x}` ⇒ [`LowerHex`](std::fmt::LowerHex) +/// * `{:X}` ⇒ [`UpperHex`](std::fmt::UpperHex) +/// * `{:b}` ⇒ [`Binary`](std::fmt::Binary) /// /// See [`std::fmt`] for more information. /// @@ -29,7 +29,8 @@ /// unsigned integers and strings. /// * [`Ident`] arguments will have their `r#` prefixes stripped, if present. /// -/// [`Ident`]: `proc_macro2::Ident` +/// [`IdentFragment`]: crate::IdentFragment +/// [`Ident`]: proc_macro2::Ident /// ///
/// @@ -59,8 +60,8 @@ /// format_ident!("MyIdent", span = my_span); /// ``` /// -/// [`Span`]: `proc_macro2::Span` -/// [`Span::call_site`]: `proc_macro2::Span::call_site` +/// [`Span`]: proc_macro2::Span +/// [`Span::call_site`]: proc_macro2::Span::call_site /// ///


/// diff -Nru cargo-0.57.0+ubuntu/vendor/quote/src/lib.rs cargo-0.58.0/vendor/quote/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/quote/src/lib.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/quote/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -81,7 +81,7 @@ //! ``` // Quote types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/quote/1.0.10")] +#![doc(html_root_url = "https://docs.rs/quote/1.0.14")] #![allow( clippy::doc_markdown, clippy::missing_errors_doc, @@ -1066,6 +1066,14 @@ $crate::__private::push_ident(&mut $tokens, stringify!($ident)); }; + ($tokens:ident $lifetime:lifetime) => { + $crate::__private::push_lifetime(&mut $tokens, stringify!($lifetime)); + }; + + ($tokens:ident _) => { + $crate::__private::push_underscore(&mut $tokens); + }; + ($tokens:ident $other:tt) => { $crate::__private::parse(&mut $tokens, stringify!($other)); }; @@ -1281,6 +1289,14 @@ $crate::__private::push_ident_spanned(&mut $tokens, $span, stringify!($ident)); }; + ($tokens:ident $span:ident $lifetime:lifetime) => { + $crate::__private::push_lifetime_spanned(&mut $tokens, $span, stringify!($lifetime)); + }; + + ($tokens:ident $span:ident _) => { + $crate::__private::push_underscore_spanned(&mut $tokens, $span); + }; + ($tokens:ident $span:ident $other:tt) => { $crate::__private::parse_spanned(&mut $tokens, $span, stringify!($other)); }; diff -Nru cargo-0.57.0+ubuntu/vendor/quote/src/runtime.rs cargo-0.58.0/vendor/quote/src/runtime.rs --- cargo-0.57.0+ubuntu/vendor/quote/src/runtime.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/quote/src/runtime.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,5 +1,6 @@ use crate::{IdentFragment, ToTokens, TokenStreamExt}; use std::fmt; +use std::iter; use std::ops::BitOr; pub use proc_macro2::*; @@ -178,15 +179,29 @@ pub fn parse(tokens: &mut TokenStream, s: &str) { let s: TokenStream = s.parse().expect("invalid token stream"); - tokens.extend(s); + tokens.extend(iter::once(s)); } pub fn parse_spanned(tokens: &mut TokenStream, span: Span, s: &str) { let s: TokenStream = s.parse().expect("invalid token stream"); - tokens.extend(s.into_iter().map(|mut t| { - t.set_span(span); - t - })); + tokens.extend(s.into_iter().map(|t| respan_token_tree(t, span))); +} + +// Token tree with every span replaced by the given one. +fn respan_token_tree(mut token: TokenTree, span: Span) -> TokenTree { + match &mut token { + TokenTree::Group(g) => { + let stream = g + .stream() + .into_iter() + .map(|token| respan_token_tree(token, span)) + .collect(); + *g = Group::new(g.delimiter(), stream); + g.set_span(span); + } + other => other.set_span(span), + } + token } pub fn push_ident(tokens: &mut TokenStream, s: &str) { @@ -213,6 +228,70 @@ } } +pub fn push_lifetime(tokens: &mut TokenStream, lifetime: &str) { + struct Lifetime<'a> { + name: &'a str, + state: u8, + } + + impl<'a> Iterator for Lifetime<'a> { + type Item = TokenTree; + + fn next(&mut self) -> Option { + match self.state { + 0 => { + self.state = 1; + Some(TokenTree::Punct(Punct::new('\'', Spacing::Joint))) + } + 1 => { + self.state = 2; + Some(TokenTree::Ident(Ident::new(self.name, Span::call_site()))) + } + _ => None, + } + } + } + + tokens.extend(Lifetime { + name: &lifetime[1..], + state: 0, + }); +} + +pub fn push_lifetime_spanned(tokens: &mut TokenStream, span: Span, lifetime: &str) { + struct Lifetime<'a> { + name: &'a str, + span: Span, + state: u8, + } + + impl<'a> Iterator for Lifetime<'a> { + type Item = TokenTree; + + fn next(&mut self) -> Option { + match self.state { + 0 => { + self.state = 1; + let mut apostrophe = Punct::new('\'', Spacing::Joint); + apostrophe.set_span(self.span); + Some(TokenTree::Punct(apostrophe)) + } + 1 => { + self.state = 2; + Some(TokenTree::Ident(Ident::new(self.name, self.span))) + } + _ => None, + } + } + } + + tokens.extend(Lifetime { + name: &lifetime[1..], + span, + state: 0, + }); +} + macro_rules! push_punct { ($name:ident $spanned:ident $char1:tt) => { pub fn $name(tokens: &mut TokenStream) { @@ -303,6 +382,14 @@ push_punct!(push_sub push_sub_spanned '-'); push_punct!(push_sub_eq push_sub_eq_spanned '-' '='); +pub fn push_underscore(tokens: &mut TokenStream) { + push_underscore_spanned(tokens, Span::call_site()); +} + +pub fn push_underscore_spanned(tokens: &mut TokenStream, span: Span) { + tokens.append(Ident::new("_", span)); +} + // Helper method for constructing identifiers from the `format_ident!` macro, // handling `r#` prefixes. // diff -Nru cargo-0.57.0+ubuntu/vendor/quote/tests/test.rs cargo-0.58.0/vendor/quote/tests/test.rs --- cargo-0.57.0+ubuntu/vendor/quote/tests/test.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/quote/tests/test.rs 2022-01-21 02:47:39.000000000 +0000 @@ -176,10 +176,11 @@ let uusize = 1usize; let tokens = quote! { + 1 1i32 1u256 #ii8 #ii16 #ii32 #ii64 #ii128 #iisize #uu8 #uu16 #uu32 #uu64 #uu128 #uusize }; - let expected = "- 1i8 - 1i16 - 1i32 - 1i64 - 1i128 - 1isize 1u8 1u16 1u32 1u64 1u128 1usize"; + let expected = "1 1i32 1u256 - 1i8 - 1i16 - 1i32 - 1i64 - 1i128 - 1isize 1u8 1u16 1u32 1u64 1u128 1usize"; assert_eq!(expected, tokens.to_string()); } @@ -230,6 +231,31 @@ } #[test] +fn test_interpolated_literal() { + macro_rules! m { + ($literal:literal) => { + quote!($literal) + }; + } + + let tokens = m!(1); + let expected = "1"; + assert_eq!(expected, tokens.to_string()); + + let tokens = m!(-1); + let expected = "- 1"; + assert_eq!(expected, tokens.to_string()); + + let tokens = m!(true); + let expected = "true"; + assert_eq!(expected, tokens.to_string()); + + let tokens = m!(-true); + let expected = "- true"; + assert_eq!(expected, tokens.to_string()); +} + +#[test] fn test_ident() { let foo = Ident::new("Foo", Span::call_site()); let bar = Ident::new(&format!("Bar{}", 7), Span::call_site()); @@ -238,6 +264,13 @@ assert_eq!(expected, tokens.to_string()); } +#[test] +fn test_underscore() { + let tokens = quote!(let _;); + let expected = "let _ ;"; + assert_eq!(expected, tokens.to_string()); +} + #[test] fn test_duplicate() { let ch = 'x'; diff -Nru cargo-0.57.0+ubuntu/vendor/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr cargo-0.58.0/vendor/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr --- cargo-0.57.0+ubuntu/vendor/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/quote/tests/ui/does-not-have-iter-interpolated-dup.stderr 2022-01-21 02:47:39.000000000 +0000 @@ -1,8 +1,8 @@ error[E0308]: mismatched types - --> $DIR/does-not-have-iter-interpolated-dup.rs:8:5 + --> tests/ui/does-not-have-iter-interpolated-dup.rs:8:5 | 8 | quote!(#(#nonrep #nonrep)*); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | expected struct `HasIterator`, found struct `ThereIsNoIteratorInRepetition` | expected due to this diff -Nru cargo-0.57.0+ubuntu/vendor/quote/tests/ui/does-not-have-iter-interpolated.stderr cargo-0.58.0/vendor/quote/tests/ui/does-not-have-iter-interpolated.stderr --- cargo-0.57.0+ubuntu/vendor/quote/tests/ui/does-not-have-iter-interpolated.stderr 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/quote/tests/ui/does-not-have-iter-interpolated.stderr 2022-01-21 02:47:39.000000000 +0000 @@ -1,8 +1,8 @@ error[E0308]: mismatched types - --> $DIR/does-not-have-iter-interpolated.rs:8:5 + --> tests/ui/does-not-have-iter-interpolated.rs:8:5 | 8 | quote!(#(#nonrep)*); - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ | | | expected struct `HasIterator`, found struct `ThereIsNoIteratorInRepetition` | expected due to this diff -Nru cargo-0.57.0+ubuntu/vendor/quote/tests/ui/does-not-have-iter-separated.stderr cargo-0.58.0/vendor/quote/tests/ui/does-not-have-iter-separated.stderr --- cargo-0.57.0+ubuntu/vendor/quote/tests/ui/does-not-have-iter-separated.stderr 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/quote/tests/ui/does-not-have-iter-separated.stderr 2022-01-21 02:47:39.000000000 +0000 @@ -1,8 +1,8 @@ error[E0308]: mismatched types - --> $DIR/does-not-have-iter-separated.rs:4:5 + --> tests/ui/does-not-have-iter-separated.rs:4:5 | 4 | quote!(#(a b),*); - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | | | expected struct `HasIterator`, found struct `ThereIsNoIteratorInRepetition` | expected due to this diff -Nru cargo-0.57.0+ubuntu/vendor/quote/tests/ui/does-not-have-iter.stderr cargo-0.58.0/vendor/quote/tests/ui/does-not-have-iter.stderr --- cargo-0.57.0+ubuntu/vendor/quote/tests/ui/does-not-have-iter.stderr 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/quote/tests/ui/does-not-have-iter.stderr 2022-01-21 02:47:39.000000000 +0000 @@ -1,8 +1,8 @@ error[E0308]: mismatched types - --> $DIR/does-not-have-iter.rs:4:5 + --> tests/ui/does-not-have-iter.rs:4:5 | 4 | quote!(#(a b)*); - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | | | expected struct `HasIterator`, found struct `ThereIsNoIteratorInRepetition` | expected due to this diff -Nru cargo-0.57.0+ubuntu/vendor/quote/tests/ui/not-quotable.stderr cargo-0.58.0/vendor/quote/tests/ui/not-quotable.stderr --- cargo-0.57.0+ubuntu/vendor/quote/tests/ui/not-quotable.stderr 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/quote/tests/ui/not-quotable.stderr 2022-01-21 02:47:39.000000000 +0000 @@ -1,15 +1,7 @@ error[E0277]: the trait bound `Ipv4Addr: ToTokens` is not satisfied - --> $DIR/not-quotable.rs:6:13 - | -6 | let _ = quote! { #ip }; - | ^^^^^^^^^^^^^^ - | | - | the trait `ToTokens` is not implemented for `Ipv4Addr` - | required by a bound introduced by this call - | -note: required by `to_tokens` - --> $DIR/to_tokens.rs:55:5 - | -55 | fn to_tokens(&self, tokens: &mut TokenStream); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `$crate::quote_token_with_context` (in Nightly builds, run with -Z macro-backtrace for more info) + --> tests/ui/not-quotable.rs:6:13 + | +6 | let _ = quote! { #ip }; + | ^^^^^^^^^^^^^^ the trait `ToTokens` is not implemented for `Ipv4Addr` + | + = note: this error originates in the macro `$crate::quote_token_with_context` (in Nightly builds, run with -Z macro-backtrace for more info) diff -Nru cargo-0.57.0+ubuntu/vendor/quote/tests/ui/not-repeatable.stderr cargo-0.58.0/vendor/quote/tests/ui/not-repeatable.stderr --- cargo-0.57.0+ubuntu/vendor/quote/tests/ui/not-repeatable.stderr 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/quote/tests/ui/not-repeatable.stderr 2022-01-21 02:47:39.000000000 +0000 @@ -1,25 +1,47 @@ error[E0599]: the method `quote_into_iter` exists for struct `Ipv4Addr`, but its trait bounds were not satisfied - --> $DIR/not-repeatable.rs:7:13 - | -3 | struct Ipv4Addr; - | ---------------- - | | - | method `quote_into_iter` not found for this - | doesn't satisfy `Ipv4Addr: Iterator` - | doesn't satisfy `Ipv4Addr: ToTokens` - | doesn't satisfy `Ipv4Addr: quote::__private::ext::RepIteratorExt` - | doesn't satisfy `Ipv4Addr: quote::__private::ext::RepToTokensExt` + --> tests/ui/not-repeatable.rs:7:13 + | +3 | struct Ipv4Addr; + | ---------------- + | | + | method `quote_into_iter` not found for this + | doesn't satisfy `Ipv4Addr: Iterator` + | doesn't satisfy `Ipv4Addr: ToTokens` + | doesn't satisfy `Ipv4Addr: quote::__private::ext::RepIteratorExt` + | doesn't satisfy `Ipv4Addr: quote::__private::ext::RepToTokensExt` ... -7 | let _ = quote! { #(#ip)* }; - | ^^^^^^^^^^^^^^^^^^ method cannot be called on `Ipv4Addr` due to unsatisfied trait bounds - | - = note: the following trait bounds were not satisfied: - `Ipv4Addr: Iterator` - which is required by `Ipv4Addr: quote::__private::ext::RepIteratorExt` - `&Ipv4Addr: Iterator` - which is required by `&Ipv4Addr: quote::__private::ext::RepIteratorExt` - `Ipv4Addr: ToTokens` - which is required by `Ipv4Addr: quote::__private::ext::RepToTokensExt` - `&mut Ipv4Addr: Iterator` - which is required by `&mut Ipv4Addr: quote::__private::ext::RepIteratorExt` - = note: this error originates in the macro `$crate::quote_bind_into_iter` (in Nightly builds, run with -Z macro-backtrace for more info) +7 | let _ = quote! { #(#ip)* }; + | ^^^^^^^^^^^^^^^^^^ method cannot be called on `Ipv4Addr` due to unsatisfied trait bounds + | + = note: the following trait bounds were not satisfied: + `Ipv4Addr: Iterator` + which is required by `Ipv4Addr: quote::__private::ext::RepIteratorExt` + `&Ipv4Addr: Iterator` + which is required by `&Ipv4Addr: quote::__private::ext::RepIteratorExt` + `Ipv4Addr: ToTokens` + which is required by `Ipv4Addr: quote::__private::ext::RepToTokensExt` + `&mut Ipv4Addr: Iterator` + which is required by `&mut Ipv4Addr: quote::__private::ext::RepIteratorExt` +note: the following traits must be implemented + --> $RUST/core/src/iter/traits/iterator.rs + | + | / pub trait Iterator { + | | /// The type of the elements being iterated over. + | | #[stable(feature = "rust1", since = "1.0.0")] + | | type Item; +... | + | | } + | | } + | |__^ + | + ::: src/to_tokens.rs + | + | / pub trait ToTokens { + | | /// Write `self` to the given `TokenStream`. + | | /// + | | /// The token append methods provided by the [`TokenStreamExt`] extension +... | + | | } + | | } + | |_^ + = note: this error originates in the macro `$crate::quote_bind_into_iter` (in Nightly builds, run with -Z macro-backtrace for more info) diff -Nru cargo-0.57.0+ubuntu/vendor/quote/tests/ui/wrong-type-span.rs cargo-0.58.0/vendor/quote/tests/ui/wrong-type-span.rs --- cargo-0.57.0+ubuntu/vendor/quote/tests/ui/wrong-type-span.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/quote/tests/ui/wrong-type-span.rs 2022-01-21 02:47:39.000000000 +0000 @@ -2,6 +2,6 @@ fn main() { let span = ""; - let x = 0; + let x = 0i32; quote_spanned!(span=> #x); } diff -Nru cargo-0.57.0+ubuntu/vendor/quote/tests/ui/wrong-type-span.stderr cargo-0.58.0/vendor/quote/tests/ui/wrong-type-span.stderr --- cargo-0.57.0+ubuntu/vendor/quote/tests/ui/wrong-type-span.stderr 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/quote/tests/ui/wrong-type-span.stderr 2022-01-21 02:47:39.000000000 +0000 @@ -1,8 +1,8 @@ error[E0308]: mismatched types - --> $DIR/wrong-type-span.rs:6:20 + --> tests/ui/wrong-type-span.rs:6:20 | 6 | quote_spanned!(span=> #x); - | ---------------^^^^------- + | ---------------^^^^------ | | | | | expected struct `Span`, found `&str` | expected due to this diff -Nru cargo-0.57.0+ubuntu/vendor/rand/.cargo-checksum.json cargo-0.58.0/vendor/rand/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/rand/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"} \ No newline at end of file +{"files":{},"package":"2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/rand/Cargo.lock cargo-0.58.0/vendor/rand/Cargo.lock --- cargo-0.57.0+ubuntu/vendor/rand/Cargo.lock 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/Cargo.lock 1970-01-01 00:00:00.000000000 +0000 @@ -1,388 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -[[package]] -name = "base-x" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "bumpalo" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "c2-chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "cfg-if" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "getrandom" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb 0.4.18 (registry+https://github.com/rust-lang/crates.io-index)", - "wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "itoa" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "libc" -version = "0.2.62" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "log" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "packed_simd" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ppv-lite86" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "proc-macro2" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "proc-macro2" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quote" -version = "0.6.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "quote" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand" -version = "0.7.3" -dependencies = [ - "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "packed_simd 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_pcg 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_chacha" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rand_pcg" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "ryu" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde" -version = "1.0.100" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "serde_derive" -version = "1.0.100" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "serde_json" -version = "1.0.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "sha1" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "stdweb" -version = "0.4.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-internal-macros 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "stdweb-internal-runtime 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base-x 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "syn" -version = "0.15.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "syn" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "unicode-xid" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "unicode-xid" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "wasi" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "wasm-bindgen" -version = "0.2.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-macro-support 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-backend 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "wasm-bindgen-shared 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.50" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum base-x 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "76f4eae81729e69bb1819a26c6caac956cc429238388091f98cb6cd858f16443" -"checksum bumpalo 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad807f2fc2bf185eeb98ff3a901bd46dc5ad58163d0fa4577ba0d25674d71708" -"checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" -"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" -"checksum discard 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" -"checksum getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" -"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" -"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -"checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" -"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" -"checksum packed_simd 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a85ea9fc0d4ac0deb6fe7911d38786b32fc11119afd9e9d38b84ff691ce64220" -"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" -"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -"checksum proc-macro2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e98a83a9f9b331f54b924e68a66acb1bb35cb01fb0a23645139967abefb697e8" -"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" -"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" -"checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" -"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -"checksum rand_pcg 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "16abd0c1b639e9eb4d7c50c0b8100b0d0f849be2349829c740fe8e6eb4816429" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)" = "f4473e8506b213730ff2061073b48fa51dcc66349219e2e7c5608f0296a1d95a" -"checksum serde_derive 1.0.100 (registry+https://github.com/rust-lang/crates.io-index)" = "11e410fde43e157d789fc290d26bc940778ad0fdd47836426fbac36573710dbb" -"checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" -"checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" -"checksum stdweb 0.4.18 (registry+https://github.com/rust-lang/crates.io-index)" = "a68c0ce28cf7400ed022e18da3c4591e14e1df02c70e93573cc59921b3923aeb" -"checksum stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e21ebd9179de08f2300a65454268a17ea3de204627458588c84319c4def3930" -"checksum stdweb-internal-macros 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e68f7d08b76979a43e93fe043b66d2626e35d41d68b0b85519202c6dd8ac59fa" -"checksum stdweb-internal-runtime 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d52317523542cc0af5b7e31017ad0f7d1e78da50455e38d5657cd17754f617da" -"checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" -"checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" -"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" -"checksum wasi 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d" -"checksum wasm-bindgen 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "dcddca308b16cd93c2b67b126c688e5467e4ef2e28200dc7dfe4ae284f2faefc" -"checksum wasm-bindgen-backend 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "f805d9328b5fc7e5c6399960fd1889271b9b58ae17bdb2417472156cc9fafdd0" -"checksum wasm-bindgen-macro 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "3ff88201a482abfc63921621f6cb18eb1efd74f136b05e5841e7f8ca434539e9" -"checksum wasm-bindgen-macro-support 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "6a433d89ecdb9f77d46fcf00c8cf9f3467b7de9954d8710c175f61e2e245bb0e" -"checksum wasm-bindgen-shared 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "d41fc1bc3570cdf8d108c15e014045fd45a95bb5eb36605f96a90461fc34027d" diff -Nru cargo-0.57.0+ubuntu/vendor/rand/Cargo.toml cargo-0.58.0/vendor/rand/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/rand/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -13,13 +13,13 @@ [package] edition = "2018" name = "rand" -version = "0.7.3" +version = "0.8.4" authors = ["The Rand Project Developers", "The Rust Project Developers"] -exclude = ["/utils/*", "/.travis.yml", "/appveyor.yml", ".gitignore"] +include = ["src/", "LICENSE-*", "README.md", "CHANGELOG.md", "COPYRIGHT"] autobenches = true description = "Random number generators and other randomness functionality.\n" -homepage = "https://crates.io/crates/rand" -documentation = "https://rust-random.github.io/rand/" +homepage = "https://rust-random.github.io/book" +documentation = "https://docs.rs/rand" readme = "README.md" keywords = ["random", "rng"] categories = ["algorithms", "no-std"] @@ -27,54 +27,55 @@ repository = "https://github.com/rust-random/rand" [package.metadata.docs.rs] all-features = true -[dependencies.getrandom_package] -version = "0.1.1" -optional = true -package = "getrandom" +rustdoc-args = ["--cfg", "doc_cfg"] +[package.metadata.playground] +features = ["small_rng", "serde1"] [dependencies.log] version = "0.4.4" optional = true [dependencies.packed_simd] -version = "0.3" +version = "0.3.5" features = ["into_bits"] optional = true +package = "packed_simd_2" [dependencies.rand_core] -version = "0.5.1" +version = "0.6.0" -[dependencies.rand_pcg] -version = "0.2" +[dependencies.serde] +version = "1.0.103" +features = ["derive"] optional = true +[dev-dependencies.bincode] +version = "1.2.1" + [dev-dependencies.rand_hc] -version = "0.2" +version = "0.3.0" [dev-dependencies.rand_pcg] -version = "0.2" +version = "0.3.0" [features] alloc = ["rand_core/alloc"] -default = ["std"] -getrandom = ["getrandom_package", "rand_core/getrandom"] -nightly = ["simd_support"] -serde1 = [] +default = ["std", "std_rng"] +getrandom = ["rand_core/getrandom"] +min_const_gen = [] +nightly = [] +serde1 = ["serde", "rand_core/serde1"] simd_support = ["packed_simd"] -small_rng = ["rand_pcg"] +small_rng = [] std = ["rand_core/std", "rand_chacha/std", "alloc", "getrandom", "libc"] -stdweb = ["getrandom_package/stdweb"] -wasm-bindgen = ["getrandom_package/wasm-bindgen"] +std_rng = ["rand_chacha", "rand_hc"] [target."cfg(not(target_os = \"emscripten\"))".dependencies.rand_chacha] -version = "0.2.1" +version = "0.3.0" +optional = true default-features = false [target."cfg(target_os = \"emscripten\")".dependencies.rand_hc] -version = "0.2" +version = "0.3.0" +optional = true [target."cfg(unix)".dependencies.libc] version = "0.2.22" optional = true default-features = false -[badges.appveyor] -repository = "rust-random/rand" - -[badges.travis-ci] -repository = "rust-random/rand" diff -Nru cargo-0.57.0+ubuntu/vendor/rand/CHANGELOG.md cargo-0.58.0/vendor/rand/CHANGELOG.md --- cargo-0.57.0+ubuntu/vendor/rand/CHANGELOG.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 @@ -8,6 +8,89 @@ You may also find the [Upgrade Guide](https://rust-random.github.io/book/update.html) useful. +## [0.8.4] - 2021-06-15 +### Additions +- Use const-generics to support arrays of all sizes (#1104) +- Implement `Clone` and `Copy` for `Alphanumeric` (#1126) +- Add `Distribution::map` to derive a distribution using a closure (#1129) +- Add `Slice` distribution (#1107) +- Add `DistString` trait with impls for `Standard` and `Alphanumeric` (#1133) + +### Other +- Reorder asserts in `Uniform` float distributions for easier debugging of non-finite arguments + (#1094, #1108) +- Add range overflow check in `Uniform` float distributions (#1108) +- Deprecate `rngs::adapter::ReadRng` (#1130) + +## [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 + providing a full integer range (eg `0..=MAX`) (#1087) + +## [0.8.1] - 2020-12-31 +### Other +- Enable all stable features in the playground (#1081) + +## [0.8.0] - 2020-12-18 +### Platform support +- The minimum supported Rust version is now 1.36 (#1011) +- `getrandom` updated to v0.2 (#1041) +- Remove `wasm-bindgen` and `stdweb` feature flags. For details of WASM support, + see the [getrandom documentation](https://docs.rs/getrandom/latest). (#948) +- `ReadRng::next_u32` and `next_u64` now use little-Endian conversion instead + of native-Endian, affecting results on Big-Endian platforms (#1061) +- The `nightly` feature no longer implies the `simd_support` feature (#1048) +- Fix `simd_support` feature to work on current nightlies (#1056) + +### Rngs +- `ThreadRng` is no longer `Copy` to enable safe usage within thread-local destructors (#1035) +- `gen_range(a, b)` was replaced with `gen_range(a..b)`. `gen_range(a..=b)` is + also supported. Note that `a` and `b` can no longer be references or SIMD types. (#744, #1003) +- Replace `AsByteSliceMut` with `Fill` and add support for `[bool], [char], [f32], [f64]` (#940) +- Restrict `rand::rngs::adapter` to `std` (#1027; see also #928) +- `StdRng`: add new `std_rng` feature flag (enabled by default, but might need + to be used if disabling default crate features) (#948) +- `StdRng`: Switch from ChaCha20 to ChaCha12 for better performance (#1028) +- `SmallRng`: Replace PCG algorithm with xoshiro{128,256}++ (#1038) + +### Sequences +- Add `IteratorRandom::choose_stable` as an alternative to `choose` which does + not depend on size hints (#1057) +- Improve accuracy and performance of `IteratorRandom::choose` (#1059) +- Implement `IntoIterator` for `IndexVec`, replacing the `into_iter` method (#1007) +- Add value stability tests for `seq` module (#933) + +### Misc +- Support `PartialEq` and `Eq` for `StdRng`, `SmallRng` and `StepRng` (#979) +- Added a `serde1` feature and added Serialize/Deserialize to `UniformInt` and `WeightedIndex` (#974) +- Drop some unsafe code (#962, #963, #1011) +- Reduce packaged crate size (#983) +- Migrate to GitHub Actions from Travis+AppVeyor (#1073) + +### Distributions +- `Alphanumeric` samples bytes instead of chars (#935) +- `Uniform` now supports `char`, enabling `rng.gen_range('A'..='Z')` (#1068) +- Add `UniformSampler::sample_single_inclusive` (#1003) + +#### Weighted sampling +- Implement weighted sampling without replacement (#976, #1013) +- `rand::distributions::alias_method::WeightedIndex` was moved to `rand_distr::WeightedAliasIndex`. + The simpler alternative `rand::distribution::WeightedIndex` remains. (#945) +- Improve treatment of rounding errors in `WeightedIndex::update_weights` (#956) +- `WeightedIndex`: return error on NaN instead of panic (#1005) + +### Documentation +- Document types supported by `random` (#994) +- Document notes on password generation (#995) +- Note that `SmallRng` may not be the best choice for performance and in some + other cases (#1038) +- Use `doc(cfg)` to annotate feature-gated items (#1019) +- Adjust README (#1065) + ## [0.7.3] - 2020-01-10 ### Fixes - The `Bernoulli` distribution constructors now reports an error on NaN and on @@ -40,7 +123,7 @@ - Fix or squelch issues from Clippy lints (#840) ### Additions -- Add a `no_std` target to CI to continously evaluate `no_std` status (#844) +- Add a `no_std` target to CI to continuously evaluate `no_std` status (#844) - `WeightedIndex`: allow adjusting a sub-set of weights (#866) ## [0.7.0] - 2019-06-28 @@ -400,7 +483,7 @@ ## [0.3.14] - 2016-02-13 ### Fixed -- Inline definitions from winapi/advapi32, wich decreases build times +- Inline definitions from winapi/advapi32, which decreases build times ## [0.3.13] - 2016-01-09 diff -Nru cargo-0.57.0+ubuntu/vendor/rand/debian/patches/Remove-__m64-support.diff cargo-0.58.0/vendor/rand/debian/patches/Remove-__m64-support.diff --- cargo-0.57.0+ubuntu/vendor/rand/debian/patches/Remove-__m64-support.diff 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/debian/patches/Remove-__m64-support.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -This patch is based on the commit described below -modified by Peter Michael Green to apply to -rust-rand 0.7.3 - -commit fe34550f4ef28056c73a785f54f908f8fc13070b -Author: Vinzent Steinberg -Date: Thu Oct 8 18:36:49 2020 +0200 - - Remove `__m64` support - - This is necessary, because support for `__m64` was removed from nighly - Rust [1]. - - Fixes #1050. - - [1] https://github.com/rust-lang/stdarch/issues/823 - -Index: rand/src/distributions/integer.rs -=================================================================== ---- rand.orig/src/distributions/integer.rs -+++ rand/src/distributions/integer.rs -@@ -158,7 +158,7 @@ simd_impl!(512, u8x64, i8x64, u16x32, i1 - feature = "nightly", - any(target_arch = "x86", target_arch = "x86_64") - ))] --simd_impl!((__m64, u8x8), (__m128i, u8x16), (__m256i, u8x32),); -+simd_impl!((__m128i, u8x16), (__m256i, u8x32),); - - #[cfg(test)] - mod tests { -Index: rand/src/distributions/utils.rs -=================================================================== ---- rand.orig/src/distributions/utils.rs -+++ rand/src/distributions/utils.rs -@@ -161,7 +161,6 @@ mod simd_wmul { - } - - wmul_impl! { (u16x2, u32x2),, 16 } -- #[cfg(not(target_feature = "sse2"))] - wmul_impl! { (u16x4, u32x4),, 16 } - #[cfg(not(target_feature = "sse4.2"))] - wmul_impl! { (u16x8, u32x8),, 16 } -@@ -188,8 +187,6 @@ mod simd_wmul { - }; - } - -- #[cfg(target_feature = "sse2")] -- wmul_impl_16! { u16x4, __m64, _mm_mulhi_pu16, _mm_mullo_pi16 } - #[cfg(target_feature = "sse4.2")] - wmul_impl_16! { u16x8, __m128i, _mm_mulhi_epu16, _mm_mullo_epi16 } - #[cfg(target_feature = "avx2")] diff -Nru cargo-0.57.0+ubuntu/vendor/rand/debian/patches/series cargo-0.58.0/vendor/rand/debian/patches/series --- cargo-0.57.0+ubuntu/vendor/rand/debian/patches/series 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -Remove-__m64-support.diff diff -Nru cargo-0.57.0+ubuntu/vendor/rand/examples/monte-carlo.rs cargo-0.58.0/vendor/rand/examples/monte-carlo.rs --- cargo-0.57.0+ubuntu/vendor/rand/examples/monte-carlo.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/examples/monte-carlo.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// Copyright 2013-2018 The Rust Project Developers. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! # Monte Carlo estimation of π -//! -//! Imagine that we have a square with sides of length 2 and a unit circle -//! (radius = 1), both centered at the origin. The areas are: -//! -//! ```text -//! area of circle = πr² = π * r * r = π -//! area of square = 2² = 4 -//! ``` -//! -//! The circle is entirely within the square, so if we sample many points -//! randomly from the square, roughly π / 4 of them should be inside the circle. -//! -//! We can use the above fact to estimate the value of π: pick many points in -//! the square at random, calculate the fraction that fall within the circle, -//! and multiply this fraction by 4. - -#![cfg(feature = "std")] - -use rand::distributions::{Distribution, Uniform}; - -fn main() { - let range = Uniform::new(-1.0f64, 1.0); - let mut rng = rand::thread_rng(); - - let total = 1_000_000; - let mut in_circle = 0; - - for _ in 0..total { - let a = range.sample(&mut rng); - let b = range.sample(&mut rng); - if a * a + b * b <= 1.0 { - in_circle += 1; - } - } - - // prints something close to 3.14159... - println!( - "π is approximately {}", - 4. * (in_circle as f64) / (total as f64) - ); -} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/examples/monty-hall.rs cargo-0.58.0/vendor/rand/examples/monty-hall.rs --- cargo-0.57.0+ubuntu/vendor/rand/examples/monty-hall.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/examples/monty-hall.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,123 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// Copyright 2013-2018 The Rust Project Developers. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! ## Monty Hall Problem -//! -//! This is a simulation of the [Monty Hall Problem][]: -//! -//! > Suppose you're on a game show, and you're given the choice of three doors: -//! > Behind one door is a car; behind the others, goats. You pick a door, say -//! > No. 1, and the host, who knows what's behind the doors, opens another -//! > door, say No. 3, which has a goat. He then says to you, "Do you want to -//! > pick door No. 2?" Is it to your advantage to switch your choice? -//! -//! The rather unintuitive answer is that you will have a 2/3 chance of winning -//! if you switch and a 1/3 chance of winning if you don't, so it's better to -//! switch. -//! -//! This program will simulate the game show and with large enough simulation -//! steps it will indeed confirm that it is better to switch. -//! -//! [Monty Hall Problem]: https://en.wikipedia.org/wiki/Monty_Hall_problem - -#![cfg(feature = "std")] - -use rand::distributions::{Distribution, Uniform}; -use rand::Rng; - -struct SimulationResult { - win: bool, - switch: bool, -} - -// Run a single simulation of the Monty Hall problem. -fn simulate(random_door: &Uniform, rng: &mut R) -> SimulationResult { - let car = random_door.sample(rng); - - // This is our initial choice - let mut choice = random_door.sample(rng); - - // The game host opens a door - let open = game_host_open(car, choice, rng); - - // Shall we switch? - let switch = rng.gen(); - if switch { - choice = switch_door(choice, open); - } - - SimulationResult { - win: choice == car, - switch, - } -} - -// Returns the door the game host opens given our choice and knowledge of -// where the car is. The game host will never open the door with the car. -fn game_host_open(car: u32, choice: u32, rng: &mut R) -> u32 { - use rand::seq::SliceRandom; - *free_doors(&[car, choice]).choose(rng).unwrap() -} - -// Returns the door we switch to, given our current choice and -// the open door. There will only be one valid door. -fn switch_door(choice: u32, open: u32) -> u32 { - free_doors(&[choice, open])[0] -} - -fn free_doors(blocked: &[u32]) -> Vec { - (0..3).filter(|x| !blocked.contains(x)).collect() -} - -fn main() { - // The estimation will be more accurate with more simulations - let num_simulations = 10000; - - let mut rng = rand::thread_rng(); - let random_door = Uniform::new(0u32, 3); - - let (mut switch_wins, mut switch_losses) = (0, 0); - let (mut keep_wins, mut keep_losses) = (0, 0); - - println!("Running {} simulations...", num_simulations); - for _ in 0..num_simulations { - let result = simulate(&random_door, &mut rng); - - match (result.win, result.switch) { - (true, true) => switch_wins += 1, - (true, false) => keep_wins += 1, - (false, true) => switch_losses += 1, - (false, false) => keep_losses += 1, - } - } - - let total_switches = switch_wins + switch_losses; - let total_keeps = keep_wins + keep_losses; - - println!( - "Switched door {} times with {} wins and {} losses", - total_switches, switch_wins, switch_losses - ); - - println!( - "Kept our choice {} times with {} wins and {} losses", - total_keeps, keep_wins, keep_losses - ); - - // With a large number of simulations, the values should converge to - // 0.667 and 0.333 respectively. - println!( - "Estimated chance to win if we switch: {}", - switch_wins as f32 / total_switches as f32 - ); - println!( - "Estimated chance to win if we don't: {}", - keep_wins as f32 / total_keeps as f32 - ); -} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/README.md cargo-0.58.0/vendor/rand/README.md --- cargo-0.57.0+ubuntu/vendor/rand/README.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/README.md 2022-01-21 02:47:39.000000000 +0000 @@ -1,26 +1,47 @@ # Rand -[![Build Status](https://travis-ci.org/rust-random/rand.svg?branch=master)](https://travis-ci.org/rust-random/rand) -[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand) +[![Test Status](https://github.com/rust-random/rand/workflows/Tests/badge.svg?event=push)](https://github.com/rust-random/rand/actions) [![Crate](https://img.shields.io/crates/v/rand.svg)](https://crates.io/crates/rand) [![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) -[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand) +[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand) [![API](https://docs.rs/rand/badge.svg)](https://docs.rs/rand) -[![Minimum rustc version](https://img.shields.io/badge/rustc-1.32+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) +[![Minimum rustc version](https://img.shields.io/badge/rustc-1.36+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) -A Rust library for random number generation. +A Rust library for random number generation, featuring: -Rand provides utilities to generate random numbers, to convert them to useful -types and distributions, and some randomness-related algorithms. - -The core random number generation traits of Rand live in the [rand_core]( -https://crates.io/crates/rand_core) crate but are also exposed here; RNG -implementations should prefer to use `rand_core` while most other users should -depend on `rand`. +- Easy random value generation and usage via the [`Rng`](https://docs.rs/rand/*/rand/trait.Rng.html), + [`SliceRandom`](https://docs.rs/rand/*/rand/seq/trait.SliceRandom.html) and + [`IteratorRandom`](https://docs.rs/rand/*/rand/seq/trait.IteratorRandom.html) traits +- Secure seeding via the [`getrandom` crate](https://crates.io/crates/getrandom) + and fast, convenient generation via [`thread_rng`](https://docs.rs/rand/*/rand/fn.thread_rng.html) +- A modular design built over [`rand_core`](https://crates.io/crates/rand_core) + ([see the book](https://rust-random.github.io/book/crates.html)) +- Fast implementations of the best-in-class [cryptographic](https://rust-random.github.io/book/guide-rngs.html#cryptographically-secure-pseudo-random-number-generators-csprngs) and + [non-cryptographic](https://rust-random.github.io/book/guide-rngs.html#basic-pseudo-random-number-generators-prngs) generators +- A flexible [`distributions`](https://docs.rs/rand/*/rand/distributions/index.html) module +- Samplers for a large number of random number distributions via our own + [`rand_distr`](https://docs.rs/rand_distr) and via + the [`statrs`](https://docs.rs/statrs/0.13.0/statrs/) +- [Portably reproducible output](https://rust-random.github.io/book/portability.html) +- `#[no_std]` compatibility (partial) +- *Many* performance optimisations + +It's also worth pointing out what `rand` *is not*: + +- Small. Most low-level crates are small, but the higher-level `rand` and + `rand_distr` each contain a lot of functionality. +- Simple (implementation). We have a strong focus on correctness, speed and flexibility, but + not simplicity. If you prefer a small-and-simple library, there are + alternatives including [fastrand](https://crates.io/crates/fastrand) + and [oorandom](https://crates.io/crates/oorandom). +- Slow. We take performance seriously, with considerations also for set-up + time of new distributions, commonly-used parameters, and parameters of the + current sampler. Documentation: + - [The Rust Rand Book](https://rust-random.github.io/book) -- [API reference (master)](https://rust-random.github.io/rand) +- [API reference (master branch)](https://rust-random.github.io/rand) - [API reference (docs.rs)](https://docs.rs/rand) @@ -30,7 +51,7 @@ ```toml [dependencies] -rand = "0.7" +rand = "0.8.0" ``` To get started using Rand, see [The Book](https://rust-random.github.io/book). @@ -38,35 +59,36 @@ ## Versions -Rand libs have inter-dependencies and make use of the -[semver trick](https://github.com/dtolnay/semver-trick/) in order to make traits -compatible across crate versions. (This is especially important for `RngCore` -and `SeedableRng`.) A few crate releases are thus compatibility shims, -depending on the *next* lib version (e.g. `rand_core` versions `0.2.2` and -`0.3.1`). This means, for example, that `rand_core_0_4_0::SeedableRng` and -`rand_core_0_3_0::SeedableRng` are distinct, incompatible traits, which can -cause build errors. Usually, running `cargo update` is enough to fix any issues. +Rand is *mature* (suitable for general usage, with infrequent breaking releases +which minimise breakage) but not yet at 1.0. We maintain compatibility with +pinned versions of the Rust compiler (see below). -The Rand lib is not yet stable, however we are careful to limit breaking changes -and warn via deprecation wherever possible. Patch versions never introduce -breaking changes. The following minor versions are supported: +Current Rand versions are: - Version 0.7 was released in June 2019, moving most non-uniform distributions to an external crate, moving `from_entropy` to `SeedableRng`, and many small changes and fixes. -- Version 0.6 was released in November 2018, redesigning the `seq` module, - moving most PRNGs to external crates, and many small changes. -- Version 0.5 was released in May 2018, as a major reorganisation - (introducing `RngCore` and `rand_core`, and deprecating `Rand` and the - previous distribution traits). -- Version 0.4 was released in December 2017, but contained almost no breaking - changes from the 0.3 series. +- Version 0.8 was released in December 2020 with many small changes. -A detailed [changelog](CHANGELOG.md) is available. +A detailed [changelog](CHANGELOG.md) is available for releases. When upgrading to the next minor series (especially 0.4 → 0.5), we recommend reading the [Upgrade Guide](https://rust-random.github.io/book/update.html). +Rand has not yet reached 1.0 implying some breaking changes may arrive in the +future ([SemVer](https://semver.org/) allows each 0.x.0 release to include +breaking changes), but is considered *mature*: breaking changes are minimised +and breaking releases are infrequent. + +Rand libs have inter-dependencies and make use of the +[semver trick](https://github.com/dtolnay/semver-trick/) in order to make traits +compatible across crate versions. (This is especially important for `RngCore` +and `SeedableRng`.) A few crate releases are thus compatibility shims, +depending on the *next* lib version (e.g. `rand_core` versions `0.2.2` and +`0.3.1`). This means, for example, that `rand_core_0_4_0::SeedableRng` and +`rand_core_0_3_0::SeedableRng` are distinct, incompatible traits, which can +cause build errors. Usually, running `cargo update` is enough to fix any issues. + ### Yanked versions Some versions of Rand crates have been yanked ("unreleased"). Where this occurs, @@ -75,14 +97,14 @@ ### Rust version requirements -Since version 0.7, Rand requires **Rustc version 1.32 or greater**. -Rand 0.5 requires Rustc 1.22 or greater while versions -0.4 and 0.3 (since approx. June 2017) require Rustc version 1.15 or -greater. Subsets of the Rand code may work with older Rust versions, but this -is not supported. +Since version 0.8, Rand requires **Rustc version 1.36 or greater**. +Rand 0.7 requires Rustc 1.32 or greater while versions 0.5 require Rustc 1.22 or +greater, and 0.4 and 0.3 (since approx. June 2017) require Rustc version 1.15 or +greater. Subsets of the Rand code may work with older Rust versions, but this is +not supported. -Travis CI always has a build with a pinned version of Rustc matching the oldest -supported Rust release. The current policy is that this can be updated in any +Continuous Integration (CI) will always test the minimum supported Rustc version +(the MSRV). The current policy is that this can be updated in any Rand release if required, but the change must be noted in the changelog. ## Crate Features @@ -90,26 +112,26 @@ Rand is built with these features enabled by default: - `std` enables functionality dependent on the `std` lib -- `alloc` (implied by `std`) enables functionality requiring an allocator (when using this feature in `no_std`, Rand requires Rustc version 1.36 or greater) +- `alloc` (implied by `std`) enables functionality requiring an allocator - `getrandom` (implied by `std`) is an optional dependency providing the code behind `rngs::OsRng` +- `std_rng` enables inclusion of `StdRng`, `thread_rng` and `random` + (the latter two *also* require that `std` be enabled) Optionally, the following dependencies can be enabled: -- `log` enables logging via the `log` crate -- `stdweb` implies `getrandom/stdweb` to enable - `getrandom` support on `wasm32-unknown-unknown` - (will be removed in rand 0.8; activate via `getrandom` crate instead) -- `wasm-bindgen` implies `getrandom/wasm-bindgen` to enable - `getrandom` support on `wasm32-unknown-unknown` - (will be removed in rand 0.8; activate via `getrandom` crate instead) +- `log` enables logging via the `log` crate` crate Additionally, these features configure Rand: - `small_rng` enables inclusion of the `SmallRng` PRNG -- `nightly` enables all experimental features +- `nightly` enables some optimizations requiring nightly Rust - `simd_support` (experimental) enables sampling of SIMD values - (uniformly random SIMD integers and floats) + (uniformly random SIMD integers and floats), requiring nightly Rust + +Note that nightly features are not stable and therefore not all library and +compiler versions will be compatible. This is especially true of Rand's +experimental `simd_support` feature. Rand supports limited functionality in `no_std` mode (enabled via `default-features = false`). In this case, `OsRng` and `from_entropy` are @@ -117,6 +139,14 @@ unavailable (unless `alloc` is enabled), and `thread_rng` and `random` are unavailable. +### WASM support + +The WASM target `wasm32-unknown-unknown` is not *automatically* supported by +`rand` or `getrandom`. To solve this, either use a different target such as +`wasm32-wasi` or add a direct dependancy on `getrandom` with the `js` feature +(if the target supports JavaScript). See +[getrandom#WebAssembly support](https://docs.rs/getrandom/latest/getrandom/#webassembly-support). + # License Rand is distributed under the terms of both the MIT license and the diff -Nru cargo-0.57.0+ubuntu/vendor/rand/rustfmt.toml cargo-0.58.0/vendor/rand/rustfmt.toml --- cargo-0.57.0+ubuntu/vendor/rand/rustfmt.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/rustfmt.toml 1970-01-01 00:00:00.000000000 +0000 @@ -1,32 +0,0 @@ -# This rustfmt file is added for configuration, but in practice much of our -# code is hand-formatted, frequently with more readable results. - -# Comments: -normalize_comments = true -wrap_comments = false -comment_width = 90 # small excess is okay but prefer 80 - -# Arguments: -use_small_heuristics = "Default" -# TODO: single line functions only where short, please? -# https://github.com/rust-lang/rustfmt/issues/3358 -fn_single_line = false -fn_args_layout = "Compressed" -overflow_delimited_expr = true -where_single_line = true - -# enum_discrim_align_threshold = 20 -# struct_field_align_threshold = 20 - -# Compatibility: -edition = "2018" # we require compatibility back to 1.32.0 - -# Misc: -inline_attribute_width = 80 -blank_lines_upper_bound = 2 -reorder_impl_items = true -# report_todo = "Unnumbered" -# report_fixme = "Unnumbered" - -# Ignored files: -ignore = [] diff -Nru cargo-0.57.0+ubuntu/vendor/rand/SECURITY.md cargo-0.58.0/vendor/rand/SECURITY.md --- cargo-0.57.0+ubuntu/vendor/rand/SECURITY.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/SECURITY.md 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -# Security Policy - -## No guarantees - -Support is provided on a best-effort bases only. -No binding guarantees can be provided. - -## Security premises - -Rand provides the trait `rand_core::CryptoRng` aka `rand::CryptoRng` as a marker -trait. Generators implementating `RngCore` *and* `CryptoRng`, and given the -additional constraints that: - -- Instances of seedable RNGs (those implementing `SeedableRng`) are - constructed with cryptographically secure seed values -- The state (memory) of the RNG and its seed value are not be exposed - -are expected to provide the following: - -- An attacker can gain no advantage over chance (50% for each bit) in - predicting the RNG output, even with full knowledge of all prior outputs. - -For some RNGs, notably `OsRng`, `ThreadRng` and those wrapped by `ReseedingRng`, -we provide limited mitigations against side-channel attacks: - -- After a process fork on Unix, there is an upper-bound on the number of bits - output by the RNG before the processes diverge, after which outputs from - each process's RNG are uncorrelated -- After the state (memory) of an RNG is leaked, there is an upper-bound on the - number of bits of output by the RNG before prediction of output by an - observer again becomes computationally-infeasible - -Additionally, derivations from such an RNG (including the `Rng` trait, -implementations of the `Distribution` trait, and `seq` algorithms) should not -introduce signficant bias other than that expected from the operation in -question (e.g. bias from a weighted distribution). - -## Supported Versions - -We will attempt to uphold these premises in the following crate versions, -provided that only the latest patch version is used, and with potential -exceptions for theoretical issues without a known exploit: - -| Crate | Versions | Exceptions | -| ----- | -------- | ---------- | -| `rand` | 0.7 | | -| `rand` | 0.5, 0.6 | Jitter | -| `rand` | 0.4 | Jitter, ISAAC | -| `rand_core` | 0.2 - 0.5 | | -| `rand_chacha` | 0.1 - 0.2 | | -| `rand_hc` | 0.1 - 0.2 | | - -Explanation of exceptions: - -- Jitter: `JitterRng` is used as an entropy source when the primary source - fails; this source may not be secure against side-channel attacks, see #699. -- ISAAC: the [ISAAC](https://burtleburtle.net/bob/rand/isaacafa.html) RNG used - to implement `thread_rng` is difficult to analyse and thus cannot provide - strong assertions of security. - -## Known issues - -In `rand` version 0.3 (0.3.18 and later), if `OsRng` fails, `thread_rng` is -seeded from the system time in an insecure manner. - -## Reporting a Vulnerability - -To report a vulnerability, [open a new issue](https://github.com/rust-random/rand/issues/new). -Once the issue is resolved, the vulnerability should be [reported to RustSec](https://github.com/RustSec/advisory-db/blob/master/CONTRIBUTING.md). diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/bernoulli.rs cargo-0.58.0/vendor/rand/src/distributions/bernoulli.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/bernoulli.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/bernoulli.rs 2022-01-21 02:47:39.000000000 +0000 @@ -12,6 +12,8 @@ use crate::Rng; use core::{fmt, u64}; +#[cfg(feature = "serde1")] +use serde::{Serialize, Deserialize}; /// The Bernoulli distribution. /// /// This is a special case of the Binomial distribution where `n = 1`. @@ -32,6 +34,7 @@ /// so only probabilities that are multiples of 2-64 can be /// represented. #[derive(Clone, Copy, Debug)] +#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] pub struct Bernoulli { /// Probability of success, relative to the maximal integer. p_int: u64, @@ -93,7 +96,7 @@ /// 2-64 in `[0, 1]` can be represented as a `f64`.) #[inline] pub fn new(p: f64) -> Result { - if !(p >= 0.0 && p < 1.0) { + if !(0.0..1.0).contains(&p) { if p == 1.0 { return Ok(Bernoulli { p_int: ALWAYS_TRUE }); } @@ -144,7 +147,19 @@ use crate::Rng; #[test] + #[cfg(feature="serde1")] + fn test_serializing_deserializing_bernoulli() { + let coin_flip = Bernoulli::new(0.5).unwrap(); + let de_coin_flip : Bernoulli = bincode::deserialize(&bincode::serialize(&coin_flip).unwrap()).unwrap(); + + assert_eq!(coin_flip.p_int, de_coin_flip.p_int); + } + + #[test] fn test_trivial() { + // We prefer to be explicit here. + #![allow(clippy::bool_assert_comparison)] + let mut r = crate::test::rng(1); let always_false = Bernoulli::new(0.0).unwrap(); let always_true = Bernoulli::new(1.0).unwrap(); diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/binomial.rs cargo-0.58.0/vendor/rand/src/distributions/binomial.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/binomial.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/binomial.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,321 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// Copyright 2016-2017 The Rust Project Developers. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The binomial distribution. -#![allow(deprecated)] -#![allow(clippy::all)] - -use crate::distributions::{Distribution, Uniform}; -use crate::Rng; - -/// The binomial distribution `Binomial(n, p)`. -/// -/// This distribution has density function: -/// `f(k) = n!/(k! (n-k)!) p^k (1-p)^(n-k)` for `k >= 0`. -#[deprecated(since = "0.7.0", note = "moved to rand_distr crate")] -#[derive(Clone, Copy, Debug)] -pub struct Binomial { - /// Number of trials. - n: u64, - /// Probability of success. - p: f64, -} - -impl Binomial { - /// Construct a new `Binomial` with the given shape parameters `n` (number - /// of trials) and `p` (probability of success). - /// - /// Panics if `p < 0` or `p > 1`. - pub fn new(n: u64, p: f64) -> Binomial { - assert!(p >= 0.0, "Binomial::new called with p < 0"); - assert!(p <= 1.0, "Binomial::new called with p > 1"); - Binomial { n, p } - } -} - -/// Convert a `f64` to an `i64`, panicing on overflow. -// In the future (Rust 1.34), this might be replaced with `TryFrom`. -fn f64_to_i64(x: f64) -> i64 { - assert!(x < (::std::i64::MAX as f64)); - x as i64 -} - -impl Distribution for Binomial { - fn sample(&self, rng: &mut R) -> u64 { - // Handle these values directly. - if self.p == 0.0 { - return 0; - } else if self.p == 1.0 { - return self.n; - } - - // The binomial distribution is symmetrical with respect to p -> 1-p, - // k -> n-k switch p so that it is less than 0.5 - this allows for lower - // expected values we will just invert the result at the end - let p = if self.p <= 0.5 { self.p } else { 1.0 - self.p }; - - let result; - let q = 1. - p; - - // For small n * min(p, 1 - p), the BINV algorithm based on the inverse - // transformation of the binomial distribution is efficient. Otherwise, - // the BTPE algorithm is used. - // - // Voratas Kachitvichyanukul and Bruce W. Schmeiser. 1988. Binomial - // random variate generation. Commun. ACM 31, 2 (February 1988), - // 216-222. http://dx.doi.org/10.1145/42372.42381 - - // Threshold for prefering the BINV algorithm. The paper suggests 10, - // Ranlib uses 30, and GSL uses 14. - const BINV_THRESHOLD: f64 = 10.; - - if (self.n as f64) * p < BINV_THRESHOLD && self.n <= (::std::i32::MAX as u64) { - // Use the BINV algorithm. - let s = p / q; - let a = ((self.n + 1) as f64) * s; - let mut r = q.powi(self.n as i32); - let mut u: f64 = rng.gen(); - let mut x = 0; - while u > r as f64 { - u -= r; - x += 1; - r *= a / (x as f64) - s; - } - result = x; - } else { - // Use the BTPE algorithm. - - // Threshold for using the squeeze algorithm. This can be freely - // chosen based on performance. Ranlib and GSL use 20. - const SQUEEZE_THRESHOLD: i64 = 20; - - // Step 0: Calculate constants as functions of `n` and `p`. - let n = self.n as f64; - let np = n * p; - let npq = np * q; - let f_m = np + p; - let m = f64_to_i64(f_m); - // radius of triangle region, since height=1 also area of region - let p1 = (2.195 * npq.sqrt() - 4.6 * q).floor() + 0.5; - // tip of triangle - let x_m = (m as f64) + 0.5; - // left edge of triangle - let x_l = x_m - p1; - // right edge of triangle - let x_r = x_m + p1; - let c = 0.134 + 20.5 / (15.3 + (m as f64)); - // p1 + area of parallelogram region - let p2 = p1 * (1. + 2. * c); - - fn lambda(a: f64) -> f64 { - a * (1. + 0.5 * a) - } - - let lambda_l = lambda((f_m - x_l) / (f_m - x_l * p)); - let lambda_r = lambda((x_r - f_m) / (x_r * q)); - // p1 + area of left tail - let p3 = p2 + c / lambda_l; - // p1 + area of right tail - let p4 = p3 + c / lambda_r; - - // return value - let mut y: i64; - - let gen_u = Uniform::new(0., p4); - let gen_v = Uniform::new(0., 1.); - - loop { - // Step 1: Generate `u` for selecting the region. If region 1 is - // selected, generate a triangularly distributed variate. - let u = gen_u.sample(rng); - let mut v = gen_v.sample(rng); - if !(u > p1) { - y = f64_to_i64(x_m - p1 * v + u); - break; - } - - if !(u > p2) { - // Step 2: Region 2, parallelograms. Check if region 2 is - // used. If so, generate `y`. - let x = x_l + (u - p1) / c; - v = v * c + 1.0 - (x - x_m).abs() / p1; - if v > 1. { - continue; - } else { - y = f64_to_i64(x); - } - } else if !(u > p3) { - // Step 3: Region 3, left exponential tail. - y = f64_to_i64(x_l + v.ln() / lambda_l); - if y < 0 { - continue; - } else { - v *= (u - p2) * lambda_l; - } - } else { - // Step 4: Region 4, right exponential tail. - y = f64_to_i64(x_r - v.ln() / lambda_r); - if y > 0 && (y as u64) > self.n { - continue; - } else { - v *= (u - p3) * lambda_r; - } - } - - // Step 5: Acceptance/rejection comparison. - - // Step 5.0: Test for appropriate method of evaluating f(y). - let k = (y - m).abs(); - if !(k > SQUEEZE_THRESHOLD && (k as f64) < 0.5 * npq - 1.) { - // Step 5.1: Evaluate f(y) via the recursive relationship. Start the - // search from the mode. - let s = p / q; - let a = s * (n + 1.); - let mut f = 1.0; - if m < y { - let mut i = m; - loop { - i += 1; - f *= a / (i as f64) - s; - if i == y { - break; - } - } - } else if m > y { - let mut i = y; - loop { - i += 1; - f /= a / (i as f64) - s; - if i == m { - break; - } - } - } - if v > f { - continue; - } else { - break; - } - } - - // Step 5.2: Squeezing. Check the value of ln(v) againts upper and - // lower bound of ln(f(y)). - let k = k as f64; - let rho = (k / npq) * ((k * (k / 3. + 0.625) + 1. / 6.) / npq + 0.5); - let t = -0.5 * k * k / npq; - let alpha = v.ln(); - if alpha < t - rho { - break; - } - if alpha > t + rho { - continue; - } - - // Step 5.3: Final acceptance/rejection test. - let x1 = (y + 1) as f64; - let f1 = (m + 1) as f64; - let z = (f64_to_i64(n) + 1 - m) as f64; - let w = (f64_to_i64(n) - y + 1) as f64; - - fn stirling(a: f64) -> f64 { - let a2 = a * a; - (13860. - (462. - (132. - (99. - 140. / a2) / a2) / a2) / a2) / a / 166320. - } - - if alpha - > x_m * (f1 / x1).ln() - + (n - (m as f64) + 0.5) * (z / w).ln() - + ((y - m) as f64) * (w * p / (x1 * q)).ln() - // We use the signs from the GSL implementation, which are - // different than the ones in the reference. According to - // the GSL authors, the new signs were verified to be - // correct by one of the original designers of the - // algorithm. - + stirling(f1) - + stirling(z) - - stirling(x1) - - stirling(w) - { - continue; - } - - break; - } - assert!(y >= 0); - result = y as u64; - } - - // Invert the result for p < 0.5. - if p != self.p { - self.n - result - } else { - result - } - } -} - -#[cfg(test)] -mod test { - use super::Binomial; - use crate::distributions::Distribution; - use crate::Rng; - - fn test_binomial_mean_and_variance(n: u64, p: f64, rng: &mut R) { - let binomial = Binomial::new(n, p); - - let expected_mean = n as f64 * p; - let expected_variance = n as f64 * p * (1.0 - p); - - let mut results = [0.0; 1000]; - for i in results.iter_mut() { - *i = binomial.sample(rng) as f64; - } - - let mean = results.iter().sum::() / results.len() as f64; - assert!( - (mean as f64 - expected_mean).abs() < expected_mean / 50.0, - "mean: {}, expected_mean: {}", - mean, - expected_mean - ); - - let variance = - results.iter().map(|x| (x - mean) * (x - mean)).sum::() / results.len() as f64; - assert!( - (variance - expected_variance).abs() < expected_variance / 10.0, - "variance: {}, expected_variance: {}", - variance, - expected_variance - ); - } - - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_binomial() { - let mut rng = crate::test::rng(351); - test_binomial_mean_and_variance(150, 0.1, &mut rng); - test_binomial_mean_and_variance(70, 0.6, &mut rng); - test_binomial_mean_and_variance(40, 0.5, &mut rng); - test_binomial_mean_and_variance(20, 0.7, &mut rng); - test_binomial_mean_and_variance(20, 0.5, &mut rng); - } - - #[test] - fn test_binomial_end_points() { - let mut rng = crate::test::rng(352); - assert_eq!(rng.sample(Binomial::new(20, 0.0)), 0); - assert_eq!(rng.sample(Binomial::new(20, 1.0)), 20); - } - - #[test] - #[should_panic] - fn test_binomial_invalid_lambda_neg() { - Binomial::new(20, -10.0); - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/cauchy.rs cargo-0.58.0/vendor/rand/src/distributions/cauchy.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/cauchy.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/cauchy.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,99 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// Copyright 2016-2017 The Rust Project Developers. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The Cauchy distribution. -#![allow(deprecated)] -#![allow(clippy::all)] - -use crate::distributions::Distribution; -use crate::Rng; -use std::f64::consts::PI; - -/// The Cauchy distribution `Cauchy(median, scale)`. -/// -/// This distribution has a density function: -/// `f(x) = 1 / (pi * scale * (1 + ((x - median) / scale)^2))` -#[deprecated(since = "0.7.0", note = "moved to rand_distr crate")] -#[derive(Clone, Copy, Debug)] -pub struct Cauchy { - median: f64, - scale: f64, -} - -impl Cauchy { - /// Construct a new `Cauchy` with the given shape parameters - /// `median` the peak location and `scale` the scale factor. - /// Panics if `scale <= 0`. - pub fn new(median: f64, scale: f64) -> Cauchy { - assert!(scale > 0.0, "Cauchy::new called with scale factor <= 0"); - Cauchy { median, scale } - } -} - -impl Distribution for Cauchy { - fn sample(&self, rng: &mut R) -> f64 { - // sample from [0, 1) - let x = rng.gen::(); - // get standard cauchy random number - // note that π/2 is not exactly representable, even if x=0.5 the result is finite - let comp_dev = (PI * x).tan(); - // shift and scale according to parameters - let result = self.median + self.scale * comp_dev; - result - } -} - -#[cfg(test)] -mod test { - use super::Cauchy; - use crate::distributions::Distribution; - - fn median(mut numbers: &mut [f64]) -> f64 { - sort(&mut numbers); - let mid = numbers.len() / 2; - numbers[mid] - } - - fn sort(numbers: &mut [f64]) { - numbers.sort_by(|a, b| a.partial_cmp(b).unwrap()); - } - - #[test] - fn test_cauchy_averages() { - // NOTE: given that the variance and mean are undefined, - // this test does not have any rigorous statistical meaning. - let cauchy = Cauchy::new(10.0, 5.0); - let mut rng = crate::test::rng(123); - let mut numbers: [f64; 1000] = [0.0; 1000]; - let mut sum = 0.0; - for i in 0..1000 { - numbers[i] = cauchy.sample(&mut rng); - sum += numbers[i]; - } - let median = median(&mut numbers); - println!("Cauchy median: {}", median); - assert!((median - 10.0).abs() < 0.4); // not 100% certain, but probable enough - let mean = sum / 1000.0; - println!("Cauchy mean: {}", mean); - // for a Cauchy distribution the mean should not converge - assert!((mean - 10.0).abs() > 0.4); // not 100% certain, but probable enough - } - - #[test] - #[should_panic] - fn test_cauchy_invalid_scale_zero() { - Cauchy::new(0.0, 0.0); - } - - #[test] - #[should_panic] - fn test_cauchy_invalid_scale_neg() { - Cauchy::new(0.0, -10.0); - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/dirichlet.rs cargo-0.58.0/vendor/rand/src/distributions/dirichlet.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/dirichlet.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/dirichlet.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,126 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// Copyright 2013 The Rust Project Developers. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The dirichlet distribution. -#![allow(deprecated)] -#![allow(clippy::all)] - -use crate::distributions::gamma::Gamma; -use crate::distributions::Distribution; -use crate::Rng; - -/// The dirichelet distribution `Dirichlet(alpha)`. -/// -/// The Dirichlet distribution is a family of continuous multivariate -/// probability distributions parameterized by a vector alpha of positive reals. -/// It is a multivariate generalization of the beta distribution. -#[deprecated(since = "0.7.0", note = "moved to rand_distr crate")] -#[derive(Clone, Debug)] -pub struct Dirichlet { - /// Concentration parameters (alpha) - alpha: Vec, -} - -impl Dirichlet { - /// Construct a new `Dirichlet` with the given alpha parameter `alpha`. - /// - /// # Panics - /// - if `alpha.len() < 2` - #[inline] - pub fn new>>(alpha: V) -> Dirichlet { - let a = alpha.into(); - assert!(a.len() > 1); - for i in 0..a.len() { - assert!(a[i] > 0.0); - } - - Dirichlet { alpha: a } - } - - /// Construct a new `Dirichlet` with the given shape parameter `alpha` and `size`. - /// - /// # Panics - /// - if `alpha <= 0.0` - /// - if `size < 2` - #[inline] - pub fn new_with_param(alpha: f64, size: usize) -> Dirichlet { - assert!(alpha > 0.0); - assert!(size > 1); - Dirichlet { - alpha: vec![alpha; size], - } - } -} - -impl Distribution> for Dirichlet { - fn sample(&self, rng: &mut R) -> Vec { - let n = self.alpha.len(); - let mut samples = vec![0.0f64; n]; - let mut sum = 0.0f64; - - for i in 0..n { - let g = Gamma::new(self.alpha[i], 1.0); - samples[i] = g.sample(rng); - sum += samples[i]; - } - let invacc = 1.0 / sum; - for i in 0..n { - samples[i] *= invacc; - } - samples - } -} - -#[cfg(test)] -mod test { - use super::Dirichlet; - use crate::distributions::Distribution; - - #[test] - fn test_dirichlet() { - let d = Dirichlet::new(vec![1.0, 2.0, 3.0]); - let mut rng = crate::test::rng(221); - let samples = d.sample(&mut rng); - let _: Vec = samples - .into_iter() - .map(|x| { - assert!(x > 0.0); - x - }) - .collect(); - } - - #[test] - fn test_dirichlet_with_param() { - let alpha = 0.5f64; - let size = 2; - let d = Dirichlet::new_with_param(alpha, size); - let mut rng = crate::test::rng(221); - let samples = d.sample(&mut rng); - let _: Vec = samples - .into_iter() - .map(|x| { - assert!(x > 0.0); - x - }) - .collect(); - } - - #[test] - #[should_panic] - fn test_dirichlet_invalid_length() { - Dirichlet::new_with_param(0.5f64, 1); - } - - #[test] - #[should_panic] - fn test_dirichlet_invalid_alpha() { - Dirichlet::new_with_param(0.0f64, 2); - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/distribution.rs cargo-0.58.0/vendor/rand/src/distributions/distribution.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/distribution.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/distribution.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,272 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2013-2017 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Distribution trait and associates + +use crate::Rng; +use core::iter; +#[cfg(feature = "alloc")] +use alloc::string::String; + +/// Types (distributions) that can be used to create a random instance of `T`. +/// +/// It is possible to sample from a distribution through both the +/// `Distribution` and [`Rng`] traits, via `distr.sample(&mut rng)` and +/// `rng.sample(distr)`. They also both offer the [`sample_iter`] method, which +/// produces an iterator that samples from the distribution. +/// +/// All implementations are expected to be immutable; this has the significant +/// advantage of not needing to consider thread safety, and for most +/// distributions efficient state-less sampling algorithms are available. +/// +/// Implementations are typically expected to be portable with reproducible +/// results when used with a PRNG with fixed seed; see the +/// [portability chapter](https://rust-random.github.io/book/portability.html) +/// of The Rust Rand Book. In some cases this does not apply, e.g. the `usize` +/// type requires different sampling on 32-bit and 64-bit machines. +/// +/// [`sample_iter`]: Distribution::sample_iter +pub trait Distribution { + /// Generate a random value of `T`, using `rng` as the source of randomness. + fn sample(&self, rng: &mut R) -> T; + + /// Create an iterator that generates random values of `T`, using `rng` as + /// the source of randomness. + /// + /// Note that this function takes `self` by value. This works since + /// `Distribution` is impl'd for `&D` where `D: Distribution`, + /// however borrowing is not automatic hence `distr.sample_iter(...)` may + /// need to be replaced with `(&distr).sample_iter(...)` to borrow or + /// `(&*distr).sample_iter(...)` to reborrow an existing reference. + /// + /// # Example + /// + /// ``` + /// use rand::thread_rng; + /// use rand::distributions::{Distribution, Alphanumeric, Uniform, Standard}; + /// + /// let mut rng = thread_rng(); + /// + /// // Vec of 16 x f32: + /// let v: Vec = Standard.sample_iter(&mut rng).take(16).collect(); + /// + /// // String: + /// let s: String = Alphanumeric + /// .sample_iter(&mut rng) + /// .take(7) + /// .map(char::from) + /// .collect(); + /// + /// // Dice-rolling: + /// let die_range = Uniform::new_inclusive(1, 6); + /// let mut roll_die = die_range.sample_iter(&mut rng); + /// while roll_die.next().unwrap() != 6 { + /// println!("Not a 6; rolling again!"); + /// } + /// ``` + fn sample_iter(self, rng: R) -> DistIter + where + R: Rng, + Self: Sized, + { + DistIter { + distr: self, + rng, + phantom: ::core::marker::PhantomData, + } + } + + /// Create a distribution of values of 'S' by mapping the output of `Self` + /// through the closure `F` + /// + /// # Example + /// + /// ``` + /// use rand::thread_rng; + /// use rand::distributions::{Distribution, Uniform}; + /// + /// let mut rng = thread_rng(); + /// + /// let die = Uniform::new_inclusive(1, 6); + /// let even_number = die.map(|num| num % 2 == 0); + /// while !even_number.sample(&mut rng) { + /// println!("Still odd; rolling again!"); + /// } + /// ``` + fn map(self, func: F) -> DistMap + where + F: Fn(T) -> S, + Self: Sized, + { + DistMap { + distr: self, + func, + phantom: ::core::marker::PhantomData, + } + } +} + +impl<'a, T, D: Distribution> Distribution for &'a D { + fn sample(&self, rng: &mut R) -> T { + (*self).sample(rng) + } +} + +/// An iterator that generates random values of `T` with distribution `D`, +/// using `R` as the source of randomness. +/// +/// This `struct` is created by the [`sample_iter`] method on [`Distribution`]. +/// See its documentation for more. +/// +/// [`sample_iter`]: Distribution::sample_iter +#[derive(Debug)] +pub struct DistIter { + distr: D, + rng: R, + phantom: ::core::marker::PhantomData, +} + +impl Iterator for DistIter +where + D: Distribution, + R: Rng, +{ + type Item = T; + + #[inline(always)] + fn next(&mut self) -> Option { + // Here, self.rng may be a reference, but we must take &mut anyway. + // Even if sample could take an R: Rng by value, we would need to do this + // since Rng is not copyable and we cannot enforce that this is "reborrowable". + Some(self.distr.sample(&mut self.rng)) + } + + fn size_hint(&self) -> (usize, Option) { + (usize::max_value(), None) + } +} + +impl iter::FusedIterator for DistIter +where + D: Distribution, + R: Rng, +{ +} + +#[cfg(features = "nightly")] +impl iter::TrustedLen for DistIter +where + D: Distribution, + R: Rng, +{ +} + +/// A distribution of values of type `S` derived from the distribution `D` +/// by mapping its output of type `T` through the closure `F`. +/// +/// This `struct` is created by the [`Distribution::map`] method. +/// See its documentation for more. +#[derive(Debug)] +pub struct DistMap { + distr: D, + func: F, + phantom: ::core::marker::PhantomData S>, +} + +impl Distribution for DistMap +where + D: Distribution, + F: Fn(T) -> S, +{ + fn sample(&self, rng: &mut R) -> S { + (self.func)(self.distr.sample(rng)) + } +} + +/// `String` sampler +/// +/// Sampling a `String` of random characters is not quite the same as collecting +/// a sequence of chars. This trait contains some helpers. +#[cfg(feature = "alloc")] +pub trait DistString { + /// Append `len` random chars to `string` + fn append_string(&self, rng: &mut R, string: &mut String, len: usize); + + /// Generate a `String` of `len` random chars + #[inline] + fn sample_string(&self, rng: &mut R, len: usize) -> String { + let mut s = String::new(); + self.append_string(rng, &mut s, len); + s + } +} + +#[cfg(test)] +mod tests { + use crate::distributions::{Alphanumeric, Distribution, Standard, Uniform}; + use crate::Rng; + + #[test] + fn test_distributions_iter() { + use crate::distributions::Open01; + let mut rng = crate::test::rng(210); + let distr = Open01; + let mut iter = Distribution::::sample_iter(distr, &mut rng); + let mut sum: f32 = 0.; + for _ in 0..100 { + sum += iter.next().unwrap(); + } + assert!(0. < sum && sum < 100.); + } + + #[test] + fn test_distributions_map() { + let dist = Uniform::new_inclusive(0, 5).map(|val| val + 15); + + let mut rng = crate::test::rng(212); + let val = dist.sample(&mut rng); + assert!(val >= 15 && val <= 20); + } + + #[test] + fn test_make_an_iter() { + fn ten_dice_rolls_other_than_five( + rng: &mut R, + ) -> impl Iterator + '_ { + Uniform::new_inclusive(1, 6) + .sample_iter(rng) + .filter(|x| *x != 5) + .take(10) + } + + let mut rng = crate::test::rng(211); + let mut count = 0; + for val in ten_dice_rolls_other_than_five(&mut rng) { + assert!((1..=6).contains(&val) && val != 5); + count += 1; + } + assert_eq!(count, 10); + } + + #[test] + #[cfg(feature = "alloc")] + fn test_dist_string() { + use core::str; + use crate::distributions::DistString; + let mut rng = crate::test::rng(213); + + let s1 = Alphanumeric.sample_string(&mut rng, 20); + assert_eq!(s1.len(), 20); + assert_eq!(str::from_utf8(s1.as_bytes()), Ok(s1.as_str())); + + let s2 = Standard.sample_string(&mut rng, 20); + assert_eq!(s2.chars().count(), 20); + assert_eq!(str::from_utf8(s2.as_bytes()), Ok(s2.as_str())); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/exponential.rs cargo-0.58.0/vendor/rand/src/distributions/exponential.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/exponential.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/exponential.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,114 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// Copyright 2013 The Rust Project Developers. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The exponential distribution. -#![allow(deprecated)] - -use crate::distributions::utils::ziggurat; -use crate::distributions::{ziggurat_tables, Distribution}; -use crate::Rng; - -/// Samples floating-point numbers according to the exponential distribution, -/// with rate parameter `λ = 1`. This is equivalent to `Exp::new(1.0)` or -/// sampling with `-rng.gen::().ln()`, but faster. -/// -/// See `Exp` for the general exponential distribution. -/// -/// Implemented via the ZIGNOR variant[^1] of the Ziggurat method. The exact -/// description in the paper was adjusted to use tables for the exponential -/// distribution rather than normal. -/// -/// [^1]: Jurgen A. Doornik (2005). [*An Improved Ziggurat Method to -/// Generate Normal Random Samples*]( -/// https://www.doornik.com/research/ziggurat.pdf). -/// Nuffield College, Oxford -#[deprecated(since = "0.7.0", note = "moved to rand_distr crate")] -#[derive(Clone, Copy, Debug)] -pub struct Exp1; - -// This could be done via `-rng.gen::().ln()` but that is slower. -impl Distribution for Exp1 { - #[inline] - fn sample(&self, rng: &mut R) -> f64 { - #[inline] - fn pdf(x: f64) -> f64 { - (-x).exp() - } - #[inline] - fn zero_case(rng: &mut R, _u: f64) -> f64 { - ziggurat_tables::ZIG_EXP_R - rng.gen::().ln() - } - - ziggurat( - rng, - false, - &ziggurat_tables::ZIG_EXP_X, - &ziggurat_tables::ZIG_EXP_F, - pdf, - zero_case, - ) - } -} - -/// The exponential distribution `Exp(lambda)`. -/// -/// This distribution has density function: `f(x) = lambda * exp(-lambda * x)` -/// for `x > 0`. -/// -/// Note that [`Exp1`](crate::distributions::Exp1) is an optimised implementation for `lambda = 1`. -#[deprecated(since = "0.7.0", note = "moved to rand_distr crate")] -#[derive(Clone, Copy, Debug)] -pub struct Exp { - /// `lambda` stored as `1/lambda`, since this is what we scale by. - lambda_inverse: f64, -} - -impl Exp { - /// Construct a new `Exp` with the given shape parameter - /// `lambda`. Panics if `lambda <= 0`. - #[inline] - pub fn new(lambda: f64) -> Exp { - assert!(lambda > 0.0, "Exp::new called with `lambda` <= 0"); - Exp { - lambda_inverse: 1.0 / lambda, - } - } -} - -impl Distribution for Exp { - fn sample(&self, rng: &mut R) -> f64 { - let n: f64 = rng.sample(Exp1); - n * self.lambda_inverse - } -} - -#[cfg(test)] -mod test { - use super::Exp; - use crate::distributions::Distribution; - - #[test] - fn test_exp() { - let exp = Exp::new(10.0); - let mut rng = crate::test::rng(221); - for _ in 0..1000 { - assert!(exp.sample(&mut rng) >= 0.0); - } - } - #[test] - #[should_panic] - fn test_exp_invalid_lambda_zero() { - Exp::new(0.0); - } - #[test] - #[should_panic] - fn test_exp_invalid_lambda_neg() { - Exp::new(-10.0); - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/float.rs cargo-0.58.0/vendor/rand/src/distributions/float.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/float.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/float.rs 2022-01-21 02:47:39.000000000 +0000 @@ -14,6 +14,9 @@ use core::mem; #[cfg(feature = "simd_support")] use packed_simd::*; +#[cfg(feature = "serde1")] +use serde::{Serialize, Deserialize}; + /// A distribution to sample floating point numbers uniformly in the half-open /// interval `(0, 1]`, i.e. including 1 but not 0. /// @@ -39,6 +42,7 @@ /// [`Open01`]: crate::distributions::Open01 /// [`Uniform`]: crate::distributions::uniform::Uniform #[derive(Clone, Copy, Debug)] +#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] pub struct OpenClosed01; /// A distribution to sample floating point numbers uniformly in the open @@ -65,6 +69,7 @@ /// [`OpenClosed01`]: crate::distributions::OpenClosed01 /// [`Uniform`]: crate::distributions::uniform::Uniform #[derive(Clone, Copy, Debug)] +#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] pub struct Open01; diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/gamma.rs cargo-0.58.0/vendor/rand/src/distributions/gamma.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/gamma.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/gamma.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,373 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// Copyright 2013 The Rust Project Developers. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The Gamma and derived distributions. -#![allow(deprecated)] - -use self::ChiSquaredRepr::*; -use self::GammaRepr::*; - -use crate::distributions::normal::StandardNormal; -use crate::distributions::{Distribution, Exp, Open01}; -use crate::Rng; - -/// The Gamma distribution `Gamma(shape, scale)` distribution. -/// -/// The density function of this distribution is -/// -/// ```text -/// f(x) = x^(k - 1) * exp(-x / θ) / (Γ(k) * θ^k) -/// ``` -/// -/// where `Γ` is the Gamma function, `k` is the shape and `θ` is the -/// scale and both `k` and `θ` are strictly positive. -/// -/// The algorithm used is that described by Marsaglia & Tsang 2000[^1], -/// falling back to directly sampling from an Exponential for `shape -/// == 1`, and using the boosting technique described in that paper for -/// `shape < 1`. -/// -/// [^1]: George Marsaglia and Wai Wan Tsang. 2000. "A Simple Method for -/// Generating Gamma Variables" *ACM Trans. Math. Softw.* 26, 3 -/// (September 2000), 363-372. -/// DOI:[10.1145/358407.358414](https://doi.acm.org/10.1145/358407.358414) -#[deprecated(since = "0.7.0", note = "moved to rand_distr crate")] -#[derive(Clone, Copy, Debug)] -pub struct Gamma { - repr: GammaRepr, -} - -#[derive(Clone, Copy, Debug)] -enum GammaRepr { - Large(GammaLargeShape), - One(Exp), - Small(GammaSmallShape), -} - -// These two helpers could be made public, but saving the -// match-on-Gamma-enum branch from using them directly (e.g. if one -// knows that the shape is always > 1) doesn't appear to be much -// faster. - -/// Gamma distribution where the shape parameter is less than 1. -/// -/// Note, samples from this require a compulsory floating-point `pow` -/// call, which makes it significantly slower than sampling from a -/// gamma distribution where the shape parameter is greater than or -/// equal to 1. -/// -/// See `Gamma` for sampling from a Gamma distribution with general -/// shape parameters. -#[derive(Clone, Copy, Debug)] -struct GammaSmallShape { - inv_shape: f64, - large_shape: GammaLargeShape, -} - -/// Gamma distribution where the shape parameter is larger than 1. -/// -/// See `Gamma` for sampling from a Gamma distribution with general -/// shape parameters. -#[derive(Clone, Copy, Debug)] -struct GammaLargeShape { - scale: f64, - c: f64, - d: f64, -} - -impl Gamma { - /// Construct an object representing the `Gamma(shape, scale)` - /// distribution. - /// - /// Panics if `shape <= 0` or `scale <= 0`. - #[inline] - pub fn new(shape: f64, scale: f64) -> Gamma { - assert!(shape > 0.0, "Gamma::new called with shape <= 0"); - assert!(scale > 0.0, "Gamma::new called with scale <= 0"); - - let repr = if shape == 1.0 { - One(Exp::new(1.0 / scale)) - } else if shape < 1.0 { - Small(GammaSmallShape::new_raw(shape, scale)) - } else { - Large(GammaLargeShape::new_raw(shape, scale)) - }; - Gamma { repr } - } -} - -impl GammaSmallShape { - fn new_raw(shape: f64, scale: f64) -> GammaSmallShape { - GammaSmallShape { - inv_shape: 1. / shape, - large_shape: GammaLargeShape::new_raw(shape + 1.0, scale), - } - } -} - -impl GammaLargeShape { - fn new_raw(shape: f64, scale: f64) -> GammaLargeShape { - let d = shape - 1. / 3.; - GammaLargeShape { - scale, - c: 1. / (9. * d).sqrt(), - d, - } - } -} - -impl Distribution for Gamma { - fn sample(&self, rng: &mut R) -> f64 { - match self.repr { - Small(ref g) => g.sample(rng), - One(ref g) => g.sample(rng), - Large(ref g) => g.sample(rng), - } - } -} -impl Distribution for GammaSmallShape { - fn sample(&self, rng: &mut R) -> f64 { - let u: f64 = rng.sample(Open01); - - self.large_shape.sample(rng) * u.powf(self.inv_shape) - } -} -impl Distribution for GammaLargeShape { - fn sample(&self, rng: &mut R) -> f64 { - loop { - let x = rng.sample(StandardNormal); - let v_cbrt = 1.0 + self.c * x; - if v_cbrt <= 0.0 { - // a^3 <= 0 iff a <= 0 - continue; - } - - let v = v_cbrt * v_cbrt * v_cbrt; - let u: f64 = rng.sample(Open01); - - let x_sqr = x * x; - if u < 1.0 - 0.0331 * x_sqr * x_sqr - || u.ln() < 0.5 * x_sqr + self.d * (1.0 - v + v.ln()) - { - return self.d * v * self.scale; - } - } - } -} - -/// The chi-squared distribution `χ²(k)`, where `k` is the degrees of -/// freedom. -/// -/// For `k > 0` integral, this distribution is the sum of the squares -/// of `k` independent standard normal random variables. For other -/// `k`, this uses the equivalent characterisation -/// `χ²(k) = Gamma(k/2, 2)`. -#[deprecated(since = "0.7.0", note = "moved to rand_distr crate")] -#[derive(Clone, Copy, Debug)] -pub struct ChiSquared { - repr: ChiSquaredRepr, -} - -#[derive(Clone, Copy, Debug)] -enum ChiSquaredRepr { - // k == 1, Gamma(alpha, ..) is particularly slow for alpha < 1, - // e.g. when alpha = 1/2 as it would be for this case, so special- - // casing and using the definition of N(0,1)^2 is faster. - DoFExactlyOne, - DoFAnythingElse(Gamma), -} - -impl ChiSquared { - /// Create a new chi-squared distribution with degrees-of-freedom - /// `k`. Panics if `k < 0`. - pub fn new(k: f64) -> ChiSquared { - let repr = if k == 1.0 { - DoFExactlyOne - } else { - assert!(k > 0.0, "ChiSquared::new called with `k` < 0"); - DoFAnythingElse(Gamma::new(0.5 * k, 2.0)) - }; - ChiSquared { repr } - } -} -impl Distribution for ChiSquared { - fn sample(&self, rng: &mut R) -> f64 { - match self.repr { - DoFExactlyOne => { - // k == 1 => N(0,1)^2 - let norm = rng.sample(StandardNormal); - norm * norm - } - DoFAnythingElse(ref g) => g.sample(rng), - } - } -} - -/// The Fisher F distribution `F(m, n)`. -/// -/// This distribution is equivalent to the ratio of two normalised -/// chi-squared distributions, that is, `F(m,n) = (χ²(m)/m) / -/// (χ²(n)/n)`. -#[deprecated(since = "0.7.0", note = "moved to rand_distr crate")] -#[derive(Clone, Copy, Debug)] -pub struct FisherF { - numer: ChiSquared, - denom: ChiSquared, - // denom_dof / numer_dof so that this can just be a straight - // multiplication, rather than a division. - dof_ratio: f64, -} - -impl FisherF { - /// Create a new `FisherF` distribution, with the given - /// parameter. Panics if either `m` or `n` are not positive. - pub fn new(m: f64, n: f64) -> FisherF { - assert!(m > 0.0, "FisherF::new called with `m < 0`"); - assert!(n > 0.0, "FisherF::new called with `n < 0`"); - - FisherF { - numer: ChiSquared::new(m), - denom: ChiSquared::new(n), - dof_ratio: n / m, - } - } -} -impl Distribution for FisherF { - fn sample(&self, rng: &mut R) -> f64 { - self.numer.sample(rng) / self.denom.sample(rng) * self.dof_ratio - } -} - -/// The Student t distribution, `t(nu)`, where `nu` is the degrees of -/// freedom. -#[deprecated(since = "0.7.0", note = "moved to rand_distr crate")] -#[derive(Clone, Copy, Debug)] -pub struct StudentT { - chi: ChiSquared, - dof: f64, -} - -impl StudentT { - /// Create a new Student t distribution with `n` degrees of - /// freedom. Panics if `n <= 0`. - pub fn new(n: f64) -> StudentT { - assert!(n > 0.0, "StudentT::new called with `n <= 0`"); - StudentT { - chi: ChiSquared::new(n), - dof: n, - } - } -} -impl Distribution for StudentT { - fn sample(&self, rng: &mut R) -> f64 { - let norm = rng.sample(StandardNormal); - norm * (self.dof / self.chi.sample(rng)).sqrt() - } -} - -/// The Beta distribution with shape parameters `alpha` and `beta`. -#[deprecated(since = "0.7.0", note = "moved to rand_distr crate")] -#[derive(Clone, Copy, Debug)] -pub struct Beta { - gamma_a: Gamma, - gamma_b: Gamma, -} - -impl Beta { - /// Construct an object representing the `Beta(alpha, beta)` - /// distribution. - /// - /// Panics if `shape <= 0` or `scale <= 0`. - pub fn new(alpha: f64, beta: f64) -> Beta { - assert!((alpha > 0.) & (beta > 0.)); - Beta { - gamma_a: Gamma::new(alpha, 1.), - gamma_b: Gamma::new(beta, 1.), - } - } -} - -impl Distribution for Beta { - fn sample(&self, rng: &mut R) -> f64 { - let x = self.gamma_a.sample(rng); - let y = self.gamma_b.sample(rng); - x / (x + y) - } -} - -#[cfg(test)] -mod test { - use super::{Beta, ChiSquared, FisherF, StudentT}; - use crate::distributions::Distribution; - - const N: u32 = 100; - - #[test] - fn test_chi_squared_one() { - let chi = ChiSquared::new(1.0); - let mut rng = crate::test::rng(201); - for _ in 0..N { - chi.sample(&mut rng); - } - } - #[test] - fn test_chi_squared_small() { - let chi = ChiSquared::new(0.5); - let mut rng = crate::test::rng(202); - for _ in 0..N { - chi.sample(&mut rng); - } - } - #[test] - fn test_chi_squared_large() { - let chi = ChiSquared::new(30.0); - let mut rng = crate::test::rng(203); - for _ in 0..N { - chi.sample(&mut rng); - } - } - #[test] - #[should_panic] - fn test_chi_squared_invalid_dof() { - ChiSquared::new(-1.0); - } - - #[test] - fn test_f() { - let f = FisherF::new(2.0, 32.0); - let mut rng = crate::test::rng(204); - for _ in 0..N { - f.sample(&mut rng); - } - } - - #[test] - fn test_t() { - let t = StudentT::new(11.0); - let mut rng = crate::test::rng(205); - for _ in 0..N { - t.sample(&mut rng); - } - } - - #[test] - fn test_beta() { - let beta = Beta::new(1.0, 2.0); - let mut rng = crate::test::rng(201); - for _ in 0..N { - beta.sample(&mut rng); - } - } - - #[test] - #[should_panic] - fn test_beta_invalid_dof() { - Beta::new(0., 0.); - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/integer.rs cargo-0.58.0/vendor/rand/src/distributions/integer.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/integer.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/integer.rs 2022-01-21 02:47:39.000000000 +0000 @@ -10,9 +10,10 @@ use crate::distributions::{Distribution, Standard}; use crate::Rng; -#[cfg(all(target_arch = "x86", feature = "nightly"))] use core::arch::x86::*; -#[cfg(all(target_arch = "x86_64", feature = "nightly"))] -use core::arch::x86_64::*; +#[cfg(all(target_arch = "x86", feature = "simd_support"))] +use core::arch::x86::{__m128i, __m256i}; +#[cfg(all(target_arch = "x86_64", feature = "simd_support"))] +use core::arch::x86_64::{__m128i, __m256i}; #[cfg(not(target_os = "emscripten"))] use core::num::NonZeroU128; use core::num::{NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize}; #[cfg(feature = "simd_support")] use packed_simd::*; @@ -155,7 +156,6 @@ simd_impl!(512, u8x64, i8x64, u16x32, i16x32, u32x16, i32x16, u64x8, i64x8,); #[cfg(all( feature = "simd_support", - feature = "nightly", any(target_arch = "x86", target_arch = "x86_64") ))] simd_impl!((__m128i, u8x16), (__m256i, u8x32),); diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/mod.rs cargo-0.58.0/vendor/rand/src/distributions/mod.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -11,11 +11,11 @@ //! //! This module is the home of the [`Distribution`] trait and several of its //! implementations. It is the workhorse behind some of the convenient -//! functionality of the [`Rng`] trait, e.g. [`Rng::gen`], [`Rng::gen_range`] and -//! of course [`Rng::sample`]. +//! functionality of the [`Rng`] trait, e.g. [`Rng::gen`] and of course +//! [`Rng::sample`]. //! //! Abstractly, a [probability distribution] describes the probability of -//! occurance of each value in its sample space. +//! occurrence of each value in its sample space. //! //! More concretely, an implementation of `Distribution` for type `X` is an //! algorithm for choosing values from the sample space (a subset of `T`) @@ -54,16 +54,16 @@ //! space to be specified as an arbitrary range within its target type `T`. //! Both [`Standard`] and [`Uniform`] are in some sense uniform distributions. //! -//! Values may be sampled from this distribution using [`Rng::gen_range`] or +//! Values may be sampled from this distribution using [`Rng::sample(Range)`] or //! by creating a distribution object with [`Uniform::new`], //! [`Uniform::new_inclusive`] or `From`. When the range limits are not //! known at compile time it is typically faster to reuse an existing -//! distribution object than to call [`Rng::gen_range`]. +//! `Uniform` object than to call [`Rng::sample(Range)`]. //! //! User types `T` may also implement `Distribution` for [`Uniform`], //! although this is less straightforward than for [`Standard`] (see the -//! documentation in the [`uniform`] module. Doing so enables generation of -//! values of type `T` with [`Rng::gen_range`]. +//! documentation in the [`uniform`] module). Doing so enables generation of +//! values of type `T` with [`Rng::sample(Range)`]. //! //! ## Open and half-open ranges //! @@ -79,7 +79,7 @@ //! the [`Bernoulli`] distribution (this is used by [`Rng::gen_bool`]). //! //! For weighted sampling from a sequence of discrete values, use the -//! [`weighted`] module. +//! [`WeightedIndex`] distribution. //! //! This crate no longer includes other non-uniform distributions; instead //! it is recommended that you use either [`rand_distr`] or [`statrs`]. @@ -93,201 +93,43 @@ //! [`rand_distr`]: https://crates.io/crates/rand_distr //! [`statrs`]: https://crates.io/crates/statrs -use crate::Rng; -use core::iter; - -pub use self::bernoulli::{Bernoulli, BernoulliError}; -pub use self::float::{Open01, OpenClosed01}; -pub use self::other::Alphanumeric; -#[doc(inline)] pub use self::uniform::Uniform; -#[cfg(feature = "alloc")] -pub use self::weighted::{WeightedError, WeightedIndex}; - -// The following are all deprecated after being moved to rand_distr -#[allow(deprecated)] -#[cfg(feature = "std")] -pub use self::binomial::Binomial; -#[allow(deprecated)] -#[cfg(feature = "std")] -pub use self::cauchy::Cauchy; -#[allow(deprecated)] -#[cfg(feature = "std")] -pub use self::dirichlet::Dirichlet; -#[allow(deprecated)] -#[cfg(feature = "std")] -pub use self::exponential::{Exp, Exp1}; -#[allow(deprecated)] -#[cfg(feature = "std")] -pub use self::gamma::{Beta, ChiSquared, FisherF, Gamma, StudentT}; -#[allow(deprecated)] -#[cfg(feature = "std")] -pub use self::normal::{LogNormal, Normal, StandardNormal}; -#[allow(deprecated)] -#[cfg(feature = "std")] -pub use self::pareto::Pareto; -#[allow(deprecated)] -#[cfg(feature = "std")] -pub use self::poisson::Poisson; -#[allow(deprecated)] -#[cfg(feature = "std")] -pub use self::triangular::Triangular; -#[allow(deprecated)] -#[cfg(feature = "std")] -pub use self::unit_circle::UnitCircle; -#[allow(deprecated)] -#[cfg(feature = "std")] -pub use self::unit_sphere::UnitSphereSurface; -#[allow(deprecated)] -#[cfg(feature = "std")] -pub use self::weibull::Weibull; - mod bernoulli; -#[cfg(feature = "std")] mod binomial; -#[cfg(feature = "std")] mod cauchy; -#[cfg(feature = "std")] mod dirichlet; -#[cfg(feature = "std")] mod exponential; -#[cfg(feature = "std")] mod gamma; -#[cfg(feature = "std")] mod normal; -#[cfg(feature = "std")] mod pareto; -#[cfg(feature = "std")] mod poisson; -#[cfg(feature = "std")] mod triangular; -pub mod uniform; -#[cfg(feature = "std")] mod unit_circle; -#[cfg(feature = "std")] mod unit_sphere; -#[cfg(feature = "std")] mod weibull; -#[cfg(feature = "alloc")] pub mod weighted; - +mod distribution; mod float; -#[doc(hidden)] -pub mod hidden_export { - pub use super::float::IntoFloat; // used by rand_distr -} mod integer; mod other; +mod slice; mod utils; -#[cfg(feature = "std")] mod ziggurat_tables; - -/// Types (distributions) that can be used to create a random instance of `T`. -/// -/// It is possible to sample from a distribution through both the -/// `Distribution` and [`Rng`] traits, via `distr.sample(&mut rng)` and -/// `rng.sample(distr)`. They also both offer the [`sample_iter`] method, which -/// produces an iterator that samples from the distribution. -/// -/// All implementations are expected to be immutable; this has the significant -/// advantage of not needing to consider thread safety, and for most -/// distributions efficient state-less sampling algorithms are available. -/// -/// Implementations are typically expected to be portable with reproducible -/// results when used with a PRNG with fixed seed; see the -/// [portability chapter](https://rust-random.github.io/book/portability.html) -/// of The Rust Rand Book. In some cases this does not apply, e.g. the `usize` -/// type requires different sampling on 32-bit and 64-bit machines. -/// -/// [`sample_iter`]: Distribution::method.sample_iter -pub trait Distribution { - /// Generate a random value of `T`, using `rng` as the source of randomness. - fn sample(&self, rng: &mut R) -> T; - - /// Create an iterator that generates random values of `T`, using `rng` as - /// the source of randomness. - /// - /// Note that this function takes `self` by value. This works since - /// `Distribution` is impl'd for `&D` where `D: Distribution`, - /// however borrowing is not automatic hence `distr.sample_iter(...)` may - /// need to be replaced with `(&distr).sample_iter(...)` to borrow or - /// `(&*distr).sample_iter(...)` to reborrow an existing reference. - /// - /// # Example - /// - /// ``` - /// use rand::thread_rng; - /// use rand::distributions::{Distribution, Alphanumeric, Uniform, Standard}; - /// - /// let rng = thread_rng(); - /// - /// // Vec of 16 x f32: - /// let v: Vec = Standard.sample_iter(rng).take(16).collect(); - /// - /// // String: - /// let s: String = Alphanumeric.sample_iter(rng).take(7).collect(); - /// - /// // Dice-rolling: - /// let die_range = Uniform::new_inclusive(1, 6); - /// let mut roll_die = die_range.sample_iter(rng); - /// while roll_die.next().unwrap() != 6 { - /// println!("Not a 6; rolling again!"); - /// } - /// ``` - fn sample_iter(self, rng: R) -> DistIter - where - R: Rng, - Self: Sized, - { - DistIter { - distr: self, - rng, - phantom: ::core::marker::PhantomData, - } - } -} - -impl<'a, T, D: Distribution> Distribution for &'a D { - fn sample(&self, rng: &mut R) -> T { - (*self).sample(rng) - } -} - - -/// An iterator that generates random values of `T` with distribution `D`, -/// using `R` as the source of randomness. -/// -/// This `struct` is created by the [`sample_iter`] method on [`Distribution`]. -/// See its documentation for more. -/// -/// [`sample_iter`]: Distribution::sample_iter -#[derive(Debug)] -pub struct DistIter { - distr: D, - rng: R, - phantom: ::core::marker::PhantomData, -} - -impl Iterator for DistIter -where - D: Distribution, - R: Rng, -{ - type Item = T; - - #[inline(always)] - fn next(&mut self) -> Option { - // Here, self.rng may be a reference, but we must take &mut anyway. - // Even if sample could take an R: Rng by value, we would need to do this - // since Rng is not copyable and we cannot enforce that this is "reborrowable". - Some(self.distr.sample(&mut self.rng)) - } - - fn size_hint(&self) -> (usize, Option) { - (usize::max_value(), None) - } -} +#[cfg(feature = "alloc")] +mod weighted_index; -impl iter::FusedIterator for DistIter -where - D: Distribution, - R: Rng, -{ +#[doc(hidden)] +pub mod hidden_export { + pub use super::float::IntoFloat; // used by rand_distr } +pub mod uniform; +#[deprecated( + since = "0.8.0", + note = "use rand::distributions::{WeightedIndex, WeightedError} instead" +)] +#[cfg(feature = "alloc")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] +pub mod weighted; -#[cfg(features = "nightly")] -impl iter::TrustedLen for DistIter -where - D: Distribution, - R: Rng, -{ -} +pub use self::bernoulli::{Bernoulli, BernoulliError}; +pub use self::distribution::{Distribution, DistIter, DistMap}; +#[cfg(feature = "alloc")] +pub use self::distribution::DistString; +pub use self::float::{Open01, OpenClosed01}; +pub use self::other::Alphanumeric; +pub use self::slice::Slice; +#[doc(inline)] +pub use self::uniform::Uniform; +#[cfg(feature = "alloc")] +pub use self::weighted_index::{WeightedError, WeightedIndex}; +#[allow(unused)] +use crate::Rng; /// A generic random value distribution, implemented for many primitive types. /// Usually generates values with a numerically uniform distribution, and with a @@ -317,6 +159,12 @@ /// * Arrays (up to 32 elements): each element is generated sequentially; /// see also [`Rng::fill`] which supports arbitrary array length for integer /// types and tends to be faster for `u32` and smaller types. +/// When using `rustc` ≥ 1.51, enable the `min_const_gen` feature to support +/// arrays larger than 32 elements. +/// Note that [`Rng::fill`] and `Standard`'s array support are *not* equivalent: +/// the former is optimised for integer types (using fewer RNG calls for +/// element types smaller than the RNG word size), while the latter supports +/// any element type supported by `Standard`. /// * `Option` first generates a `bool`, and if true generates and returns /// `Some(value)` where `value: T`, otherwise returning `None`. /// @@ -359,48 +207,12 @@ /// multiplicative method: `(rng.gen::<$uty>() >> N) as $ty * (ε/2)`. /// /// See also: [`Open01`] which samples from `(0, 1)`, [`OpenClosed01`] which -/// samples from `(0, 1]` and `Rng::gen_range(0, 1)` which also samples from -/// `[0, 1)`. Note that `Open01` and `gen_range` (which uses [`Uniform`]) use -/// transmute-based methods which yield 1 bit less precision but may perform -/// faster on some architectures (on modern Intel CPUs all methods have -/// approximately equal performance). +/// samples from `(0, 1]` and `Rng::gen_range(0..1)` which also samples from +/// `[0, 1)`. Note that `Open01` uses transmute-based methods which yield 1 bit +/// less precision but may perform faster on some architectures (on modern Intel +/// CPUs all methods have approximately equal performance). /// /// [`Uniform`]: uniform::Uniform #[derive(Clone, Copy, Debug)] +#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))] pub struct Standard; - - -#[cfg(all(test, feature = "std"))] -mod tests { - use super::{Distribution, Uniform}; - use crate::Rng; - - #[test] - fn test_distributions_iter() { - use crate::distributions::Open01; - let mut rng = crate::test::rng(210); - let distr = Open01; - let results: Vec = distr.sample_iter(&mut rng).take(100).collect(); - println!("{:?}", results); - } - - #[test] - fn test_make_an_iter() { - fn ten_dice_rolls_other_than_five<'a, R: Rng>( - rng: &'a mut R, - ) -> impl Iterator + 'a { - Uniform::new_inclusive(1, 6) - .sample_iter(rng) - .filter(|x| *x != 5) - .take(10) - } - - let mut rng = crate::test::rng(211); - let mut count = 0; - for val in ten_dice_rolls_other_than_five(&mut rng) { - assert!(val >= 1 && val <= 6 && val != 5); - count += 1; - } - assert_eq!(count, 10); - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/normal.rs cargo-0.58.0/vendor/rand/src/distributions/normal.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/normal.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/normal.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,177 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// Copyright 2013 The Rust Project Developers. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The normal and derived distributions. -#![allow(deprecated)] - -use crate::distributions::utils::ziggurat; -use crate::distributions::{ziggurat_tables, Distribution, Open01}; -use crate::Rng; - -/// Samples floating-point numbers according to the normal distribution -/// `N(0, 1)` (a.k.a. a standard normal, or Gaussian). This is equivalent to -/// `Normal::new(0.0, 1.0)` but faster. -/// -/// See `Normal` for the general normal distribution. -/// -/// Implemented via the ZIGNOR variant[^1] of the Ziggurat method. -/// -/// [^1]: Jurgen A. Doornik (2005). [*An Improved Ziggurat Method to -/// Generate Normal Random Samples*]( -/// https://www.doornik.com/research/ziggurat.pdf). -/// Nuffield College, Oxford -#[deprecated(since = "0.7.0", note = "moved to rand_distr crate")] -#[derive(Clone, Copy, Debug)] -pub struct StandardNormal; - -impl Distribution for StandardNormal { - fn sample(&self, rng: &mut R) -> f64 { - #[inline] - fn pdf(x: f64) -> f64 { - (-x * x / 2.0).exp() - } - #[inline] - fn zero_case(rng: &mut R, u: f64) -> f64 { - // compute a random number in the tail by hand - - // strange initial conditions, because the loop is not - // do-while, so the condition should be true on the first - // run, they get overwritten anyway (0 < 1, so these are - // good). - let mut x = 1.0f64; - let mut y = 0.0f64; - - while -2.0 * y < x * x { - let x_: f64 = rng.sample(Open01); - let y_: f64 = rng.sample(Open01); - - x = x_.ln() / ziggurat_tables::ZIG_NORM_R; - y = y_.ln(); - } - - if u < 0.0 { - x - ziggurat_tables::ZIG_NORM_R - } else { - ziggurat_tables::ZIG_NORM_R - x - } - } - - ziggurat( - rng, - true, // this is symmetric - &ziggurat_tables::ZIG_NORM_X, - &ziggurat_tables::ZIG_NORM_F, - pdf, - zero_case, - ) - } -} - -/// The normal distribution `N(mean, std_dev**2)`. -/// -/// This uses the ZIGNOR variant of the Ziggurat method, see [`StandardNormal`] -/// for more details. -/// -/// Note that [`StandardNormal`] is an optimised implementation for mean 0, and -/// standard deviation 1. -/// -/// [`StandardNormal`]: crate::distributions::StandardNormal -#[deprecated(since = "0.7.0", note = "moved to rand_distr crate")] -#[derive(Clone, Copy, Debug)] -pub struct Normal { - mean: f64, - std_dev: f64, -} - -impl Normal { - /// Construct a new `Normal` distribution with the given mean and - /// standard deviation. - /// - /// # Panics - /// - /// Panics if `std_dev < 0`. - #[inline] - pub fn new(mean: f64, std_dev: f64) -> Normal { - assert!(std_dev >= 0.0, "Normal::new called with `std_dev` < 0"); - Normal { mean, std_dev } - } -} -impl Distribution for Normal { - fn sample(&self, rng: &mut R) -> f64 { - let n = rng.sample(StandardNormal); - self.mean + self.std_dev * n - } -} - - -/// The log-normal distribution `ln N(mean, std_dev**2)`. -/// -/// If `X` is log-normal distributed, then `ln(X)` is `N(mean, std_dev**2)` -/// distributed. -#[deprecated(since = "0.7.0", note = "moved to rand_distr crate")] -#[derive(Clone, Copy, Debug)] -pub struct LogNormal { - norm: Normal, -} - -impl LogNormal { - /// Construct a new `LogNormal` distribution with the given mean - /// and standard deviation. - /// - /// # Panics - /// - /// Panics if `std_dev < 0`. - #[inline] - pub fn new(mean: f64, std_dev: f64) -> LogNormal { - assert!(std_dev >= 0.0, "LogNormal::new called with `std_dev` < 0"); - LogNormal { - norm: Normal::new(mean, std_dev), - } - } -} -impl Distribution for LogNormal { - fn sample(&self, rng: &mut R) -> f64 { - self.norm.sample(rng).exp() - } -} - -#[cfg(test)] -mod tests { - use super::{LogNormal, Normal}; - use crate::distributions::Distribution; - - #[test] - fn test_normal() { - let norm = Normal::new(10.0, 10.0); - let mut rng = crate::test::rng(210); - for _ in 0..1000 { - norm.sample(&mut rng); - } - } - #[test] - #[should_panic] - fn test_normal_invalid_sd() { - Normal::new(10.0, -1.0); - } - - - #[test] - fn test_log_normal() { - let lnorm = LogNormal::new(10.0, 10.0); - let mut rng = crate::test::rng(211); - for _ in 0..1000 { - lnorm.sample(&mut rng); - } - } - #[test] - #[should_panic] - fn test_log_normal_invalid_sd() { - LogNormal::new(10.0, -1.0); - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/other.rs cargo-0.58.0/vendor/rand/src/distributions/other.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/other.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/other.rs 2022-01-21 02:47:39.000000000 +0000 @@ -10,13 +10,23 @@ use core::char; use core::num::Wrapping; +#[cfg(feature = "alloc")] +use alloc::string::String; use crate::distributions::{Distribution, Standard, Uniform}; +#[cfg(feature = "alloc")] +use crate::distributions::DistString; use crate::Rng; +#[cfg(feature = "serde1")] +use serde::{Serialize, Deserialize}; +#[cfg(feature = "min_const_gen")] +use std::mem::{self, MaybeUninit}; + + // ----- Sampling distributions ----- -/// Sample a `char`, uniformly distributed over ASCII letters and numbers: +/// Sample a `u8`, uniformly distributed over ASCII letters and numbers: /// a-z, A-Z and 0-9. /// /// # Example @@ -29,11 +39,30 @@ /// let mut rng = thread_rng(); /// let chars: String = iter::repeat(()) /// .map(|()| rng.sample(Alphanumeric)) +/// .map(char::from) /// .take(7) /// .collect(); /// println!("Random chars: {}", chars); /// ``` -#[derive(Debug)] +/// +/// # Passwords +/// +/// Users sometimes ask whether it is safe to use a string of random characters +/// as a password. In principle, all RNGs in Rand implementing `CryptoRng` are +/// suitable as a source of randomness for generating passwords (if they are +/// properly seeded), but it is more conservative to only use randomness +/// directly from the operating system via the `getrandom` crate, or the +/// corresponding bindings of a crypto library. +/// +/// When generating passwords or keys, it is important to consider the threat +/// model and in some cases the memorability of the password. This is out of +/// scope of the Rand project, and therefore we defer to the following +/// references: +/// +/// - [Wikipedia article on Password Strength](https://en.wikipedia.org/wiki/Password_strength) +/// - [Diceware for generating memorable passwords](https://en.wikipedia.org/wiki/Diceware) +#[derive(Debug, Clone, Copy)] +#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] pub struct Alphanumeric; @@ -60,8 +89,21 @@ } } -impl Distribution for Alphanumeric { - fn sample(&self, rng: &mut R) -> char { +/// Note: the `String` is potentially left with excess capacity; optionally the +/// user may call `string.shrink_to_fit()` afterwards. +#[cfg(feature = "alloc")] +impl DistString for Standard { + fn append_string(&self, rng: &mut R, s: &mut String, len: usize) { + // A char is encoded with at most four bytes, thus this reservation is + // guaranteed to be sufficient. We do not shrink_to_fit afterwards so + // that repeated usage on the same `String` buffer does not reallocate. + s.reserve(4 * len); + s.extend(Distribution::::sample_iter(self, rng).take(len)); + } +} + +impl Distribution for Alphanumeric { + fn sample(&self, rng: &mut R) -> u8 { const RANGE: u32 = 26 + 26 + 10; const GEN_ASCII_STR_CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ abcdefghijklmnopqrstuvwxyz\ @@ -73,12 +115,22 @@ loop { let var = rng.next_u32() >> (32 - 6); if var < RANGE { - return GEN_ASCII_STR_CHARSET[var as usize] as char; + return GEN_ASCII_STR_CHARSET[var as usize]; } } } } +#[cfg(feature = "alloc")] +impl DistString for Alphanumeric { + fn append_string(&self, rng: &mut R, string: &mut String, len: usize) { + unsafe { + let v = string.as_mut_vec(); + v.extend(self.sample_iter(rng).take(len)); + } + } +} + impl Distribution for Standard { #[inline] fn sample(&self, rng: &mut R) -> bool { @@ -134,6 +186,23 @@ tuple_impl! {A, B, C, D, E, F, G, H, I, J, K} tuple_impl! {A, B, C, D, E, F, G, H, I, J, K, L} +#[cfg(feature = "min_const_gen")] +impl Distribution<[T; N]> for Standard +where Standard: Distribution +{ + #[inline] + fn sample(&self, _rng: &mut R) -> [T; N] { + let mut buff: [MaybeUninit; N] = unsafe { MaybeUninit::uninit().assume_init() }; + + for elem in &mut buff { + *elem = MaybeUninit::new(_rng.gen()); + } + + unsafe { mem::transmute_copy::<_, _>(&buff) } + } +} + +#[cfg(not(feature = "min_const_gen"))] macro_rules! array_impl { // recursive, given at least one type parameter: {$n:expr, $t:ident, $($ts:ident,)*} => { @@ -154,6 +223,7 @@ }; } +#[cfg(not(feature = "min_const_gen"))] array_impl! {32, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T,} impl Distribution> for Standard @@ -184,7 +254,7 @@ mod tests { use super::*; use crate::RngCore; - #[cfg(all(not(feature = "std"), feature = "alloc"))] use alloc::string::String; + #[cfg(feature = "alloc")] use alloc::string::String; #[test] fn test_misc() { @@ -206,7 +276,7 @@ .map(|()| rng.gen::()) .take(1000) .collect(); - assert!(word.len() != 0); + assert!(!word.is_empty()); } #[test] @@ -217,12 +287,12 @@ // take the rejection sampling path. let mut incorrect = false; for _ in 0..100 { - let c = rng.sample(Alphanumeric); - incorrect |= !((c >= '0' && c <= '9') || - (c >= 'A' && c <= 'Z') || - (c >= 'a' && c <= 'z') ); + let c: char = rng.sample(Alphanumeric).into(); + incorrect |= !(('0'..='9').contains(&c) || + ('A'..='Z').contains(&c) || + ('a'..='z').contains(&c) ); } - assert!(incorrect == false); + assert!(!incorrect); } #[test] @@ -245,7 +315,7 @@ '\u{ed692}', '\u{35888}', ]); - test_samples(&Alphanumeric, 'a', &['h', 'm', 'e', '3', 'M']); + test_samples(&Alphanumeric, 0, &[104, 109, 101, 51, 77]); test_samples(&Standard, false, &[true, true, false, true, false]); test_samples(&Standard, None as Option, &[ Some(true), diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/pareto.rs cargo-0.58.0/vendor/rand/src/distributions/pareto.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/pareto.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/pareto.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The Pareto distribution. -#![allow(deprecated)] - -use crate::distributions::{Distribution, OpenClosed01}; -use crate::Rng; - -/// Samples floating-point numbers according to the Pareto distribution -#[deprecated(since = "0.7.0", note = "moved to rand_distr crate")] -#[derive(Clone, Copy, Debug)] -pub struct Pareto { - scale: f64, - inv_neg_shape: f64, -} - -impl Pareto { - /// Construct a new Pareto distribution with given `scale` and `shape`. - /// - /// In the literature, `scale` is commonly written as xm or k and - /// `shape` is often written as α. - /// - /// # Panics - /// - /// `scale` and `shape` have to be non-zero and positive. - pub fn new(scale: f64, shape: f64) -> Pareto { - assert!((scale > 0.) & (shape > 0.)); - Pareto { - scale, - inv_neg_shape: -1.0 / shape, - } - } -} - -impl Distribution for Pareto { - fn sample(&self, rng: &mut R) -> f64 { - let u: f64 = rng.sample(OpenClosed01); - self.scale * u.powf(self.inv_neg_shape) - } -} - -#[cfg(test)] -mod tests { - use super::Pareto; - use crate::distributions::Distribution; - - #[test] - #[should_panic] - fn invalid() { - Pareto::new(0., 0.); - } - - #[test] - fn sample() { - let scale = 1.0; - let shape = 2.0; - let d = Pareto::new(scale, shape); - let mut rng = crate::test::rng(1); - for _ in 0..1000 { - let r = d.sample(&mut rng); - assert!(r >= scale); - } - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/poisson.rs cargo-0.58.0/vendor/rand/src/distributions/poisson.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/poisson.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/poisson.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,151 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// Copyright 2016-2017 The Rust Project Developers. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The Poisson distribution. -#![allow(deprecated)] - -use crate::distributions::utils::log_gamma; -use crate::distributions::{Cauchy, Distribution}; -use crate::Rng; - -/// The Poisson distribution `Poisson(lambda)`. -/// -/// This distribution has a density function: -/// `f(k) = lambda^k * exp(-lambda) / k!` for `k >= 0`. -#[deprecated(since = "0.7.0", note = "moved to rand_distr crate")] -#[derive(Clone, Copy, Debug)] -pub struct Poisson { - lambda: f64, - // precalculated values - exp_lambda: f64, - log_lambda: f64, - sqrt_2lambda: f64, - magic_val: f64, -} - -impl Poisson { - /// Construct a new `Poisson` with the given shape parameter - /// `lambda`. Panics if `lambda <= 0`. - pub fn new(lambda: f64) -> Poisson { - assert!(lambda > 0.0, "Poisson::new called with lambda <= 0"); - let log_lambda = lambda.ln(); - Poisson { - lambda, - exp_lambda: (-lambda).exp(), - log_lambda, - sqrt_2lambda: (2.0 * lambda).sqrt(), - magic_val: lambda * log_lambda - log_gamma(1.0 + lambda), - } - } -} - -impl Distribution for Poisson { - fn sample(&self, rng: &mut R) -> u64 { - // using the algorithm from Numerical Recipes in C - - // for low expected values use the Knuth method - if self.lambda < 12.0 { - let mut result = 0; - let mut p = 1.0; - while p > self.exp_lambda { - p *= rng.gen::(); - result += 1; - } - result - 1 - } - // high expected values - rejection method - else { - let mut int_result: u64; - - // we use the Cauchy distribution as the comparison distribution - // f(x) ~ 1/(1+x^2) - let cauchy = Cauchy::new(0.0, 1.0); - - loop { - let mut result; - let mut comp_dev; - - loop { - // draw from the Cauchy distribution - comp_dev = rng.sample(cauchy); - // shift the peak of the comparison ditribution - result = self.sqrt_2lambda * comp_dev + self.lambda; - // repeat the drawing until we are in the range of possible values - if result >= 0.0 { - break; - } - } - // now the result is a random variable greater than 0 with Cauchy distribution - // the result should be an integer value - result = result.floor(); - int_result = result as u64; - - // this is the ratio of the Poisson distribution to the comparison distribution - // the magic value scales the distribution function to a range of approximately 0-1 - // since it is not exact, we multiply the ratio by 0.9 to avoid ratios greater than 1 - // this doesn't change the resulting distribution, only increases the rate of failed drawings - let check = 0.9 - * (1.0 + comp_dev * comp_dev) - * (result * self.log_lambda - log_gamma(1.0 + result) - self.magic_val).exp(); - - // check with uniform random value - if below the threshold, we are within the target distribution - if rng.gen::() <= check { - break; - } - } - int_result - } - } -} - -#[cfg(test)] -mod test { - use super::Poisson; - use crate::distributions::Distribution; - - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_poisson_10() { - let poisson = Poisson::new(10.0); - let mut rng = crate::test::rng(123); - let mut sum = 0; - for _ in 0..1000 { - sum += poisson.sample(&mut rng); - } - let avg = (sum as f64) / 1000.0; - println!("Poisson average: {}", avg); - assert!((avg - 10.0).abs() < 0.5); // not 100% certain, but probable enough - } - - #[test] - fn test_poisson_15() { - // Take the 'high expected values' path - let poisson = Poisson::new(15.0); - let mut rng = crate::test::rng(123); - let mut sum = 0; - for _ in 0..1000 { - sum += poisson.sample(&mut rng); - } - let avg = (sum as f64) / 1000.0; - println!("Poisson average: {}", avg); - assert!((avg - 15.0).abs() < 0.5); // not 100% certain, but probable enough - } - - #[test] - #[should_panic] - fn test_poisson_invalid_lambda_zero() { - Poisson::new(0.0); - } - - #[test] - #[should_panic] - fn test_poisson_invalid_lambda_neg() { - Poisson::new(-10.0); - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/slice.rs cargo-0.58.0/vendor/rand/src/distributions/slice.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/slice.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/slice.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,117 @@ +// Copyright 2021 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use crate::distributions::{Distribution, Uniform}; + +/// A distribution to sample items uniformly from a slice. +/// +/// [`Slice::new`] constructs a distribution referencing a slice and uniformly +/// samples references from the items in the slice. It may do extra work up +/// front to make sampling of multiple values faster; if only one sample from +/// the slice is required, [`SliceRandom::choose`] can be more efficient. +/// +/// Steps are taken to avoid bias which might be present in naive +/// implementations; for example `slice[rng.gen() % slice.len()]` samples from +/// the slice, but may be more likely to select numbers in the low range than +/// other values. +/// +/// This distribution samples with replacement; each sample is independent. +/// Sampling without replacement requires state to be retained, and therefore +/// cannot be handled by a distribution; you should instead consider methods +/// on [`SliceRandom`], such as [`SliceRandom::choose_multiple`]. +/// +/// # Example +/// +/// ``` +/// use rand::Rng; +/// use rand::distributions::Slice; +/// +/// let vowels = ['a', 'e', 'i', 'o', 'u']; +/// let vowels_dist = Slice::new(&vowels).unwrap(); +/// let rng = rand::thread_rng(); +/// +/// // build a string of 10 vowels +/// let vowel_string: String = rng +/// .sample_iter(&vowels_dist) +/// .take(10) +/// .collect(); +/// +/// println!("{}", vowel_string); +/// assert_eq!(vowel_string.len(), 10); +/// assert!(vowel_string.chars().all(|c| vowels.contains(&c))); +/// ``` +/// +/// For a single sample, [`SliceRandom::choose`][crate::seq::SliceRandom::choose] +/// may be preferred: +/// +/// ``` +/// use rand::seq::SliceRandom; +/// +/// let vowels = ['a', 'e', 'i', 'o', 'u']; +/// let mut rng = rand::thread_rng(); +/// +/// println!("{}", vowels.choose(&mut rng).unwrap()) +/// ``` +/// +/// [`SliceRandom`]: crate::seq::SliceRandom +/// [`SliceRandom::choose`]: crate::seq::SliceRandom::choose +/// [`SliceRandom::choose_multiple`]: crate::seq::SliceRandom::choose_multiple +#[derive(Debug, Clone, Copy)] +pub struct Slice<'a, T> { + slice: &'a [T], + range: Uniform, +} + +impl<'a, T> Slice<'a, T> { + /// Create a new `Slice` instance which samples uniformly from the slice. + /// Returns `Err` if the slice is empty. + pub fn new(slice: &'a [T]) -> Result { + match slice.len() { + 0 => Err(EmptySlice), + len => Ok(Self { + slice, + range: Uniform::new(0, len), + }), + } + } +} + +impl<'a, T> Distribution<&'a T> for Slice<'a, T> { + fn sample(&self, rng: &mut R) -> &'a T { + let idx = self.range.sample(rng); + + debug_assert!( + idx < self.slice.len(), + "Uniform::new(0, {}) somehow returned {}", + self.slice.len(), + idx + ); + + // Safety: at construction time, it was ensured that the slice was + // non-empty, and that the `Uniform` range produces values in range + // for the slice + unsafe { self.slice.get_unchecked(idx) } + } +} + +/// Error type indicating that a [`Slice`] distribution was improperly +/// constructed with an empty slice. +#[derive(Debug, Clone, Copy)] +pub struct EmptySlice; + +impl core::fmt::Display for EmptySlice { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!( + f, + "Tried to create a `distributions::Slice` with an empty slice" + ) + } +} + +#[cfg(feature = "std")] +impl std::error::Error for EmptySlice {} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/triangular.rs cargo-0.58.0/vendor/rand/src/distributions/triangular.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/triangular.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/triangular.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,83 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The triangular distribution. -#![allow(deprecated)] - -use crate::distributions::{Distribution, Standard}; -use crate::Rng; - -/// The triangular distribution. -#[deprecated(since = "0.7.0", note = "moved to rand_distr crate")] -#[derive(Clone, Copy, Debug)] -pub struct Triangular { - min: f64, - max: f64, - mode: f64, -} - -impl Triangular { - /// Construct a new `Triangular` with minimum `min`, maximum `max` and mode - /// `mode`. - /// - /// # Panics - /// - /// If `max < mode`, `mode < max` or `max == min`. - #[inline] - pub fn new(min: f64, max: f64, mode: f64) -> Triangular { - assert!(max >= mode); - assert!(mode >= min); - assert!(max != min); - Triangular { min, max, mode } - } -} - -impl Distribution for Triangular { - #[inline] - fn sample(&self, rng: &mut R) -> f64 { - let f: f64 = rng.sample(Standard); - let diff_mode_min = self.mode - self.min; - let diff_max_min = self.max - self.min; - if f * diff_max_min < diff_mode_min { - self.min + (f * diff_max_min * diff_mode_min).sqrt() - } else { - self.max - ((1. - f) * diff_max_min * (self.max - self.mode)).sqrt() - } - } -} - -#[cfg(test)] -mod test { - use super::Triangular; - use crate::distributions::Distribution; - - #[test] - fn test_new() { - for &(min, max, mode) in &[ - (-1., 1., 0.), - (1., 2., 1.), - (5., 25., 25.), - (1e-5, 1e5, 1e-3), - (0., 1., 0.9), - (-4., -0.5, -2.), - (-13.039, 8.41, 1.17), - ] { - println!("{} {} {}", min, max, mode); - let _ = Triangular::new(min, max, mode); - } - } - - #[test] - fn test_sample() { - let norm = Triangular::new(0., 1., 0.5); - let mut rng = crate::test::rng(1); - for _ in 0..1000 { - norm.sample(&mut rng); - } - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/uniform.rs cargo-0.58.0/vendor/rand/src/distributions/uniform.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/uniform.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/uniform.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,4 +1,4 @@ -// Copyright 2018 Developers of the Rand project. +// Copyright 2018-2020 Developers of the Rand project. // Copyright 2017 The Rust Project Developers. // // Licensed under the Apache License, Version 2.0 = high`. /// /// # Example @@ -145,20 +149,29 @@ /// ``` /// use rand::distributions::{Distribution, Uniform}; /// -/// fn main() { -/// let between = Uniform::from(10..10000); -/// let mut rng = rand::thread_rng(); -/// let mut sum = 0; -/// for _ in 0..1000 { -/// sum += between.sample(&mut rng); -/// } -/// println!("{}", sum); +/// let between = Uniform::from(10..10000); +/// let mut rng = rand::thread_rng(); +/// let mut sum = 0; +/// for _ in 0..1000 { +/// sum += between.sample(&mut rng); /// } +/// println!("{}", sum); +/// ``` +/// +/// For a single sample, [`Rng::gen_range`] may be prefered: +/// +/// ``` +/// use rand::Rng; +/// +/// let mut rng = rand::thread_rng(); +/// println!("{}", rng.gen_range(0..10)); /// ``` /// /// [`new`]: Uniform::new /// [`new_inclusive`]: Uniform::new_inclusive +/// [`Rng::gen_range`]: Rng::gen_range #[derive(Clone, Copy, Debug)] +#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] pub struct Uniform(X::Sampler); impl Uniform { @@ -265,20 +278,38 @@ let uniform: Self = UniformSampler::new(low, high); uniform.sample(rng) } + + /// Sample a single value uniformly from a range with inclusive lower bound + /// and inclusive upper bound `[low, high]`. + /// + /// By default this is implemented using + /// `UniformSampler::new_inclusive(low, high).sample(rng)`. However, for + /// some types more optimal implementations for single usage may be provided + /// via this method. + /// Results may not be identical. + fn sample_single_inclusive(low: B1, high: B2, rng: &mut R) + -> Self::X + where B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized + { + let uniform: Self = UniformSampler::new_inclusive(low, high); + uniform.sample(rng) + } } -impl From<::core::ops::Range> for Uniform { +impl From> for Uniform { fn from(r: ::core::ops::Range) -> Uniform { Uniform::new(r.start, r.end) } } -impl From<::core::ops::RangeInclusive> for Uniform { +impl From> for Uniform { fn from(r: ::core::ops::RangeInclusive) -> Uniform { Uniform::new_inclusive(r.start(), r.end()) } } + /// Helper trait similar to [`Borrow`] but implemented /// only for SampleUniform and references to SampleUniform in /// order to resolve ambiguity issues. @@ -307,6 +338,43 @@ } } +/// Range that supports generating a single sample efficiently. +/// +/// Any type implementing this trait can be used to specify the sampled range +/// for `Rng::gen_range`. +pub trait SampleRange { + /// Generate a sample from the given range. + fn sample_single(self, rng: &mut R) -> T; + + /// Check whether the range is empty. + fn is_empty(&self) -> bool; +} + +impl SampleRange for Range { + #[inline] + fn sample_single(self, rng: &mut R) -> T { + T::Sampler::sample_single(self.start, self.end, rng) + } + + #[inline] + fn is_empty(&self) -> bool { + !(self.start < self.end) + } +} + +impl SampleRange for RangeInclusive { + #[inline] + fn sample_single(self, rng: &mut R) -> T { + T::Sampler::sample_single_inclusive(self.start(), self.end(), rng) + } + + #[inline] + fn is_empty(&self) -> bool { + !(self.start() <= self.end()) + } +} + + //////////////////////////////////////////////////////////////////////////////// // What follows are all back-ends. @@ -347,6 +415,7 @@ /// multiply by `range`, the result is in the high word. Then comparing the low /// word against `zone` makes sure our distribution is uniform. #[derive(Clone, Copy, Debug)] +#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] pub struct UniformInt { low: X, range: X, @@ -404,13 +473,14 @@ }; UniformInt { - low: low, + low, // These are really $unsigned values, but store as $ty: range: range as $ty, z: ints_to_reject as $unsigned as $ty, } } + #[inline] fn sample(&self, rng: &mut R) -> Self::X { let range = self.range as $unsigned as $u_large; if range > 0 { @@ -429,6 +499,7 @@ } } + #[inline] fn sample_single(low_b: B1, high_b: B2, rng: &mut R) -> Self::X where B1: SampleBorrow + Sized, @@ -437,7 +508,25 @@ let low = *low_b.borrow(); let high = *high_b.borrow(); assert!(low < high, "UniformSampler::sample_single: low >= high"); - let range = high.wrapping_sub(low) as $unsigned as $u_large; + Self::sample_single_inclusive(low, high - 1, rng) + } + + #[inline] + fn sample_single_inclusive(low_b: B1, high_b: B2, rng: &mut R) -> Self::X + where + B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized, + { + let low = *low_b.borrow(); + let high = *high_b.borrow(); + assert!(low <= high, "UniformSampler::sample_single_inclusive: low > high"); + let range = high.wrapping_sub(low).wrapping_add(1) as $unsigned as $u_large; + // If the above resulted in wrap-around to 0, the range is $ty::MIN..=$ty::MAX, + // and any integer will do. + if range == 0 { + return rng.gen(); + } + let zone = if ::core::$unsigned::MAX <= ::core::u16::MAX as $unsigned { // Using a modulus is faster than the approximation for // i8 and i16. I suppose we trade the cost of one @@ -478,7 +567,7 @@ #[cfg(not(target_os = "emscripten"))] uniform_int_impl! { u128, u128, u128 } -#[cfg(all(feature = "simd_support", feature = "nightly"))] +#[cfg(feature = "simd_support")] macro_rules! uniform_simd_int_impl { ($ty:ident, $unsigned:ident, $u_scalar:ident) => { // The "pick the largest zone that can fit in an `u32`" optimization @@ -535,7 +624,7 @@ let zone = unsigned_max - ints_to_reject; UniformInt { - low: low, + low, // These are really $unsigned values, but store as $ty: range: range.cast(), z: zone.cast(), @@ -585,7 +674,7 @@ }; } -#[cfg(all(feature = "simd_support", feature = "nightly"))] +#[cfg(feature = "simd_support")] uniform_simd_int_impl! { (u64x2, i64x2), (u64x4, i64x4), @@ -593,7 +682,7 @@ u64 } -#[cfg(all(feature = "simd_support", feature = "nightly"))] +#[cfg(feature = "simd_support")] uniform_simd_int_impl! { (u32x2, i32x2), (u32x4, i32x4), @@ -602,7 +691,7 @@ u32 } -#[cfg(all(feature = "simd_support", feature = "nightly"))] +#[cfg(feature = "simd_support")] uniform_simd_int_impl! { (u16x2, i16x2), (u16x4, i16x4), @@ -612,7 +701,7 @@ u16 } -#[cfg(all(feature = "simd_support", feature = "nightly"))] +#[cfg(feature = "simd_support")] uniform_simd_int_impl! { (u8x2, i8x2), (u8x4, i8x4), @@ -623,6 +712,78 @@ u8 } +impl SampleUniform for char { + type Sampler = UniformChar; +} + +/// The back-end implementing [`UniformSampler`] for `char`. +/// +/// Unless you are implementing [`UniformSampler`] for your own type, this type +/// should not be used directly, use [`Uniform`] instead. +/// +/// This differs from integer range sampling since the range `0xD800..=0xDFFF` +/// are used for surrogate pairs in UCS and UTF-16, and consequently are not +/// valid Unicode code points. We must therefore avoid sampling values in this +/// range. +#[derive(Clone, Copy, Debug)] +#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +pub struct UniformChar { + sampler: UniformInt, +} + +/// UTF-16 surrogate range start +const CHAR_SURROGATE_START: u32 = 0xD800; +/// UTF-16 surrogate range size +const CHAR_SURROGATE_LEN: u32 = 0xE000 - CHAR_SURROGATE_START; + +/// Convert `char` to compressed `u32` +fn char_to_comp_u32(c: char) -> u32 { + match c as u32 { + c if c >= CHAR_SURROGATE_START => c - CHAR_SURROGATE_LEN, + c => c, + } +} + +impl UniformSampler for UniformChar { + type X = char; + + #[inline] // if the range is constant, this helps LLVM to do the + // calculations at compile-time. + fn new(low_b: B1, high_b: B2) -> Self + where + B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized, + { + let low = char_to_comp_u32(*low_b.borrow()); + let high = char_to_comp_u32(*high_b.borrow()); + let sampler = UniformInt::::new(low, high); + UniformChar { sampler } + } + + #[inline] // if the range is constant, this helps LLVM to do the + // calculations at compile-time. + fn new_inclusive(low_b: B1, high_b: B2) -> Self + where + B1: SampleBorrow + Sized, + B2: SampleBorrow + Sized, + { + let low = char_to_comp_u32(*low_b.borrow()); + let high = char_to_comp_u32(*high_b.borrow()); + let sampler = UniformInt::::new_inclusive(low, high); + UniformChar { sampler } + } + + fn sample(&self, rng: &mut R) -> Self::X { + let mut x = self.sampler.sample(rng); + if x >= CHAR_SURROGATE_START { + x += CHAR_SURROGATE_LEN; + } + // SAFETY: x must not be in surrogate range or greater than char::MAX. + // This relies on range constructors which accept char arguments. + // Validity of input char values is assumed. + unsafe { core::char::from_u32_unchecked(x) } + } +} /// The back-end implementing [`UniformSampler`] for floating-point types. /// @@ -644,6 +805,7 @@ /// [`new_inclusive`]: UniformSampler::new_inclusive /// [`Standard`]: crate::distributions::Standard #[derive(Clone, Copy, Debug)] +#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] pub struct UniformFloat { low: X, scale: X, @@ -665,16 +827,21 @@ { let low = *low_b.borrow(); let high = *high_b.borrow(); - assert!(low.all_lt(high), "Uniform::new called with `low >= high`"); - assert!( - low.all_finite() && high.all_finite(), - "Uniform::new called with non-finite boundaries" + debug_assert!( + low.all_finite(), + "Uniform::new called with `low` non-finite." ); + debug_assert!( + high.all_finite(), + "Uniform::new called with `high` non-finite." + ); + assert!(low.all_lt(high), "Uniform::new called with `low >= high`"); let max_rand = <$ty>::splat( (::core::$u_scalar::MAX >> $bits_to_discard).into_float_with_exponent(0) - 1.0, ); let mut scale = high - low; + assert!(scale.all_finite(), "Uniform::new: range overflow"); loop { let mask = (scale * max_rand + low).ge_mask(high); @@ -696,19 +863,24 @@ { let low = *low_b.borrow(); let high = *high_b.borrow(); + debug_assert!( + low.all_finite(), + "Uniform::new_inclusive called with `low` non-finite." + ); + debug_assert!( + high.all_finite(), + "Uniform::new_inclusive called with `high` non-finite." + ); assert!( low.all_le(high), "Uniform::new_inclusive called with `low > high`" ); - assert!( - low.all_finite() && high.all_finite(), - "Uniform::new_inclusive called with non-finite boundaries" - ); let max_rand = <$ty>::splat( (::core::$u_scalar::MAX >> $bits_to_discard).into_float_with_exponent(0) - 1.0, ); let mut scale = (high - low) / max_rand; + assert!(scale.all_finite(), "Uniform::new_inclusive: range overflow"); loop { let mask = (scale * max_rand + low).gt_mask(high); @@ -747,11 +919,20 @@ { let low = *low_b.borrow(); let high = *high_b.borrow(); + debug_assert!( + low.all_finite(), + "UniformSampler::sample_single called with `low` non-finite." + ); + debug_assert!( + high.all_finite(), + "UniformSampler::sample_single called with `high` non-finite." + ); assert!( low.all_lt(high), "UniformSampler::sample_single: low >= high" ); let mut scale = high - low; + assert!(scale.all_finite(), "UniformSampler::sample_single: range overflow"); loop { // Generate a value in the range [1, 2) @@ -837,12 +1018,14 @@ /// Unless you are implementing [`UniformSampler`] for your own types, this type /// should not be used directly, use [`Uniform`] instead. #[derive(Clone, Copy, Debug)] +#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] pub struct UniformDuration { mode: UniformDurationMode, offset: u32, } #[derive(Debug, Copy, Clone)] +#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] enum UniformDurationMode { Small { secs: u64, @@ -947,7 +1130,7 @@ max_nanos, secs, } => { - // constant folding means this is at least as fast as `gen_range` + // constant folding means this is at least as fast as `Rng::sample(Range)` let nano_range = Uniform::new(0, 1_000_000_000); loop { let s = secs.sample(rng); @@ -967,6 +1150,56 @@ use super::*; use crate::rngs::mock::StepRng; + #[test] + #[cfg(feature = "serde1")] + fn test_serialization_uniform_duration() { + let distr = UniformDuration::new(std::time::Duration::from_secs(10), std::time::Duration::from_secs(60)); + let de_distr: UniformDuration = bincode::deserialize(&bincode::serialize(&distr).unwrap()).unwrap(); + assert_eq!( + distr.offset, de_distr.offset + ); + match (distr.mode, de_distr.mode) { + (UniformDurationMode::Small {secs: a_secs, nanos: a_nanos}, UniformDurationMode::Small {secs, nanos}) => { + assert_eq!(a_secs, secs); + + assert_eq!(a_nanos.0.low, nanos.0.low); + assert_eq!(a_nanos.0.range, nanos.0.range); + assert_eq!(a_nanos.0.z, nanos.0.z); + } + (UniformDurationMode::Medium {nanos: a_nanos} , UniformDurationMode::Medium {nanos}) => { + assert_eq!(a_nanos.0.low, nanos.0.low); + assert_eq!(a_nanos.0.range, nanos.0.range); + assert_eq!(a_nanos.0.z, nanos.0.z); + } + (UniformDurationMode::Large {max_secs:a_max_secs, max_nanos:a_max_nanos, secs:a_secs}, UniformDurationMode::Large {max_secs, max_nanos, secs} ) => { + assert_eq!(a_max_secs, max_secs); + assert_eq!(a_max_nanos, max_nanos); + + assert_eq!(a_secs.0.low, secs.0.low); + assert_eq!(a_secs.0.range, secs.0.range); + assert_eq!(a_secs.0.z, secs.0.z); + } + _ => panic!("`UniformDurationMode` was not serialized/deserialized correctly") + } + } + + #[test] + #[cfg(feature = "serde1")] + fn test_uniform_serialization() { + let unit_box: Uniform = Uniform::new(-1, 1); + let de_unit_box: Uniform = bincode::deserialize(&bincode::serialize(&unit_box).unwrap()).unwrap(); + + assert_eq!(unit_box.0.low, de_unit_box.0.low); + assert_eq!(unit_box.0.range, de_unit_box.0.range); + assert_eq!(unit_box.0.z, de_unit_box.0.z); + + let unit_box: Uniform = Uniform::new(-1., 1.); + let de_unit_box: Uniform = bincode::deserialize(&bincode::serialize(&unit_box).unwrap()).unwrap(); + + assert_eq!(unit_box.0.low, de_unit_box.0.low); + assert_eq!(unit_box.0.scale, de_unit_box.0.scale); + } + #[should_panic] #[test] fn test_uniform_bad_limits_equal_int() { @@ -1024,9 +1257,14 @@ } for _ in 0..1000 { - let v: $ty = rng.gen_range(low, high); + let v = <$ty as SampleUniform>::Sampler::sample_single(low, high, &mut rng); assert!($le(low, v) && $lt(v, high)); } + + for _ in 0..1000 { + let v = <$ty as SampleUniform>::Sampler::sample_single_inclusive(low, high, &mut rng); + assert!($le(low, v) && $le(v, high)); + } } }}; @@ -1058,7 +1296,7 @@ #[cfg(not(target_os = "emscripten"))] t!(i128, u128); - #[cfg(all(feature = "simd_support", feature = "nightly"))] + #[cfg(feature = "simd_support")] { t!(u8x2, u8x4, u8x8, u8x16, u8x32, u8x64 => u8); t!(i8x2, i8x4, i8x8, i8x16, i8x32, i8x64 => i8); @@ -1073,6 +1311,27 @@ #[test] #[cfg_attr(miri, ignore)] // Miri is too slow + fn test_char() { + let mut rng = crate::test::rng(891); + let mut max = core::char::from_u32(0).unwrap(); + for _ in 0..100 { + let c = rng.gen_range('A'..='Z'); + assert!(('A'..='Z').contains(&c)); + max = max.max(c); + } + assert_eq!(max, 'Z'); + let d = Uniform::new( + core::char::from_u32(0xD7F0).unwrap(), + core::char::from_u32(0xE010).unwrap(), + ); + for _ in 0..100 { + let c = d.sample(&mut rng); + assert!((c as u32) < 0xD800 || (c as u32) > 0xDFFF); + } + } + + #[test] + #[cfg_attr(miri, ignore)] // Miri is too slow fn test_floats() { let mut rng = crate::test::rng(252); let mut zero_rng = StepRng::new(0, 0); @@ -1088,12 +1347,8 @@ (-<$f_scalar>::from_bits(10), -<$f_scalar>::from_bits(1)), (-<$f_scalar>::from_bits(5), 0.0), (-<$f_scalar>::from_bits(7), -0.0), - (10.0, ::core::$f_scalar::MAX), - (-100.0, ::core::$f_scalar::MAX), - (-::core::$f_scalar::MAX / 5.0, ::core::$f_scalar::MAX), - (-::core::$f_scalar::MAX, ::core::$f_scalar::MAX / 5.0), - (-::core::$f_scalar::MAX * 0.8, ::core::$f_scalar::MAX * 0.7), - (-::core::$f_scalar::MAX, ::core::$f_scalar::MAX), + (0.1 * ::core::$f_scalar::MAX, ::core::$f_scalar::MAX), + (-::core::$f_scalar::MAX * 0.2, ::core::$f_scalar::MAX * 0.7), ]; for &(low_scalar, high_scalar) in v.iter() { for lane in 0..<$ty>::lanes() { @@ -1106,7 +1361,8 @@ assert!(low_scalar <= v && v < high_scalar); let v = rng.sample(my_incl_uniform).extract(lane); assert!(low_scalar <= v && v <= high_scalar); - let v = rng.gen_range(low, high).extract(lane); + let v = <$ty as SampleUniform>::Sampler + ::sample_single(low, high, &mut rng).extract(lane); assert!(low_scalar <= v && v < high_scalar); } @@ -1117,7 +1373,9 @@ assert_eq!(zero_rng.sample(my_uniform).extract(lane), low_scalar); assert_eq!(zero_rng.sample(my_incl_uniform).extract(lane), low_scalar); - assert_eq!(zero_rng.gen_range(low, high).extract(lane), low_scalar); + assert_eq!(<$ty as SampleUniform>::Sampler + ::sample_single(low, high, &mut zero_rng) + .extract(lane), low_scalar); assert!(max_rng.sample(my_uniform).extract(lane) < high_scalar); assert!(max_rng.sample(my_incl_uniform).extract(lane) <= high_scalar); @@ -1130,7 +1388,9 @@ (-1i64 << $bits_shifted) as u64, ); assert!( - lowering_max_rng.gen_range(low, high).extract(lane) < high_scalar + <$ty as SampleUniform>::Sampler + ::sample_single(low, high, &mut lowering_max_rng) + .extract(lane) < high_scalar ); } } @@ -1168,6 +1428,19 @@ } #[test] + #[should_panic] + fn test_float_overflow() { + Uniform::from(::core::f64::MIN..::core::f64::MAX); + } + + #[test] + #[should_panic] + fn test_float_overflow_single() { + let mut rng = crate::test::rng(252); + rng.gen_range(::core::f64::MIN..::core::f64::MAX); + } + + #[test] #[cfg(all( feature = "std", not(target_arch = "wasm32"), @@ -1178,7 +1451,7 @@ use std::panic::catch_unwind; fn range(low: T, high: T) { let mut rng = crate::test::rng(253); - rng.gen_range(low, high); + T::Sampler::sample_single(low, high, &mut rng); } macro_rules! t { diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/unit_circle.rs cargo-0.58.0/vendor/rand/src/distributions/unit_circle.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/unit_circle.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/unit_circle.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,102 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(deprecated)] -#![allow(clippy::all)] - -use crate::distributions::{Distribution, Uniform}; -use crate::Rng; - -/// Samples uniformly from the edge of the unit circle in two dimensions. -/// -/// Implemented via a method by von Neumann[^1]. -/// -/// [^1]: von Neumann, J. (1951) [*Various Techniques Used in Connection with -/// Random Digits.*](https://mcnp.lanl.gov/pdf_files/nbs_vonneumann.pdf) -/// NBS Appl. Math. Ser., No. 12. Washington, DC: U.S. Government Printing -/// Office, pp. 36-38. -#[deprecated(since = "0.7.0", note = "moved to rand_distr crate")] -#[derive(Clone, Copy, Debug)] -pub struct UnitCircle; - -impl UnitCircle { - /// Construct a new `UnitCircle` distribution. - #[inline] - pub fn new() -> UnitCircle { - UnitCircle - } -} - -impl Distribution<[f64; 2]> for UnitCircle { - #[inline] - fn sample(&self, rng: &mut R) -> [f64; 2] { - let uniform = Uniform::new(-1., 1.); - let mut x1; - let mut x2; - let mut sum; - loop { - x1 = uniform.sample(rng); - x2 = uniform.sample(rng); - sum = x1 * x1 + x2 * x2; - if sum < 1. { - break; - } - } - let diff = x1 * x1 - x2 * x2; - [diff / sum, 2. * x1 * x2 / sum] - } -} - -#[cfg(test)] -mod tests { - use super::UnitCircle; - use crate::distributions::Distribution; - - /// Assert that two numbers are almost equal to each other. - /// - /// On panic, this macro will print the values of the expressions with their - /// debug representations. - macro_rules! assert_almost_eq { - ($a:expr, $b:expr, $prec:expr) => { - let diff = ($a - $b).abs(); - if diff > $prec { - panic!(format!( - "assertion failed: `abs(left - right) = {:.1e} < {:e}`, \ - (left: `{}`, right: `{}`)", - diff, $prec, $a, $b - )); - } - }; - } - - #[test] - fn norm() { - let mut rng = crate::test::rng(1); - let dist = UnitCircle::new(); - for _ in 0..1000 { - let x = dist.sample(&mut rng); - assert_almost_eq!(x[0] * x[0] + x[1] * x[1], 1., 1e-15); - } - } - - #[test] - fn value_stability() { - let mut rng = crate::test::rng(2); - let expected = [ - [-0.9965658683520504, -0.08280380447614634], - [-0.9790853270389644, -0.20345004884984505], - [-0.8449189758898707, 0.5348943112253227], - ]; - let samples = [ - UnitCircle.sample(&mut rng), - UnitCircle.sample(&mut rng), - UnitCircle.sample(&mut rng), - ]; - assert_eq!(samples, expected); - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/unit_sphere.rs cargo-0.58.0/vendor/rand/src/distributions/unit_sphere.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/unit_sphere.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/unit_sphere.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,97 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(deprecated)] -#![allow(clippy::all)] - -use crate::distributions::{Distribution, Uniform}; -use crate::Rng; - -/// Samples uniformly from the surface of the unit sphere in three dimensions. -/// -/// Implemented via a method by Marsaglia[^1]. -/// -/// [^1]: Marsaglia, George (1972). [*Choosing a Point from the Surface of a -/// Sphere.*](https://doi.org/10.1214/aoms/1177692644) -/// Ann. Math. Statist. 43, no. 2, 645--646. -#[deprecated(since = "0.7.0", note = "moved to rand_distr crate")] -#[derive(Clone, Copy, Debug)] -pub struct UnitSphereSurface; - -impl UnitSphereSurface { - /// Construct a new `UnitSphereSurface` distribution. - #[inline] - pub fn new() -> UnitSphereSurface { - UnitSphereSurface - } -} - -impl Distribution<[f64; 3]> for UnitSphereSurface { - #[inline] - fn sample(&self, rng: &mut R) -> [f64; 3] { - let uniform = Uniform::new(-1., 1.); - loop { - let (x1, x2) = (uniform.sample(rng), uniform.sample(rng)); - let sum = x1 * x1 + x2 * x2; - if sum >= 1. { - continue; - } - let factor = 2. * (1.0_f64 - sum).sqrt(); - return [x1 * factor, x2 * factor, 1. - 2. * sum]; - } - } -} - -#[cfg(test)] -mod tests { - use super::UnitSphereSurface; - use crate::distributions::Distribution; - - /// Assert that two numbers are almost equal to each other. - /// - /// On panic, this macro will print the values of the expressions with their - /// debug representations. - macro_rules! assert_almost_eq { - ($a:expr, $b:expr, $prec:expr) => { - let diff = ($a - $b).abs(); - if diff > $prec { - panic!(format!( - "assertion failed: `abs(left - right) = {:.1e} < {:e}`, \ - (left: `{}`, right: `{}`)", - diff, $prec, $a, $b - )); - } - }; - } - - #[test] - fn norm() { - let mut rng = crate::test::rng(1); - let dist = UnitSphereSurface::new(); - for _ in 0..1000 { - let x = dist.sample(&mut rng); - assert_almost_eq!(x[0] * x[0] + x[1] * x[1] + x[2] * x[2], 1., 1e-15); - } - } - - #[test] - fn value_stability() { - let mut rng = crate::test::rng(2); - let expected = [ - [0.03247542860231647, -0.7830477442152738, 0.6211131755296027], - [-0.09978440840914075, 0.9706650829833128, -0.21875184231323952], - [0.2735582468624679, 0.9435374242279655, -0.1868234852870203], - ]; - let samples = [ - UnitSphereSurface.sample(&mut rng), - UnitSphereSurface.sample(&mut rng), - UnitSphereSurface.sample(&mut rng), - ]; - assert_eq!(samples, expected); - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/utils.rs cargo-0.58.0/vendor/rand/src/distributions/utils.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/utils.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/utils.rs 2022-01-21 02:47:39.000000000 +0000 @@ -8,12 +8,10 @@ //! Math helper functions -#[cfg(feature = "std")] use crate::distributions::ziggurat_tables; -#[cfg(feature = "std")] use crate::Rng; #[cfg(feature = "simd_support")] use packed_simd::*; -pub trait WideningMultiply { +pub(crate) trait WideningMultiply { type Output; fn wmul(self, x: RHS) -> Self::Output; @@ -145,7 +143,7 @@ #[cfg(target_pointer_width = "64")] wmul_impl_usize! { u64 } -#[cfg(all(feature = "simd_support", feature = "nightly"))] +#[cfg(feature = "simd_support")] mod simd_wmul { use super::*; #[cfg(target_arch = "x86")] use core::arch::x86::*; @@ -162,7 +160,7 @@ wmul_impl! { (u16x2, u32x2),, 16 } wmul_impl! { (u16x4, u32x4),, 16 } - #[cfg(not(target_feature = "sse4.2"))] + #[cfg(not(target_feature = "sse2"))] wmul_impl! { (u16x8, u32x8),, 16 } #[cfg(not(target_feature = "avx2"))] wmul_impl! { (u16x16, u32x16),, 16 } @@ -187,7 +185,7 @@ }; } - #[cfg(target_feature = "sse4.2")] + #[cfg(target_feature = "sse2")] wmul_impl_16! { u16x8, __m128i, _mm_mulhi_epu16, _mm_mullo_epi16 } #[cfg(target_feature = "avx2")] wmul_impl_16! { u16x16, __m256i, _mm256_mulhi_epu16, _mm256_mullo_epi16 } @@ -207,9 +205,6 @@ wmul_impl_large! { (u32x16,) u32, 16 } wmul_impl_large! { (u64x2, u64x4, u64x8,) u64, 32 } } -#[cfg(all(feature = "simd_support", feature = "nightly"))] -pub use self::simd_wmul::*; - /// Helper trait when dealing with scalar and SIMD floating point types. pub(crate) trait FloatSIMDUtils { @@ -240,6 +235,8 @@ /// Implement functions available in std builds but missing from core primitives #[cfg(not(std))] +// False positive: We are following `std` here. +#[allow(clippy::wrong_self_convention)] pub(crate) trait Float: Sized { fn is_nan(self) -> bool; fn is_infinite(self) -> bool; @@ -432,113 +429,3 @@ #[cfg(feature="simd_support")] simd_impl! { f64x2, f64, m64x2, u64x2 } #[cfg(feature="simd_support")] simd_impl! { f64x4, f64, m64x4, u64x4 } #[cfg(feature="simd_support")] simd_impl! { f64x8, f64, m64x8, u64x8 } - -/// Calculates ln(gamma(x)) (natural logarithm of the gamma -/// function) using the Lanczos approximation. -/// -/// The approximation expresses the gamma function as: -/// `gamma(z+1) = sqrt(2*pi)*(z+g+0.5)^(z+0.5)*exp(-z-g-0.5)*Ag(z)` -/// `g` is an arbitrary constant; we use the approximation with `g=5`. -/// -/// Noting that `gamma(z+1) = z*gamma(z)` and applying `ln` to both sides: -/// `ln(gamma(z)) = (z+0.5)*ln(z+g+0.5)-(z+g+0.5) + ln(sqrt(2*pi)*Ag(z)/z)` -/// -/// `Ag(z)` is an infinite series with coefficients that can be calculated -/// ahead of time - we use just the first 6 terms, which is good enough -/// for most purposes. -#[cfg(feature = "std")] -pub fn log_gamma(x: f64) -> f64 { - // precalculated 6 coefficients for the first 6 terms of the series - let coefficients: [f64; 6] = [ - 76.18009172947146, - -86.50532032941677, - 24.01409824083091, - -1.231739572450155, - 0.1208650973866179e-2, - -0.5395239384953e-5, - ]; - - // (x+0.5)*ln(x+g+0.5)-(x+g+0.5) - let tmp = x + 5.5; - let log = (x + 0.5) * tmp.ln() - tmp; - - // the first few terms of the series for Ag(x) - let mut a = 1.000000000190015; - let mut denom = x; - for coeff in &coefficients { - denom += 1.0; - a += coeff / denom; - } - - // get everything together - // a is Ag(x) - // 2.5066... is sqrt(2pi) - log + (2.5066282746310005 * a / x).ln() -} - -/// Sample a random number using the Ziggurat method (specifically the -/// ZIGNOR variant from Doornik 2005). Most of the arguments are -/// directly from the paper: -/// -/// * `rng`: source of randomness -/// * `symmetric`: whether this is a symmetric distribution, or one-sided with P(x < 0) = 0. -/// * `X`: the $x_i$ abscissae. -/// * `F`: precomputed values of the PDF at the $x_i$, (i.e. $f(x_i)$) -/// * `F_DIFF`: precomputed values of $f(x_i) - f(x_{i+1})$ -/// * `pdf`: the probability density function -/// * `zero_case`: manual sampling from the tail when we chose the -/// bottom box (i.e. i == 0) - -// the perf improvement (25-50%) is definitely worth the extra code -// size from force-inlining. -#[cfg(feature = "std")] -#[inline(always)] -pub fn ziggurat( - rng: &mut R, - symmetric: bool, - x_tab: ziggurat_tables::ZigTable, - f_tab: ziggurat_tables::ZigTable, - mut pdf: P, - mut zero_case: Z -) -> f64 -where - P: FnMut(f64) -> f64, - Z: FnMut(&mut R, f64) -> f64, -{ - use crate::distributions::float::IntoFloat; - loop { - // As an optimisation we re-implement the conversion to a f64. - // From the remaining 12 most significant bits we use 8 to construct `i`. - // This saves us generating a whole extra random number, while the added - // precision of using 64 bits for f64 does not buy us much. - let bits = rng.next_u64(); - let i = bits as usize & 0xff; - - let u = if symmetric { - // Convert to a value in the range [2,4) and substract to get [-1,1) - // We can't convert to an open range directly, that would require - // substracting `3.0 - EPSILON`, which is not representable. - // It is possible with an extra step, but an open range does not - // seem neccesary for the ziggurat algorithm anyway. - (bits >> 12).into_float_with_exponent(1) - 3.0 - } else { - // Convert to a value in the range [1,2) and substract to get (0,1) - (bits >> 12).into_float_with_exponent(0) - (1.0 - ::core::f64::EPSILON / 2.0) - }; - let x = u * x_tab[i]; - - let test_x = if symmetric { x.abs() } else { x }; - - // algebraically equivalent to |u| < x_tab[i+1]/x_tab[i] (or u < x_tab[i+1]/x_tab[i]) - if test_x < x_tab[i + 1] { - return x; - } - if i == 0 { - return zero_case(rng, u); - } - // algebraically equivalent to f1 + DRanU()*(f0 - f1) < 1 - if f_tab[i + 1] + (f_tab[i] - f_tab[i + 1]) * rng.gen::() < pdf(x) { - return x; - } - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/weibull.rs cargo-0.58.0/vendor/rand/src/distributions/weibull.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/weibull.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/weibull.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! The Weibull distribution. -#![allow(deprecated)] - -use crate::distributions::{Distribution, OpenClosed01}; -use crate::Rng; - -/// Samples floating-point numbers according to the Weibull distribution -#[deprecated(since = "0.7.0", note = "moved to rand_distr crate")] -#[derive(Clone, Copy, Debug)] -pub struct Weibull { - inv_shape: f64, - scale: f64, -} - -impl Weibull { - /// Construct a new `Weibull` distribution with given `scale` and `shape`. - /// - /// # Panics - /// - /// `scale` and `shape` have to be non-zero and positive. - pub fn new(scale: f64, shape: f64) -> Weibull { - assert!((scale > 0.) & (shape > 0.)); - Weibull { - inv_shape: 1. / shape, - scale, - } - } -} - -impl Distribution for Weibull { - fn sample(&self, rng: &mut R) -> f64 { - let x: f64 = rng.sample(OpenClosed01); - self.scale * (-x.ln()).powf(self.inv_shape) - } -} - -#[cfg(test)] -mod tests { - use super::Weibull; - use crate::distributions::Distribution; - - #[test] - #[should_panic] - fn invalid() { - Weibull::new(0., 0.); - } - - #[test] - fn sample() { - let scale = 1.0; - let shape = 2.0; - let d = Weibull::new(scale, shape); - let mut rng = crate::test::rng(1); - for _ in 0..1000 { - let r = d.sample(&mut rng); - assert!(r >= 0.); - } - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/weighted/alias_method.rs cargo-0.58.0/vendor/rand/src/distributions/weighted/alias_method.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/weighted/alias_method.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/weighted/alias_method.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,517 +0,0 @@ -//! This module contains an implementation of alias method for sampling random -//! indices with probabilities proportional to a collection of weights. - -use super::WeightedError; -#[cfg(not(feature = "std"))] use crate::alloc::vec; -#[cfg(not(feature = "std"))] use crate::alloc::vec::Vec; -use crate::distributions::uniform::SampleUniform; -use crate::distributions::Distribution; -use crate::distributions::Uniform; -use crate::Rng; -use core::fmt; -use core::iter::Sum; -use core::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign}; - -/// A distribution using weighted sampling to pick a discretely selected item. -/// -/// Sampling a [`WeightedIndex`] distribution returns the index of a randomly -/// selected element from the vector used to create the [`WeightedIndex`]. -/// The chance of a given element being picked is proportional to the value of -/// the element. The weights can have any type `W` for which a implementation of -/// [`Weight`] exists. -/// -/// # Performance -/// -/// Given that `n` is the number of items in the vector used to create an -/// [`WeightedIndex`], [`WeightedIndex`] will require `O(n)` amount of -/// memory. More specifically it takes up some constant amount of memory plus -/// the vector used to create it and a [`Vec`] with capacity `n`. -/// -/// Time complexity for the creation of a [`WeightedIndex`] is `O(n)`. -/// Sampling is `O(1)`, it makes a call to [`Uniform::sample`] and a call -/// to [`Uniform::sample`]. -/// -/// # Example -/// -/// ``` -/// use rand::distributions::weighted::alias_method::WeightedIndex; -/// use rand::prelude::*; -/// -/// let choices = vec!['a', 'b', 'c']; -/// let weights = vec![2, 1, 1]; -/// let dist = WeightedIndex::new(weights).unwrap(); -/// let mut rng = thread_rng(); -/// for _ in 0..100 { -/// // 50% chance to print 'a', 25% chance to print 'b', 25% chance to print 'c' -/// println!("{}", choices[dist.sample(&mut rng)]); -/// } -/// -/// let items = [('a', 0), ('b', 3), ('c', 7)]; -/// let dist2 = WeightedIndex::new(items.iter().map(|item| item.1).collect()).unwrap(); -/// for _ in 0..100 { -/// // 0% chance to print 'a', 30% chance to print 'b', 70% chance to print 'c' -/// println!("{}", items[dist2.sample(&mut rng)].0); -/// } -/// ``` -/// -/// [`WeightedIndex`]: crate::distributions::weighted::alias_method::WeightedIndex -/// [`Weight`]: crate::distributions::weighted::alias_method::Weight -/// [`Vec`]: Vec -/// [`Uniform::sample`]: Distribution::sample -/// [`Uniform::sample`]: Distribution::sample -pub struct WeightedIndex { - aliases: Vec, - no_alias_odds: Vec, - uniform_index: Uniform, - uniform_within_weight_sum: Uniform, -} - -impl WeightedIndex { - /// Creates a new [`WeightedIndex`]. - /// - /// Returns an error if: - /// - The vector is empty. - /// - The vector is longer than `u32::MAX`. - /// - For any weight `w`: `w < 0` or `w > max` where `max = W::MAX / - /// weights.len()`. - /// - The sum of weights is zero. - pub fn new(weights: Vec) -> Result { - let n = weights.len(); - if n == 0 { - return Err(WeightedError::NoItem); - } else if n > ::core::u32::MAX as usize { - return Err(WeightedError::TooMany); - } - let n = n as u32; - - let max_weight_size = W::try_from_u32_lossy(n) - .map(|n| W::MAX / n) - .unwrap_or(W::ZERO); - if !weights - .iter() - .all(|&w| W::ZERO <= w && w <= max_weight_size) - { - return Err(WeightedError::InvalidWeight); - } - - // The sum of weights will represent 100% of no alias odds. - let weight_sum = Weight::sum(weights.as_slice()); - // Prevent floating point overflow due to rounding errors. - let weight_sum = if weight_sum > W::MAX { - W::MAX - } else { - weight_sum - }; - if weight_sum == W::ZERO { - return Err(WeightedError::AllWeightsZero); - } - - // `weight_sum` would have been zero if `try_from_lossy` causes an error here. - let n_converted = W::try_from_u32_lossy(n).unwrap(); - - let mut no_alias_odds = weights; - for odds in no_alias_odds.iter_mut() { - *odds *= n_converted; - // Prevent floating point overflow due to rounding errors. - *odds = if *odds > W::MAX { W::MAX } else { *odds }; - } - - /// This struct is designed to contain three data structures at once, - /// sharing the same memory. More precisely it contains two linked lists - /// and an alias map, which will be the output of this method. To keep - /// the three data structures from getting in each other's way, it must - /// be ensured that a single index is only ever in one of them at the - /// same time. - struct Aliases { - aliases: Vec, - smalls_head: u32, - bigs_head: u32, - } - - impl Aliases { - fn new(size: u32) -> Self { - Aliases { - aliases: vec![0; size as usize], - smalls_head: ::core::u32::MAX, - bigs_head: ::core::u32::MAX, - } - } - - fn push_small(&mut self, idx: u32) { - self.aliases[idx as usize] = self.smalls_head; - self.smalls_head = idx; - } - - fn push_big(&mut self, idx: u32) { - self.aliases[idx as usize] = self.bigs_head; - self.bigs_head = idx; - } - - fn pop_small(&mut self) -> u32 { - let popped = self.smalls_head; - self.smalls_head = self.aliases[popped as usize]; - popped - } - - fn pop_big(&mut self) -> u32 { - let popped = self.bigs_head; - self.bigs_head = self.aliases[popped as usize]; - popped - } - - fn smalls_is_empty(&self) -> bool { - self.smalls_head == ::core::u32::MAX - } - - fn bigs_is_empty(&self) -> bool { - self.bigs_head == ::core::u32::MAX - } - - fn set_alias(&mut self, idx: u32, alias: u32) { - self.aliases[idx as usize] = alias; - } - } - - let mut aliases = Aliases::new(n); - - // Split indices into those with small weights and those with big weights. - for (index, &odds) in no_alias_odds.iter().enumerate() { - if odds < weight_sum { - aliases.push_small(index as u32); - } else { - aliases.push_big(index as u32); - } - } - - // Build the alias map by finding an alias with big weight for each index with - // small weight. - while !aliases.smalls_is_empty() && !aliases.bigs_is_empty() { - let s = aliases.pop_small(); - let b = aliases.pop_big(); - - aliases.set_alias(s, b); - no_alias_odds[b as usize] = - no_alias_odds[b as usize] - weight_sum + no_alias_odds[s as usize]; - - if no_alias_odds[b as usize] < weight_sum { - aliases.push_small(b); - } else { - aliases.push_big(b); - } - } - - // The remaining indices should have no alias odds of about 100%. This is due to - // numeric accuracy. Otherwise they would be exactly 100%. - while !aliases.smalls_is_empty() { - no_alias_odds[aliases.pop_small() as usize] = weight_sum; - } - while !aliases.bigs_is_empty() { - no_alias_odds[aliases.pop_big() as usize] = weight_sum; - } - - // Prepare distributions for sampling. Creating them beforehand improves - // sampling performance. - let uniform_index = Uniform::new(0, n); - let uniform_within_weight_sum = Uniform::new(W::ZERO, weight_sum); - - Ok(Self { - aliases: aliases.aliases, - no_alias_odds, - uniform_index, - uniform_within_weight_sum, - }) - } -} - -impl Distribution for WeightedIndex { - fn sample(&self, rng: &mut R) -> usize { - let candidate = rng.sample(self.uniform_index); - if rng.sample(&self.uniform_within_weight_sum) < self.no_alias_odds[candidate as usize] { - candidate as usize - } else { - self.aliases[candidate as usize] as usize - } - } -} - -impl fmt::Debug for WeightedIndex -where - W: fmt::Debug, - Uniform: fmt::Debug, -{ - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - f.debug_struct("WeightedIndex") - .field("aliases", &self.aliases) - .field("no_alias_odds", &self.no_alias_odds) - .field("uniform_index", &self.uniform_index) - .field("uniform_within_weight_sum", &self.uniform_within_weight_sum) - .finish() - } -} - -impl Clone for WeightedIndex -where Uniform: Clone -{ - fn clone(&self) -> Self { - Self { - aliases: self.aliases.clone(), - no_alias_odds: self.no_alias_odds.clone(), - uniform_index: self.uniform_index.clone(), - uniform_within_weight_sum: self.uniform_within_weight_sum.clone(), - } - } -} - -/// Trait that must be implemented for weights, that are used with -/// [`WeightedIndex`]. Currently no guarantees on the correctness of -/// [`WeightedIndex`] are given for custom implementations of this trait. -pub trait Weight: - Sized - + Copy - + SampleUniform - + PartialOrd - + Add - + AddAssign - + Sub - + SubAssign - + Mul - + MulAssign - + Div - + DivAssign - + Sum -{ - /// Maximum number representable by `Self`. - const MAX: Self; - - /// Element of `Self` equivalent to 0. - const ZERO: Self; - - /// Produce an instance of `Self` from a `u32` value, or return `None` if - /// out of range. Loss of precision (where `Self` is a floating point type) - /// is acceptable. - fn try_from_u32_lossy(n: u32) -> Option; - - /// Sums all values in slice `values`. - fn sum(values: &[Self]) -> Self { - values.iter().map(|x| *x).sum() - } -} - -macro_rules! impl_weight_for_float { - ($T: ident) => { - impl Weight for $T { - const MAX: Self = ::core::$T::MAX; - const ZERO: Self = 0.0; - - fn try_from_u32_lossy(n: u32) -> Option { - Some(n as $T) - } - - fn sum(values: &[Self]) -> Self { - pairwise_sum(values) - } - } - }; -} - -/// In comparison to naive accumulation, the pairwise sum algorithm reduces -/// rounding errors when there are many floating point values. -fn pairwise_sum(values: &[T]) -> T { - if values.len() <= 32 { - values.iter().map(|x| *x).sum() - } else { - let mid = values.len() / 2; - let (a, b) = values.split_at(mid); - pairwise_sum(a) + pairwise_sum(b) - } -} - -macro_rules! impl_weight_for_int { - ($T: ident) => { - impl Weight for $T { - const MAX: Self = ::core::$T::MAX; - const ZERO: Self = 0; - - fn try_from_u32_lossy(n: u32) -> Option { - let n_converted = n as Self; - if n_converted >= Self::ZERO && n_converted as u32 == n { - Some(n_converted) - } else { - None - } - } - } - }; -} - -impl_weight_for_float!(f64); -impl_weight_for_float!(f32); -impl_weight_for_int!(usize); -#[cfg(not(target_os = "emscripten"))] -impl_weight_for_int!(u128); -impl_weight_for_int!(u64); -impl_weight_for_int!(u32); -impl_weight_for_int!(u16); -impl_weight_for_int!(u8); -impl_weight_for_int!(isize); -#[cfg(not(target_os = "emscripten"))] -impl_weight_for_int!(i128); -impl_weight_for_int!(i64); -impl_weight_for_int!(i32); -impl_weight_for_int!(i16); -impl_weight_for_int!(i8); - -#[cfg(test)] -mod test { - use super::*; - - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_weighted_index_f32() { - test_weighted_index(f32::into); - - // Floating point special cases - assert_eq!( - WeightedIndex::new(vec![::core::f32::INFINITY]).unwrap_err(), - WeightedError::InvalidWeight - ); - assert_eq!( - WeightedIndex::new(vec![-0_f32]).unwrap_err(), - WeightedError::AllWeightsZero - ); - assert_eq!( - WeightedIndex::new(vec![-1_f32]).unwrap_err(), - WeightedError::InvalidWeight - ); - assert_eq!( - WeightedIndex::new(vec![-::core::f32::INFINITY]).unwrap_err(), - WeightedError::InvalidWeight - ); - assert_eq!( - WeightedIndex::new(vec![::core::f32::NAN]).unwrap_err(), - WeightedError::InvalidWeight - ); - } - - #[cfg(not(target_os = "emscripten"))] - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_weighted_index_u128() { - test_weighted_index(|x: u128| x as f64); - } - - #[cfg(all(rustc_1_26, not(target_os = "emscripten")))] - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_weighted_index_i128() { - test_weighted_index(|x: i128| x as f64); - - // Signed integer special cases - assert_eq!( - WeightedIndex::new(vec![-1_i128]).unwrap_err(), - WeightedError::InvalidWeight - ); - assert_eq!( - WeightedIndex::new(vec![::core::i128::MIN]).unwrap_err(), - WeightedError::InvalidWeight - ); - } - - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_weighted_index_u8() { - test_weighted_index(u8::into); - } - - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_weighted_index_i8() { - test_weighted_index(i8::into); - - // Signed integer special cases - assert_eq!( - WeightedIndex::new(vec![-1_i8]).unwrap_err(), - WeightedError::InvalidWeight - ); - assert_eq!( - WeightedIndex::new(vec![::core::i8::MIN]).unwrap_err(), - WeightedError::InvalidWeight - ); - } - - fn test_weighted_index f64>(w_to_f64: F) - where WeightedIndex: fmt::Debug { - const NUM_WEIGHTS: u32 = 10; - const ZERO_WEIGHT_INDEX: u32 = 3; - const NUM_SAMPLES: u32 = 15000; - let mut rng = crate::test::rng(0x9c9fa0b0580a7031); - - let weights = { - let mut weights = Vec::with_capacity(NUM_WEIGHTS as usize); - let random_weight_distribution = crate::distributions::Uniform::new_inclusive( - W::ZERO, - W::MAX / W::try_from_u32_lossy(NUM_WEIGHTS).unwrap(), - ); - for _ in 0..NUM_WEIGHTS { - weights.push(rng.sample(&random_weight_distribution)); - } - weights[ZERO_WEIGHT_INDEX as usize] = W::ZERO; - weights - }; - let weight_sum = weights.iter().map(|w| *w).sum::(); - let expected_counts = weights - .iter() - .map(|&w| w_to_f64(w) / w_to_f64(weight_sum) * NUM_SAMPLES as f64) - .collect::>(); - let weight_distribution = WeightedIndex::new(weights).unwrap(); - - let mut counts = vec![0; NUM_WEIGHTS as usize]; - for _ in 0..NUM_SAMPLES { - counts[rng.sample(&weight_distribution)] += 1; - } - - assert_eq!(counts[ZERO_WEIGHT_INDEX as usize], 0); - for (count, expected_count) in counts.into_iter().zip(expected_counts) { - let difference = (count as f64 - expected_count).abs(); - let max_allowed_difference = NUM_SAMPLES as f64 / NUM_WEIGHTS as f64 * 0.1; - assert!(difference <= max_allowed_difference); - } - - assert_eq!( - WeightedIndex::::new(vec![]).unwrap_err(), - WeightedError::NoItem - ); - assert_eq!( - WeightedIndex::new(vec![W::ZERO]).unwrap_err(), - WeightedError::AllWeightsZero - ); - assert_eq!( - WeightedIndex::new(vec![W::MAX, W::MAX]).unwrap_err(), - WeightedError::InvalidWeight - ); - } - - #[test] - fn value_stability() { - fn test_samples(weights: Vec, buf: &mut [usize], expected: &[usize]) { - assert_eq!(buf.len(), expected.len()); - let distr = WeightedIndex::new(weights).unwrap(); - let mut rng = crate::test::rng(0x9c9fa0b0580a7031); - for r in buf.iter_mut() { - *r = rng.sample(&distr); - } - assert_eq!(buf, expected); - } - - let mut buf = [0; 10]; - test_samples(vec![1i32, 1, 1, 1, 1, 1, 1, 1, 1], &mut buf, &[ - 6, 5, 7, 5, 8, 7, 6, 2, 3, 7, - ]); - test_samples(vec![0.7f32, 0.1, 0.1, 0.1], &mut buf, &[ - 2, 0, 0, 0, 0, 0, 0, 0, 1, 3, - ]); - test_samples(vec![1.0f64, 0.999, 0.998, 0.997], &mut buf, &[ - 2, 1, 2, 3, 2, 1, 3, 2, 1, 1, - ]); - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/weighted/mod.rs cargo-0.58.0/vendor/rand/src/distributions/weighted/mod.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/weighted/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/weighted/mod.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,413 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Weighted index sampling -//! -//! This module provides two implementations for sampling indices: -//! -//! * [`WeightedIndex`] allows `O(log N)` sampling -//! * [`alias_method::WeightedIndex`] allows `O(1)` sampling, but with -//! much greater set-up cost -//! -//! [`alias_method::WeightedIndex`]: alias_method/struct.WeightedIndex.html - -pub mod alias_method; - -use crate::distributions::uniform::{SampleBorrow, SampleUniform, UniformSampler}; -use crate::distributions::Distribution; -use crate::Rng; -use core::cmp::PartialOrd; -use core::fmt; - -// Note that this whole module is only imported if feature="alloc" is enabled. -#[cfg(not(feature = "std"))] use crate::alloc::vec::Vec; - -/// A distribution using weighted sampling to pick a discretely selected -/// item. -/// -/// Sampling a `WeightedIndex` distribution returns the index of a randomly -/// selected element from the iterator used when the `WeightedIndex` was -/// created. The chance of a given element being picked is proportional to the -/// value of the element. The weights can use any type `X` for which an -/// implementation of [`Uniform`] exists. -/// -/// # Performance -/// -/// A `WeightedIndex` contains a `Vec` and a [`Uniform`] and so its -/// size is the sum of the size of those objects, possibly plus some alignment. -/// -/// Creating a `WeightedIndex` will allocate enough space to hold `N - 1` -/// weights of type `X`, where `N` is the number of weights. However, since -/// `Vec` doesn't guarantee a particular growth strategy, additional memory -/// might be allocated but not used. Since the `WeightedIndex` object also -/// contains, this might cause additional allocations, though for primitive -/// types, ['Uniform`] doesn't allocate any memory. -/// -/// Time complexity of sampling from `WeightedIndex` is `O(log N)` where -/// `N` is the number of weights. -/// -/// Sampling from `WeightedIndex` will result in a single call to -/// `Uniform::sample` (method of the [`Distribution`] trait), which typically -/// will request a single value from the underlying [`RngCore`], though the -/// exact number depends on the implementaiton of `Uniform::sample`. -/// -/// # Example -/// -/// ``` -/// use rand::prelude::*; -/// use rand::distributions::WeightedIndex; -/// -/// let choices = ['a', 'b', 'c']; -/// let weights = [2, 1, 1]; -/// let dist = WeightedIndex::new(&weights).unwrap(); -/// let mut rng = thread_rng(); -/// for _ in 0..100 { -/// // 50% chance to print 'a', 25% chance to print 'b', 25% chance to print 'c' -/// println!("{}", choices[dist.sample(&mut rng)]); -/// } -/// -/// let items = [('a', 0), ('b', 3), ('c', 7)]; -/// let dist2 = WeightedIndex::new(items.iter().map(|item| item.1)).unwrap(); -/// for _ in 0..100 { -/// // 0% chance to print 'a', 30% chance to print 'b', 70% chance to print 'c' -/// println!("{}", items[dist2.sample(&mut rng)].0); -/// } -/// ``` -/// -/// [`Uniform`]: crate::distributions::uniform::Uniform -/// [`RngCore`]: crate::RngCore -#[derive(Debug, Clone)] -pub struct WeightedIndex { - cumulative_weights: Vec, - total_weight: X, - weight_distribution: X::Sampler, -} - -impl WeightedIndex { - /// Creates a new a `WeightedIndex` [`Distribution`] using the values - /// in `weights`. The weights can use any type `X` for which an - /// implementation of [`Uniform`] exists. - /// - /// Returns an error if the iterator is empty, if any weight is `< 0`, or - /// if its total value is 0. - /// - /// [`Uniform`]: crate::distributions::uniform::Uniform - pub fn new(weights: I) -> Result, WeightedError> - where - I: IntoIterator, - I::Item: SampleBorrow, - X: for<'a> ::core::ops::AddAssign<&'a X> + Clone + Default, - { - let mut iter = weights.into_iter(); - let mut total_weight: X = iter.next().ok_or(WeightedError::NoItem)?.borrow().clone(); - - let zero = ::default(); - if total_weight < zero { - return Err(WeightedError::InvalidWeight); - } - - let mut weights = Vec::::with_capacity(iter.size_hint().0); - for w in iter { - if *w.borrow() < zero { - return Err(WeightedError::InvalidWeight); - } - weights.push(total_weight.clone()); - total_weight += w.borrow(); - } - - if total_weight == zero { - return Err(WeightedError::AllWeightsZero); - } - let distr = X::Sampler::new(zero, total_weight.clone()); - - Ok(WeightedIndex { - cumulative_weights: weights, - total_weight, - weight_distribution: distr, - }) - } - - /// Update a subset of weights, without changing the number of weights. - /// - /// `new_weights` must be sorted by the index. - /// - /// Using this method instead of `new` might be more efficient if only a small number of - /// weights is modified. No allocations are performed, unless the weight type `X` uses - /// allocation internally. - /// - /// In case of error, `self` is not modified. - pub fn update_weights(&mut self, new_weights: &[(usize, &X)]) -> Result<(), WeightedError> - where X: for<'a> ::core::ops::AddAssign<&'a X> - + for<'a> ::core::ops::SubAssign<&'a X> - + Clone - + Default { - if new_weights.is_empty() { - return Ok(()); - } - - let zero = ::default(); - - let mut total_weight = self.total_weight.clone(); - - // Check for errors first, so we don't modify `self` in case something - // goes wrong. - let mut prev_i = None; - for &(i, w) in new_weights { - if let Some(old_i) = prev_i { - if old_i >= i { - return Err(WeightedError::InvalidWeight); - } - } - if *w < zero { - return Err(WeightedError::InvalidWeight); - } - if i >= self.cumulative_weights.len() + 1 { - return Err(WeightedError::TooMany); - } - - let mut old_w = if i < self.cumulative_weights.len() { - self.cumulative_weights[i].clone() - } else { - self.total_weight.clone() - }; - if i > 0 { - old_w -= &self.cumulative_weights[i - 1]; - } - - total_weight -= &old_w; - total_weight += w; - prev_i = Some(i); - } - if total_weight == zero { - return Err(WeightedError::AllWeightsZero); - } - - // Update the weights. Because we checked all the preconditions in the - // previous loop, this should never panic. - let mut iter = new_weights.iter(); - - let mut prev_weight = zero.clone(); - let mut next_new_weight = iter.next(); - let &(first_new_index, _) = next_new_weight.unwrap(); - let mut cumulative_weight = if first_new_index > 0 { - self.cumulative_weights[first_new_index - 1].clone() - } else { - zero.clone() - }; - for i in first_new_index..self.cumulative_weights.len() { - match next_new_weight { - Some(&(j, w)) if i == j => { - cumulative_weight += w; - next_new_weight = iter.next(); - } - _ => { - let mut tmp = self.cumulative_weights[i].clone(); - tmp -= &prev_weight; // We know this is positive. - cumulative_weight += &tmp; - } - } - prev_weight = cumulative_weight.clone(); - core::mem::swap(&mut prev_weight, &mut self.cumulative_weights[i]); - } - - self.total_weight = total_weight; - self.weight_distribution = X::Sampler::new(zero, self.total_weight.clone()); - - Ok(()) - } -} - -impl Distribution for WeightedIndex -where X: SampleUniform + PartialOrd -{ - fn sample(&self, rng: &mut R) -> usize { - use ::core::cmp::Ordering; - let chosen_weight = self.weight_distribution.sample(rng); - // Find the first item which has a weight *higher* than the chosen weight. - self.cumulative_weights - .binary_search_by(|w| { - if *w <= chosen_weight { - Ordering::Less - } else { - Ordering::Greater - } - }) - .unwrap_err() - } -} - -#[cfg(test)] -mod test { - use super::*; - - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_weightedindex() { - let mut r = crate::test::rng(700); - const N_REPS: u32 = 5000; - let weights = [1u32, 2, 3, 0, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7]; - let total_weight = weights.iter().sum::() as f32; - - let verify = |result: [i32; 14]| { - for (i, count) in result.iter().enumerate() { - let exp = (weights[i] * N_REPS) as f32 / total_weight; - let mut err = (*count as f32 - exp).abs(); - if err != 0.0 { - err /= exp; - } - assert!(err <= 0.25); - } - }; - - // WeightedIndex from vec - let mut chosen = [0i32; 14]; - let distr = WeightedIndex::new(weights.to_vec()).unwrap(); - for _ in 0..N_REPS { - chosen[distr.sample(&mut r)] += 1; - } - verify(chosen); - - // WeightedIndex from slice - chosen = [0i32; 14]; - let distr = WeightedIndex::new(&weights[..]).unwrap(); - for _ in 0..N_REPS { - chosen[distr.sample(&mut r)] += 1; - } - verify(chosen); - - // WeightedIndex from iterator - chosen = [0i32; 14]; - let distr = WeightedIndex::new(weights.iter()).unwrap(); - for _ in 0..N_REPS { - chosen[distr.sample(&mut r)] += 1; - } - verify(chosen); - - for _ in 0..5 { - assert_eq!(WeightedIndex::new(&[0, 1]).unwrap().sample(&mut r), 1); - assert_eq!(WeightedIndex::new(&[1, 0]).unwrap().sample(&mut r), 0); - assert_eq!( - WeightedIndex::new(&[0, 0, 0, 0, 10, 0]) - .unwrap() - .sample(&mut r), - 4 - ); - } - - assert_eq!( - WeightedIndex::new(&[10][0..0]).unwrap_err(), - WeightedError::NoItem - ); - assert_eq!( - WeightedIndex::new(&[0]).unwrap_err(), - WeightedError::AllWeightsZero - ); - assert_eq!( - WeightedIndex::new(&[10, 20, -1, 30]).unwrap_err(), - WeightedError::InvalidWeight - ); - assert_eq!( - WeightedIndex::new(&[-10, 20, 1, 30]).unwrap_err(), - WeightedError::InvalidWeight - ); - assert_eq!( - WeightedIndex::new(&[-10]).unwrap_err(), - WeightedError::InvalidWeight - ); - } - - #[test] - fn test_update_weights() { - let data = [ - ( - &[10u32, 2, 3, 4][..], - &[(1, &100), (2, &4)][..], // positive change - &[10, 100, 4, 4][..], - ), - ( - &[1u32, 2, 3, 0, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7][..], - &[(2, &1), (5, &1), (13, &100)][..], // negative change and last element - &[1u32, 2, 1, 0, 5, 1, 7, 1, 2, 3, 4, 5, 6, 100][..], - ), - ]; - - for (weights, update, expected_weights) in data.iter() { - let total_weight = weights.iter().sum::(); - let mut distr = WeightedIndex::new(weights.to_vec()).unwrap(); - assert_eq!(distr.total_weight, total_weight); - - distr.update_weights(update).unwrap(); - let expected_total_weight = expected_weights.iter().sum::(); - let expected_distr = WeightedIndex::new(expected_weights.to_vec()).unwrap(); - assert_eq!(distr.total_weight, expected_total_weight); - assert_eq!(distr.total_weight, expected_distr.total_weight); - assert_eq!(distr.cumulative_weights, expected_distr.cumulative_weights); - } - } - - #[test] - fn value_stability() { - fn test_samples( - weights: I, buf: &mut [usize], expected: &[usize], - ) where - I: IntoIterator, - I::Item: SampleBorrow, - X: for<'a> ::core::ops::AddAssign<&'a X> + Clone + Default, - { - assert_eq!(buf.len(), expected.len()); - let distr = WeightedIndex::new(weights).unwrap(); - let mut rng = crate::test::rng(701); - for r in buf.iter_mut() { - *r = rng.sample(&distr); - } - assert_eq!(buf, expected); - } - - let mut buf = [0; 10]; - test_samples(&[1i32, 1, 1, 1, 1, 1, 1, 1, 1], &mut buf, &[ - 0, 6, 2, 6, 3, 4, 7, 8, 2, 5, - ]); - test_samples(&[0.7f32, 0.1, 0.1, 0.1], &mut buf, &[ - 0, 0, 0, 1, 0, 0, 2, 3, 0, 0, - ]); - test_samples(&[1.0f64, 0.999, 0.998, 0.997], &mut buf, &[ - 2, 2, 1, 3, 2, 1, 3, 3, 2, 1, - ]); - } -} - -/// Error type returned from `WeightedIndex::new`. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum WeightedError { - /// The provided weight collection contains no items. - NoItem, - - /// A weight is either less than zero, greater than the supported maximum or - /// otherwise invalid. - InvalidWeight, - - /// All items in the provided weight collection are zero. - AllWeightsZero, - - /// Too many weights are provided (length greater than `u32::MAX`) - TooMany, -} - -#[cfg(feature = "std")] -impl ::std::error::Error for WeightedError {} - -impl fmt::Display for WeightedError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match *self { - WeightedError::NoItem => write!(f, "No weights provided."), - WeightedError::InvalidWeight => write!(f, "A weight is invalid."), - WeightedError::AllWeightsZero => write!(f, "All weights are zero."), - WeightedError::TooMany => write!(f, "Too many weights (hit u32::MAX)"), - } - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/weighted_index.rs cargo-0.58.0/vendor/rand/src/distributions/weighted_index.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/weighted_index.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/weighted_index.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,453 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Weighted index sampling + +use crate::distributions::uniform::{SampleBorrow, SampleUniform, UniformSampler}; +use crate::distributions::Distribution; +use crate::Rng; +use core::cmp::PartialOrd; +use core::fmt; + +// Note that this whole module is only imported if feature="alloc" is enabled. +use alloc::vec::Vec; + +#[cfg(feature = "serde1")] +use serde::{Serialize, Deserialize}; + +/// A distribution using weighted sampling of discrete items +/// +/// Sampling a `WeightedIndex` distribution returns the index of a randomly +/// selected element from the iterator used when the `WeightedIndex` was +/// created. The chance of a given element being picked is proportional to the +/// value of the element. The weights can use any type `X` for which an +/// implementation of [`Uniform`] exists. +/// +/// # Performance +/// +/// Time complexity of sampling from `WeightedIndex` is `O(log N)` where +/// `N` is the number of weights. As an alternative, +/// [`rand_distr::weighted_alias`](https://docs.rs/rand_distr/*/rand_distr/weighted_alias/index.html) +/// supports `O(1)` sampling, but with much higher initialisation cost. +/// +/// A `WeightedIndex` contains a `Vec` and a [`Uniform`] and so its +/// size is the sum of the size of those objects, possibly plus some alignment. +/// +/// Creating a `WeightedIndex` will allocate enough space to hold `N - 1` +/// weights of type `X`, where `N` is the number of weights. However, since +/// `Vec` doesn't guarantee a particular growth strategy, additional memory +/// might be allocated but not used. Since the `WeightedIndex` object also +/// contains, this might cause additional allocations, though for primitive +/// types, [`Uniform`] doesn't allocate any memory. +/// +/// Sampling from `WeightedIndex` will result in a single call to +/// `Uniform::sample` (method of the [`Distribution`] trait), which typically +/// will request a single value from the underlying [`RngCore`], though the +/// exact number depends on the implementation of `Uniform::sample`. +/// +/// # Example +/// +/// ``` +/// use rand::prelude::*; +/// use rand::distributions::WeightedIndex; +/// +/// let choices = ['a', 'b', 'c']; +/// let weights = [2, 1, 1]; +/// let dist = WeightedIndex::new(&weights).unwrap(); +/// let mut rng = thread_rng(); +/// for _ in 0..100 { +/// // 50% chance to print 'a', 25% chance to print 'b', 25% chance to print 'c' +/// println!("{}", choices[dist.sample(&mut rng)]); +/// } +/// +/// let items = [('a', 0), ('b', 3), ('c', 7)]; +/// let dist2 = WeightedIndex::new(items.iter().map(|item| item.1)).unwrap(); +/// for _ in 0..100 { +/// // 0% chance to print 'a', 30% chance to print 'b', 70% chance to print 'c' +/// println!("{}", items[dist2.sample(&mut rng)].0); +/// } +/// ``` +/// +/// [`Uniform`]: crate::distributions::Uniform +/// [`RngCore`]: crate::RngCore +#[derive(Debug, Clone)] +#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] +#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] +pub struct WeightedIndex { + cumulative_weights: Vec, + total_weight: X, + weight_distribution: X::Sampler, +} + +impl WeightedIndex { + /// Creates a new a `WeightedIndex` [`Distribution`] using the values + /// in `weights`. The weights can use any type `X` for which an + /// implementation of [`Uniform`] exists. + /// + /// Returns an error if the iterator is empty, if any weight is `< 0`, or + /// if its total value is 0. + /// + /// [`Uniform`]: crate::distributions::uniform::Uniform + pub fn new(weights: I) -> Result, WeightedError> + where + I: IntoIterator, + I::Item: SampleBorrow, + X: for<'a> ::core::ops::AddAssign<&'a X> + Clone + Default, + { + let mut iter = weights.into_iter(); + let mut total_weight: X = iter.next().ok_or(WeightedError::NoItem)?.borrow().clone(); + + let zero = ::default(); + if !(total_weight >= zero) { + return Err(WeightedError::InvalidWeight); + } + + let mut weights = Vec::::with_capacity(iter.size_hint().0); + for w in iter { + // Note that `!(w >= x)` is not equivalent to `w < x` for partially + // ordered types due to NaNs which are equal to nothing. + if !(w.borrow() >= &zero) { + return Err(WeightedError::InvalidWeight); + } + weights.push(total_weight.clone()); + total_weight += w.borrow(); + } + + if total_weight == zero { + return Err(WeightedError::AllWeightsZero); + } + let distr = X::Sampler::new(zero, total_weight.clone()); + + Ok(WeightedIndex { + cumulative_weights: weights, + total_weight, + weight_distribution: distr, + }) + } + + /// Update a subset of weights, without changing the number of weights. + /// + /// `new_weights` must be sorted by the index. + /// + /// Using this method instead of `new` might be more efficient if only a small number of + /// weights is modified. No allocations are performed, unless the weight type `X` uses + /// allocation internally. + /// + /// In case of error, `self` is not modified. + pub fn update_weights(&mut self, new_weights: &[(usize, &X)]) -> Result<(), WeightedError> + where X: for<'a> ::core::ops::AddAssign<&'a X> + + for<'a> ::core::ops::SubAssign<&'a X> + + Clone + + Default { + if new_weights.is_empty() { + return Ok(()); + } + + let zero = ::default(); + + let mut total_weight = self.total_weight.clone(); + + // Check for errors first, so we don't modify `self` in case something + // goes wrong. + let mut prev_i = None; + for &(i, w) in new_weights { + if let Some(old_i) = prev_i { + if old_i >= i { + return Err(WeightedError::InvalidWeight); + } + } + if !(*w >= zero) { + return Err(WeightedError::InvalidWeight); + } + if i > self.cumulative_weights.len() { + return Err(WeightedError::TooMany); + } + + let mut old_w = if i < self.cumulative_weights.len() { + self.cumulative_weights[i].clone() + } else { + self.total_weight.clone() + }; + if i > 0 { + old_w -= &self.cumulative_weights[i - 1]; + } + + total_weight -= &old_w; + total_weight += w; + prev_i = Some(i); + } + if total_weight <= zero { + return Err(WeightedError::AllWeightsZero); + } + + // Update the weights. Because we checked all the preconditions in the + // previous loop, this should never panic. + let mut iter = new_weights.iter(); + + let mut prev_weight = zero.clone(); + let mut next_new_weight = iter.next(); + let &(first_new_index, _) = next_new_weight.unwrap(); + let mut cumulative_weight = if first_new_index > 0 { + self.cumulative_weights[first_new_index - 1].clone() + } else { + zero.clone() + }; + for i in first_new_index..self.cumulative_weights.len() { + match next_new_weight { + Some(&(j, w)) if i == j => { + cumulative_weight += w; + next_new_weight = iter.next(); + } + _ => { + let mut tmp = self.cumulative_weights[i].clone(); + tmp -= &prev_weight; // We know this is positive. + cumulative_weight += &tmp; + } + } + prev_weight = cumulative_weight.clone(); + core::mem::swap(&mut prev_weight, &mut self.cumulative_weights[i]); + } + + self.total_weight = total_weight; + self.weight_distribution = X::Sampler::new(zero, self.total_weight.clone()); + + Ok(()) + } +} + +impl Distribution for WeightedIndex +where X: SampleUniform + PartialOrd +{ + fn sample(&self, rng: &mut R) -> usize { + use ::core::cmp::Ordering; + let chosen_weight = self.weight_distribution.sample(rng); + // Find the first item which has a weight *higher* than the chosen weight. + self.cumulative_weights + .binary_search_by(|w| { + if *w <= chosen_weight { + Ordering::Less + } else { + Ordering::Greater + } + }) + .unwrap_err() + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[cfg(feature = "serde1")] + #[test] + fn test_weightedindex_serde1() { + let weighted_index = WeightedIndex::new(&[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]).unwrap(); + + let ser_weighted_index = bincode::serialize(&weighted_index).unwrap(); + let de_weighted_index: WeightedIndex = + bincode::deserialize(&ser_weighted_index).unwrap(); + + assert_eq!( + de_weighted_index.cumulative_weights, + weighted_index.cumulative_weights + ); + assert_eq!(de_weighted_index.total_weight, weighted_index.total_weight); + } + + #[test] + fn test_accepting_nan(){ + assert_eq!( + WeightedIndex::new(&[core::f32::NAN, 0.5]).unwrap_err(), + WeightedError::InvalidWeight, + ); + assert_eq!( + WeightedIndex::new(&[core::f32::NAN]).unwrap_err(), + WeightedError::InvalidWeight, + ); + assert_eq!( + WeightedIndex::new(&[0.5, core::f32::NAN]).unwrap_err(), + WeightedError::InvalidWeight, + ); + + assert_eq!( + WeightedIndex::new(&[0.5, 7.0]) + .unwrap() + .update_weights(&[(0, &core::f32::NAN)]) + .unwrap_err(), + WeightedError::InvalidWeight, + ) + } + + + #[test] + #[cfg_attr(miri, ignore)] // Miri is too slow + fn test_weightedindex() { + let mut r = crate::test::rng(700); + const N_REPS: u32 = 5000; + let weights = [1u32, 2, 3, 0, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7]; + let total_weight = weights.iter().sum::() as f32; + + let verify = |result: [i32; 14]| { + for (i, count) in result.iter().enumerate() { + let exp = (weights[i] * N_REPS) as f32 / total_weight; + let mut err = (*count as f32 - exp).abs(); + if err != 0.0 { + err /= exp; + } + assert!(err <= 0.25); + } + }; + + // WeightedIndex from vec + let mut chosen = [0i32; 14]; + let distr = WeightedIndex::new(weights.to_vec()).unwrap(); + for _ in 0..N_REPS { + chosen[distr.sample(&mut r)] += 1; + } + verify(chosen); + + // WeightedIndex from slice + chosen = [0i32; 14]; + let distr = WeightedIndex::new(&weights[..]).unwrap(); + for _ in 0..N_REPS { + chosen[distr.sample(&mut r)] += 1; + } + verify(chosen); + + // WeightedIndex from iterator + chosen = [0i32; 14]; + let distr = WeightedIndex::new(weights.iter()).unwrap(); + for _ in 0..N_REPS { + chosen[distr.sample(&mut r)] += 1; + } + verify(chosen); + + for _ in 0..5 { + assert_eq!(WeightedIndex::new(&[0, 1]).unwrap().sample(&mut r), 1); + assert_eq!(WeightedIndex::new(&[1, 0]).unwrap().sample(&mut r), 0); + assert_eq!( + WeightedIndex::new(&[0, 0, 0, 0, 10, 0]) + .unwrap() + .sample(&mut r), + 4 + ); + } + + assert_eq!( + WeightedIndex::new(&[10][0..0]).unwrap_err(), + WeightedError::NoItem + ); + assert_eq!( + WeightedIndex::new(&[0]).unwrap_err(), + WeightedError::AllWeightsZero + ); + assert_eq!( + WeightedIndex::new(&[10, 20, -1, 30]).unwrap_err(), + WeightedError::InvalidWeight + ); + assert_eq!( + WeightedIndex::new(&[-10, 20, 1, 30]).unwrap_err(), + WeightedError::InvalidWeight + ); + assert_eq!( + WeightedIndex::new(&[-10]).unwrap_err(), + WeightedError::InvalidWeight + ); + } + + #[test] + fn test_update_weights() { + let data = [ + ( + &[10u32, 2, 3, 4][..], + &[(1, &100), (2, &4)][..], // positive change + &[10, 100, 4, 4][..], + ), + ( + &[1u32, 2, 3, 0, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7][..], + &[(2, &1), (5, &1), (13, &100)][..], // negative change and last element + &[1u32, 2, 1, 0, 5, 1, 7, 1, 2, 3, 4, 5, 6, 100][..], + ), + ]; + + for (weights, update, expected_weights) in data.iter() { + let total_weight = weights.iter().sum::(); + let mut distr = WeightedIndex::new(weights.to_vec()).unwrap(); + assert_eq!(distr.total_weight, total_weight); + + distr.update_weights(update).unwrap(); + let expected_total_weight = expected_weights.iter().sum::(); + let expected_distr = WeightedIndex::new(expected_weights.to_vec()).unwrap(); + assert_eq!(distr.total_weight, expected_total_weight); + assert_eq!(distr.total_weight, expected_distr.total_weight); + assert_eq!(distr.cumulative_weights, expected_distr.cumulative_weights); + } + } + + #[test] + fn value_stability() { + fn test_samples( + weights: I, buf: &mut [usize], expected: &[usize], + ) where + I: IntoIterator, + I::Item: SampleBorrow, + X: for<'a> ::core::ops::AddAssign<&'a X> + Clone + Default, + { + assert_eq!(buf.len(), expected.len()); + let distr = WeightedIndex::new(weights).unwrap(); + let mut rng = crate::test::rng(701); + for r in buf.iter_mut() { + *r = rng.sample(&distr); + } + assert_eq!(buf, expected); + } + + let mut buf = [0; 10]; + test_samples(&[1i32, 1, 1, 1, 1, 1, 1, 1, 1], &mut buf, &[ + 0, 6, 2, 6, 3, 4, 7, 8, 2, 5, + ]); + test_samples(&[0.7f32, 0.1, 0.1, 0.1], &mut buf, &[ + 0, 0, 0, 1, 0, 0, 2, 3, 0, 0, + ]); + test_samples(&[1.0f64, 0.999, 0.998, 0.997], &mut buf, &[ + 2, 2, 1, 3, 2, 1, 3, 3, 2, 1, + ]); + } +} + +/// Error type returned from `WeightedIndex::new`. +#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum WeightedError { + /// The provided weight collection contains no items. + NoItem, + + /// A weight is either less than zero, greater than the supported maximum, + /// NaN, or otherwise invalid. + InvalidWeight, + + /// All items in the provided weight collection are zero. + AllWeightsZero, + + /// Too many weights are provided (length greater than `u32::MAX`) + TooMany, +} + +#[cfg(feature = "std")] +impl std::error::Error for WeightedError {} + +impl fmt::Display for WeightedError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str(match *self { + WeightedError::NoItem => "No weights provided in distribution", + WeightedError::InvalidWeight => "A weight is invalid in distribution", + WeightedError::AllWeightsZero => "All weights are zero in distribution", + WeightedError::TooMany => "Too many weights (hit u32::MAX) in distribution", + }) + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/weighted.rs cargo-0.58.0/vendor/rand/src/distributions/weighted.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/weighted.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/weighted.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,48 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Weighted index sampling +//! +//! This module is deprecated. Use [`crate::distributions::WeightedIndex`] and +//! [`crate::distributions::WeightedError`] instead. + +pub use super::{WeightedIndex, WeightedError}; + +#[allow(missing_docs)] +#[deprecated(since = "0.8.0", note = "moved to rand_distr crate")] +pub mod alias_method { + // This module exists to provide a deprecation warning which minimises + // compile errors, but still fails to compile if ever used. + use core::marker::PhantomData; + use alloc::vec::Vec; + use super::WeightedError; + + #[derive(Debug)] + pub struct WeightedIndex { + _phantom: PhantomData, + } + impl WeightedIndex { + pub fn new(_weights: Vec) -> Result { + Err(WeightedError::NoItem) + } + } + + pub trait Weight {} + macro_rules! impl_weight { + () => {}; + ($T:ident, $($more:ident,)*) => { + impl Weight for $T {} + impl_weight!($($more,)*); + }; + } + impl_weight!(f64, f32,); + impl_weight!(u8, u16, u32, u64, usize,); + impl_weight!(i8, i16, i32, i64, isize,); + #[cfg(not(target_os = "emscripten"))] + impl_weight!(u128, i128,); +} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/distributions/ziggurat_tables.rs cargo-0.58.0/vendor/rand/src/distributions/ziggurat_tables.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/distributions/ziggurat_tables.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/distributions/ziggurat_tables.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,283 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// Copyright 2013 The Rust Project Developers. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Tables for distributions which are sampled using the ziggurat -// algorithm. Autogenerated by `ziggurat_tables.py`. - -pub type ZigTable = &'static [f64; 257]; -pub const ZIG_NORM_R: f64 = 3.654152885361008796; -#[rustfmt::skip] -pub static ZIG_NORM_X: [f64; 257] = - [3.910757959537090045, 3.654152885361008796, 3.449278298560964462, 3.320244733839166074, - 3.224575052047029100, 3.147889289517149969, 3.083526132001233044, 3.027837791768635434, - 2.978603279880844834, 2.934366867207854224, 2.894121053612348060, 2.857138730872132548, - 2.822877396825325125, 2.790921174000785765, 2.760944005278822555, 2.732685359042827056, - 2.705933656121858100, 2.680514643284522158, 2.656283037575502437, 2.633116393630324570, - 2.610910518487548515, 2.589575986706995181, 2.569035452680536569, 2.549221550323460761, - 2.530075232158516929, 2.511544441625342294, 2.493583041269680667, 2.476149939669143318, - 2.459208374333311298, 2.442725318198956774, 2.426670984935725972, 2.411018413899685520, - 2.395743119780480601, 2.380822795170626005, 2.366237056715818632, 2.351967227377659952, - 2.337996148795031370, 2.324308018869623016, 2.310888250599850036, 2.297723348901329565, - 2.284800802722946056, 2.272108990226823888, 2.259637095172217780, 2.247375032945807760, - 2.235313384928327984, 2.223443340090905718, 2.211756642882544366, 2.200245546609647995, - 2.188902771624720689, 2.177721467738641614, 2.166695180352645966, 2.155817819875063268, - 2.145083634046203613, 2.134487182844320152, 2.124023315687815661, 2.113687150684933957, - 2.103474055713146829, 2.093379631137050279, 2.083399693996551783, 2.073530263516978778, - 2.063767547809956415, 2.054107931648864849, 2.044547965215732788, 2.035084353727808715, - 2.025713947862032960, 2.016433734904371722, 2.007240830558684852, 1.998132471356564244, - 1.989106007615571325, 1.980158896898598364, 1.971288697931769640, 1.962493064942461896, - 1.953769742382734043, 1.945116560006753925, 1.936531428273758904, 1.928012334050718257, - 1.919557336591228847, 1.911164563769282232, 1.902832208548446369, 1.894558525668710081, - 1.886341828534776388, 1.878180486290977669, 1.870072921069236838, 1.862017605397632281, - 1.854013059758148119, 1.846057850283119750, 1.838150586580728607, 1.830289919680666566, - 1.822474540091783224, 1.814703175964167636, 1.806974591348693426, 1.799287584547580199, - 1.791640986550010028, 1.784033659547276329, 1.776464495522344977, 1.768932414909077933, - 1.761436365316706665, 1.753975320315455111, 1.746548278279492994, 1.739154261283669012, - 1.731792314050707216, 1.724461502945775715, 1.717160915015540690, 1.709889657069006086, - 1.702646854797613907, 1.695431651932238548, 1.688243209434858727, 1.681080704722823338, - 1.673943330923760353, 1.666830296159286684, 1.659740822855789499, 1.652674147080648526, - 1.645629517902360339, 1.638606196773111146, 1.631603456932422036, 1.624620582830568427, - 1.617656869570534228, 1.610711622367333673, 1.603784156023583041, 1.596873794420261339, - 1.589979870021648534, 1.583101723393471438, 1.576238702733332886, 1.569390163412534456, - 1.562555467528439657, 1.555733983466554893, 1.548925085471535512, 1.542128153226347553, - 1.535342571438843118, 1.528567729435024614, 1.521803020758293101, 1.515047842773992404, - 1.508301596278571965, 1.501563685112706548, 1.494833515777718391, 1.488110497054654369, - 1.481394039625375747, 1.474683555695025516, 1.467978458615230908, 1.461278162507407830, - 1.454582081885523293, 1.447889631277669675, 1.441200224845798017, 1.434513276002946425, - 1.427828197027290358, 1.421144398672323117, 1.414461289772464658, 1.407778276843371534, - 1.401094763676202559, 1.394410150925071257, 1.387723835686884621, 1.381035211072741964, - 1.374343665770030531, 1.367648583594317957, 1.360949343030101844, 1.354245316759430606, - 1.347535871177359290, 1.340820365893152122, 1.334098153216083604, 1.327368577624624679, - 1.320630975217730096, 1.313884673146868964, 1.307128989027353860, 1.300363230327433728, - 1.293586693733517645, 1.286798664489786415, 1.279998415710333237, 1.273185207661843732, - 1.266358287014688333, 1.259516886060144225, 1.252660221891297887, 1.245787495544997903, - 1.238897891102027415, 1.231990574742445110, 1.225064693752808020, 1.218119375481726552, - 1.211153726239911244, 1.204166830140560140, 1.197157747875585931, 1.190125515422801650, - 1.183069142678760732, 1.175987612011489825, 1.168879876726833800, 1.161744859441574240, - 1.154581450355851802, 1.147388505416733873, 1.140164844363995789, 1.132909248648336975, - 1.125620459211294389, 1.118297174115062909, 1.110938046009249502, 1.103541679420268151, - 1.096106627847603487, 1.088631390649514197, 1.081114409698889389, 1.073554065787871714, - 1.065948674757506653, 1.058296483326006454, 1.050595664586207123, 1.042844313139370538, - 1.035040439828605274, 1.027181966030751292, 1.019266717460529215, 1.011292417434978441, - 1.003256679539591412, 0.995156999629943084, 0.986990747093846266, 0.978755155288937750, - 0.970447311058864615, 0.962064143217605250, 0.953602409875572654, 0.945058684462571130, - 0.936429340280896860, 0.927710533396234771, 0.918898183643734989, 0.909987953490768997, - 0.900975224455174528, 0.891855070726792376, 0.882622229578910122, 0.873271068082494550, - 0.863795545546826915, 0.854189171001560554, 0.844444954902423661, 0.834555354079518752, - 0.824512208745288633, 0.814306670128064347, 0.803929116982664893, 0.793369058833152785, - 0.782615023299588763, 0.771654424216739354, 0.760473406422083165, 0.749056662009581653, - 0.737387211425838629, 0.725446140901303549, 0.713212285182022732, 0.700661841097584448, - 0.687767892786257717, 0.674499822827436479, 0.660822574234205984, 0.646695714884388928, - 0.632072236375024632, 0.616896989996235545, 0.601104617743940417, 0.584616766093722262, - 0.567338257040473026, 0.549151702313026790, 0.529909720646495108, 0.509423329585933393, - 0.487443966121754335, 0.463634336771763245, 0.437518402186662658, 0.408389134588000746, - 0.375121332850465727, 0.335737519180459465, 0.286174591747260509, 0.215241895913273806, - 0.000000000000000000]; -#[rustfmt::skip] -pub static ZIG_NORM_F: [f64; 257] = - [0.000477467764586655, 0.001260285930498598, 0.002609072746106363, 0.004037972593371872, - 0.005522403299264754, 0.007050875471392110, 0.008616582769422917, 0.010214971439731100, - 0.011842757857943104, 0.013497450601780807, 0.015177088307982072, 0.016880083152595839, - 0.018605121275783350, 0.020351096230109354, 0.022117062707379922, 0.023902203305873237, - 0.025705804008632656, 0.027527235669693315, 0.029365939758230111, 0.031221417192023690, - 0.033093219458688698, 0.034980941461833073, 0.036884215688691151, 0.038802707404656918, - 0.040736110656078753, 0.042684144916619378, 0.044646552251446536, 0.046623094902089664, - 0.048613553216035145, 0.050617723861121788, 0.052635418276973649, 0.054666461325077916, - 0.056710690106399467, 0.058767952921137984, 0.060838108349751806, 0.062921024437977854, - 0.065016577971470438, 0.067124653828023989, 0.069245144397250269, 0.071377949059141965, - 0.073522973714240991, 0.075680130359194964, 0.077849336702372207, 0.080030515814947509, - 0.082223595813495684, 0.084428509570654661, 0.086645194450867782, 0.088873592068594229, - 0.091113648066700734, 0.093365311913026619, 0.095628536713353335, 0.097903279039215627, - 0.100189498769172020, 0.102487158942306270, 0.104796225622867056, 0.107116667775072880, - 0.109448457147210021, 0.111791568164245583, 0.114145977828255210, 0.116511665626037014, - 0.118888613443345698, 0.121276805485235437, 0.123676228202051403, 0.126086870220650349, - 0.128508722280473636, 0.130941777174128166, 0.133386029692162844, 0.135841476571757352, - 0.138308116449064322, 0.140785949814968309, 0.143274978974047118, 0.145775208006537926, - 0.148286642733128721, 0.150809290682410169, 0.153343161060837674, 0.155888264725064563, - 0.158444614156520225, 0.161012223438117663, 0.163591108232982951, 0.166181285765110071, - 0.168782774801850333, 0.171395595638155623, 0.174019770082499359, 0.176655321444406654, - 0.179302274523530397, 0.181960655600216487, 0.184630492427504539, 0.187311814224516926, - 0.190004651671193070, 0.192709036904328807, 0.195425003514885592, 0.198152586546538112, - 0.200891822495431333, 0.203642749311121501, 0.206405406398679298, 0.209179834621935651, - 0.211966076307852941, 0.214764175252008499, 0.217574176725178370, 0.220396127481011589, - 0.223230075764789593, 0.226076071323264877, 0.228934165415577484, 0.231804410825248525, - 0.234686861873252689, 0.237581574432173676, 0.240488605941449107, 0.243408015423711988, - 0.246339863502238771, 0.249284212419516704, 0.252241126056943765, 0.255210669955677150, - 0.258192911338648023, 0.261187919133763713, 0.264195763998317568, 0.267216518344631837, - 0.270250256366959984, 0.273297054069675804, 0.276356989296781264, 0.279430141762765316, - 0.282516593084849388, 0.285616426816658109, 0.288729728483353931, 0.291856585618280984, - 0.294997087801162572, 0.298151326697901342, 0.301319396102034120, 0.304501391977896274, - 0.307697412505553769, 0.310907558127563710, 0.314131931597630143, 0.317370638031222396, - 0.320623784958230129, 0.323891482377732021, 0.327173842814958593, 0.330470981380537099, - 0.333783015832108509, 0.337110066638412809, 0.340452257045945450, 0.343809713148291340, - 0.347182563958251478, 0.350570941482881204, 0.353974980801569250, 0.357394820147290515, - 0.360830600991175754, 0.364282468130549597, 0.367750569780596226, 0.371235057669821344, - 0.374736087139491414, 0.378253817247238111, 0.381788410875031348, 0.385340034841733958, - 0.388908860020464597, 0.392495061461010764, 0.396098818517547080, 0.399720314981931668, - 0.403359739222868885, 0.407017284331247953, 0.410693148271983222, 0.414387534042706784, - 0.418100649839684591, 0.421832709231353298, 0.425583931339900579, 0.429354541031341519, - 0.433144769114574058, 0.436954852549929273, 0.440785034667769915, 0.444635565397727750, - 0.448506701509214067, 0.452398706863882505, 0.456311852680773566, 0.460246417814923481, - 0.464202689050278838, 0.468180961407822172, 0.472181538469883255, 0.476204732721683788, - 0.480250865911249714, 0.484320269428911598, 0.488413284707712059, 0.492530263646148658, - 0.496671569054796314, 0.500837575128482149, 0.505028667945828791, 0.509245245998136142, - 0.513487720749743026, 0.517756517232200619, 0.522052074674794864, 0.526374847174186700, - 0.530725304406193921, 0.535103932383019565, 0.539511234259544614, 0.543947731192649941, - 0.548413963257921133, 0.552910490428519918, 0.557437893621486324, 0.561996775817277916, - 0.566587763258951771, 0.571211506738074970, 0.575868682975210544, 0.580559996103683473, - 0.585286179266300333, 0.590047996335791969, 0.594846243770991268, 0.599681752622167719, - 0.604555390700549533, 0.609468064928895381, 0.614420723892076803, 0.619414360609039205, - 0.624450015550274240, 0.629528779928128279, 0.634651799290960050, 0.639820277456438991, - 0.645035480824251883, 0.650298743114294586, 0.655611470583224665, 0.660975147780241357, - 0.666391343912380640, 0.671861719900766374, 0.677388036222513090, 0.682972161648791376, - 0.688616083008527058, 0.694321916130032579, 0.700091918140490099, 0.705928501336797409, - 0.711834248882358467, 0.717811932634901395, 0.723864533472881599, 0.729995264565802437, - 0.736207598131266683, 0.742505296344636245, 0.748892447223726720, 0.755373506511754500, - 0.761953346841546475, 0.768637315803334831, 0.775431304986138326, 0.782341832659861902, - 0.789376143571198563, 0.796542330428254619, 0.803849483176389490, 0.811307874318219935, - 0.818929191609414797, 0.826726833952094231, 0.834716292992930375, 0.842915653118441077, - 0.851346258465123684, 0.860033621203008636, 0.869008688043793165, 0.878309655816146839, - 0.887984660763399880, 0.898095921906304051, 0.908726440060562912, 0.919991505048360247, - 0.932060075968990209, 0.945198953453078028, 0.959879091812415930, 0.977101701282731328, - 1.000000000000000000]; -pub const ZIG_EXP_R: f64 = 7.697117470131050077; -#[rustfmt::skip] -pub static ZIG_EXP_X: [f64; 257] = - [8.697117470131052741, 7.697117470131050077, 6.941033629377212577, 6.478378493832569696, - 6.144164665772472667, 5.882144315795399869, 5.666410167454033697, 5.482890627526062488, - 5.323090505754398016, 5.181487281301500047, 5.054288489981304089, 4.938777085901250530, - 4.832939741025112035, 4.735242996601741083, 4.644491885420085175, 4.559737061707351380, - 4.480211746528421912, 4.405287693473573185, 4.334443680317273007, 4.267242480277365857, - 4.203313713735184365, 4.142340865664051464, 4.084051310408297830, 4.028208544647936762, - 3.974606066673788796, 3.923062500135489739, 3.873417670399509127, 3.825529418522336744, - 3.779270992411667862, 3.734528894039797375, 3.691201090237418825, 3.649195515760853770, - 3.608428813128909507, 3.568825265648337020, 3.530315889129343354, 3.492837654774059608, - 3.456332821132760191, 3.420748357251119920, 3.386035442460300970, 3.352149030900109405, - 3.319047470970748037, 3.286692171599068679, 3.255047308570449882, 3.224079565286264160, - 3.193757903212240290, 3.164053358025972873, 3.134938858084440394, 3.106389062339824481, - 3.078380215254090224, 3.050890016615455114, 3.023897504455676621, 2.997382949516130601, - 2.971327759921089662, 2.945714394895045718, 2.920526286512740821, 2.895747768600141825, - 2.871364012015536371, 2.847360965635188812, 2.823725302450035279, 2.800444370250737780, - 2.777506146439756574, 2.754899196562344610, 2.732612636194700073, 2.710636095867928752, - 2.688959688741803689, 2.667573980773266573, 2.646469963151809157, 2.625639026797788489, - 2.605072938740835564, 2.584763820214140750, 2.564704126316905253, 2.544886627111869970, - 2.525304390037828028, 2.505950763528594027, 2.486819361740209455, 2.467904050297364815, - 2.449198932978249754, 2.430698339264419694, 2.412396812688870629, 2.394289099921457886, - 2.376370140536140596, 2.358635057409337321, 2.341079147703034380, 2.323697874390196372, - 2.306486858283579799, 2.289441870532269441, 2.272558825553154804, 2.255833774367219213, - 2.239262898312909034, 2.222842503111036816, 2.206569013257663858, 2.190438966723220027, - 2.174449009937774679, 2.158595893043885994, 2.142876465399842001, 2.127287671317368289, - 2.111826546019042183, 2.096490211801715020, 2.081275874393225145, 2.066180819490575526, - 2.051202409468584786, 2.036338080248769611, 2.021585338318926173, 2.006941757894518563, - 1.992404978213576650, 1.977972700957360441, 1.963642687789548313, 1.949412758007184943, - 1.935280786297051359, 1.921244700591528076, 1.907302480018387536, 1.893452152939308242, - 1.879691795072211180, 1.866019527692827973, 1.852433515911175554, 1.838931967018879954, - 1.825513128903519799, 1.812175288526390649, 1.798916770460290859, 1.785735935484126014, - 1.772631179231305643, 1.759600930889074766, 1.746643651946074405, 1.733757834985571566, - 1.720942002521935299, 1.708194705878057773, 1.695514524101537912, 1.682900062917553896, - 1.670349953716452118, 1.657862852574172763, 1.645437439303723659, 1.633072416535991334, - 1.620766508828257901, 1.608518461798858379, 1.596327041286483395, 1.584191032532688892, - 1.572109239386229707, 1.560080483527888084, 1.548103603714513499, 1.536177455041032092, - 1.524300908219226258, 1.512472848872117082, 1.500692176842816750, 1.488957805516746058, - 1.477268661156133867, 1.465623682245745352, 1.454021818848793446, 1.442462031972012504, - 1.430943292938879674, 1.419464582769983219, 1.408024891569535697, 1.396623217917042137, - 1.385258568263121992, 1.373929956328490576, 1.362636402505086775, 1.351376933258335189, - 1.340150580529504643, 1.328956381137116560, 1.317793376176324749, 1.306660610415174117, - 1.295557131686601027, 1.284481990275012642, 1.273434238296241139, 1.262412929069615330, - 1.251417116480852521, 1.240445854334406572, 1.229498195693849105, 1.218573192208790124, - 1.207669893426761121, 1.196787346088403092, 1.185924593404202199, 1.175080674310911677, - 1.164254622705678921, 1.153445466655774743, 1.142652227581672841, 1.131873919411078511, - 1.121109547701330200, 1.110358108727411031, 1.099618588532597308, 1.088889961938546813, - 1.078171191511372307, 1.067461226479967662, 1.056759001602551429, 1.046063435977044209, - 1.035373431790528542, 1.024687873002617211, 1.014005623957096480, 1.003325527915696735, - 0.992646405507275897, 0.981967053085062602, 0.971286240983903260, 0.960602711668666509, - 0.949915177764075969, 0.939222319955262286, 0.928522784747210395, 0.917815182070044311, - 0.907098082715690257, 0.896370015589889935, 0.885629464761751528, 0.874874866291025066, - 0.864104604811004484, 0.853317009842373353, 0.842510351810368485, 0.831682837734273206, - 0.820832606554411814, 0.809957724057418282, 0.799056177355487174, 0.788125868869492430, - 0.777164609759129710, 0.766170112735434672, 0.755139984181982249, 0.744071715500508102, - 0.732962673584365398, 0.721810090308756203, 0.710611050909655040, 0.699362481103231959, - 0.688061132773747808, 0.676703568029522584, 0.665286141392677943, 0.653804979847664947, - 0.642255960424536365, 0.630634684933490286, 0.618936451394876075, 0.607156221620300030, - 0.595288584291502887, 0.583327712748769489, 0.571267316532588332, 0.559100585511540626, - 0.546820125163310577, 0.534417881237165604, 0.521885051592135052, 0.509211982443654398, - 0.496388045518671162, 0.483401491653461857, 0.470239275082169006, 0.456886840931420235, - 0.443327866073552401, 0.429543940225410703, 0.415514169600356364, 0.401214678896277765, - 0.386617977941119573, 0.371692145329917234, 0.356399760258393816, 0.340696481064849122, - 0.324529117016909452, 0.307832954674932158, 0.290527955491230394, 0.272513185478464703, - 0.253658363385912022, 0.233790483059674731, 0.212671510630966620, 0.189958689622431842, - 0.165127622564187282, 0.137304980940012589, 0.104838507565818778, 0.063852163815001570, - 0.000000000000000000]; -#[rustfmt::skip] -pub static ZIG_EXP_F: [f64; 257] = - [0.000167066692307963, 0.000454134353841497, 0.000967269282327174, 0.001536299780301573, - 0.002145967743718907, 0.002788798793574076, 0.003460264777836904, 0.004157295120833797, - 0.004877655983542396, 0.005619642207205489, 0.006381905937319183, 0.007163353183634991, - 0.007963077438017043, 0.008780314985808977, 0.009614413642502212, 0.010464810181029981, - 0.011331013597834600, 0.012212592426255378, 0.013109164931254991, 0.014020391403181943, - 0.014945968011691148, 0.015885621839973156, 0.016839106826039941, 0.017806200410911355, - 0.018786700744696024, 0.019780424338009740, 0.020787204072578114, 0.021806887504283581, - 0.022839335406385240, 0.023884420511558174, 0.024942026419731787, 0.026012046645134221, - 0.027094383780955803, 0.028188948763978646, 0.029295660224637411, 0.030414443910466622, - 0.031545232172893622, 0.032687963508959555, 0.033842582150874358, 0.035009037697397431, - 0.036187284781931443, 0.037377282772959382, 0.038578995503074871, 0.039792391023374139, - 0.041017441380414840, 0.042254122413316254, 0.043502413568888197, 0.044762297732943289, - 0.046033761076175184, 0.047316792913181561, 0.048611385573379504, 0.049917534282706379, - 0.051235237055126281, 0.052564494593071685, 0.053905310196046080, 0.055257689676697030, - 0.056621641283742870, 0.057997175631200659, 0.059384305633420280, 0.060783046445479660, - 0.062193415408541036, 0.063615431999807376, 0.065049117786753805, 0.066494496385339816, - 0.067951593421936643, 0.069420436498728783, 0.070901055162371843, 0.072393480875708752, - 0.073897746992364746, 0.075413888734058410, 0.076941943170480517, 0.078481949201606435, - 0.080033947542319905, 0.081597980709237419, 0.083174093009632397, 0.084762330532368146, - 0.086362741140756927, 0.087975374467270231, 0.089600281910032886, 0.091237516631040197, - 0.092887133556043569, 0.094549189376055873, 0.096223742550432825, 0.097910853311492213, - 0.099610583670637132, 0.101322997425953631, 0.103048160171257702, 0.104786139306570145, - 0.106537004050001632, 0.108300825451033755, 0.110077676405185357, 0.111867631670056283, - 0.113670767882744286, 0.115487163578633506, 0.117316899211555525, 0.119160057175327641, - 0.121016721826674792, 0.122886979509545108, 0.124770918580830933, 0.126668629437510671, - 0.128580204545228199, 0.130505738468330773, 0.132445327901387494, 0.134399071702213602, - 0.136367070926428829, 0.138349428863580176, 0.140346251074862399, 0.142357645432472146, - 0.144383722160634720, 0.146424593878344889, 0.148480375643866735, 0.150551185001039839, - 0.152637142027442801, 0.154738369384468027, 0.156854992369365148, 0.158987138969314129, - 0.161134939917591952, 0.163298528751901734, 0.165478041874935922, 0.167673618617250081, - 0.169885401302527550, 0.172113535315319977, 0.174358169171353411, 0.176619454590494829, - 0.178897546572478278, 0.181192603475496261, 0.183504787097767436, 0.185834262762197083, - 0.188181199404254262, 0.190545769663195363, 0.192928149976771296, 0.195328520679563189, - 0.197747066105098818, 0.200183974691911210, 0.202639439093708962, 0.205113656293837654, - 0.207606827724221982, 0.210119159388988230, 0.212650861992978224, 0.215202151075378628, - 0.217773247148700472, 0.220364375843359439, 0.222975768058120111, 0.225607660116683956, - 0.228260293930716618, 0.230933917169627356, 0.233628783437433291, 0.236345152457059560, - 0.239083290262449094, 0.241843469398877131, 0.244625969131892024, 0.247431075665327543, - 0.250259082368862240, 0.253110290015629402, 0.255985007030415324, 0.258883549749016173, - 0.261806242689362922, 0.264753418835062149, 0.267725419932044739, 0.270722596799059967, - 0.273745309652802915, 0.276793928448517301, 0.279868833236972869, 0.282970414538780746, - 0.286099073737076826, 0.289255223489677693, 0.292439288161892630, 0.295651704281261252, - 0.298892921015581847, 0.302163400675693528, 0.305463619244590256, 0.308794066934560185, - 0.312155248774179606, 0.315547685227128949, 0.318971912844957239, 0.322428484956089223, - 0.325917972393556354, 0.329440964264136438, 0.332998068761809096, 0.336589914028677717, - 0.340217149066780189, 0.343880444704502575, 0.347580494621637148, 0.351318016437483449, - 0.355093752866787626, 0.358908472948750001, 0.362762973354817997, 0.366658079781514379, - 0.370594648435146223, 0.374573567615902381, 0.378595759409581067, 0.382662181496010056, - 0.386773829084137932, 0.390931736984797384, 0.395136981833290435, 0.399390684475231350, - 0.403694012530530555, 0.408048183152032673, 0.412454465997161457, 0.416914186433003209, - 0.421428728997616908, 0.425999541143034677, 0.430628137288459167, 0.435316103215636907, - 0.440065100842354173, 0.444876873414548846, 0.449753251162755330, 0.454696157474615836, - 0.459707615642138023, 0.464789756250426511, 0.469944825283960310, 0.475175193037377708, - 0.480483363930454543, 0.485871987341885248, 0.491343869594032867, 0.496901987241549881, - 0.502549501841348056, 0.508289776410643213, 0.514126393814748894, 0.520063177368233931, - 0.526104213983620062, 0.532253880263043655, 0.538516872002862246, 0.544898237672440056, - 0.551403416540641733, 0.558038282262587892, 0.564809192912400615, 0.571723048664826150, - 0.578787358602845359, 0.586010318477268366, 0.593400901691733762, 0.600968966365232560, - 0.608725382079622346, 0.616682180915207878, 0.624852738703666200, 0.633251994214366398, - 0.641896716427266423, 0.650805833414571433, 0.660000841079000145, 0.669506316731925177, - 0.679350572264765806, 0.689566496117078431, 0.700192655082788606, 0.711274760805076456, - 0.722867659593572465, 0.735038092431424039, 0.747868621985195658, 0.761463388849896838, - 0.775956852040116218, 0.791527636972496285, 0.808421651523009044, 0.826993296643051101, - 0.847785500623990496, 0.871704332381204705, 0.900469929925747703, 0.938143680862176477, - 1.000000000000000000]; diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/lib.rs cargo-0.58.0/vendor/rand/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/lib.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -37,7 +37,7 @@ //! //! # The Book //! -//! For the user guide and futher documentation, please read +//! For the user guide and further documentation, please read //! [The Rust Rand Book](https://rust-random.github.io/book). #![doc( @@ -48,15 +48,17 @@ #![deny(missing_docs)] #![deny(missing_debug_implementations)] #![doc(test(attr(allow(unused_variables), deny(warnings))))] -#![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(all(feature = "simd_support", feature = "nightly"), feature(stdsimd))] +#![no_std] +#![cfg_attr(feature = "simd_support", feature(stdsimd))] +#![cfg_attr(feature = "nightly", feature(slice_partition_at_index))] +#![cfg_attr(doc_cfg, feature(doc_cfg))] #![allow( - clippy::excessive_precision, - clippy::unreadable_literal, - clippy::float_cmp + clippy::float_cmp, + clippy::neg_cmp_op_on_partial_ord, )] -#[cfg(all(feature = "alloc", not(feature = "std")))] extern crate alloc; +#[cfg(feature = "std")] extern crate std; +#[cfg(feature = "alloc")] extern crate alloc; #[allow(unused)] macro_rules! trace { ($($x:tt)*) => ( @@ -92,418 +94,20 @@ // Re-exports from rand_core pub use rand_core::{CryptoRng, Error, RngCore, SeedableRng}; -// Public exports -#[cfg(feature = "std")] pub use crate::rngs::thread::thread_rng; - // Public modules pub mod distributions; pub mod prelude; +mod rng; pub mod rngs; pub mod seq; +// Public exports +#[cfg(all(feature = "std", feature = "std_rng"))] +pub use crate::rngs::thread::thread_rng; +pub use rng::{Fill, Rng}; -use crate::distributions::uniform::{SampleBorrow, SampleUniform, UniformSampler}; +#[cfg(all(feature = "std", feature = "std_rng"))] use crate::distributions::{Distribution, Standard}; -use core::num::Wrapping; -use core::{mem, slice}; - -/// An automatically-implemented extension trait on [`RngCore`] providing high-level -/// generic methods for sampling values and other convenience methods. -/// -/// This is the primary trait to use when generating random values. -/// -/// # Generic usage -/// -/// The basic pattern is `fn foo(rng: &mut R)`. Some -/// things are worth noting here: -/// -/// - Since `Rng: RngCore` and every `RngCore` implements `Rng`, it makes no -/// difference whether we use `R: Rng` or `R: RngCore`. -/// - The `+ ?Sized` un-bounding allows functions to be called directly on -/// type-erased references; i.e. `foo(r)` where `r: &mut RngCore`. Without -/// this it would be necessary to write `foo(&mut r)`. -/// -/// An alternative pattern is possible: `fn foo(rng: R)`. This has some -/// trade-offs. It allows the argument to be consumed directly without a `&mut` -/// (which is how `from_rng(thread_rng())` works); also it still works directly -/// on references (including type-erased references). Unfortunately within the -/// function `foo` it is not known whether `rng` is a reference type or not, -/// hence many uses of `rng` require an extra reference, either explicitly -/// (`distr.sample(&mut rng)`) or implicitly (`rng.gen()`); one may hope the -/// optimiser can remove redundant references later. -/// -/// Example: -/// -/// ``` -/// # use rand::thread_rng; -/// use rand::Rng; -/// -/// fn foo(rng: &mut R) -> f32 { -/// rng.gen() -/// } -/// -/// # let v = foo(&mut thread_rng()); -/// ``` -pub trait Rng: RngCore { - /// Return a random value supporting the [`Standard`] distribution. - /// - /// # Example - /// - /// ``` - /// use rand::{thread_rng, Rng}; - /// - /// let mut rng = thread_rng(); - /// let x: u32 = rng.gen(); - /// println!("{}", x); - /// println!("{:?}", rng.gen::<(f64, bool)>()); - /// ``` - /// - /// # Arrays and tuples - /// - /// The `rng.gen()` method is able to generate arrays (up to 32 elements) - /// and tuples (up to 12 elements), so long as all element types can be - /// generated. - /// - /// For arrays of integers, especially for those with small element types - /// (< 64 bit), it will likely be faster to instead use [`Rng::fill`]. - /// - /// ``` - /// use rand::{thread_rng, Rng}; - /// - /// let mut rng = thread_rng(); - /// let tuple: (u8, i32, char) = rng.gen(); // arbitrary tuple support - /// - /// let arr1: [f32; 32] = rng.gen(); // array construction - /// let mut arr2 = [0u8; 128]; - /// rng.fill(&mut arr2); // array fill - /// ``` - /// - /// [`Standard`]: distributions::Standard - #[inline] - fn gen(&mut self) -> T - where Standard: Distribution { - Standard.sample(self) - } - - /// Generate a random value in the range [`low`, `high`), i.e. inclusive of - /// `low` and exclusive of `high`. - /// - /// This function is optimised for the case that only a single sample is - /// made from the given range. See also the [`Uniform`] distribution - /// type which may be faster if sampling from the same range repeatedly. - /// - /// # Panics - /// - /// Panics if `low >= high`. - /// - /// # Example - /// - /// ``` - /// use rand::{thread_rng, Rng}; - /// - /// let mut rng = thread_rng(); - /// let n: u32 = rng.gen_range(0, 10); - /// println!("{}", n); - /// let m: f64 = rng.gen_range(-40.0f64, 1.3e5f64); - /// println!("{}", m); - /// ``` - /// - /// [`Uniform`]: distributions::uniform::Uniform - fn gen_range(&mut self, low: B1, high: B2) -> T - where - B1: SampleBorrow + Sized, - B2: SampleBorrow + Sized, - { - T::Sampler::sample_single(low, high, self) - } - - /// Sample a new value, using the given distribution. - /// - /// ### Example - /// - /// ``` - /// use rand::{thread_rng, Rng}; - /// use rand::distributions::Uniform; - /// - /// let mut rng = thread_rng(); - /// let x = rng.sample(Uniform::new(10u32, 15)); - /// // Type annotation requires two types, the type and distribution; the - /// // distribution can be inferred. - /// let y = rng.sample::(Uniform::new(10, 15)); - /// ``` - fn sample>(&mut self, distr: D) -> T { - distr.sample(self) - } - - /// Create an iterator that generates values using the given distribution. - /// - /// Note that this function takes its arguments by value. This works since - /// `(&mut R): Rng where R: Rng` and - /// `(&D): Distribution where D: Distribution`, - /// however borrowing is not automatic hence `rng.sample_iter(...)` may - /// need to be replaced with `(&mut rng).sample_iter(...)`. - /// - /// # Example - /// - /// ``` - /// use rand::{thread_rng, Rng}; - /// use rand::distributions::{Alphanumeric, Uniform, Standard}; - /// - /// let rng = thread_rng(); - /// - /// // Vec of 16 x f32: - /// let v: Vec = rng.sample_iter(Standard).take(16).collect(); - /// - /// // String: - /// let s: String = rng.sample_iter(Alphanumeric).take(7).collect(); - /// - /// // Combined values - /// println!("{:?}", rng.sample_iter(Standard).take(5) - /// .collect::>()); - /// - /// // Dice-rolling: - /// let die_range = Uniform::new_inclusive(1, 6); - /// let mut roll_die = rng.sample_iter(die_range); - /// while roll_die.next().unwrap() != 6 { - /// println!("Not a 6; rolling again!"); - /// } - /// ``` - fn sample_iter(self, distr: D) -> distributions::DistIter - where - D: Distribution, - Self: Sized, - { - distr.sample_iter(self) - } - - /// Fill `dest` entirely with random bytes (uniform value distribution), - /// where `dest` is any type supporting [`AsByteSliceMut`], namely slices - /// and arrays over primitive integer types (`i8`, `i16`, `u32`, etc.). - /// - /// On big-endian platforms this performs byte-swapping to ensure - /// portability of results from reproducible generators. - /// - /// This uses [`fill_bytes`] internally which may handle some RNG errors - /// implicitly (e.g. waiting if the OS generator is not ready), but panics - /// on other errors. See also [`try_fill`] which returns errors. - /// - /// # Example - /// - /// ``` - /// use rand::{thread_rng, Rng}; - /// - /// let mut arr = [0i8; 20]; - /// thread_rng().fill(&mut arr[..]); - /// ``` - /// - /// [`fill_bytes`]: RngCore::fill_bytes - /// [`try_fill`]: Rng::try_fill - fn fill(&mut self, dest: &mut T) { - self.fill_bytes(dest.as_byte_slice_mut()); - dest.to_le(); - } - - /// Fill `dest` entirely with random bytes (uniform value distribution), - /// where `dest` is any type supporting [`AsByteSliceMut`], namely slices - /// and arrays over primitive integer types (`i8`, `i16`, `u32`, etc.). - /// - /// On big-endian platforms this performs byte-swapping to ensure - /// portability of results from reproducible generators. - /// - /// This is identical to [`fill`] except that it uses [`try_fill_bytes`] - /// internally and forwards RNG errors. - /// - /// # Example - /// - /// ``` - /// # use rand::Error; - /// use rand::{thread_rng, Rng}; - /// - /// # fn try_inner() -> Result<(), Error> { - /// let mut arr = [0u64; 4]; - /// thread_rng().try_fill(&mut arr[..])?; - /// # Ok(()) - /// # } - /// - /// # try_inner().unwrap() - /// ``` - /// - /// [`try_fill_bytes`]: RngCore::try_fill_bytes - /// [`fill`]: Rng::fill - fn try_fill(&mut self, dest: &mut T) -> Result<(), Error> { - self.try_fill_bytes(dest.as_byte_slice_mut())?; - dest.to_le(); - Ok(()) - } - - /// Return a bool with a probability `p` of being true. - /// - /// See also the [`Bernoulli`] distribution, which may be faster if - /// sampling from the same probability repeatedly. - /// - /// # Example - /// - /// ``` - /// use rand::{thread_rng, Rng}; - /// - /// let mut rng = thread_rng(); - /// println!("{}", rng.gen_bool(1.0 / 3.0)); - /// ``` - /// - /// # Panics - /// - /// If `p < 0` or `p > 1`. - /// - /// [`Bernoulli`]: distributions::bernoulli::Bernoulli - #[inline] - fn gen_bool(&mut self, p: f64) -> bool { - let d = distributions::Bernoulli::new(p).unwrap(); - self.sample(d) - } - - /// Return a bool with a probability of `numerator/denominator` of being - /// true. I.e. `gen_ratio(2, 3)` has chance of 2 in 3, or about 67%, of - /// returning true. If `numerator == denominator`, then the returned value - /// is guaranteed to be `true`. If `numerator == 0`, then the returned - /// value is guaranteed to be `false`. - /// - /// See also the [`Bernoulli`] distribution, which may be faster if - /// sampling from the same `numerator` and `denominator` repeatedly. - /// - /// # Panics - /// - /// If `denominator == 0` or `numerator > denominator`. - /// - /// # Example - /// - /// ``` - /// use rand::{thread_rng, Rng}; - /// - /// let mut rng = thread_rng(); - /// println!("{}", rng.gen_ratio(2, 3)); - /// ``` - /// - /// [`Bernoulli`]: distributions::bernoulli::Bernoulli - #[inline] - fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool { - let d = distributions::Bernoulli::from_ratio(numerator, denominator).unwrap(); - self.sample(d) - } -} - -impl Rng for R {} - -/// Trait for casting types to byte slices -/// -/// This is used by the [`Rng::fill`] and [`Rng::try_fill`] methods. -pub trait AsByteSliceMut { - /// Return a mutable reference to self as a byte slice - fn as_byte_slice_mut(&mut self) -> &mut [u8]; - - /// Call `to_le` on each element (i.e. byte-swap on Big Endian platforms). - fn to_le(&mut self); -} - -impl AsByteSliceMut for [u8] { - fn as_byte_slice_mut(&mut self) -> &mut [u8] { - self - } - - fn to_le(&mut self) {} -} - -macro_rules! impl_as_byte_slice { - () => {}; - ($t:ty) => { - impl AsByteSliceMut for [$t] { - fn as_byte_slice_mut(&mut self) -> &mut [u8] { - if self.len() == 0 { - unsafe { - // must not use null pointer - slice::from_raw_parts_mut(0x1 as *mut u8, 0) - } - } else { - unsafe { - slice::from_raw_parts_mut(self.as_mut_ptr() - as *mut u8, - self.len() * mem::size_of::<$t>() - ) - } - } - } - - fn to_le(&mut self) { - for x in self { - *x = x.to_le(); - } - } - } - - impl AsByteSliceMut for [Wrapping<$t>] { - fn as_byte_slice_mut(&mut self) -> &mut [u8] { - if self.len() == 0 { - unsafe { - // must not use null pointer - slice::from_raw_parts_mut(0x1 as *mut u8, 0) - } - } else { - unsafe { - slice::from_raw_parts_mut(self.as_mut_ptr() - as *mut u8, - self.len() * mem::size_of::<$t>() - ) - } - } - } - - fn to_le(&mut self) { - for x in self { - *x = Wrapping(x.0.to_le()); - } - } - } - }; - ($t:ty, $($tt:ty,)*) => { - impl_as_byte_slice!($t); - // TODO: this could replace above impl once Rust #32463 is fixed - // impl_as_byte_slice!(Wrapping<$t>); - impl_as_byte_slice!($($tt,)*); - } -} - -impl_as_byte_slice!(u16, u32, u64, usize,); -#[cfg(not(target_os = "emscripten"))] -impl_as_byte_slice!(u128); -impl_as_byte_slice!(i8, i16, i32, i64, isize,); -#[cfg(not(target_os = "emscripten"))] -impl_as_byte_slice!(i128); - -macro_rules! impl_as_byte_slice_arrays { - ($n:expr,) => {}; - ($n:expr, $N:ident) => { - impl AsByteSliceMut for [T; $n] where [T]: AsByteSliceMut { - fn as_byte_slice_mut(&mut self) -> &mut [u8] { - self[..].as_byte_slice_mut() - } - - fn to_le(&mut self) { - self[..].to_le() - } - } - }; - ($n:expr, $N:ident, $($NN:ident,)*) => { - impl_as_byte_slice_arrays!($n, $N); - impl_as_byte_slice_arrays!($n - 1, $($NN,)*); - }; - (!div $n:expr,) => {}; - (!div $n:expr, $N:ident, $($NN:ident,)*) => { - impl_as_byte_slice_arrays!($n, $N); - impl_as_byte_slice_arrays!(!div $n / 2, $($NN,)*); - }; -} -#[rustfmt::skip] -impl_as_byte_slice_arrays!(32, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,); -impl_as_byte_slice_arrays!(!div 4096, N,N,N,N,N,N,N,); /// Generates a random value using the thread-local random number generator. /// @@ -511,6 +115,33 @@ /// documentation of the entropy source and [`Standard`] for documentation of /// distributions and type-specific generation. /// +/// # Provided implementations +/// +/// The following types have provided implementations that +/// generate values with the following ranges and distributions: +/// +/// * Integers (`i32`, `u32`, `isize`, `usize`, etc.): Uniformly distributed +/// over all values of the type. +/// * `char`: Uniformly distributed over all Unicode scalar values, i.e. all +/// code points in the range `0...0x10_FFFF`, except for the range +/// `0xD800...0xDFFF` (the surrogate code points). This includes +/// unassigned/reserved code points. +/// * `bool`: Generates `false` or `true`, each with probability 0.5. +/// * Floating point types (`f32` and `f64`): Uniformly distributed in the +/// half-open range `[0, 1)`. See notes below. +/// * Wrapping integers (`Wrapping`), besides the type identical to their +/// normal integer variants. +/// +/// Also supported is the generation of the following +/// compound types where all component types are supported: +/// +/// * Tuples (up to 12 elements): each element is generated sequentially. +/// * Arrays (up to 32 elements): each element is generated sequentially; +/// see also [`Rng::fill`] which supports arbitrary array length for integer +/// types and tends to be faster for `u32` and smaller types. +/// * `Option` first generates a `bool`, and if true generates and returns +/// `Some(value)` where `value: T`, otherwise returning `None`. +/// /// # Examples /// /// ``` @@ -547,7 +178,8 @@ /// ``` /// /// [`Standard`]: distributions::Standard -#[cfg(feature = "std")] +#[cfg(all(feature = "std", feature = "std_rng"))] +#[cfg_attr(doc_cfg, doc(cfg(all(feature = "std", feature = "std_rng"))))] #[inline] pub fn random() -> T where Standard: Distribution { @@ -557,8 +189,6 @@ #[cfg(test)] mod test { use super::*; - use crate::rngs::mock::StepRng; - #[cfg(all(not(feature = "std"), feature = "alloc"))] use alloc::boxed::Box; /// Construct a deterministic RNG with the given seed pub fn rng(seed: u64) -> impl RngCore { @@ -569,131 +199,12 @@ } #[test] - fn test_fill_bytes_default() { - let mut r = StepRng::new(0x11_22_33_44_55_66_77_88, 0); - - // check every remainder mod 8, both in small and big vectors. - let lengths = [0, 1, 2, 3, 4, 5, 6, 7, 80, 81, 82, 83, 84, 85, 86, 87]; - for &n in lengths.iter() { - let mut buffer = [0u8; 87]; - let v = &mut buffer[0..n]; - r.fill_bytes(v); - - // use this to get nicer error messages. - for (i, &byte) in v.iter().enumerate() { - if byte == 0 { - panic!("byte {} of {} is zero", i, n) - } - } - } - } - - #[test] - fn test_fill() { - let x = 9041086907909331047; // a random u64 - let mut rng = StepRng::new(x, 0); - - // Convert to byte sequence and back to u64; byte-swap twice if BE. - let mut array = [0u64; 2]; - rng.fill(&mut array[..]); - assert_eq!(array, [x, x]); - assert_eq!(rng.next_u64(), x); - - // Convert to bytes then u32 in LE order - let mut array = [0u32; 2]; - rng.fill(&mut array[..]); - assert_eq!(array, [x as u32, (x >> 32) as u32]); - assert_eq!(rng.next_u32(), x as u32); - - // Check equivalence using wrapped arrays - let mut warray = [Wrapping(0u32); 2]; - rng.fill(&mut warray[..]); - assert_eq!(array[0], warray[0].0); - assert_eq!(array[1], warray[1].0); - } - - #[test] - fn test_fill_empty() { - let mut array = [0u32; 0]; - let mut rng = StepRng::new(0, 1); - rng.fill(&mut array); - rng.fill(&mut array[..]); - } - - #[test] - fn test_gen_range() { - let mut r = rng(101); - for _ in 0..1000 { - let a = r.gen_range(-4711, 17); - assert!(a >= -4711 && a < 17); - let a = r.gen_range(-3i8, 42); - assert!(a >= -3i8 && a < 42i8); - let a = r.gen_range(&10u16, 99); - assert!(a >= 10u16 && a < 99u16); - let a = r.gen_range(-100i32, &2000); - assert!(a >= -100i32 && a < 2000i32); - let a = r.gen_range(&12u32, &24u32); - assert!(a >= 12u32 && a < 24u32); - - assert_eq!(r.gen_range(0u32, 1), 0u32); - assert_eq!(r.gen_range(-12i64, -11), -12i64); - assert_eq!(r.gen_range(3_000_000, 3_000_001), 3_000_000); - } - } - - #[test] - #[should_panic] - fn test_gen_range_panic_int() { - let mut r = rng(102); - r.gen_range(5, -2); - } - - #[test] - #[should_panic] - fn test_gen_range_panic_usize() { - let mut r = rng(103); - r.gen_range(5, 2); - } - - #[test] - fn test_gen_bool() { - let mut r = rng(105); - for _ in 0..5 { - assert_eq!(r.gen_bool(0.0), false); - assert_eq!(r.gen_bool(1.0), true); - } - } - - #[test] - fn test_rng_trait_object() { - use crate::distributions::{Distribution, Standard}; - let mut rng = rng(109); - let mut r = &mut rng as &mut dyn RngCore; - r.next_u32(); - r.gen::(); - assert_eq!(r.gen_range(0, 1), 0); - let _c: u8 = Standard.sample(&mut r); - } - - #[test] - #[cfg(feature = "alloc")] - fn test_rng_boxed_trait() { - use crate::distributions::{Distribution, Standard}; - let rng = rng(110); - let mut r = Box::new(rng) as Box; - r.next_u32(); - r.gen::(); - assert_eq!(r.gen_range(0, 1), 0); - let _c: u8 = Standard.sample(&mut r); - } - - #[test] - #[cfg(feature = "std")] + #[cfg(all(feature = "std", feature = "std_rng"))] fn test_random() { - // not sure how to test this aside from just getting some values let _n: usize = random(); let _f: f32 = random(); let _o: Option> = random(); + #[allow(clippy::type_complexity)] let _many: ( (), (usize, isize, Option<(u32, (bool,))>), @@ -701,23 +212,4 @@ (f32, (f64, (f64,))), ) = random(); } - - #[test] - #[cfg_attr(miri, ignore)] // Miri is too slow - fn test_gen_ratio_average() { - const NUM: u32 = 3; - const DENOM: u32 = 10; - const N: u32 = 100_000; - - let mut sum: u32 = 0; - let mut rng = rng(111); - for _ in 0..N { - if rng.gen_ratio(NUM, DENOM) { - sum += 1; - } - } - // Have Binomial(N, NUM/DENOM) distribution - let expected = (NUM * N) / DENOM; // exact integer - assert!(((sum - expected) as i32).abs() < 500); - } } diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/prelude.rs cargo-0.58.0/vendor/rand/src/prelude.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/prelude.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/prelude.rs 2022-01-21 02:47:39.000000000 +0000 @@ -22,12 +22,13 @@ #[cfg(feature = "small_rng")] #[doc(no_inline)] pub use crate::rngs::SmallRng; +#[cfg(feature = "std_rng")] #[doc(no_inline)] pub use crate::rngs::StdRng; #[doc(no_inline)] -#[cfg(feature = "std")] +#[cfg(all(feature = "std", feature = "std_rng"))] pub use crate::rngs::ThreadRng; #[doc(no_inline)] pub use crate::seq::{IteratorRandom, SliceRandom}; #[doc(no_inline)] -#[cfg(feature = "std")] +#[cfg(all(feature = "std", feature = "std_rng"))] pub use crate::{random, thread_rng}; #[doc(no_inline)] pub use crate::{CryptoRng, Rng, RngCore, SeedableRng}; diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/rng.rs cargo-0.58.0/vendor/rand/src/rng.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/rng.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/rng.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,603 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2013-2017 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! [`Rng`] trait + +use rand_core::{Error, RngCore}; +use crate::distributions::uniform::{SampleRange, SampleUniform}; +use crate::distributions::{self, Distribution, Standard}; +use core::num::Wrapping; +use core::{mem, slice}; + +/// An automatically-implemented extension trait on [`RngCore`] providing high-level +/// generic methods for sampling values and other convenience methods. +/// +/// This is the primary trait to use when generating random values. +/// +/// # Generic usage +/// +/// The basic pattern is `fn foo(rng: &mut R)`. Some +/// things are worth noting here: +/// +/// - Since `Rng: RngCore` and every `RngCore` implements `Rng`, it makes no +/// difference whether we use `R: Rng` or `R: RngCore`. +/// - The `+ ?Sized` un-bounding allows functions to be called directly on +/// type-erased references; i.e. `foo(r)` where `r: &mut dyn RngCore`. Without +/// this it would be necessary to write `foo(&mut r)`. +/// +/// An alternative pattern is possible: `fn foo(rng: R)`. This has some +/// trade-offs. It allows the argument to be consumed directly without a `&mut` +/// (which is how `from_rng(thread_rng())` works); also it still works directly +/// on references (including type-erased references). Unfortunately within the +/// function `foo` it is not known whether `rng` is a reference type or not, +/// hence many uses of `rng` require an extra reference, either explicitly +/// (`distr.sample(&mut rng)`) or implicitly (`rng.gen()`); one may hope the +/// optimiser can remove redundant references later. +/// +/// Example: +/// +/// ``` +/// # use rand::thread_rng; +/// use rand::Rng; +/// +/// fn foo(rng: &mut R) -> f32 { +/// rng.gen() +/// } +/// +/// # let v = foo(&mut thread_rng()); +/// ``` +pub trait Rng: RngCore { + /// Return a random value supporting the [`Standard`] distribution. + /// + /// # Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// + /// let mut rng = thread_rng(); + /// let x: u32 = rng.gen(); + /// println!("{}", x); + /// println!("{:?}", rng.gen::<(f64, bool)>()); + /// ``` + /// + /// # Arrays and tuples + /// + /// The `rng.gen()` method is able to generate arrays (up to 32 elements) + /// and tuples (up to 12 elements), so long as all element types can be + /// generated. + /// When using `rustc` ≥ 1.51, enable the `min_const_gen` feature to support + /// arrays larger than 32 elements. + /// + /// For arrays of integers, especially for those with small element types + /// (< 64 bit), it will likely be faster to instead use [`Rng::fill`]. + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// + /// let mut rng = thread_rng(); + /// let tuple: (u8, i32, char) = rng.gen(); // arbitrary tuple support + /// + /// let arr1: [f32; 32] = rng.gen(); // array construction + /// let mut arr2 = [0u8; 128]; + /// rng.fill(&mut arr2); // array fill + /// ``` + /// + /// [`Standard`]: distributions::Standard + #[inline] + fn gen(&mut self) -> T + where Standard: Distribution { + Standard.sample(self) + } + + /// Generate a random value in the given range. + /// + /// This function is optimised for the case that only a single sample is + /// made from the given range. See also the [`Uniform`] distribution + /// type which may be faster if sampling from the same range repeatedly. + /// + /// Only `gen_range(low..high)` and `gen_range(low..=high)` are supported. + /// + /// # Panics + /// + /// Panics if the range is empty. + /// + /// # Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// + /// let mut rng = thread_rng(); + /// + /// // Exclusive range + /// let n: u32 = rng.gen_range(0..10); + /// println!("{}", n); + /// let m: f64 = rng.gen_range(-40.0..1.3e5); + /// println!("{}", m); + /// + /// // Inclusive range + /// let n: u32 = rng.gen_range(0..=10); + /// println!("{}", n); + /// ``` + /// + /// [`Uniform`]: distributions::uniform::Uniform + fn gen_range(&mut self, range: R) -> T + where + T: SampleUniform, + R: SampleRange + { + assert!(!range.is_empty(), "cannot sample empty range"); + range.sample_single(self) + } + + /// Sample a new value, using the given distribution. + /// + /// ### Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// use rand::distributions::Uniform; + /// + /// let mut rng = thread_rng(); + /// let x = rng.sample(Uniform::new(10u32, 15)); + /// // Type annotation requires two types, the type and distribution; the + /// // distribution can be inferred. + /// let y = rng.sample::(Uniform::new(10, 15)); + /// ``` + fn sample>(&mut self, distr: D) -> T { + distr.sample(self) + } + + /// Create an iterator that generates values using the given distribution. + /// + /// Note that this function takes its arguments by value. This works since + /// `(&mut R): Rng where R: Rng` and + /// `(&D): Distribution where D: Distribution`, + /// however borrowing is not automatic hence `rng.sample_iter(...)` may + /// need to be replaced with `(&mut rng).sample_iter(...)`. + /// + /// # Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// use rand::distributions::{Alphanumeric, Uniform, Standard}; + /// + /// let mut rng = thread_rng(); + /// + /// // Vec of 16 x f32: + /// let v: Vec = (&mut rng).sample_iter(Standard).take(16).collect(); + /// + /// // String: + /// let s: String = (&mut rng).sample_iter(Alphanumeric) + /// .take(7) + /// .map(char::from) + /// .collect(); + /// + /// // Combined values + /// println!("{:?}", (&mut rng).sample_iter(Standard).take(5) + /// .collect::>()); + /// + /// // Dice-rolling: + /// let die_range = Uniform::new_inclusive(1, 6); + /// let mut roll_die = (&mut rng).sample_iter(die_range); + /// while roll_die.next().unwrap() != 6 { + /// println!("Not a 6; rolling again!"); + /// } + /// ``` + fn sample_iter(self, distr: D) -> distributions::DistIter + where + D: Distribution, + Self: Sized, + { + distr.sample_iter(self) + } + + /// Fill any type implementing [`Fill`] with random data + /// + /// The distribution is expected to be uniform with portable results, but + /// this cannot be guaranteed for third-party implementations. + /// + /// This is identical to [`try_fill`] except that it panics on error. + /// + /// # Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// + /// let mut arr = [0i8; 20]; + /// thread_rng().fill(&mut arr[..]); + /// ``` + /// + /// [`fill_bytes`]: RngCore::fill_bytes + /// [`try_fill`]: Rng::try_fill + fn fill(&mut self, dest: &mut T) { + dest.try_fill(self).unwrap_or_else(|_| panic!("Rng::fill failed")) + } + + /// Fill any type implementing [`Fill`] with random data + /// + /// The distribution is expected to be uniform with portable results, but + /// this cannot be guaranteed for third-party implementations. + /// + /// This is identical to [`fill`] except that it forwards errors. + /// + /// # Example + /// + /// ``` + /// # use rand::Error; + /// use rand::{thread_rng, Rng}; + /// + /// # fn try_inner() -> Result<(), Error> { + /// let mut arr = [0u64; 4]; + /// thread_rng().try_fill(&mut arr[..])?; + /// # Ok(()) + /// # } + /// + /// # try_inner().unwrap() + /// ``` + /// + /// [`try_fill_bytes`]: RngCore::try_fill_bytes + /// [`fill`]: Rng::fill + fn try_fill(&mut self, dest: &mut T) -> Result<(), Error> { + dest.try_fill(self) + } + + /// Return a bool with a probability `p` of being true. + /// + /// See also the [`Bernoulli`] distribution, which may be faster if + /// sampling from the same probability repeatedly. + /// + /// # Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// + /// let mut rng = thread_rng(); + /// println!("{}", rng.gen_bool(1.0 / 3.0)); + /// ``` + /// + /// # Panics + /// + /// If `p < 0` or `p > 1`. + /// + /// [`Bernoulli`]: distributions::Bernoulli + #[inline] + fn gen_bool(&mut self, p: f64) -> bool { + let d = distributions::Bernoulli::new(p).unwrap(); + self.sample(d) + } + + /// Return a bool with a probability of `numerator/denominator` of being + /// true. I.e. `gen_ratio(2, 3)` has chance of 2 in 3, or about 67%, of + /// returning true. If `numerator == denominator`, then the returned value + /// is guaranteed to be `true`. If `numerator == 0`, then the returned + /// value is guaranteed to be `false`. + /// + /// See also the [`Bernoulli`] distribution, which may be faster if + /// sampling from the same `numerator` and `denominator` repeatedly. + /// + /// # Panics + /// + /// If `denominator == 0` or `numerator > denominator`. + /// + /// # Example + /// + /// ``` + /// use rand::{thread_rng, Rng}; + /// + /// let mut rng = thread_rng(); + /// println!("{}", rng.gen_ratio(2, 3)); + /// ``` + /// + /// [`Bernoulli`]: distributions::Bernoulli + #[inline] + fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool { + let d = distributions::Bernoulli::from_ratio(numerator, denominator).unwrap(); + self.sample(d) + } +} + +impl Rng for R {} + +/// Types which may be filled with random data +/// +/// This trait allows arrays to be efficiently filled with random data. +/// +/// Implementations are expected to be portable across machines unless +/// clearly documented otherwise (see the +/// [Chapter on Portability](https://rust-random.github.io/book/portability.html)). +pub trait Fill { + /// Fill self with random data + fn try_fill(&mut self, rng: &mut R) -> Result<(), Error>; +} + +macro_rules! impl_fill_each { + () => {}; + ($t:ty) => { + impl Fill for [$t] { + fn try_fill(&mut self, rng: &mut R) -> Result<(), Error> { + for elt in self.iter_mut() { + *elt = rng.gen(); + } + Ok(()) + } + } + }; + ($t:ty, $($tt:ty,)*) => { + impl_fill_each!($t); + impl_fill_each!($($tt,)*); + }; +} + +impl_fill_each!(bool, char, f32, f64,); + +impl Fill for [u8] { + fn try_fill(&mut self, rng: &mut R) -> Result<(), Error> { + rng.try_fill_bytes(self) + } +} + +macro_rules! impl_fill { + () => {}; + ($t:ty) => { + impl Fill for [$t] { + #[inline(never)] // in micro benchmarks, this improves performance + fn try_fill(&mut self, rng: &mut R) -> Result<(), Error> { + if self.len() > 0 { + rng.try_fill_bytes(unsafe { + slice::from_raw_parts_mut(self.as_mut_ptr() + as *mut u8, + self.len() * mem::size_of::<$t>() + ) + })?; + for x in self { + *x = x.to_le(); + } + } + Ok(()) + } + } + + impl Fill for [Wrapping<$t>] { + #[inline(never)] + fn try_fill(&mut self, rng: &mut R) -> Result<(), Error> { + if self.len() > 0 { + rng.try_fill_bytes(unsafe { + slice::from_raw_parts_mut(self.as_mut_ptr() + as *mut u8, + self.len() * mem::size_of::<$t>() + ) + })?; + for x in self { + *x = Wrapping(x.0.to_le()); + } + } + Ok(()) + } + } + }; + ($t:ty, $($tt:ty,)*) => { + impl_fill!($t); + // TODO: this could replace above impl once Rust #32463 is fixed + // impl_fill!(Wrapping<$t>); + impl_fill!($($tt,)*); + } +} + +impl_fill!(u16, u32, u64, usize,); +#[cfg(not(target_os = "emscripten"))] +impl_fill!(u128); +impl_fill!(i8, i16, i32, i64, isize,); +#[cfg(not(target_os = "emscripten"))] +impl_fill!(i128); + +#[cfg(feature = "min_const_gen")] +impl Fill for [T; N] +where [T]: Fill +{ + fn try_fill(&mut self, rng: &mut R) -> Result<(), Error> { + self[..].try_fill(rng) + } +} + +#[cfg(not(feature = "min_const_gen"))] +macro_rules! impl_fill_arrays { + ($n:expr,) => {}; + ($n:expr, $N:ident) => { + impl Fill for [T; $n] where [T]: Fill { + fn try_fill(&mut self, rng: &mut R) -> Result<(), Error> { + self[..].try_fill(rng) + } + } + }; + ($n:expr, $N:ident, $($NN:ident,)*) => { + impl_fill_arrays!($n, $N); + impl_fill_arrays!($n - 1, $($NN,)*); + }; + (!div $n:expr,) => {}; + (!div $n:expr, $N:ident, $($NN:ident,)*) => { + impl_fill_arrays!($n, $N); + impl_fill_arrays!(!div $n / 2, $($NN,)*); + }; +} +#[cfg(not(feature = "min_const_gen"))] +#[rustfmt::skip] +impl_fill_arrays!(32, N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,); +#[cfg(not(feature = "min_const_gen"))] +impl_fill_arrays!(!div 4096, N,N,N,N,N,N,N,); + +#[cfg(test)] +mod test { + use super::*; + use crate::test::rng; + use crate::rngs::mock::StepRng; + #[cfg(feature = "alloc")] use alloc::boxed::Box; + + #[test] + fn test_fill_bytes_default() { + let mut r = StepRng::new(0x11_22_33_44_55_66_77_88, 0); + + // check every remainder mod 8, both in small and big vectors. + let lengths = [0, 1, 2, 3, 4, 5, 6, 7, 80, 81, 82, 83, 84, 85, 86, 87]; + for &n in lengths.iter() { + let mut buffer = [0u8; 87]; + let v = &mut buffer[0..n]; + r.fill_bytes(v); + + // use this to get nicer error messages. + for (i, &byte) in v.iter().enumerate() { + if byte == 0 { + panic!("byte {} of {} is zero", i, n) + } + } + } + } + + #[test] + fn test_fill() { + let x = 9041086907909331047; // a random u64 + let mut rng = StepRng::new(x, 0); + + // Convert to byte sequence and back to u64; byte-swap twice if BE. + let mut array = [0u64; 2]; + rng.fill(&mut array[..]); + assert_eq!(array, [x, x]); + assert_eq!(rng.next_u64(), x); + + // Convert to bytes then u32 in LE order + let mut array = [0u32; 2]; + rng.fill(&mut array[..]); + assert_eq!(array, [x as u32, (x >> 32) as u32]); + assert_eq!(rng.next_u32(), x as u32); + + // Check equivalence using wrapped arrays + let mut warray = [Wrapping(0u32); 2]; + rng.fill(&mut warray[..]); + assert_eq!(array[0], warray[0].0); + assert_eq!(array[1], warray[1].0); + + // Check equivalence for generated floats + let mut array = [0f32; 2]; + rng.fill(&mut array); + let gen: [f32; 2] = rng.gen(); + assert_eq!(array, gen); + } + + #[test] + fn test_fill_empty() { + let mut array = [0u32; 0]; + let mut rng = StepRng::new(0, 1); + rng.fill(&mut array); + rng.fill(&mut array[..]); + } + + #[test] + fn test_gen_range_int() { + let mut r = rng(101); + for _ in 0..1000 { + let a = r.gen_range(-4711..17); + assert!((-4711..17).contains(&a)); + let a: i8 = r.gen_range(-3..42); + assert!((-3..42).contains(&a)); + let a: u16 = r.gen_range(10..99); + assert!((10..99).contains(&a)); + let a: i32 = r.gen_range(-100..2000); + assert!((-100..2000).contains(&a)); + let a: u32 = r.gen_range(12..=24); + assert!((12..=24).contains(&a)); + + assert_eq!(r.gen_range(0u32..1), 0u32); + assert_eq!(r.gen_range(-12i64..-11), -12i64); + assert_eq!(r.gen_range(3_000_000..3_000_001), 3_000_000); + } + } + + #[test] + fn test_gen_range_float() { + let mut r = rng(101); + for _ in 0..1000 { + let a = r.gen_range(-4.5..1.7); + assert!((-4.5..1.7).contains(&a)); + let a = r.gen_range(-1.1..=-0.3); + assert!((-1.1..=-0.3).contains(&a)); + + assert_eq!(r.gen_range(0.0f32..=0.0), 0.); + assert_eq!(r.gen_range(-11.0..=-11.0), -11.); + assert_eq!(r.gen_range(3_000_000.0..=3_000_000.0), 3_000_000.); + } + } + + #[test] + #[should_panic] + fn test_gen_range_panic_int() { + #![allow(clippy::reversed_empty_ranges)] + let mut r = rng(102); + r.gen_range(5..-2); + } + + #[test] + #[should_panic] + fn test_gen_range_panic_usize() { + #![allow(clippy::reversed_empty_ranges)] + let mut r = rng(103); + r.gen_range(5..2); + } + + #[test] + fn test_gen_bool() { + #![allow(clippy::bool_assert_comparison)] + + let mut r = rng(105); + for _ in 0..5 { + assert_eq!(r.gen_bool(0.0), false); + assert_eq!(r.gen_bool(1.0), true); + } + } + + #[test] + fn test_rng_trait_object() { + use crate::distributions::{Distribution, Standard}; + let mut rng = rng(109); + let mut r = &mut rng as &mut dyn RngCore; + r.next_u32(); + r.gen::(); + assert_eq!(r.gen_range(0..1), 0); + let _c: u8 = Standard.sample(&mut r); + } + + #[test] + #[cfg(feature = "alloc")] + fn test_rng_boxed_trait() { + use crate::distributions::{Distribution, Standard}; + let rng = rng(110); + let mut r = Box::new(rng) as Box; + r.next_u32(); + r.gen::(); + assert_eq!(r.gen_range(0..1), 0); + let _c: u8 = Standard.sample(&mut r); + } + + #[test] + #[cfg_attr(miri, ignore)] // Miri is too slow + fn test_gen_ratio_average() { + const NUM: u32 = 3; + const DENOM: u32 = 10; + const N: u32 = 100_000; + + let mut sum: u32 = 0; + let mut rng = rng(111); + for _ in 0..N { + if rng.gen_ratio(NUM, DENOM) { + sum += 1; + } + } + // Have Binomial(N, NUM/DENOM) distribution + let expected = (NUM * N) / DENOM; // exact integer + assert!(((sum - expected) as i32).abs() < 500); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/rngs/adapter/mod.rs cargo-0.58.0/vendor/rand/src/rngs/adapter/mod.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/rngs/adapter/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/rngs/adapter/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -8,8 +8,9 @@ //! Wrappers / adapters forming RNGs -#[cfg(feature = "std")] mod read; +mod read; mod reseeding; -#[cfg(feature = "std")] pub use self::read::{ReadError, ReadRng}; +#[allow(deprecated)] +pub use self::read::{ReadError, ReadRng}; pub use self::reseeding::ReseedingRng; diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/rngs/adapter/read.rs cargo-0.58.0/vendor/rand/src/rngs/adapter/read.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/rngs/adapter/read.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/rngs/adapter/read.rs 2022-01-21 02:47:39.000000000 +0000 @@ -9,6 +9,8 @@ //! A wrapper around any Read to treat it as an RNG. +#![allow(deprecated)] + use std::fmt; use std::io::Read; @@ -30,20 +32,10 @@ /// have enough data, will only be reported through [`try_fill_bytes`]. /// The other [`RngCore`] methods will panic in case of an error. /// -/// # Example -/// -/// ``` -/// use rand::Rng; -/// use rand::rngs::adapter::ReadRng; -/// -/// let data = vec![1, 2, 3, 4, 5, 6, 7, 8]; -/// let mut rng = ReadRng::new(&data[..]); -/// println!("{:x}", rng.gen::()); -/// ``` -/// /// [`OsRng`]: crate::rngs::OsRng /// [`try_fill_bytes`]: RngCore::try_fill_bytes #[derive(Debug)] +#[deprecated(since="0.8.4", note="removal due to lack of usage")] pub struct ReadRng { reader: R, } @@ -86,6 +78,7 @@ /// `ReadRng` error type #[derive(Debug)] +#[deprecated(since="0.8.4")] pub struct ReadError(std::io::Error); impl fmt::Display for ReadError { @@ -103,6 +96,8 @@ #[cfg(test)] mod test { + use std::println; + use super::ReadRng; use crate::RngCore; @@ -110,24 +105,24 @@ fn test_reader_rng_u64() { // transmute from the target to avoid endianness concerns. #[rustfmt::skip] - let v = vec![0u8, 0, 0, 0, 0, 0, 0, 1, - 0 , 0, 0, 0, 0, 0, 0, 2, - 0, 0, 0, 0, 0, 0, 0, 3]; + let v = [0u8, 0, 0, 0, 0, 0, 0, 1, + 0, 4, 0, 0, 3, 0, 0, 2, + 5, 0, 0, 0, 0, 0, 0, 0]; let mut rng = ReadRng::new(&v[..]); - assert_eq!(rng.next_u64(), 1_u64.to_be()); - assert_eq!(rng.next_u64(), 2_u64.to_be()); - assert_eq!(rng.next_u64(), 3_u64.to_be()); + assert_eq!(rng.next_u64(), 1 << 56); + assert_eq!(rng.next_u64(), (2 << 56) + (3 << 32) + (4 << 8)); + assert_eq!(rng.next_u64(), 5); } #[test] fn test_reader_rng_u32() { - let v = vec![0u8, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3]; + let v = [0u8, 0, 0, 1, 0, 0, 2, 0, 3, 0, 0, 0]; let mut rng = ReadRng::new(&v[..]); - assert_eq!(rng.next_u32(), 1_u32.to_be()); - assert_eq!(rng.next_u32(), 2_u32.to_be()); - assert_eq!(rng.next_u32(), 3_u32.to_be()); + assert_eq!(rng.next_u32(), 1 << 24); + assert_eq!(rng.next_u32(), 2 << 16); + assert_eq!(rng.next_u32(), 3); } #[test] diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/rngs/adapter/reseeding.rs cargo-0.58.0/vendor/rand/src/rngs/adapter/reseeding.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/rngs/adapter/reseeding.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/rngs/adapter/reseeding.rs 2022-01-21 02:47:39.000000000 +0000 @@ -279,7 +279,7 @@ } -#[cfg(all(unix, feature = "std", not(target_os = "emscripten")))] +#[cfg(all(unix, not(target_os = "emscripten")))] mod fork { use core::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Once; @@ -316,7 +316,7 @@ } } -#[cfg(not(all(unix, feature = "std", not(target_os = "emscripten"))))] +#[cfg(not(all(unix, not(target_os = "emscripten"))))] mod fork { pub fn get_fork_counter() -> usize { 0 @@ -325,6 +325,7 @@ } +#[cfg(feature = "std_rng")] #[cfg(test)] mod test { use super::ReseedingRng; @@ -354,6 +355,8 @@ #[test] fn test_clone_reseeding() { + #![allow(clippy::redundant_clone)] + let mut zero = StepRng::new(0, 0); let rng = Core::from_rng(&mut zero).unwrap(); let mut rng1 = ReseedingRng::new(rng, 32 * 4, zero); diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/rngs/entropy.rs cargo-0.58.0/vendor/rand/src/rngs/entropy.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/rngs/entropy.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/rngs/entropy.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,76 +0,0 @@ -// Copyright 2018 Developers of the Rand project. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Entropy generator, or wrapper around external generators - -#![allow(deprecated)] // whole module is deprecated - -use crate::rngs::OsRng; -use rand_core::{CryptoRng, Error, RngCore}; - -/// An interface returning random data from external source(s), provided -/// specifically for securely seeding algorithmic generators (PRNGs). -/// -/// This is deprecated. It is suggested you use [`rngs::OsRng`] instead. -/// -/// [`rngs::OsRng`]: crate::rngs::OsRng -#[derive(Debug)] -#[deprecated(since = "0.7.0", note = "use rngs::OsRng instead")] -pub struct EntropyRng { - source: OsRng, -} - -impl EntropyRng { - /// Create a new `EntropyRng`. - /// - /// This method will do no system calls or other initialization routines, - /// those are done on first use. This is done to make `new` infallible, - /// and `try_fill_bytes` the only place to report errors. - pub fn new() -> Self { - EntropyRng { source: OsRng } - } -} - -impl Default for EntropyRng { - fn default() -> Self { - EntropyRng::new() - } -} - -impl RngCore for EntropyRng { - fn next_u32(&mut self) -> u32 { - self.source.next_u32() - } - - fn next_u64(&mut self) -> u64 { - self.source.next_u64() - } - - fn fill_bytes(&mut self, dest: &mut [u8]) { - self.source.fill_bytes(dest) - } - - fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { - self.source.try_fill_bytes(dest) - } -} - -impl CryptoRng for EntropyRng {} - - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn test_entropy() { - let mut rng = EntropyRng::new(); - let n = (rng.next_u32() ^ rng.next_u32()).count_ones(); - assert!(n >= 2); // p(failure) approx 1e-7 - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/rngs/mock.rs cargo-0.58.0/vendor/rand/src/rngs/mock.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/rngs/mock.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/rngs/mock.rs 2022-01-21 02:47:39.000000000 +0000 @@ -10,6 +10,9 @@ use rand_core::{impls, Error, RngCore}; +#[cfg(feature = "serde1")] +use serde::{Serialize, Deserialize}; + /// A simple implementation of `RngCore` for testing purposes. /// /// This generates an arithmetic sequence (i.e. adds a constant each step) @@ -24,7 +27,8 @@ /// let sample: [u64; 3] = my_rng.gen(); /// assert_eq!(sample, [2, 3, 4]); /// ``` -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] pub struct StepRng { v: u64, a: u64, @@ -65,3 +69,19 @@ Ok(()) } } + +#[cfg(test)] +mod tests { + #[test] + #[cfg(feature = "serde1")] + fn test_serialization_step_rng() { + use super::StepRng; + + let some_rng = StepRng::new(42, 7); + let de_some_rng: StepRng = + bincode::deserialize(&bincode::serialize(&some_rng).unwrap()).unwrap(); + assert_eq!(some_rng.v, de_some_rng.v); + assert_eq!(some_rng.a, de_some_rng.a); + + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/rngs/mod.rs cargo-0.58.0/vendor/rand/src/rngs/mod.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/rngs/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/rngs/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -58,7 +58,7 @@ //! is local, it is typically much faster than [`OsRng`]. It should be //! secure, though the paranoid may prefer [`OsRng`]. //! - [`StdRng`] is a CSPRNG chosen for good performance and trust of security -//! (based on reviews, maturity and usage). The current algorithm is ChaCha20, +//! (based on reviews, maturity and usage). The current algorithm is ChaCha12, //! which is well established and rigorously analysed. //! [`StdRng`] provides the algorithm used by [`ThreadRng`] but without //! periodic reseeding. @@ -96,21 +96,24 @@ //! [`rand_xoshiro`]: https://crates.io/crates/rand_xoshiro //! [`rng` tag]: https://crates.io/keywords/rng -pub mod adapter; +#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] +#[cfg(feature = "std")] pub mod adapter; -#[cfg(feature = "std")] mod entropy; pub mod mock; // Public so we don't export `StepRng` directly, making it a bit // more clear it is intended for testing. + +#[cfg(all(feature = "small_rng", target_pointer_width = "64"))] +mod xoshiro256plusplus; +#[cfg(all(feature = "small_rng", not(target_pointer_width = "64")))] +mod xoshiro128plusplus; #[cfg(feature = "small_rng")] mod small; -mod std; -#[cfg(feature = "std")] pub(crate) mod thread; -#[allow(deprecated)] -#[cfg(feature = "std")] -pub use self::entropy::EntropyRng; +#[cfg(feature = "std_rng")] mod std; +#[cfg(all(feature = "std", feature = "std_rng"))] pub(crate) mod thread; #[cfg(feature = "small_rng")] pub use self::small::SmallRng; -pub use self::std::StdRng; -#[cfg(feature = "std")] pub use self::thread::ThreadRng; +#[cfg(feature = "std_rng")] pub use self::std::StdRng; +#[cfg(all(feature = "std", feature = "std_rng"))] pub use self::thread::ThreadRng; +#[cfg_attr(doc_cfg, doc(cfg(feature = "getrandom")))] #[cfg(feature = "getrandom")] pub use rand_core::OsRng; diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/rngs/small.rs cargo-0.58.0/vendor/rand/src/rngs/small.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/rngs/small.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/rngs/small.rs 2022-01-21 02:47:39.000000000 +0000 @@ -10,33 +10,36 @@ use rand_core::{Error, RngCore, SeedableRng}; -#[cfg(all(not(target_os = "emscripten"), target_pointer_width = "64"))] -type Rng = rand_pcg::Pcg64Mcg; -#[cfg(not(all(not(target_os = "emscripten"), target_pointer_width = "64")))] -type Rng = rand_pcg::Pcg32; +#[cfg(target_pointer_width = "64")] +type Rng = super::xoshiro256plusplus::Xoshiro256PlusPlus; +#[cfg(not(target_pointer_width = "64"))] +type Rng = super::xoshiro128plusplus::Xoshiro128PlusPlus; /// A small-state, fast non-crypto PRNG /// /// `SmallRng` may be a good choice when a PRNG with small state, cheap /// initialization, good statistical quality and good performance are required. -/// It is **not** a good choice when security against prediction or -/// reproducibility are important. -/// -/// This PRNG is **feature-gated**: to use, you must enable the crate feature -/// `small_rng`. +/// Note that depending on the application, [`StdRng`] may be faster on many +/// modern platforms while providing higher-quality randomness. Furthermore, +/// `SmallRng` is **not** a good choice when: +/// - Security against prediction is important. Use [`StdRng`] instead. +/// - Seeds with many zeros are provided. In such cases, it takes `SmallRng` +/// about 10 samples to produce 0 and 1 bits with equal probability. Either +/// provide seeds with an approximately equal number of 0 and 1 (for example +/// by using [`SeedableRng::from_entropy`] or [`SeedableRng::seed_from_u64`]), +/// or use [`StdRng`] instead. /// /// The algorithm is deterministic but should not be considered reproducible /// due to dependence on platform and possible replacement in future /// library versions. For a reproducible generator, use a named PRNG from an -/// external crate, e.g. [rand_pcg] or [rand_chacha]. +/// external crate, e.g. [rand_xoshiro] or [rand_chacha]. /// Refer also to [The Book](https://rust-random.github.io/book/guide-rngs.html). /// -/// The PRNG algorithm in `SmallRng` is chosen to be -/// efficient on the current platform, without consideration for cryptography -/// or security. The size of its state is much smaller than [`StdRng`]. -/// The current algorithm is [`Pcg64Mcg`](rand_pcg::Pcg64Mcg) on 64-bit -/// platforms and [`Pcg32`](rand_pcg::Pcg32) on 32-bit platforms. Both are -/// implemented by the [rand_pcg] crate. +/// The PRNG algorithm in `SmallRng` is chosen to be efficient on the current +/// platform, without consideration for cryptography or security. The size of +/// its state is much smaller than [`StdRng`]. The current algorithm is +/// `Xoshiro256PlusPlus` on 64-bit platforms and `Xoshiro128PlusPlus` on 32-bit +/// platforms. Both are also implemented by the [rand_xoshiro] crate. /// /// # Examples /// @@ -72,8 +75,9 @@ /// [`StdRng`]: crate::rngs::StdRng /// [`thread_rng`]: crate::thread_rng /// [rand_chacha]: https://crates.io/crates/rand_chacha -/// [rand_pcg]: https://crates.io/crates/rand_pcg -#[derive(Clone, Debug)] +/// [rand_xoshiro]: https://crates.io/crates/rand_xoshiro +#[cfg_attr(doc_cfg, doc(cfg(feature = "small_rng")))] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct SmallRng(Rng); impl RngCore for SmallRng { diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/rngs/std.rs cargo-0.58.0/vendor/rand/src/rngs/std.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/rngs/std.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/rngs/std.rs 2022-01-21 02:47:39.000000000 +0000 @@ -11,20 +11,20 @@ use crate::{CryptoRng, Error, RngCore, SeedableRng}; #[cfg(all(any(test, feature = "std"), not(target_os = "emscripten")))] -pub(crate) use rand_chacha::ChaCha20Core as Core; +pub(crate) use rand_chacha::ChaCha12Core as Core; #[cfg(all(any(test, feature = "std"), target_os = "emscripten"))] pub(crate) use rand_hc::Hc128Core as Core; -#[cfg(not(target_os = "emscripten"))] use rand_chacha::ChaCha20Rng as Rng; +#[cfg(not(target_os = "emscripten"))] use rand_chacha::ChaCha12Rng as Rng; #[cfg(target_os = "emscripten")] use rand_hc::Hc128Rng as Rng; /// The standard RNG. The PRNG algorithm in `StdRng` is chosen to be efficient /// on the current platform, to be statistically strong and unpredictable /// (meaning a cryptographically secure PRNG). /// -/// The current algorithm used is the ChaCha block cipher with 20 rounds. -/// This may change as new evidence of cipher security and performance -/// becomes available. +/// The current algorithm used is the ChaCha block cipher with 12 rounds. Please +/// see this relevant [rand issue] for the discussion. This may change as new +/// evidence of cipher security and performance becomes available. /// /// The algorithm is deterministic but should not be considered reproducible /// due to dependence on configuration and possible replacement in future @@ -32,7 +32,9 @@ /// the [rand_chacha] crate directly. /// /// [rand_chacha]: https://crates.io/crates/rand_chacha -#[derive(Clone, Debug)] +/// [rand issue]: https://github.com/rust-random/rand/issues/932 +#[cfg_attr(doc_cfg, doc(cfg(feature = "std_rng")))] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct StdRng(Rng); impl RngCore for StdRng { @@ -87,9 +89,6 @@ let seed = [1,0,0,0, 23,0,0,0, 200,1,0,0, 210,30,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; - #[cfg(any(feature = "stdrng_strong", not(feature = "stdrng_fast")))] - let target = [3950704604716924505, 5573172343717151650]; - #[cfg(all(not(feature = "stdrng_strong"), feature = "stdrng_fast"))] let target = [10719222850664546238, 14064965282130556830]; let mut rng0 = StdRng::from_seed(seed); diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/rngs/thread.rs cargo-0.58.0/vendor/rand/src/rngs/thread.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/rngs/thread.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/rngs/thread.rs 2022-01-21 02:47:39.000000000 +0000 @@ -8,8 +8,9 @@ //! Thread-local random number generator -use std::cell::UnsafeCell; -use std::ptr::NonNull; +use core::cell::UnsafeCell; +use std::rc::Rc; +use std::thread_local; use super::std::Core; use crate::rngs::adapter::ReseedingRng; @@ -36,37 +37,42 @@ // of 32 kB and less. We choose 64 kB to avoid significant overhead. const THREAD_RNG_RESEED_THRESHOLD: u64 = 1024 * 64; -/// The type returned by [`thread_rng`], essentially just a reference to the -/// PRNG in thread-local memory. +/// A reference to the thread-local generator /// -/// `ThreadRng` uses the same PRNG as [`StdRng`] for security and performance. -/// As hinted by the name, the generator is thread-local. `ThreadRng` is a -/// handle to this generator and thus supports `Copy`, but not `Send` or `Sync`. +/// An instance can be obtained via [`thread_rng`] or via `ThreadRng::default()`. +/// This handle is safe to use everywhere (including thread-local destructors) +/// but cannot be passed between threads (is not `Send` or `Sync`). /// -/// Unlike `StdRng`, `ThreadRng` uses the [`ReseedingRng`] wrapper to reseed -/// the PRNG from fresh entropy every 64 kiB of random data. -/// [`OsRng`] is used to provide seed data. +/// `ThreadRng` uses the same PRNG as [`StdRng`] for security and performance +/// and is automatically seeded from [`OsRng`]. /// +/// Unlike `StdRng`, `ThreadRng` uses the [`ReseedingRng`] wrapper to reseed +/// the PRNG from fresh entropy every 64 kiB of random data as well as after a +/// fork on Unix (though not quite immediately; see documentation of +/// [`ReseedingRng`]). /// Note that the reseeding is done as an extra precaution against side-channel /// attacks and mis-use (e.g. if somehow weak entropy were supplied initially). /// The PRNG algorithms used are assumed to be secure. /// /// [`ReseedingRng`]: crate::rngs::adapter::ReseedingRng /// [`StdRng`]: crate::rngs::StdRng -#[derive(Copy, Clone, Debug)] +#[cfg_attr(doc_cfg, doc(cfg(all(feature = "std", feature = "std_rng"))))] +#[derive(Clone, Debug)] pub struct ThreadRng { - // inner raw pointer implies type is neither Send nor Sync - rng: NonNull>, + // Rc is explictly !Send and !Sync + rng: Rc>>, } thread_local!( - static THREAD_RNG_KEY: UnsafeCell> = { + // We require Rc<..> to avoid premature freeing when thread_rng is used + // within thread-local destructors. See #968. + static THREAD_RNG_KEY: Rc>> = { let r = Core::from_rng(OsRng).unwrap_or_else(|err| panic!("could not initialize thread_rng: {}", err)); let rng = ReseedingRng::new(r, THREAD_RNG_RESEED_THRESHOLD, OsRng); - UnsafeCell::new(rng) + Rc::new(UnsafeCell::new(rng)) } ); @@ -77,10 +83,10 @@ /// `ThreadRng::default()` equivalent. /// /// For more information see [`ThreadRng`]. +#[cfg_attr(doc_cfg, doc(cfg(all(feature = "std", feature = "std_rng"))))] pub fn thread_rng() -> ThreadRng { - let raw = THREAD_RNG_KEY.with(|t| t.get()); - let nn = NonNull::new(raw).unwrap(); - ThreadRng { rng: nn } + let rng = THREAD_RNG_KEY.with(|t| t.clone()); + ThreadRng { rng } } impl Default for ThreadRng { @@ -92,20 +98,32 @@ impl RngCore for ThreadRng { #[inline(always)] fn next_u32(&mut self) -> u32 { - unsafe { self.rng.as_mut().next_u32() } + // SAFETY: We must make sure to stop using `rng` before anyone else + // creates another mutable reference + let rng = unsafe { &mut *self.rng.get() }; + rng.next_u32() } #[inline(always)] fn next_u64(&mut self) -> u64 { - unsafe { self.rng.as_mut().next_u64() } + // SAFETY: We must make sure to stop using `rng` before anyone else + // creates another mutable reference + let rng = unsafe { &mut *self.rng.get() }; + rng.next_u64() } fn fill_bytes(&mut self, dest: &mut [u8]) { - unsafe { self.rng.as_mut().fill_bytes(dest) } + // SAFETY: We must make sure to stop using `rng` before anyone else + // creates another mutable reference + let rng = unsafe { &mut *self.rng.get() }; + rng.fill_bytes(dest) } fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { - unsafe { self.rng.as_mut().try_fill_bytes(dest) } + // SAFETY: We must make sure to stop using `rng` before anyone else + // creates another mutable reference + let rng = unsafe { &mut *self.rng.get() }; + rng.try_fill_bytes(dest) } } @@ -119,6 +137,6 @@ use crate::Rng; let mut r = crate::thread_rng(); r.gen::(); - assert_eq!(r.gen_range(0, 1), 0); + assert_eq!(r.gen_range(0..1), 0); } } diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/rngs/xoshiro128plusplus.rs cargo-0.58.0/vendor/rand/src/rngs/xoshiro128plusplus.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/rngs/xoshiro128plusplus.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/rngs/xoshiro128plusplus.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,118 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[cfg(feature="serde1")] use serde::{Serialize, Deserialize}; +use rand_core::impls::{next_u64_via_u32, fill_bytes_via_next}; +use rand_core::le::read_u32_into; +use rand_core::{SeedableRng, RngCore, Error}; + +/// A xoshiro128++ random number generator. +/// +/// The xoshiro128++ algorithm is not suitable for cryptographic purposes, but +/// is very fast and has excellent statistical properties. +/// +/// The algorithm used here is translated from [the `xoshiro128plusplus.c` +/// reference source code](http://xoshiro.di.unimi.it/xoshiro128plusplus.c) by +/// David Blackman and Sebastiano Vigna. +#[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +pub struct Xoshiro128PlusPlus { + s: [u32; 4], +} + +impl SeedableRng for Xoshiro128PlusPlus { + type Seed = [u8; 16]; + + /// Create a new `Xoshiro128PlusPlus`. If `seed` is entirely 0, it will be + /// mapped to a different seed. + #[inline] + fn from_seed(seed: [u8; 16]) -> Xoshiro128PlusPlus { + if seed.iter().all(|&x| x == 0) { + return Self::seed_from_u64(0); + } + let mut state = [0; 4]; + read_u32_into(&seed, &mut state); + Xoshiro128PlusPlus { s: state } + } + + /// Create a new `Xoshiro128PlusPlus` from a `u64` seed. + /// + /// This uses the SplitMix64 generator internally. + fn seed_from_u64(mut state: u64) -> Self { + const PHI: u64 = 0x9e3779b97f4a7c15; + let mut seed = Self::Seed::default(); + for chunk in seed.as_mut().chunks_mut(8) { + state = state.wrapping_add(PHI); + let mut z = state; + z = (z ^ (z >> 30)).wrapping_mul(0xbf58476d1ce4e5b9); + z = (z ^ (z >> 27)).wrapping_mul(0x94d049bb133111eb); + z = z ^ (z >> 31); + chunk.copy_from_slice(&z.to_le_bytes()); + } + Self::from_seed(seed) + } +} + +impl RngCore for Xoshiro128PlusPlus { + #[inline] + fn next_u32(&mut self) -> u32 { + let result_starstar = self.s[0] + .wrapping_add(self.s[3]) + .rotate_left(7) + .wrapping_add(self.s[0]); + + let t = self.s[1] << 9; + + self.s[2] ^= self.s[0]; + self.s[3] ^= self.s[1]; + self.s[1] ^= self.s[2]; + self.s[0] ^= self.s[3]; + + self.s[2] ^= t; + + self.s[3] = self.s[3].rotate_left(11); + + result_starstar + } + + #[inline] + fn next_u64(&mut self) -> u64 { + next_u64_via_u32(self) + } + + #[inline] + fn fill_bytes(&mut self, dest: &mut [u8]) { + fill_bytes_via_next(self, dest); + } + + #[inline] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.fill_bytes(dest); + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn reference() { + let mut rng = Xoshiro128PlusPlus::from_seed( + [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0]); + // These values were produced with the reference implementation: + // http://xoshiro.di.unimi.it/xoshiro128plusplus.c + let expected = [ + 641, 1573767, 3222811527, 3517856514, 836907274, 4247214768, + 3867114732, 1355841295, 495546011, 621204420, + ]; + for &e in &expected { + assert_eq!(rng.next_u32(), e); + } + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/rngs/xoshiro256plusplus.rs cargo-0.58.0/vendor/rand/src/rngs/xoshiro256plusplus.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/rngs/xoshiro256plusplus.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/rngs/xoshiro256plusplus.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,122 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[cfg(feature="serde1")] use serde::{Serialize, Deserialize}; +use rand_core::impls::fill_bytes_via_next; +use rand_core::le::read_u64_into; +use rand_core::{SeedableRng, RngCore, Error}; + +/// A xoshiro256++ random number generator. +/// +/// The xoshiro256++ algorithm is not suitable for cryptographic purposes, but +/// is very fast and has excellent statistical properties. +/// +/// The algorithm used here is translated from [the `xoshiro256plusplus.c` +/// reference source code](http://xoshiro.di.unimi.it/xoshiro256plusplus.c) by +/// David Blackman and Sebastiano Vigna. +#[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +pub struct Xoshiro256PlusPlus { + s: [u64; 4], +} + +impl SeedableRng for Xoshiro256PlusPlus { + type Seed = [u8; 32]; + + /// Create a new `Xoshiro256PlusPlus`. If `seed` is entirely 0, it will be + /// mapped to a different seed. + #[inline] + fn from_seed(seed: [u8; 32]) -> Xoshiro256PlusPlus { + if seed.iter().all(|&x| x == 0) { + return Self::seed_from_u64(0); + } + let mut state = [0; 4]; + read_u64_into(&seed, &mut state); + Xoshiro256PlusPlus { s: state } + } + + /// Create a new `Xoshiro256PlusPlus` from a `u64` seed. + /// + /// This uses the SplitMix64 generator internally. + fn seed_from_u64(mut state: u64) -> Self { + const PHI: u64 = 0x9e3779b97f4a7c15; + let mut seed = Self::Seed::default(); + for chunk in seed.as_mut().chunks_mut(8) { + state = state.wrapping_add(PHI); + let mut z = state; + z = (z ^ (z >> 30)).wrapping_mul(0xbf58476d1ce4e5b9); + z = (z ^ (z >> 27)).wrapping_mul(0x94d049bb133111eb); + z = z ^ (z >> 31); + chunk.copy_from_slice(&z.to_le_bytes()); + } + Self::from_seed(seed) + } +} + +impl RngCore for Xoshiro256PlusPlus { + #[inline] + fn next_u32(&mut self) -> u32 { + // The lowest bits have some linear dependencies, so we use the + // upper bits instead. + (self.next_u64() >> 32) as u32 + } + + #[inline] + fn next_u64(&mut self) -> u64 { + let result_plusplus = self.s[0] + .wrapping_add(self.s[3]) + .rotate_left(23) + .wrapping_add(self.s[0]); + + let t = self.s[1] << 17; + + self.s[2] ^= self.s[0]; + self.s[3] ^= self.s[1]; + self.s[1] ^= self.s[2]; + self.s[0] ^= self.s[3]; + + self.s[2] ^= t; + + self.s[3] = self.s[3].rotate_left(45); + + result_plusplus + } + + #[inline] + fn fill_bytes(&mut self, dest: &mut [u8]) { + fill_bytes_via_next(self, dest); + } + + #[inline] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.fill_bytes(dest); + Ok(()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn reference() { + let mut rng = Xoshiro256PlusPlus::from_seed( + [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0]); + // These values were produced with the reference implementation: + // http://xoshiro.di.unimi.it/xoshiro256plusplus.c + let expected = [ + 41943041, 58720359, 3588806011781223, 3591011842654386, + 9228616714210784205, 9973669472204895162, 14011001112246962877, + 12406186145184390807, 15849039046786891736, 10450023813501588000, + ]; + for &e in &expected { + assert_eq!(rng.next_u64(), e); + } + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/seq/index.rs cargo-0.58.0/vendor/rand/src/seq/index.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/seq/index.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/seq/index.rs 2022-01-21 02:47:39.000000000 +0000 @@ -10,22 +10,26 @@ #[cfg(feature = "alloc")] use core::slice; -#[cfg(all(feature = "alloc", not(feature = "std")))] -use crate::alloc::vec::{self, Vec}; -#[cfg(feature = "std")] use std::vec; +#[cfg(feature = "alloc")] use alloc::vec::{self, Vec}; // BTreeMap is not as fast in tests, but better than nothing. #[cfg(all(feature = "alloc", not(feature = "std")))] -use crate::alloc::collections::BTreeSet; +use alloc::collections::BTreeSet; #[cfg(feature = "std")] use std::collections::HashSet; #[cfg(feature = "alloc")] use crate::distributions::{uniform::SampleUniform, Distribution, Uniform}; +#[cfg(feature = "std")] +use crate::distributions::WeightedError; use crate::Rng; +#[cfg(feature = "serde1")] +use serde::{Serialize, Deserialize}; + /// A vector of indices. /// /// Multiple internal representations are possible. #[derive(Clone, Debug)] +#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] pub enum IndexVec { #[doc(hidden)] U32(Vec), @@ -81,10 +85,15 @@ IndexVec::USize(ref v) => IndexVecIter::USize(v.iter()), } } +} + +impl IntoIterator for IndexVec { + type Item = usize; + type IntoIter = IndexVecIntoIter; /// Convert into an iterator over the indices as a sequence of `usize` values #[inline] - pub fn into_iter(self) -> IndexVecIntoIter { + fn into_iter(self) -> IndexVecIntoIter { match self { IndexVec::U32(v) => IndexVecIntoIter::U32(v.into_iter()), IndexVec::USize(v) => IndexVecIntoIter::USize(v.into_iter()), @@ -249,6 +258,154 @@ } } +/// Randomly sample exactly `amount` distinct indices from `0..length`, and +/// return them in an arbitrary order (there is no guarantee of shuffling or +/// ordering). The weights are to be provided by the input function `weights`, +/// which will be called once for each index. +/// +/// This method is used internally by the slice sampling methods, but it can +/// sometimes be useful to have the indices themselves so this is provided as +/// an alternative. +/// +/// This implementation uses `O(length + amount)` space and `O(length)` time +/// if the "nightly" feature is enabled, or `O(length)` space and +/// `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( + rng: &mut R, length: usize, weight: F, amount: usize, +) -> Result +where + R: Rng + ?Sized, + F: Fn(usize) -> X, + X: Into, +{ + if length > (core::u32::MAX as usize) { + sample_efraimidis_spirakis(rng, length, weight, amount) + } else { + assert!(amount <= core::u32::MAX as usize); + let amount = amount as u32; + let length = length as u32; + sample_efraimidis_spirakis(rng, length, weight, amount) + } +} + + +/// Randomly sample exactly `amount` distinct indices from `0..length`, and +/// return them in an arbitrary order (there is no guarantee of shuffling or +/// ordering). The weights are to be provided by the input function `weights`, +/// which will be called once for each index. +/// +/// This implementation uses the algorithm described by Efraimidis and Spirakis +/// in this paper: https://doi.org/10.1016/j.ipl.2005.11.003 +/// It uses `O(length + amount)` space and `O(length)` time if the +/// "nightly" feature is enabled, or `O(length)` space and `O(length +/// + amount * log length)` time otherwise. +/// +/// Panics if `amount > length`. +#[cfg(feature = "std")] +fn sample_efraimidis_spirakis( + rng: &mut R, length: N, weight: F, amount: N, +) -> Result +where + R: Rng + ?Sized, + F: Fn(usize) -> X, + X: Into, + N: UInt, + IndexVec: From>, +{ + if amount == N::zero() { + return Ok(IndexVec::U32(Vec::new())); + } + + if amount > length { + panic!("`amount` of samples must be less than or equal to `length`"); + } + + struct Element { + index: N, + key: f64, + } + impl PartialOrd for Element { + fn partial_cmp(&self, other: &Self) -> Option { + self.key.partial_cmp(&other.key) + } + } + impl Ord for Element { + fn cmp(&self, other: &Self) -> core::cmp::Ordering { + // partial_cmp will always produce a value, + // because we check that the weights are not nan + self.partial_cmp(other).unwrap() + } + } + impl PartialEq for Element { + fn eq(&self, other: &Self) -> bool { + self.key == other.key + } + } + impl Eq for Element {} + + #[cfg(feature = "nightly")] + { + let mut candidates = Vec::with_capacity(length.as_usize()); + let mut index = N::zero(); + while index < length { + let weight = weight(index.as_usize()).into(); + if !(weight >= 0.) { + return Err(WeightedError::InvalidWeight); + } + + let key = rng.gen::().powf(1.0 / weight); + candidates.push(Element { index, key }); + + index += N::one(); + } + + // Partially sort the array to find the `amount` elements with the greatest + // keys. Do this by using `select_nth_unstable` to put the elements with + // the *smallest* keys at the beginning of the list in `O(n)` time, which + // provides equivalent information about the elements with the *greatest* keys. + let (_, mid, greater) + = candidates.select_nth_unstable(length.as_usize() - amount.as_usize()); + + let mut result: Vec = Vec::with_capacity(amount.as_usize()); + result.push(mid.index); + for element in greater { + result.push(element.index); + } + Ok(IndexVec::from(result)) + } + + #[cfg(not(feature = "nightly"))] + { + use std::collections::BinaryHeap; + + // Partially sort the array such that the `amount` elements with the largest + // keys are first using a binary max heap. + let mut candidates = BinaryHeap::with_capacity(length.as_usize()); + let mut index = N::zero(); + while index < length { + let weight = weight(index.as_usize()).into(); + if !(weight >= 0.) { + return Err(WeightedError::InvalidWeight); + } + + let key = rng.gen::().powf(1.0 / weight); + candidates.push(Element { index, key }); + + index += N::one(); + } + + let mut result: Vec = Vec::with_capacity(amount.as_usize()); + while result.len() < amount.as_usize() { + result.push(candidates.pop().unwrap().index); + } + Ok(IndexVec::from(result)) + } +} + /// Randomly sample exactly `amount` indices from `0..length`, using Floyd's /// combination algorithm. /// @@ -265,7 +422,7 @@ debug_assert!(amount <= length); let mut indices = Vec::with_capacity(amount as usize); for j in length - amount..length { - let t = rng.gen_range(0, j + 1); + let t = rng.gen_range(0..=j); if floyd_shuffle { if let Some(pos) = indices.iter().position(|&x| x == t) { indices.insert(pos, j); @@ -281,7 +438,7 @@ // Reimplement SliceRandom::shuffle with smaller indices for i in (1..amount).rev() { // invariant: elements with index > i have been locked in place. - indices.swap(i as usize, rng.gen_range(0, i + 1) as usize); + indices.swap(i as usize, rng.gen_range(0..=i) as usize); } } IndexVec::from(indices) @@ -305,7 +462,7 @@ let mut indices: Vec = Vec::with_capacity(length as usize); indices.extend(0..length); for i in 0..amount { - let j: u32 = rng.gen_range(i, length); + let j: u32 = rng.gen_range(i..length); indices.swap(i as usize, j as usize); } indices.truncate(amount as usize); @@ -313,8 +470,10 @@ IndexVec::from(indices) } -trait UInt: Copy + PartialOrd + Ord + PartialEq + Eq + SampleUniform + core::hash::Hash { +trait UInt: Copy + PartialOrd + Ord + PartialEq + Eq + SampleUniform + + core::hash::Hash + core::ops::AddAssign { fn zero() -> Self; + fn one() -> Self; fn as_usize(self) -> usize; } impl UInt for u32 { @@ -324,6 +483,11 @@ } #[inline] + fn one() -> Self { + 1 + } + + #[inline] fn as_usize(self) -> usize { self as usize } @@ -335,6 +499,11 @@ } #[inline] + fn one() -> Self { + 1 + } + + #[inline] fn as_usize(self) -> usize { self } @@ -376,8 +545,24 @@ #[cfg(test)] mod test { use super::*; - #[cfg(all(feature = "alloc", not(feature = "std")))] use crate::alloc::vec; - #[cfg(feature = "std")] use std::vec; + + #[test] + #[cfg(feature = "serde1")] + fn test_serialization_index_vec() { + let some_index_vec = IndexVec::from(vec![254_usize, 234, 2, 1]); + let de_some_index_vec: IndexVec = bincode::deserialize(&bincode::serialize(&some_index_vec).unwrap()).unwrap(); + match (some_index_vec, de_some_index_vec) { + (IndexVec::U32(a), IndexVec::U32(b)) => { + assert_eq!(a, b); + }, + (IndexVec::USize(a), IndexVec::USize(b)) => { + assert_eq!(a, b); + }, + _ => {panic!("failed to seralize/deserialize `IndexVec`")} + } + } + + #[cfg(feature = "alloc")] use alloc::vec; #[test] fn test_sample_boundaries() { @@ -435,4 +620,59 @@ assert!(v1.iter().all(|e| e < length)); assert_eq!(v1, v2); } + + #[cfg(feature = "std")] + #[test] + fn test_sample_weighted() { + let seed_rng = crate::test::rng; + for &(amount, len) in &[(0, 10), (5, 10), (10, 10)] { + let v = sample_weighted(&mut seed_rng(423), len, |i| i as f64, amount).unwrap(); + match v { + IndexVec::U32(mut indices) => { + assert_eq!(indices.len(), amount); + indices.sort_unstable(); + indices.dedup(); + assert_eq!(indices.len(), amount); + for &i in &indices { + assert!((i as usize) < len); + } + }, + IndexVec::USize(_) => panic!("expected `IndexVec::U32`"), + } + } + } + + #[test] + fn value_stability_sample() { + let do_test = |length, amount, values: &[u32]| { + let mut buf = [0u32; 8]; + let mut rng = crate::test::rng(410); + + let res = sample(&mut rng, length, amount); + let len = res.len().min(buf.len()); + for (x, y) in res.into_iter().zip(buf.iter_mut()) { + *y = x as u32; + } + assert_eq!( + &buf[0..len], + values, + "failed sampling {}, {}", + length, + amount + ); + }; + + do_test(10, 6, &[8, 0, 3, 5, 9, 6]); // floyd + do_test(25, 10, &[18, 15, 14, 9, 0, 13, 5, 24]); // floyd + do_test(300, 8, &[30, 283, 150, 1, 73, 13, 285, 35]); // floyd + do_test(300, 80, &[31, 289, 248, 154, 5, 78, 19, 286]); // inplace + do_test(300, 180, &[31, 289, 248, 154, 5, 78, 19, 286]); // inplace + + do_test(1_000_000, 8, &[ + 103717, 963485, 826422, 509101, 736394, 807035, 5327, 632573, + ]); // floyd + do_test(1_000_000, 180, &[ + 103718, 963490, 826426, 509103, 736396, 807036, 5327, 632573, + ]); // rejection + } } diff -Nru cargo-0.57.0+ubuntu/vendor/rand/src/seq/mod.rs cargo-0.58.0/vendor/rand/src/seq/mod.rs --- cargo-0.57.0+ubuntu/vendor/rand/src/seq/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand/src/seq/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -17,19 +17,21 @@ //! //! Also see: //! -//! * [`crate::distributions::weighted`] module which provides -//! implementations of weighted index sampling. +//! * [`crate::distributions::WeightedIndex`] distribution which provides +//! weighted index sampling. //! //! In order to make results reproducible across 32-64 bit architectures, all //! `usize` indices are sampled as a `u32` where possible (also providing a //! small performance boost in some cases). -#[cfg(feature = "alloc")] pub mod index; +#[cfg(feature = "alloc")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] +pub mod index; #[cfg(feature = "alloc")] use core::ops::Index; -#[cfg(all(feature = "alloc", not(feature = "std")))] use crate::alloc::vec::Vec; +#[cfg(feature = "alloc")] use alloc::vec::Vec; #[cfg(feature = "alloc")] use crate::distributions::uniform::{SampleBorrow, SampleUniform}; @@ -44,13 +46,11 @@ /// ``` /// use rand::seq::SliceRandom; /// -/// fn main() { -/// let mut rng = rand::thread_rng(); -/// let mut bytes = "Hello, random!".to_string().into_bytes(); -/// bytes.shuffle(&mut rng); -/// let str = String::from_utf8(bytes).unwrap(); -/// println!("{}", str); -/// } +/// let mut rng = rand::thread_rng(); +/// let mut bytes = "Hello, random!".to_string().into_bytes(); +/// bytes.shuffle(&mut rng); +/// let str = String::from_utf8(bytes).unwrap(); +/// println!("{}", str); /// ``` /// Example output (non-deterministic): /// ```none @@ -111,6 +111,7 @@ /// } /// ``` #[cfg(feature = "alloc")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] fn choose_multiple(&self, rng: &mut R, amount: usize) -> SliceChooseIter where R: Rng + ?Sized; @@ -138,6 +139,7 @@ /// [`choose_weighted_mut`]: SliceRandom::choose_weighted_mut /// [`distributions::weighted`]: crate::distributions::weighted #[cfg(feature = "alloc")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] fn choose_weighted( &self, rng: &mut R, weight: F, ) -> Result<&Self::Item, WeightedError> @@ -165,6 +167,7 @@ /// [`choose_weighted`]: SliceRandom::choose_weighted /// [`distributions::weighted`]: crate::distributions::weighted #[cfg(feature = "alloc")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] fn choose_weighted_mut( &mut self, rng: &mut R, weight: F, ) -> Result<&mut Self::Item, WeightedError> @@ -178,6 +181,50 @@ + Clone + Default; + /// Similar to [`choose_multiple`], but where the likelihood of each element's + /// inclusion in the output may be specified. The elements are returned in an + /// arbitrary, unspecified order. + /// + /// The specified function `weight` maps each item `x` to a relative + /// likelihood `weight(x)`. The probability of each item being selected is + /// therefore `weight(x) / s`, where `s` is the sum of all `weight(x)`. + /// + /// If all of the weights are equal, even if they are all zero, each element has + /// an equal likelihood of being selected. + /// + /// The complexity of this method depends on the feature `partition_at_index`. + /// If the feature is enabled, then for slices of length `n`, the complexity + /// is `O(n)` space and `O(n)` time. Otherwise, the complexity is `O(n)` space and + /// `O(n * log amount)` time. + /// + /// # Example + /// + /// ``` + /// use rand::prelude::*; + /// + /// let choices = [('a', 2), ('b', 1), ('c', 1)]; + /// let mut rng = thread_rng(); + /// // First Draw * Second Draw = total odds + /// // ----------------------- + /// // (50% * 50%) + (25% * 67%) = 41.7% chance that the output is `['a', 'b']` in some order. + /// // (50% * 50%) + (25% * 67%) = 41.7% chance that the output is `['a', 'c']` in some order. + /// // (25% * 33%) + (25% * 33%) = 16.6% chance that the output is `['b', 'c']` in some order. + /// println!("{:?}", choices.choose_multiple_weighted(&mut rng, 2, |item| item.1).unwrap().collect::>()); + /// ``` + /// [`choose_multiple`]: SliceRandom::choose_multiple + // + // 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( + &self, rng: &mut R, amount: usize, weight: F, + ) -> Result, WeightedError> + where + R: Rng + ?Sized, + F: Fn(&Self::Item) -> X, + X: Into; + /// Shuffle a mutable slice in place. /// /// For slices of length `n`, complexity is `O(n)`. @@ -222,18 +269,17 @@ /// Extension trait on iterators, providing random sampling methods. /// -/// This trait is implemented on all sized iterators, providing methods for +/// This trait is implemented on all iterators `I` where `I: Iterator + Sized` +/// and provides methods for /// choosing one or more elements. You must `use` this trait: /// /// ``` /// use rand::seq::IteratorRandom; /// -/// fn main() { -/// let mut rng = rand::thread_rng(); -/// -/// let faces = "😀😎😐😕😠😢"; -/// println!("I am {}!", faces.chars().choose(&mut rng).unwrap()); -/// } +/// let mut rng = rand::thread_rng(); +/// +/// let faces = "😀😎😐😕😠😢"; +/// println!("I am {}!", faces.chars().choose(&mut rng).unwrap()); /// ``` /// Example output (non-deterministic): /// ```none @@ -250,14 +296,20 @@ /// available, complexity is `O(n)` where `n` is the iterator length. /// Partial hints (where `lower > 0`) also improve performance. /// - /// For slices, prefer [`SliceRandom::choose`] which guarantees `O(1)` - /// performance. + /// Note that the output values and the number of RNG samples used + /// depends on size hints. In particular, `Iterator` combinators that don't + /// change the values yielded but change the size hints may result in + /// `choose` returning different elements. If you want consistent results + /// and RNG usage consider using [`IteratorRandom::choose_stable`]. fn choose(mut self, rng: &mut R) -> Option where R: Rng + ?Sized { let (mut lower, mut upper) = self.size_hint(); let mut consumed = 0; let mut result = None; + // Handling for this condition outside the loop allows the optimizer to eliminate the loop + // when the Iterator is an ExactSizeIterator. This has a large performance impact on e.g. + // seq_iter_choose_from_1000. if upper == Some(lower) { return if lower == 0 { None @@ -289,8 +341,7 @@ return result; } consumed += 1; - let denom = consumed as f64; // accurate to 2^53 elements - if rng.gen_bool(1.0 / denom) { + if gen_index(rng, consumed) == 0 { result = elem; } } @@ -301,6 +352,64 @@ } } + /// Choose one element at random from the iterator. + /// + /// Returns `None` if and only if the iterator is empty. + /// + /// This method is very similar to [`choose`] except that the result + /// only depends on the length of the iterator and the values produced by + /// `rng`. Notably for any iterator of a given length this will make the + /// same requests to `rng` and if the same sequence of values are produced + /// the same index will be selected from `self`. This may be useful if you + /// need consistent results no matter what type of iterator you are working + /// with. If you do not need this stability prefer [`choose`]. + /// + /// Note that this method still uses [`Iterator::size_hint`] to skip + /// constructing elements where possible, however the selection and `rng` + /// calls are the same in the face of this optimization. If you want to + /// force every element to be created regardless call `.inspect(|e| ())`. + /// + /// [`choose`]: IteratorRandom::choose + fn choose_stable(mut self, rng: &mut R) -> Option + where R: Rng + ?Sized { + let mut consumed = 0; + let mut result = None; + + loop { + // Currently the only way to skip elements is `nth()`. So we need to + // store what index to access next here. + // This should be replaced by `advance_by()` once it is stable: + // https://github.com/rust-lang/rust/issues/77404 + let mut next = 0; + + let (lower, _) = self.size_hint(); + if lower >= 2 { + let highest_selected = (0..lower) + .filter(|ix| gen_index(rng, consumed+ix+1) == 0) + .last(); + + consumed += lower; + next = lower; + + if let Some(ix) = highest_selected { + result = self.nth(ix); + next -= ix + 1; + debug_assert!(result.is_some(), "iterator shorter than size_hint().0"); + } + } + + let elem = self.nth(next); + if elem.is_none() { + return result + } + + if gen_index(rng, consumed+1) == 0 { + result = elem; + } + consumed += 1; + } + } + /// Collects values at random from the iterator into a supplied buffer /// until that buffer is filled. /// @@ -353,6 +462,7 @@ /// Complexity is `O(n)` where `n` is the length of the iterator. /// For slices, prefer [`SliceRandom::choose_multiple`]. #[cfg(feature = "alloc")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] fn choose_multiple(mut self, rng: &mut R, amount: usize) -> Vec where R: Rng + ?Sized { let mut reservoir = Vec::with_capacity(amount); @@ -450,6 +560,29 @@ Ok(&mut self[distr.sample(rng)]) } + #[cfg(feature = "std")] + fn choose_multiple_weighted( + &self, rng: &mut R, amount: usize, weight: F, + ) -> Result, WeightedError> + where + R: Rng + ?Sized, + F: Fn(&Self::Item) -> X, + X: Into, + { + let amount = ::core::cmp::min(amount, self.len()); + Ok(SliceChooseIter { + slice: self, + _phantom: Default::default(), + indices: index::sample_weighted( + rng, + self.len(), + |idx| weight(&self[idx]).into(), + amount, + )? + .into_iter(), + }) + } + fn shuffle(&mut self, rng: &mut R) where R: Rng + ?Sized { for i in (1..self.len()).rev() { @@ -487,6 +620,7 @@ /// This struct is created by /// [`SliceRandom::choose_multiple`](trait.SliceRandom.html#tymethod.choose_multiple). #[cfg(feature = "alloc")] +#[cfg_attr(doc_cfg, doc(cfg(feature = "alloc")))] #[derive(Debug)] pub struct SliceChooseIter<'a, S: ?Sized + 'a, T: 'a> { slice: &'a S, @@ -524,9 +658,9 @@ #[inline] fn gen_index(rng: &mut R, ubound: usize) -> usize { if ubound <= (core::u32::MAX as usize) { - rng.gen_range(0, ubound as u32) as usize + rng.gen_range(0..ubound as u32) as usize } else { - rng.gen_range(0, ubound) + rng.gen_range(0..ubound) } } @@ -567,6 +701,40 @@ assert_eq!(v.choose_mut(&mut r), None); } + #[test] + fn value_stability_slice() { + let mut r = crate::test::rng(413); + let chars = [ + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + ]; + let mut nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; + + assert_eq!(chars.choose(&mut r), Some(&'l')); + assert_eq!(nums.choose_mut(&mut r), Some(&mut 10)); + + #[cfg(feature = "alloc")] + assert_eq!( + &chars + .choose_multiple(&mut r, 8) + .cloned() + .collect::>(), + &['d', 'm', 'b', 'n', 'c', 'k', 'h', 'e'] + ); + + #[cfg(feature = "alloc")] + assert_eq!(chars.choose_weighted(&mut r, |_| 1), Ok(&'f')); + #[cfg(feature = "alloc")] + assert_eq!(nums.choose_weighted_mut(&mut r, |_| 1), Ok(&mut 5)); + + let mut r = crate::test::rng(414); + nums.shuffle(&mut r); + assert_eq!(nums, [9, 5, 3, 10, 7, 12, 8, 11, 6, 4, 0, 2, 1]); + nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; + let res = nums.partial_shuffle(&mut r, 6); + assert_eq!(res.0, &mut [7, 4, 8, 6, 9, 3]); + assert_eq!(res.1, &mut [0, 1, 2, 12, 11, 5, 10]); + } + #[derive(Clone)] struct UnhintedIterator { iter: I, @@ -691,6 +859,103 @@ #[test] #[cfg_attr(miri, ignore)] // Miri is too slow + fn test_iterator_choose_stable() { + let r = &mut crate::test::rng(109); + fn test_iter + Clone>(r: &mut R, iter: Iter) { + let mut chosen = [0i32; 9]; + for _ in 0..1000 { + let picked = iter.clone().choose_stable(r).unwrap(); + chosen[picked] += 1; + } + for count in chosen.iter() { + // Samples should follow Binomial(1000, 1/9) + // Octave: binopdf(x, 1000, 1/9) gives the prob of *count == x + // Note: have seen 153, which is unlikely but not impossible. + assert!( + 72 < *count && *count < 154, + "count not close to 1000/9: {}", + count + ); + } + } + + test_iter(r, 0..9); + test_iter(r, [0, 1, 2, 3, 4, 5, 6, 7, 8].iter().cloned()); + #[cfg(feature = "alloc")] + test_iter(r, (0..9).collect::>().into_iter()); + test_iter(r, UnhintedIterator { iter: 0..9 }); + test_iter(r, ChunkHintedIterator { + iter: 0..9, + chunk_size: 4, + chunk_remaining: 4, + hint_total_size: false, + }); + test_iter(r, ChunkHintedIterator { + iter: 0..9, + chunk_size: 4, + chunk_remaining: 4, + hint_total_size: true, + }); + test_iter(r, WindowHintedIterator { + iter: 0..9, + window_size: 2, + hint_total_size: false, + }); + test_iter(r, WindowHintedIterator { + iter: 0..9, + window_size: 2, + hint_total_size: true, + }); + + assert_eq!((0..0).choose(r), None); + assert_eq!(UnhintedIterator { iter: 0..0 }.choose(r), None); + } + + #[test] + #[cfg_attr(miri, ignore)] // Miri is too slow + fn test_iterator_choose_stable_stability() { + fn test_iter(iter: impl Iterator + Clone) -> [i32; 9] { + let r = &mut crate::test::rng(109); + let mut chosen = [0i32; 9]; + for _ in 0..1000 { + let picked = iter.clone().choose_stable(r).unwrap(); + chosen[picked] += 1; + } + chosen + } + + let reference = test_iter(0..9); + assert_eq!(test_iter([0, 1, 2, 3, 4, 5, 6, 7, 8].iter().cloned()), reference); + + #[cfg(feature = "alloc")] + assert_eq!(test_iter((0..9).collect::>().into_iter()), reference); + assert_eq!(test_iter(UnhintedIterator { iter: 0..9 }), reference); + assert_eq!(test_iter(ChunkHintedIterator { + iter: 0..9, + chunk_size: 4, + chunk_remaining: 4, + hint_total_size: false, + }), reference); + assert_eq!(test_iter(ChunkHintedIterator { + iter: 0..9, + chunk_size: 4, + chunk_remaining: 4, + hint_total_size: true, + }), reference); + assert_eq!(test_iter(WindowHintedIterator { + iter: 0..9, + window_size: 2, + hint_total_size: false, + }), reference); + assert_eq!(test_iter(WindowHintedIterator { + iter: 0..9, + window_size: 2, + hint_total_size: true, + }), reference); + } + + #[test] + #[cfg_attr(miri, ignore)] // Miri is too slow fn test_shuffle() { let mut r = crate::test::rng(108); let empty: &mut [isize] = &mut []; @@ -726,8 +991,8 @@ move_last(&mut arr, pos); assert_eq!(arr[3], i); } - for i in 0..4 { - assert_eq!(arr[i], i); + for (i, &a) in arr.iter().enumerate() { + assert_eq!(a, i); } counts[permutation] += 1; } @@ -847,4 +1112,248 @@ Err(WeightedError::InvalidWeight) ); } + + #[test] + fn value_stability_choose() { + fn choose>(iter: I) -> Option { + let mut rng = crate::test::rng(411); + iter.choose(&mut rng) + } + + assert_eq!(choose([].iter().cloned()), None); + assert_eq!(choose(0..100), Some(33)); + assert_eq!(choose(UnhintedIterator { iter: 0..100 }), Some(40)); + assert_eq!( + choose(ChunkHintedIterator { + iter: 0..100, + chunk_size: 32, + chunk_remaining: 32, + hint_total_size: false, + }), + Some(39) + ); + assert_eq!( + choose(ChunkHintedIterator { + iter: 0..100, + chunk_size: 32, + chunk_remaining: 32, + hint_total_size: true, + }), + Some(39) + ); + assert_eq!( + choose(WindowHintedIterator { + iter: 0..100, + window_size: 32, + hint_total_size: false, + }), + Some(90) + ); + assert_eq!( + choose(WindowHintedIterator { + iter: 0..100, + window_size: 32, + hint_total_size: true, + }), + Some(90) + ); + } + + #[test] + fn value_stability_choose_stable() { + fn choose>(iter: I) -> Option { + let mut rng = crate::test::rng(411); + iter.choose_stable(&mut rng) + } + + assert_eq!(choose([].iter().cloned()), None); + assert_eq!(choose(0..100), Some(40)); + assert_eq!(choose(UnhintedIterator { iter: 0..100 }), Some(40)); + assert_eq!( + choose(ChunkHintedIterator { + iter: 0..100, + chunk_size: 32, + chunk_remaining: 32, + hint_total_size: false, + }), + Some(40) + ); + assert_eq!( + choose(ChunkHintedIterator { + iter: 0..100, + chunk_size: 32, + chunk_remaining: 32, + hint_total_size: true, + }), + Some(40) + ); + assert_eq!( + choose(WindowHintedIterator { + iter: 0..100, + window_size: 32, + hint_total_size: false, + }), + Some(40) + ); + assert_eq!( + choose(WindowHintedIterator { + iter: 0..100, + window_size: 32, + hint_total_size: true, + }), + Some(40) + ); + } + + #[test] + fn value_stability_choose_multiple() { + fn do_test>(iter: I, v: &[u32]) { + let mut rng = crate::test::rng(412); + let mut buf = [0u32; 8]; + assert_eq!(iter.choose_multiple_fill(&mut rng, &mut buf), v.len()); + assert_eq!(&buf[0..v.len()], v); + } + + do_test(0..4, &[0, 1, 2, 3]); + do_test(0..8, &[0, 1, 2, 3, 4, 5, 6, 7]); + do_test(0..100, &[58, 78, 80, 92, 43, 8, 96, 7]); + + #[cfg(feature = "alloc")] + { + fn do_test>(iter: I, v: &[u32]) { + let mut rng = crate::test::rng(412); + assert_eq!(iter.choose_multiple(&mut rng, v.len()), v); + } + + do_test(0..4, &[0, 1, 2, 3]); + do_test(0..8, &[0, 1, 2, 3, 4, 5, 6, 7]); + do_test(0..100, &[58, 78, 80, 92, 43, 8, 96, 7]); + } + } + + #[test] + #[cfg(feature = "std")] + fn test_multiple_weighted_edge_cases() { + use super::*; + + let mut rng = crate::test::rng(413); + + // Case 1: One of the weights is 0 + let choices = [('a', 2), ('b', 1), ('c', 0)]; + for _ in 0..100 { + let result = choices + .choose_multiple_weighted(&mut rng, 2, |item| item.1) + .unwrap() + .collect::>(); + + assert_eq!(result.len(), 2); + assert!(!result.iter().any(|val| val.0 == 'c')); + } + + // Case 2: All of the weights are 0 + let choices = [('a', 0), ('b', 0), ('c', 0)]; + let result = choices + .choose_multiple_weighted(&mut rng, 2, |item| item.1) + .unwrap() + .collect::>(); + assert_eq!(result.len(), 2); + + // Case 3: Negative weights + let choices = [('a', -1), ('b', 1), ('c', 1)]; + assert_eq!( + choices + .choose_multiple_weighted(&mut rng, 2, |item| item.1) + .unwrap_err(), + WeightedError::InvalidWeight + ); + + // Case 4: Empty list + let choices = []; + let result = choices + .choose_multiple_weighted(&mut rng, 0, |_: &()| 0) + .unwrap() + .collect::>(); + assert_eq!(result.len(), 0); + + // Case 5: NaN weights + let choices = [('a', core::f64::NAN), ('b', 1.0), ('c', 1.0)]; + assert_eq!( + choices + .choose_multiple_weighted(&mut rng, 2, |item| item.1) + .unwrap_err(), + WeightedError::InvalidWeight + ); + + // Case 6: +infinity weights + let choices = [('a', core::f64::INFINITY), ('b', 1.0), ('c', 1.0)]; + for _ in 0..100 { + let result = choices + .choose_multiple_weighted(&mut rng, 2, |item| item.1) + .unwrap() + .collect::>(); + assert_eq!(result.len(), 2); + assert!(result.iter().any(|val| val.0 == 'a')); + } + + // Case 7: -infinity weights + let choices = [('a', core::f64::NEG_INFINITY), ('b', 1.0), ('c', 1.0)]; + assert_eq!( + choices + .choose_multiple_weighted(&mut rng, 2, |item| item.1) + .unwrap_err(), + WeightedError::InvalidWeight + ); + + // Case 8: -0 weights + let choices = [('a', -0.0), ('b', 1.0), ('c', 1.0)]; + assert!(choices + .choose_multiple_weighted(&mut rng, 2, |item| item.1) + .is_ok()); + } + + #[test] + #[cfg(feature = "std")] + fn test_multiple_weighted_distributions() { + use super::*; + + // The theoretical probabilities of the different outcomes are: + // AB: 0.5 * 0.5 = 0.250 + // AC: 0.5 * 0.5 = 0.250 + // BA: 0.25 * 0.67 = 0.167 + // BC: 0.25 * 0.33 = 0.082 + // CA: 0.25 * 0.67 = 0.167 + // CB: 0.25 * 0.33 = 0.082 + let choices = [('a', 2), ('b', 1), ('c', 1)]; + let mut rng = crate::test::rng(414); + + let mut results = [0i32; 3]; + let expected_results = [4167, 4167, 1666]; + for _ in 0..10000 { + let result = choices + .choose_multiple_weighted(&mut rng, 2, |item| item.1) + .unwrap() + .collect::>(); + + assert_eq!(result.len(), 2); + + match (result[0].0, result[1].0) { + ('a', 'b') | ('b', 'a') => { + results[0] += 1; + } + ('a', 'c') | ('c', 'a') => { + results[1] += 1; + } + ('b', 'c') | ('c', 'b') => { + results[2] += 1; + } + (_, _) => panic!("unexpected result"), + } + } + + let mut diffs = results + .iter() + .zip(&expected_results) + .map(|(a, b)| (a - b).abs()); + assert!(!diffs.any(|deviation| deviation > 100)); + } } diff -Nru cargo-0.57.0+ubuntu/vendor/rand_chacha/.cargo-checksum.json cargo-0.58.0/vendor/rand_chacha/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/rand_chacha/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_chacha/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"} \ No newline at end of file +{"files":{},"package":"e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/rand_chacha/Cargo.toml cargo-0.58.0/vendor/rand_chacha/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/rand_chacha/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_chacha/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -13,30 +13,33 @@ [package] edition = "2018" name = "rand_chacha" -version = "0.2.2" +version = "0.3.1" authors = ["The Rand Project Developers", "The Rust Project Developers", "The CryptoCorrosion Contributors"] description = "ChaCha random number generator\n" -homepage = "https://crates.io/crates/rand_chacha" -documentation = "https://rust-random.github.io/rand/rand_chacha/" +homepage = "https://rust-random.github.io/book" +documentation = "https://docs.rs/rand_chacha" readme = "README.md" keywords = ["random", "rng", "chacha"] categories = ["algorithms", "no-std"] license = "MIT OR Apache-2.0" repository = "https://github.com/rust-random/rand" [dependencies.ppv-lite86] -version = "0.2.6" +version = "0.2.8" features = ["simd"] default-features = false [dependencies.rand_core] -version = "0.5" +version = "0.6.0" + +[dependencies.serde] +version = "1.0" +features = ["derive"] +optional = true +[dev-dependencies.serde_json] +version = "1.0" [features] -default = ["std", "simd"] +default = ["std"] +serde1 = ["serde"] simd = [] std = ["ppv-lite86/std"] -[badges.appveyor] -repository = "rust-random/rand" - -[badges.travis-ci] -repository = "rust-random/rand" diff -Nru cargo-0.57.0+ubuntu/vendor/rand_chacha/CHANGELOG.md cargo-0.58.0/vendor/rand_chacha/CHANGELOG.md --- cargo-0.57.0+ubuntu/vendor/rand_chacha/CHANGELOG.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_chacha/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 @@ -4,6 +4,19 @@ 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.3.1] - 2021-06-09 +- add getters corresponding to existing setters: `get_seed`, `get_stream` (#1124) +- add serde support, gated by the `serde1` feature (#1124) +- ensure expected layout via `repr(transparent)` (#1120) + +## [0.3.0] - 2020-12-08 +- Bump `rand_core` version to 0.6.0 +- Bump MSRV to 1.36 (#1011) +- Remove usage of deprecated feature "simd" of `ppv-lite86` (#979), then revert + this change (#1023) since SIMD is only enabled by default from `ppv-lite86 v0.2.10` +- impl PartialEq+Eq for ChaChaXRng and ChaChaXCore (#979) +- Fix panic on block counter wrap that was occurring in debug builds (#980) + ## [0.2.2] - 2020-03-09 - Integrate `c2-chacha`, reducing dependency count (#931) - Add CryptoRng to ChaChaXCore (#944) diff -Nru cargo-0.57.0+ubuntu/vendor/rand_chacha/README.md cargo-0.58.0/vendor/rand_chacha/README.md --- cargo-0.57.0+ubuntu/vendor/rand_chacha/README.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_chacha/README.md 2022-01-21 02:47:39.000000000 +0000 @@ -1,12 +1,11 @@ # rand_chacha -[![Build Status](https://travis-ci.org/rust-random/rand.svg)](https://travis-ci.org/rust-random/rand) -[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand) +[![Test Status](https://github.com/rust-random/rand/workflows/Tests/badge.svg?event=push)](https://github.com/rust-random/rand/actions) [![Latest version](https://img.shields.io/crates/v/rand_chacha.svg)](https://crates.io/crates/rand_chacha) [![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) [![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_chacha) [![API](https://docs.rs/rand_chacha/badge.svg)](https://docs.rs/rand_chacha) -[![Minimum rustc version](https://img.shields.io/badge/rustc-1.32+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) +[![Minimum rustc version](https://img.shields.io/badge/rustc-1.36+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) A cryptographically secure random number generator that uses the ChaCha algorithm. diff -Nru cargo-0.57.0+ubuntu/vendor/rand_chacha/src/chacha.rs cargo-0.58.0/vendor/rand_chacha/src/chacha.rs --- cargo-0.57.0+ubuntu/vendor/rand_chacha/src/chacha.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_chacha/src/chacha.rs 2022-01-21 02:47:39.000000000 +0000 @@ -16,9 +16,14 @@ use rand_core::block::{BlockRng, BlockRngCore}; use rand_core::{CryptoRng, Error, RngCore, SeedableRng}; -const STREAM_PARAM_NONCE: u32 = 1; -const STREAM_PARAM_BLOCK: u32 = 0; +#[cfg(feature = "serde1")] use serde::{Serialize, Deserialize, Serializer, Deserializer}; +// NB. this must remain consistent with some currently hard-coded numbers in this module +const BUF_BLOCKS: u8 = 4; +// number of 32-bit words per ChaCha block (fixed by algorithm definition) +const BLOCK_WORDS: u8 = 16; + +#[repr(transparent)] pub struct Array64([T; 64]); impl Default for Array64 where T: Default @@ -63,9 +68,9 @@ } macro_rules! chacha_impl { - ($ChaChaXCore:ident, $ChaChaXRng:ident, $rounds:expr, $doc:expr) => { + ($ChaChaXCore:ident, $ChaChaXRng:ident, $rounds:expr, $doc:expr, $abst:ident) => { #[doc=$doc] - #[derive(Clone)] + #[derive(Clone, PartialEq, Eq)] pub struct $ChaChaXCore { state: ChaCha, } @@ -187,10 +192,19 @@ /// byte-offset. #[inline] pub fn get_word_pos(&self) -> u128 { - let mut block = u128::from(self.rng.core.state.get_stream_param(STREAM_PARAM_BLOCK)); - // counter is incremented *after* filling buffer - block -= 4; - (block << 4) + self.rng.index() as u128 + let buf_start_block = { + let buf_end_block = self.rng.core.state.get_block_pos(); + u64::wrapping_sub(buf_end_block, BUF_BLOCKS.into()) + }; + let (buf_offset_blocks, block_offset_words) = { + let buf_offset_words = self.rng.index() as u64; + let blocks_part = buf_offset_words / u64::from(BLOCK_WORDS); + let words_part = buf_offset_words % u64::from(BLOCK_WORDS); + (blocks_part, words_part) + }; + let pos_block = u64::wrapping_add(buf_start_block, buf_offset_blocks); + let pos_block_words = u128::from(pos_block) * u128::from(BLOCK_WORDS); + pos_block_words + u128::from(block_offset_words) } /// Set the offset from the start of the stream, in 32-bit words. @@ -200,12 +214,12 @@ /// 60 bits. #[inline] pub fn set_word_pos(&mut self, word_offset: u128) { - let block = (word_offset >> 4) as u64; + let block = (word_offset / u128::from(BLOCK_WORDS)) as u64; self.rng .core .state - .set_stream_param(STREAM_PARAM_BLOCK, block); - self.rng.generate_and_set((word_offset & 15) as usize); + .set_block_pos(block); + self.rng.generate_and_set((word_offset % u128::from(BLOCK_WORDS)) as usize); } /// Set the stream number. @@ -224,12 +238,30 @@ self.rng .core .state - .set_stream_param(STREAM_PARAM_NONCE, stream); + .set_nonce(stream); if self.rng.index() != 64 { let wp = self.get_word_pos(); self.set_word_pos(wp); } } + + /// Get the stream number. + #[inline] + pub fn get_stream(&self) -> u64 { + self.rng + .core + .state + .get_nonce() + } + + /// Get the seed. + #[inline] + pub fn get_seed(&self) -> [u8; 32] { + self.rng + .core + .state + .get_seed() + } } impl CryptoRng for $ChaChaXRng {} @@ -241,19 +273,132 @@ } } } + + impl PartialEq<$ChaChaXRng> for $ChaChaXRng { + fn eq(&self, rhs: &$ChaChaXRng) -> bool { + let a: $abst::$ChaChaXRng = self.into(); + let b: $abst::$ChaChaXRng = rhs.into(); + a == b + } + } + impl Eq for $ChaChaXRng {} + + #[cfg(feature = "serde1")] + impl Serialize for $ChaChaXRng { + fn serialize(&self, s: S) -> Result + where S: Serializer { + $abst::$ChaChaXRng::from(self).serialize(s) + } + } + #[cfg(feature = "serde1")] + impl<'de> Deserialize<'de> for $ChaChaXRng { + fn deserialize(d: D) -> Result where D: Deserializer<'de> { + $abst::$ChaChaXRng::deserialize(d).map(|x| Self::from(&x)) + } + } + + mod $abst { + #[cfg(feature = "serde1")] use serde::{Serialize, Deserialize}; + + // The abstract state of a ChaCha stream, independent of implementation choices. The + // comparison and serialization of this object is considered a semver-covered part of + // the API. + #[derive(Debug, PartialEq, Eq)] + #[cfg_attr( + feature = "serde1", + derive(Serialize, Deserialize), + )] + pub(crate) struct $ChaChaXRng { + seed: [u8; 32], + stream: u64, + word_pos: u128, + } + + impl From<&super::$ChaChaXRng> for $ChaChaXRng { + // Forget all information about the input except what is necessary to determine the + // outputs of any sequence of pub API calls. + fn from(r: &super::$ChaChaXRng) -> Self { + Self { + seed: r.get_seed(), + stream: r.get_stream(), + word_pos: r.get_word_pos(), + } + } + } + + impl From<&$ChaChaXRng> for super::$ChaChaXRng { + // Construct one of the possible concrete RNGs realizing an abstract state. + fn from(a: &$ChaChaXRng) -> Self { + use rand_core::SeedableRng; + let mut r = Self::from_seed(a.seed); + r.set_stream(a.stream); + r.set_word_pos(a.word_pos); + r + } + } + } } } -chacha_impl!(ChaCha20Core, ChaCha20Rng, 10, "ChaCha with 20 rounds"); -chacha_impl!(ChaCha12Core, ChaCha12Rng, 6, "ChaCha with 12 rounds"); -chacha_impl!(ChaCha8Core, ChaCha8Rng, 4, "ChaCha with 8 rounds"); +chacha_impl!(ChaCha20Core, ChaCha20Rng, 10, "ChaCha with 20 rounds", abstract20); +chacha_impl!(ChaCha12Core, ChaCha12Rng, 6, "ChaCha with 12 rounds", abstract12); +chacha_impl!(ChaCha8Core, ChaCha8Rng, 4, "ChaCha with 8 rounds", abstract8); #[cfg(test)] mod test { use rand_core::{RngCore, SeedableRng}; + #[cfg(feature = "serde1")] use super::{ChaCha20Rng, ChaCha12Rng, ChaCha8Rng}; + type ChaChaRng = super::ChaCha20Rng; + #[cfg(feature = "serde1")] + #[test] + fn test_chacha_serde_roundtrip() { + let seed = [ + 1, 0, 52, 0, 0, 0, 0, 0, 1, 0, 10, 0, 22, 32, 0, 0, 2, 0, 55, 49, 0, 11, 0, 0, 3, 0, 0, 0, 0, + 0, 2, 92, + ]; + let mut rng1 = ChaCha20Rng::from_seed(seed); + let mut rng2 = ChaCha12Rng::from_seed(seed); + let mut rng3 = ChaCha8Rng::from_seed(seed); + + let encoded1 = serde_json::to_string(&rng1).unwrap(); + let encoded2 = serde_json::to_string(&rng2).unwrap(); + let encoded3 = serde_json::to_string(&rng3).unwrap(); + + let mut decoded1: ChaCha20Rng = serde_json::from_str(&encoded1).unwrap(); + let mut decoded2: ChaCha12Rng = serde_json::from_str(&encoded2).unwrap(); + let mut decoded3: ChaCha8Rng = serde_json::from_str(&encoded3).unwrap(); + + assert_eq!(rng1, decoded1); + assert_eq!(rng2, decoded2); + assert_eq!(rng3, decoded3); + + assert_eq!(rng1.next_u32(), decoded1.next_u32()); + assert_eq!(rng2.next_u32(), decoded2.next_u32()); + assert_eq!(rng3.next_u32(), decoded3.next_u32()); + } + + // This test validates that: + // 1. a hard-coded serialization demonstrating the format at time of initial release can still + // be deserialized to a ChaChaRng + // 2. re-serializing the resultant object produces exactly the original string + // + // Condition 2 is stronger than necessary: an equivalent serialization (e.g. with field order + // permuted, or whitespace differences) would also be admissible, but would fail this test. + // However testing for equivalence of serialized data is difficult, and there shouldn't be any + // reason we need to violate the stronger-than-needed condition, e.g. by changing the field + // definition order. + #[cfg(feature = "serde1")] + #[test] + fn test_chacha_serde_format_stability() { + let j = r#"{"seed":[4,8,15,16,23,42,4,8,15,16,23,42,4,8,15,16,23,42,4,8,15,16,23,42,4,8,15,16,23,42,4,8],"stream":27182818284,"word_pos":314159265359}"#; + let r: ChaChaRng = serde_json::from_str(&j).unwrap(); + let j1 = serde_json::to_string(&r).unwrap(); + assert_eq!(j, j1); + } + #[test] fn test_chacha_construction() { let seed = [ @@ -456,4 +601,32 @@ assert_eq!(rng.next_u32(), clone.next_u32()); } } + + #[test] + fn test_chacha_word_pos_wrap_exact() { + use super::{BUF_BLOCKS, BLOCK_WORDS}; + let mut rng = ChaChaRng::from_seed(Default::default()); + // refilling the buffer in set_word_pos will wrap the block counter to 0 + let last_block = (1 << 68) - u128::from(BUF_BLOCKS * BLOCK_WORDS); + rng.set_word_pos(last_block); + assert_eq!(rng.get_word_pos(), last_block); + } + + #[test] + fn test_chacha_word_pos_wrap_excess() { + use super::BLOCK_WORDS; + let mut rng = ChaChaRng::from_seed(Default::default()); + // refilling the buffer in set_word_pos will wrap the block counter past 0 + let last_block = (1 << 68) - u128::from(BLOCK_WORDS); + rng.set_word_pos(last_block); + assert_eq!(rng.get_word_pos(), last_block); + } + + #[test] + fn test_chacha_word_pos_zero() { + let mut rng = ChaChaRng::from_seed(Default::default()); + assert_eq!(rng.get_word_pos(), 0); + rng.set_word_pos(0); + assert_eq!(rng.get_word_pos(), 0); + } } diff -Nru cargo-0.57.0+ubuntu/vendor/rand_chacha/src/guts.rs cargo-0.58.0/vendor/rand_chacha/src/guts.rs --- cargo-0.57.0+ubuntu/vendor/rand_chacha/src/guts.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_chacha/src/guts.rs 2022-01-21 02:47:39.000000000 +0000 @@ -21,7 +21,10 @@ pub(crate) const BUFSZ64: u64 = BLOCK64 * BUFBLOCKS; pub(crate) const BUFSZ: usize = BUFSZ64 as usize; -#[derive(Clone)] +const STREAM_PARAM_NONCE: u32 = 1; +const STREAM_PARAM_BLOCK: u32 = 0; + +#[derive(Clone, PartialEq, Eq)] pub struct ChaCha { pub(crate) b: vec128_storage, pub(crate) c: vec128_storage, @@ -83,16 +86,32 @@ } #[inline(always)] - pub fn set_stream_param(&mut self, param: u32, value: u64) { - set_stream_param(self, param, value) + pub fn set_block_pos(&mut self, value: u64) { + set_stream_param(self, STREAM_PARAM_BLOCK, value) + } + + #[inline(always)] + pub fn get_block_pos(&self) -> u64 { + get_stream_param(self, STREAM_PARAM_BLOCK) + } + + #[inline(always)] + pub fn set_nonce(&mut self, value: u64) { + set_stream_param(self, STREAM_PARAM_NONCE, value) } #[inline(always)] - pub fn get_stream_param(&self, param: u32) -> u64 { - get_stream_param(self, param) + pub fn get_nonce(&self) -> u64 { + get_stream_param(self, STREAM_PARAM_NONCE) + } + + #[inline(always)] + pub fn get_seed(&self) -> [u8; 32] { + get_seed(self) } } +#[allow(clippy::many_single_char_names)] #[inline(always)] fn refill_wide_impl( m: Mach, state: &mut ChaCha, drounds: u32, out: &mut [u8; BUFSZ], @@ -100,11 +119,11 @@ let k = m.vec([0x6170_7865, 0x3320_646e, 0x7962_2d32, 0x6b20_6574]); let mut pos = state.pos64(m); let d0: Mach::u32x4 = m.unpack(state.d); - pos += 1; + pos = pos.wrapping_add(1); let d1 = d0.insert((pos >> 32) as u32, 1).insert(pos as u32, 0); - pos += 1; + pos = pos.wrapping_add(1); let d2 = d0.insert((pos >> 32) as u32, 1).insert(pos as u32, 0); - pos += 1; + pos = pos.wrapping_add(1); let d3 = d0.insert((pos >> 32) as u32, 1).insert(pos as u32, 0); let b = m.unpack(state.b); @@ -121,13 +140,13 @@ } let mut pos = state.pos64(m); let d0: Mach::u32x4 = m.unpack(state.d); - pos += 1; + pos = pos.wrapping_add(1); let d1 = d0.insert((pos >> 32) as u32, 1).insert(pos as u32, 0); - pos += 1; + pos = pos.wrapping_add(1); let d2 = d0.insert((pos >> 32) as u32, 1).insert(pos as u32, 0); - pos += 1; + pos = pos.wrapping_add(1); let d3 = d0.insert((pos >> 32) as u32, 1).insert(pos as u32, 0); - pos += 1; + pos = pos.wrapping_add(1); let d4 = d0.insert((pos >> 32) as u32, 1).insert(pos as u32, 0); let (a, b, c, d) = ( @@ -196,6 +215,17 @@ } }); +dispatch_light128!(m, Mach, { + fn get_seed(state: &ChaCha) -> [u8; 32] { + let b: Mach::u32x4 = m.unpack(state.b); + let c: Mach::u32x4 = m.unpack(state.c); + let mut key = [0u8; 32]; + b.write_le(&mut key[..16]); + c.write_le(&mut key[16..]); + key + } +}); + fn read_u32le(xs: &[u8]) -> u32 { assert_eq!(xs.len(), 4); u32::from(xs[0]) | (u32::from(xs[1]) << 8) | (u32::from(xs[2]) << 16) | (u32::from(xs[3]) << 24) diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core/.cargo-checksum.json cargo-0.58.0/vendor/rand_core/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/rand_core/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"} \ No newline at end of file +{"files":{},"package":"d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core/Cargo.toml cargo-0.58.0/vendor/rand_core/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/rand_core/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -13,18 +13,24 @@ [package] edition = "2018" name = "rand_core" -version = "0.5.1" +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://crates.io/crates/rand_core" -documentation = "https://rust-random.github.io/rand/rand_core/" +homepage = "https://rust-random.github.io/book" +documentation = "https://docs.rs/rand_core" readme = "README.md" keywords = ["random", "rng"] categories = ["algorithms", "no-std"] license = "MIT OR Apache-2.0" repository = "https://github.com/rust-random/rand" +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "doc_cfg"] + +[package.metadata.playground] +all-features = true [dependencies.getrandom] -version = "0.1" +version = "0.2" optional = true [dependencies.serde] @@ -36,8 +42,3 @@ alloc = [] serde1 = ["serde"] std = ["alloc", "getrandom", "getrandom/std"] -[badges.appveyor] -repository = "rust-random/rand" - -[badges.travis-ci] -repository = "rust-random/rand" diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core/CHANGELOG.md cargo-0.58.0/vendor/rand_core/CHANGELOG.md --- cargo-0.57.0+ubuntu/vendor/rand_core/CHANGELOG.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 @@ -4,6 +4,37 @@ 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 + have allowed buffers not to be fully populated (#1096) + +## [0.6.1] - 2021-01-03 +### Fixed +- Avoid panic when using `RngCore::seed_from_u64` with a seed which is not a + multiple of four (#1082) +### Other +- Enable all stable features in the playground (#1081) + +## [0.6.0] - 2020-12-08 +### Breaking changes +- Bump MSRV to 1.36, various code improvements (#1011) +- Update to getrandom v0.2 (#1041) +- Fix: `next_u32_via_fill` and `next_u64_via_fill` now use LE as documented (#1061) + +### Other +- Reduce usage of `unsafe` (#962, #963, #1011) +- Annotate feature-gates in documentation (#1019) +- Document available error codes (#1061) +- Various documentation tweaks +- Fix some clippy warnings (#1036) +- Apply rustfmt (#926) + ## [0.5.1] - 2019-08-28 - `OsRng` added to `rand_core` (#863) - `Error::INTERNAL_START` and `Error::CUSTOM_START` constants (#864) diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core/README.md cargo-0.58.0/vendor/rand_core/README.md --- cargo-0.57.0+ubuntu/vendor/rand_core/README.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core/README.md 2022-01-21 02:47:39.000000000 +0000 @@ -1,12 +1,11 @@ # rand_core -[![Build Status](https://travis-ci.org/rust-random/rand.svg)](https://travis-ci.org/rust-random/rand) -[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand) +[![Test Status](https://github.com/rust-random/rand/workflows/Tests/badge.svg?event=push)](https://github.com/rust-random/rand/actions) [![Latest version](https://img.shields.io/crates/v/rand_core.svg)](https://crates.io/crates/rand_core) [![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) [![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_core) [![API](https://docs.rs/rand_core/badge.svg)](https://docs.rs/rand_core) -[![Minimum rustc version](https://img.shields.io/badge/rustc-1.32+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) +[![Minimum rustc version](https://img.shields.io/badge/rustc-1.36+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) Core traits and error types of the [rand] library, plus tools for implementing RNGs. @@ -44,7 +43,7 @@ The current version is: ``` -rand_core = "0.5.0" +rand_core = "0.6.0" ``` Rand libs have inter-dependencies and make use of the diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core/src/block.rs cargo-0.58.0/vendor/rand_core/src/block.rs --- cargo-0.57.0+ubuntu/vendor/rand_core/src/block.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core/src/block.rs 2022-01-21 02:47:39.000000000 +0000 @@ -21,12 +21,14 @@ //! //! # Example //! -//! ```norun +//! ```no_run +//! use rand_core::{RngCore, SeedableRng}; //! use rand_core::block::{BlockRngCore, BlockRng}; //! //! struct MyRngCore; //! //! impl BlockRngCore for MyRngCore { +//! type Item = u32; //! type Results = [u32; 16]; //! //! fn generate(&mut self, results: &mut Self::Results) { @@ -35,7 +37,7 @@ //! } //! //! impl SeedableRng for MyRngCore { -//! type Seed = unimplemented!(); +//! type Seed = [u8; 32]; //! fn from_seed(seed: Self::Seed) -> Self { //! unimplemented!() //! } @@ -44,17 +46,19 @@ //! // optionally, also implement CryptoRng for MyRngCore //! //! // Final RNG. -//! type MyRng = BlockRng; +//! let mut rng = BlockRng::::seed_from_u64(0); +//! println!("First value: {}", rng.next_u32()); //! ``` //! //! [`BlockRngCore`]: crate::block::BlockRngCore //! [`fill_bytes`]: RngCore::fill_bytes -use core::convert::AsRef; -use core::{fmt, ptr}; -#[cfg(feature="serde1")] use serde::{Serialize, Deserialize}; -use crate::{RngCore, CryptoRng, SeedableRng, Error}; use crate::impls::{fill_via_u32_chunks, fill_via_u64_chunks}; +use crate::{CryptoRng, Error, RngCore, SeedableRng}; +use core::convert::AsRef; +use core::fmt; +#[cfg(feature = "serde1")] +use serde::{Deserialize, Serialize}; /// A trait for RNGs which do not generate random numbers individually, but in /// blocks (typically `[u32; N]`). This technique is commonly used by @@ -73,7 +77,6 @@ fn generate(&mut self, results: &mut Self::Results); } - /// A wrapper type implementing [`RngCore`] for some type implementing /// [`BlockRngCore`] with `u32` array buffer; i.e. this can be used to implement /// a full RNG from just a `generate` function. @@ -110,7 +113,13 @@ /// [`fill_bytes`]: RngCore::fill_bytes /// [`try_fill_bytes`]: RngCore::try_fill_bytes #[derive(Clone)] -#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +#[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 { results: R::Results, index: usize, @@ -122,10 +131,10 @@ impl fmt::Debug for BlockRng { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fmt.debug_struct("BlockRng") - .field("core", &self.core) - .field("result_len", &self.results.as_ref().len()) - .field("index", &self.index) - .finish() + .field("core", &self.core) + .field("result_len", &self.results.as_ref().len()) + .field("index", &self.index) + .finish() } } @@ -133,7 +142,7 @@ /// Create a new `BlockRng` from an existing RNG implementing /// `BlockRngCore`. Results will be generated on first use. #[inline] - pub fn new(core: R) -> BlockRng{ + pub fn new(core: R) -> BlockRng { let results_empty = R::Results::default(); BlockRng { core, @@ -169,8 +178,9 @@ } } -impl> RngCore for BlockRng -where ::Results: AsRef<[u32]> + AsMut<[u32]> +impl> RngCore for BlockRng +where + ::Results: AsRef<[u32]> + AsMut<[u32]>, { #[inline] fn next_u32(&mut self) -> u32 { @@ -186,22 +196,14 @@ #[inline] fn next_u64(&mut self) -> u64 { let read_u64 = |results: &[u32], index| { - if cfg!(any(target_endian = "little")) { - // requires little-endian CPU - #[allow(clippy::cast_ptr_alignment)] // false positive - let ptr: *const u64 = results[index..=index+1].as_ptr() as *const u64; - unsafe { ptr::read_unaligned(ptr) } - } else { - let x = u64::from(results[index]); - let y = u64::from(results[index + 1]); - (y << 32) | x - } + let data = &results[index..=index + 1]; + u64::from(data[1]) << 32 | u64::from(data[0]) }; let len = self.results.as_ref().len(); let index = self.index; - if index < len-1 { + if index < len - 1 { self.index += 2; // Read an u64 from the current index read_u64(self.results.as_ref(), index) @@ -209,7 +211,7 @@ self.generate_and_set(2); read_u64(self.results.as_ref(), 0) } else { - let x = u64::from(self.results.as_ref()[len-1]); + let x = u64::from(self.results.as_ref()[len - 1]); self.generate_and_set(1); let y = u64::from(self.results.as_ref()[0]); (y << 32) | x @@ -224,8 +226,7 @@ self.generate_and_set(0); } let (consumed_u32, filled_u8) = - fill_via_u32_chunks(&self.results.as_ref()[self.index..], - &mut dest[read_len..]); + fill_via_u32_chunks(&self.results.as_ref()[self.index..], &mut dest[read_len..]); self.index += consumed_u32; read_len += filled_u8; @@ -258,8 +259,6 @@ } } - - /// A wrapper type implementing [`RngCore`] for some type implementing /// [`BlockRngCore`] with `u64` array buffer; i.e. this can be used to implement /// a full RNG from just a `generate` function. @@ -283,7 +282,7 @@ /// [`fill_bytes`]: RngCore::fill_bytes /// [`try_fill_bytes`]: RngCore::try_fill_bytes #[derive(Clone)] -#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))] pub struct BlockRng64 { results: R::Results, index: usize, @@ -296,11 +295,11 @@ impl fmt::Debug for BlockRng64 { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fmt.debug_struct("BlockRng64") - .field("core", &self.core) - .field("result_len", &self.results.as_ref().len()) - .field("index", &self.index) - .field("half_used", &self.half_used) - .finish() + .field("core", &self.core) + .field("result_len", &self.results.as_ref().len()) + .field("index", &self.index) + .field("half_used", &self.half_used) + .finish() } } @@ -308,7 +307,7 @@ /// Create a new `BlockRng` from an existing RNG implementing /// `BlockRngCore`. Results will be generated on first use. #[inline] - pub fn new(core: R) -> BlockRng64{ + pub fn new(core: R) -> BlockRng64 { let results_empty = R::Results::default(); BlockRng64 { core, @@ -347,8 +346,9 @@ } } -impl> RngCore for BlockRng64 -where ::Results: AsRef<[u64]> + AsMut<[u64]> +impl> RngCore for BlockRng64 +where + ::Results: AsRef<[u64]> + AsMut<[u64]>, { #[inline] fn next_u32(&mut self) -> u32 { @@ -366,8 +366,7 @@ // Index as if this is a u32 slice. unsafe { - let results = - &*(self.results.as_ref() as *const [u64] as *const [u32]); + let results = &*(self.results.as_ref() as *const [u64] as *const [u32]); if cfg!(target_endian = "little") { *results.get_unchecked(index) } else { @@ -399,9 +398,10 @@ self.index = 0; } - let (consumed_u64, filled_u8) = - fill_via_u64_chunks(&self.results.as_ref()[self.index as usize..], - &mut dest[read_len..]); + let (consumed_u64, filled_u8) = fill_via_u64_chunks( + &self.results.as_ref()[self.index as usize..], + &mut dest[read_len..], + ); self.index += consumed_u64; read_len += filled_u8; diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core/src/error.rs cargo-0.58.0/vendor/rand_core/src/error.rs --- cargo-0.57.0+ubuntu/vendor/rand_core/src/error.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core/src/error.rs 2022-01-21 02:47:39.000000000 +0000 @@ -11,6 +11,7 @@ use core::fmt; use core::num::NonZeroU32; +#[cfg(feature = "std")] use std::boxed::Box; /// Error type of random number generators /// @@ -18,54 +19,64 @@ /// possible implementations: with `std` a boxed `Error` trait object is stored, /// while with `no_std` we merely store an error code. pub struct Error { - #[cfg(feature="std")] + #[cfg(feature = "std")] inner: Box, - #[cfg(not(feature="std"))] + #[cfg(not(feature = "std"))] code: NonZeroU32, } impl Error { + /// Codes at or above this point can be used by users to define their own + /// custom errors. + /// + /// This has a fixed value of `(1 << 31) + (1 << 30) = 0xC000_0000`, + /// therefore the number of values available for custom codes is `1 << 30`. + /// + /// This is identical to [`getrandom::Error::CUSTOM_START`](https://docs.rs/getrandom/latest/getrandom/struct.Error.html#associatedconstant.CUSTOM_START). + pub const CUSTOM_START: u32 = (1 << 31) + (1 << 30); + /// Codes below this point represent OS Errors (i.e. positive i32 values). + /// Codes at or above this point, but below [`Error::CUSTOM_START`] are + /// reserved for use by the `rand` and `getrandom` crates. + /// + /// This is identical to [`getrandom::Error::INTERNAL_START`](https://docs.rs/getrandom/latest/getrandom/struct.Error.html#associatedconstant.INTERNAL_START). + pub const INTERNAL_START: u32 = 1 << 31; + /// Construct from any type supporting `std::error::Error` - /// + /// /// Available only when configured with `std`. - /// + /// /// See also `From`, which is available with and without `std`. - #[cfg(feature="std")] + #[cfg(feature = "std")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] #[inline] pub fn new(err: E) -> Self - where E: Into> + where + E: Into>, { Error { inner: err.into() } } - + /// Reference the inner error (`std` only) - /// + /// /// When configured with `std`, this is a trivial operation and never /// panics. Without `std`, this method is simply unavailable. - #[cfg(feature="std")] + #[cfg(feature = "std")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] #[inline] pub fn inner(&self) -> &(dyn std::error::Error + Send + Sync + 'static) { &*self.inner } - + /// Unwrap the inner error (`std` only) - /// + /// /// When configured with `std`, this is a trivial operation and never /// panics. Without `std`, this method is simply unavailable. - #[cfg(feature="std")] + #[cfg(feature = "std")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] #[inline] pub fn take_inner(self) -> Box { self.inner } - - /// Codes below this point represent OS Errors (i.e. positive i32 values). - /// Codes at or above this point, but below [`Error::CUSTOM_START`] are - /// reserved for use by the `rand` and `getrandom` crates. - pub const INTERNAL_START: u32 = 1 << 31; - - /// Codes at or above this point can be used by users to define their own - /// custom errors. - pub const CUSTOM_START: u32 = (1 << 31) + (1 << 30); /// Extract the raw OS error code (if this error came from the OS) /// @@ -74,29 +85,31 @@ /// error value can still be formatted via the `Diplay` implementation. #[inline] pub fn raw_os_error(&self) -> Option { - #[cfg(feature="std")] { + #[cfg(feature = "std")] + { if let Some(e) = self.inner.downcast_ref::() { return e.raw_os_error(); } } match self.code() { - Some(code) if u32::from(code) < Self::INTERNAL_START => - Some(u32::from(code) as i32), + Some(code) if u32::from(code) < Self::INTERNAL_START => Some(u32::from(code) as i32), _ => None, } } /// Retrieve the error code, if any. - /// + /// /// If this `Error` was constructed via `From`, then this method /// will return this `NonZeroU32` code (for `no_std` this is always the /// case). Otherwise, this method will return `None`. #[inline] pub fn code(&self) -> Option { - #[cfg(feature="std")] { + #[cfg(feature = "std")] + { self.inner.downcast_ref::().map(|c| c.0) } - #[cfg(not(feature="std"))] { + #[cfg(not(feature = "std"))] + { Some(self.code) } } @@ -104,13 +117,16 @@ impl fmt::Debug for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - #[cfg(feature="std")] { + #[cfg(feature = "std")] + { write!(f, "Error {{ inner: {:?} }}", self.inner) } - #[cfg(all(feature="getrandom", not(feature="std")))] { + #[cfg(all(feature = "getrandom", not(feature = "std")))] + { getrandom::Error::from(self.code).fmt(f) } - #[cfg(not(feature="getrandom"))] { + #[cfg(not(feature = "getrandom"))] + { write!(f, "Error {{ code: {} }}", self.code) } } @@ -118,13 +134,16 @@ impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - #[cfg(feature="std")] { + #[cfg(feature = "std")] + { write!(f, "{}", self.inner) } - #[cfg(all(feature="getrandom", not(feature="std")))] { + #[cfg(all(feature = "getrandom", not(feature = "std")))] + { getrandom::Error::from(self.code).fmt(f) } - #[cfg(not(feature="getrandom"))] { + #[cfg(not(feature = "getrandom"))] + { write!(f, "error code {}", self.code) } } @@ -133,29 +152,37 @@ impl From for Error { #[inline] fn from(code: NonZeroU32) -> Self { - #[cfg(feature="std")] { - Error { inner: Box::new(ErrorCode(code)) } + #[cfg(feature = "std")] + { + Error { + inner: Box::new(ErrorCode(code)), + } } - #[cfg(not(feature="std"))] { + #[cfg(not(feature = "std"))] + { Error { code } } } } -#[cfg(feature="getrandom")] +#[cfg(feature = "getrandom")] impl From for Error { #[inline] fn from(error: getrandom::Error) -> Self { - #[cfg(feature="std")] { - Error { inner: Box::new(error) } + #[cfg(feature = "std")] + { + Error { + inner: Box::new(error), + } } - #[cfg(not(feature="std"))] { + #[cfg(not(feature = "std"))] + { Error { code: error.code() } } } } -#[cfg(feature="std")] +#[cfg(feature = "std")] impl std::error::Error for Error { #[inline] fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { @@ -163,7 +190,7 @@ } } -#[cfg(feature="std")] +#[cfg(feature = "std")] impl From for std::io::Error { #[inline] fn from(error: Error) -> Self { @@ -175,16 +202,27 @@ } } -#[cfg(feature="std")] +#[cfg(feature = "std")] #[derive(Debug, Copy, Clone)] struct ErrorCode(NonZeroU32); -#[cfg(feature="std")] +#[cfg(feature = "std")] impl fmt::Display for ErrorCode { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "error code {}", self.0) } } -#[cfg(feature="std")] +#[cfg(feature = "std")] impl std::error::Error for ErrorCode {} + +#[cfg(test)] +mod test { + #[cfg(feature = "getrandom")] + #[test] + fn test_error_codes() { + // Make sure the values are the same as in `getrandom`. + assert_eq!(super::Error::CUSTOM_START, getrandom::Error::CUSTOM_START); + assert_eq!(super::Error::INTERNAL_START, getrandom::Error::INTERNAL_START); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core/src/impls.rs cargo-0.58.0/vendor/rand_core/src/impls.rs --- cargo-0.57.0+ubuntu/vendor/rand_core/src/impls.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core/src/impls.rs 2022-01-21 02:47:39.000000000 +0000 @@ -17,12 +17,8 @@ //! to/from byte sequences, and since its purpose is reproducibility, //! non-reproducible sources (e.g. `OsRng`) need not bother with it. -use core::ptr::copy_nonoverlapping; -use core::slice; -use core::cmp::min; -use core::mem::size_of; use crate::RngCore; - +use core::cmp::min; /// Implement `next_u64` via `next_u32`, little-endian order. pub fn next_u64_via_u32(rng: &mut R) -> u64 { @@ -41,7 +37,7 @@ pub fn fill_bytes_via_next(rng: &mut R, dest: &mut [u8]) { let mut left = dest; while left.len() >= 8 { - let (l, r) = {left}.split_at_mut(8); + let (l, r) = { left }.split_at_mut(8); left = r; let chunk: [u8; 8] = rng.next_u64().to_le_bytes(); l.copy_from_slice(&chunk); @@ -56,45 +52,36 @@ } } -macro_rules! impl_uint_from_fill { - ($rng:expr, $ty:ty, $N:expr) => ({ - debug_assert!($N == size_of::<$ty>()); - - let mut int: $ty = 0; - unsafe { - let ptr = &mut int as *mut $ty as *mut u8; - let slice = slice::from_raw_parts_mut(ptr, $N); - $rng.fill_bytes(slice); - } - int - }); -} - macro_rules! fill_via_chunks { - ($src:expr, $dst:expr, $ty:ty, $size:expr) => ({ - let chunk_size_u8 = min($src.len() * $size, $dst.len()); - let chunk_size = (chunk_size_u8 + $size - 1) / $size; - if cfg!(target_endian="little") { + ($src:expr, $dst:expr, $ty:ty) => {{ + const SIZE: usize = core::mem::size_of::<$ty>(); + let chunk_size_u8 = min($src.len() * SIZE, $dst.len()); + let chunk_size = (chunk_size_u8 + SIZE - 1) / SIZE; + + // The following can be replaced with safe code, but unfortunately it's + // ca. 8% slower. + if cfg!(target_endian = "little") { unsafe { - copy_nonoverlapping( + core::ptr::copy_nonoverlapping( $src.as_ptr() as *const u8, $dst.as_mut_ptr(), chunk_size_u8); } } else { - for (&n, chunk) in $src.iter().zip($dst.chunks_mut($size)) { + for (&n, chunk) in $src.iter().zip($dst.chunks_mut(SIZE)) { let tmp = n.to_le(); let src_ptr = &tmp as *const $ty as *const u8; unsafe { - copy_nonoverlapping(src_ptr, - chunk.as_mut_ptr(), - chunk.len()); + core::ptr::copy_nonoverlapping( + src_ptr, + chunk.as_mut_ptr(), + chunk.len()); } } } (chunk_size, chunk_size_u8) - }); + }}; } /// Implement `fill_bytes` by reading chunks from the output buffer of a block @@ -128,7 +115,7 @@ /// } /// ``` pub fn fill_via_u32_chunks(src: &[u32], dest: &mut [u8]) -> (usize, usize) { - fill_via_chunks!(src, dest, u32, 4) + fill_via_chunks!(src, dest, u32) } /// Implement `fill_bytes` by reading chunks from the output buffer of a block @@ -142,17 +129,56 @@ /// /// See `fill_via_u32_chunks` for an example. pub fn fill_via_u64_chunks(src: &[u64], dest: &mut [u8]) -> (usize, usize) { - fill_via_chunks!(src, dest, u64, 8) + fill_via_chunks!(src, dest, u64) } /// Implement `next_u32` via `fill_bytes`, little-endian order. pub fn next_u32_via_fill(rng: &mut R) -> u32 { - impl_uint_from_fill!(rng, u32, 4) + let mut buf = [0; 4]; + rng.fill_bytes(&mut buf); + u32::from_le_bytes(buf) } /// Implement `next_u64` via `fill_bytes`, little-endian order. pub fn next_u64_via_fill(rng: &mut R) -> u64 { - impl_uint_from_fill!(rng, u64, 8) -} + let mut buf = [0; 8]; + rng.fill_bytes(&mut buf); + u64::from_le_bytes(buf) +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_fill_via_u32_chunks() { + let src = [1, 2, 3]; + let mut dst = [0u8; 11]; + assert_eq!(fill_via_u32_chunks(&src, &mut dst), (3, 11)); + assert_eq!(dst, [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0]); + + let mut dst = [0u8; 13]; + assert_eq!(fill_via_u32_chunks(&src, &mut dst), (3, 12)); + assert_eq!(dst, [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0]); + + let mut dst = [0u8; 5]; + assert_eq!(fill_via_u32_chunks(&src, &mut dst), (2, 5)); + assert_eq!(dst, [1, 0, 0, 0, 2]); + } -// TODO: implement tests for the above + #[test] + fn test_fill_via_u64_chunks() { + let src = [1, 2]; + let mut dst = [0u8; 11]; + assert_eq!(fill_via_u64_chunks(&src, &mut dst), (2, 11)); + assert_eq!(dst, [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0]); + + let mut dst = [0u8; 17]; + assert_eq!(fill_via_u64_chunks(&src, &mut dst), (2, 16)); + assert_eq!(dst, [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0]); + + let mut dst = [0u8; 5]; + assert_eq!(fill_via_u64_chunks(&src, &mut dst), (1, 5)); + assert_eq!(dst, [1, 0, 0, 0, 0]); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core/src/le.rs cargo-0.58.0/vendor/rand_core/src/le.rs --- cargo-0.57.0+ubuntu/vendor/rand_core/src/le.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core/src/le.rs 2022-01-21 02:47:39.000000000 +0000 @@ -7,61 +7,49 @@ // except according to those terms. //! Little-Endian utilities -//! +//! //! Little-Endian order has been chosen for internal usage; this makes some //! useful functions available. -use core::ptr; - -macro_rules! read_slice { - ($src:expr, $dst:expr, $size:expr, $which:ident) => {{ - assert_eq!($src.len(), $size * $dst.len()); - - unsafe { - ptr::copy_nonoverlapping( - $src.as_ptr(), - $dst.as_mut_ptr() as *mut u8, - $src.len()); - } - for v in $dst.iter_mut() { - *v = v.$which(); - } - }}; -} +use core::convert::TryInto; /// Reads unsigned 32 bit integers from `src` into `dst`. -/// Borrowed from the `byteorder` crate. #[inline] pub fn read_u32_into(src: &[u8], dst: &mut [u32]) { - read_slice!(src, dst, 4, to_le); + assert!(src.len() >= 4 * dst.len()); + for (out, chunk) in dst.iter_mut().zip(src.chunks_exact(4)) { + *out = u32::from_le_bytes(chunk.try_into().unwrap()); + } } /// Reads unsigned 64 bit integers from `src` into `dst`. -/// Borrowed from the `byteorder` crate. #[inline] pub fn read_u64_into(src: &[u8], dst: &mut [u64]) { - read_slice!(src, dst, 8, to_le); + assert!(src.len() >= 8 * dst.len()); + for (out, chunk) in dst.iter_mut().zip(src.chunks_exact(8)) { + *out = u64::from_le_bytes(chunk.try_into().unwrap()); + } } #[test] fn test_read() { let bytes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; - + let mut buf = [0u32; 4]; read_u32_into(&bytes, &mut buf); assert_eq!(buf[0], 0x04030201); assert_eq!(buf[3], 0x100F0E0D); - + let mut buf = [0u32; 3]; - read_u32_into(&bytes[1..13], &mut buf); // unaligned + read_u32_into(&bytes[1..13], &mut buf); // unaligned assert_eq!(buf[0], 0x05040302); assert_eq!(buf[2], 0x0D0C0B0A); - + let mut buf = [0u64; 2]; read_u64_into(&bytes, &mut buf); assert_eq!(buf[0], 0x0807060504030201); assert_eq!(buf[1], 0x100F0E0D0C0B0A09); - + let mut buf = [0u64; 1]; read_u64_into(&bytes[7..15], &mut buf); // unaligned assert_eq!(buf[0], 0x0F0E0D0C0B0A0908); diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core/src/lib.rs cargo-0.58.0/vendor/rand_core/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/rand_core/src/lib.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -27,35 +27,33 @@ //! //! [`rand`]: https://docs.rs/rand -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", - html_favicon_url = "https://www.rust-lang.org/favicon.ico", - html_root_url = "https://rust-random.github.io/rand/")] - +#![doc( + html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", + html_favicon_url = "https://www.rust-lang.org/favicon.ico", + html_root_url = "https://rust-random.github.io/rand/" +)] #![deny(missing_docs)] #![deny(missing_debug_implementations)] #![doc(test(attr(allow(unused_variables), deny(warnings))))] +#![cfg_attr(doc_cfg, feature(doc_cfg))] +#![no_std] -#![allow(clippy::unreadable_literal)] - -#![cfg_attr(not(feature="std"), no_std)] - - -use core::default::Default; use core::convert::AsMut; -use core::ptr::copy_nonoverlapping; +use core::default::Default; -#[cfg(all(feature="alloc", not(feature="std")))] extern crate alloc; -#[cfg(all(feature="alloc", not(feature="std")))] use alloc::boxed::Box; +#[cfg(feature = "std")] extern crate std; +#[cfg(feature = "alloc")] extern crate alloc; +#[cfg(feature = "alloc")] use alloc::boxed::Box; pub use error::Error; -#[cfg(feature="getrandom")] pub use os::OsRng; +#[cfg(feature = "getrandom")] pub use os::OsRng; -mod error; pub mod block; +mod error; pub mod impls; pub mod le; -#[cfg(feature="getrandom")] mod os; +#[cfg(feature = "getrandom")] mod os; /// The core of a random number generator. @@ -69,19 +67,26 @@ /// optimal implementation of each is dependent on the type of generator. There /// is no required relationship between the output of each; e.g. many /// implementations of [`fill_bytes`] consume a whole number of `u32` or `u64` -/// values and drop any remaining unused bytes. +/// values and drop any remaining unused bytes. The same can happen with the +/// [`next_u32`] and [`next_u64`] methods, implementations may discard some +/// random bits for efficiency. /// /// The [`try_fill_bytes`] method is a variant of [`fill_bytes`] allowing error /// handling; it is not deemed sufficiently useful to add equivalents for /// [`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. /// @@ -139,24 +144,22 @@ /// /// RNGs must implement at least one method from this trait directly. In /// the case this method is not implemented directly, it can be implemented - /// using `self.next_u64() as u32` or via - /// [`fill_bytes`](impls::next_u32_via_fill). + /// using `self.next_u64() as u32` or via [`impls::next_u32_via_fill`]. fn next_u32(&mut self) -> u32; /// Return the next random `u64`. /// /// RNGs must implement at least one method from this trait directly. In /// the case this method is not implemented directly, it can be implemented - /// via [`next_u32`](impls::next_u64_via_u32) or via - /// [`fill_bytes`](impls::next_u64_via_fill). + /// via [`impls::next_u64_via_u32`] or via [`impls::next_u64_via_fill`]. fn next_u64(&mut self) -> u64; /// Fill `dest` with random data. /// /// RNGs must implement at least one method from this trait directly. In /// the case this method is not implemented directly, it can be implemented - /// via [`next_u*`](impls::fill_bytes_via_next) or - /// via [`try_fill_bytes`](RngCore::try_fill_bytes); if this generator can + /// via [`impls::fill_bytes_via_next`] or + /// via [`RngCore::try_fill_bytes`]; if this generator can /// fail the implementation must choose how best to handle errors here /// (e.g. panic with a descriptive message or log a warning and retry a few /// times). @@ -174,12 +177,10 @@ /// by external (true) RNGs (e.g. `OsRng`) which can fail. It may be used /// directly to generate keys and to seed (infallible) PRNGs. /// - /// Other than error handling, this method is identical to [`fill_bytes`]; + /// Other than error handling, this method is identical to [`RngCore::fill_bytes`]; /// thus this may be implemented using `Ok(self.fill_bytes(dest))` or /// `fill_bytes` may be implemented with /// `self.try_fill_bytes(dest).unwrap()` or more specific error handling. - /// - /// [`fill_bytes`]: RngCore::fill_bytes fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>; } @@ -304,24 +305,30 @@ /// considered a value-breaking change. fn seed_from_u64(mut state: u64) -> Self { // We use PCG32 to generate a u32 sequence, and copy to the seed - const MUL: u64 = 6364136223846793005; - const INC: u64 = 11634580027462260723; + fn pcg32(state: &mut u64) -> [u8; 4] { + const MUL: u64 = 6364136223846793005; + const INC: u64 = 11634580027462260723; - let mut seed = Self::Seed::default(); - for chunk in seed.as_mut().chunks_mut(4) { // We advance the state first (to get away from the input value, // in case it has low Hamming Weight). - state = state.wrapping_mul(MUL).wrapping_add(INC); + *state = state.wrapping_mul(MUL).wrapping_add(INC); + let state = *state; // Use PCG output function with to_le to generate x: let xorshifted = (((state >> 18) ^ state) >> 27) as u32; let rot = (state >> 59) as u32; - let x = xorshifted.rotate_right(rot).to_le(); + let x = xorshifted.rotate_right(rot); + x.to_le_bytes() + } - unsafe { - let p = &x as *const u32 as *const u8; - copy_nonoverlapping(p, chunk.as_mut_ptr(), chunk.len()); - } + let mut seed = Self::Seed::default(); + let mut iter = seed.as_mut().chunks_exact_mut(4); + for chunk in &mut iter { + chunk.copy_from_slice(&pcg32(&mut state)); + } + let rem = iter.into_remainder(); + if !rem.is_empty() { + rem.copy_from_slice(&pcg32(&mut state)[..rem.len()]); } Self::from_seed(seed) @@ -351,7 +358,6 @@ /// (in prior versions this was not required). /// /// [`rand`]: https://docs.rs/rand - /// [`rand_os`]: https://docs.rs/rand_os fn from_rng(mut rng: R) -> Result { let mut seed = Self::Seed::default(); rng.try_fill_bytes(seed.as_mut())?; @@ -372,7 +378,8 @@ /// If [`getrandom`] is unable to provide secure entropy this method will panic. /// /// [`getrandom`]: https://docs.rs/getrandom - #[cfg(feature="getrandom")] + #[cfg(feature = "getrandom")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "getrandom")))] fn from_entropy() -> Self { let mut seed = Self::Seed::default(); if let Err(err) = getrandom::getrandom(seed.as_mut()) { @@ -410,7 +417,7 @@ // Implement `RngCore` for boxed references to an `RngCore`. // Force inlining all functions, so that it is up to the `RngCore` // implementation and the optimizer to decide on inlining. -#[cfg(feature="alloc")] +#[cfg(feature = "alloc")] impl RngCore for Box { #[inline(always)] fn next_u32(&mut self) -> u32 { @@ -433,7 +440,7 @@ } } -#[cfg(feature="std")] +#[cfg(feature = "std")] impl std::io::Read for dyn RngCore { fn read(&mut self, buf: &mut [u8]) -> Result { self.try_fill_bytes(buf)?; @@ -445,7 +452,7 @@ impl<'a, R: CryptoRng + ?Sized> CryptoRng for &'a mut R {} // Implement `CryptoRng` for boxed references to an `CryptoRng`. -#[cfg(feature="alloc")] +#[cfg(feature = "alloc")] impl CryptoRng for Box {} #[cfg(test)] @@ -457,6 +464,7 @@ struct SeedableNum(u64); impl SeedableRng for SeedableNum { type Seed = [u8; 8]; + fn from_seed(seed: Self::Seed) -> Self { let mut x = [0u64; 1]; le::read_u64_into(&seed, &mut x); @@ -477,10 +485,12 @@ // 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 { continue; } + if i1 == i2 { + continue; + } let diff_weight = (r1 ^ r2).count_ones(); assert!(diff_weight >= 20); } diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core/src/os.rs cargo-0.58.0/vendor/rand_core/src/os.rs --- cargo-0.57.0+ubuntu/vendor/rand_core/src/os.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core/src/os.rs 2022-01-21 02:47:39.000000000 +0000 @@ -7,12 +7,11 @@ // except according to those terms. //! Interface to the random number generator of the operating system. -// Note: keep this code in sync with the rand_os crate! +use crate::{impls, CryptoRng, Error, RngCore}; use getrandom::getrandom; -use crate::{CryptoRng, RngCore, Error, impls}; -/// A random number generator that retrieves randomness from from the +/// A random number generator that retrieves randomness from the /// operating system. /// /// This is a zero-sized struct. It can be freely constructed with `OsRng`. @@ -44,6 +43,7 @@ /// ``` /// /// [getrandom]: https://crates.io/crates/getrandom +#[cfg_attr(doc_cfg, doc(cfg(feature = "getrandom")))] #[derive(Clone, Copy, Debug, Default)] pub struct OsRng; diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/.cargo-checksum.json cargo-0.58.0/vendor/rand_core-0.5.1/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/.cargo-checksum.json 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core-0.5.1/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1 @@ +{"files":{},"package":"90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/Cargo.toml cargo-0.58.0/vendor/rand_core-0.5.1/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core-0.5.1/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,43 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# 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 +# +# 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) + +[package] +edition = "2018" +name = "rand_core" +version = "0.5.1" +authors = ["The Rand Project Developers", "The Rust Project Developers"] +description = "Core random number generator traits and tools for implementation.\n" +homepage = "https://crates.io/crates/rand_core" +documentation = "https://rust-random.github.io/rand/rand_core/" +readme = "README.md" +keywords = ["random", "rng"] +categories = ["algorithms", "no-std"] +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-random/rand" +[dependencies.getrandom] +version = "0.1" +optional = true + +[dependencies.serde] +version = "1" +features = ["derive"] +optional = true + +[features] +alloc = [] +serde1 = ["serde"] +std = ["alloc", "getrandom", "getrandom/std"] +[badges.appveyor] +repository = "rust-random/rand" + +[badges.travis-ci] +repository = "rust-random/rand" diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/CHANGELOG.md cargo-0.58.0/vendor/rand_core-0.5.1/CHANGELOG.md --- cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/CHANGELOG.md 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core-0.5.1/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,58 @@ +# Changelog +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.5.1] - 2019-08-28 +- `OsRng` added to `rand_core` (#863) +- `Error::INTERNAL_START` and `Error::CUSTOM_START` constants (#864) +- `Error::raw_os_error` method (#864) +- `Debug` and `Display` formatting for `getrandom` error codes without `std` (#864) +### Changed +- `alloc` feature in `no_std` is available since Rust 1.36 (#856) +- Added `#[inline]` to `Error` conversion methods (#864) + +## [0.5.0] - 2019-06-06 +### Changed +- Enable testing with Miri and fix incorrect pointer usages (#779, #780, #781, #783, #784) +- Rewrite `Error` type and adjust API (#800) +- Adjust usage of `#[inline]` for `BlockRng` and `BlockRng64` + +## [0.4.0] - 2019-01-24 +### Changed +- Disable the `std` feature by default (#702) + +## [0.3.0] - 2018-09-24 +### Added +- Add `SeedableRng::seed_from_u64` for convenient seeding. (#537) + +## [0.2.1] - 2018-06-08 +### Added +- References to a `CryptoRng` now also implement `CryptoRng`. (#470) + +## [0.2.0] - 2018-05-21 +### Changed +- Enable the `std` feature by default. (#409) +- Remove `BlockRng{64}::inner` and `BlockRng::inner_mut`; instead making `core` public +- Change `BlockRngCore::Results` bound to also require `AsMut<[Self::Item]>`. (#419) +### Added +- Add `BlockRng{64}::index` and `BlockRng{64}::generate_and_set`. (#374, #419) +- Implement `std::io::Read` for RngCore. (#434) + +## [0.1.0] - 2018-04-17 +(Split out of the Rand crate, changes here are relative to rand 0.4.2.) +### Added +- `RngCore` and `SeedableRng` are now part of `rand_core`. (#288) +- Add modules to help implementing RNGs `impl` and `le`. (#209, #228) +- Add `Error` and `ErrorKind`. (#225) +- Add `CryptoRng` marker trait. (#273) +- Add `BlockRngCore` trait. (#281) +- Add `BlockRng` and `BlockRng64` wrappers to help implementations. (#281, #325) +- Add `RngCore::try_fill_bytes`. (#225) +### Changed +- Revise the `SeedableRng` trait. (#233) +- Remove default implementations for `RngCore::next_u64` and `RngCore::fill_bytes`. (#288) + +## [0.0.1] - 2017-09-14 (yanked) +Experimental version as part of the rand crate refactor. diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/COPYRIGHT cargo-0.58.0/vendor/rand_core-0.5.1/COPYRIGHT --- cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/COPYRIGHT 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core-0.5.1/COPYRIGHT 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,12 @@ +Copyrights in the Rand project are retained by their contributors. No +copyright assignment is required to contribute to the Rand project. + +For full authorship information, see the version control history. + +Except as otherwise noted (below and/or in individual files), Rand is +licensed under the Apache License, Version 2.0 or + or the MIT license + or , at your option. + +The Rand project includes code from the Rust project +published under these same licenses. diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/LICENSE-APACHE cargo-0.58.0/vendor/rand_core-0.5.1/LICENSE-APACHE --- cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/LICENSE-APACHE 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core-0.5.1/LICENSE-APACHE 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + https://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/LICENSE-MIT cargo-0.58.0/vendor/rand_core-0.5.1/LICENSE-MIT --- cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/LICENSE-MIT 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core-0.5.1/LICENSE-MIT 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,26 @@ +Copyright 2018 Developers of the Rand project +Copyright (c) 2014 The Rust Project Developers + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/README.md cargo-0.58.0/vendor/rand_core-0.5.1/README.md --- cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/README.md 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core-0.5.1/README.md 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,82 @@ +# rand_core + +[![Build Status](https://travis-ci.org/rust-random/rand.svg)](https://travis-ci.org/rust-random/rand) +[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand) +[![Latest version](https://img.shields.io/crates/v/rand_core.svg)](https://crates.io/crates/rand_core) +[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) +[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_core) +[![API](https://docs.rs/rand_core/badge.svg)](https://docs.rs/rand_core) +[![Minimum rustc version](https://img.shields.io/badge/rustc-1.32+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) + +Core traits and error types of the [rand] library, plus tools for implementing +RNGs. + +This crate is intended for use when implementing the core trait, `RngCore`; it +defines the core traits to be implemented as well as several small functions to +aid in their implementation and types required for error handling. + +The main [rand] crate re-exports most items defined in this crate, along with +tools to convert the integer samples generated by `RngCore` to many different +applications (including sampling from restricted ranges, conversion to floating +point, list permutations and secure initialisation of RNGs). Most users should +prefer to use the main [rand] crate. + +Links: + +- [API documentation (master)](https://rust-random.github.io/rand/rand_core) +- [API documentation (docs.rs)](https://docs.rs/rand_core) +- [Changelog](https://github.com/rust-random/rand/blob/master/rand_core/CHANGELOG.md) + +[rand]: https://crates.io/crates/rand + + +## Functionality + +The `rand_core` crate provides: + +- base random number generator traits +- error-reporting types +- functionality to aid implementation of RNGs + +The traits and error types are also available via `rand`. + +## Versions + +The current version is: +``` +rand_core = "0.5.0" +``` + +Rand libs have inter-dependencies and make use of the +[semver trick](https://github.com/dtolnay/semver-trick/) in order to make traits +compatible across crate versions. (This is especially important for `RngCore` +and `SeedableRng`.) A few crate releases are thus compatibility shims, +depending on the *next* lib version (e.g. `rand_core` versions `0.2.2` and +`0.3.1`). This means, for example, that `rand_core_0_4_0::SeedableRng` and +`rand_core_0_3_0::SeedableRng` are distinct, incompatible traits, which can +cause build errors. Usually, running `cargo update` is enough to fix any issues. + +## Crate Features + +`rand_core` supports `no_std` and `alloc`-only configurations, as well as full +`std` functionality. The differences between `no_std` and full `std` are small, +comprising `RngCore` support for `Box` types where `R: RngCore`, +`std::io::Read` support for types supporting `RngCore`, and +extensions to the `Error` type's functionality. + +The `std` feature is *not enabled by default*. This is primarily to avoid build +problems where one crate implicitly requires `rand_core` with `std` support and +another crate requires `rand` *without* `std` support. However, the `rand` crate +continues to enable `std` support by default, both for itself and `rand_core`. + +The `serde1` feature can be used to derive `Serialize` and `Deserialize` for RNG +implementations that use the `BlockRng` or `BlockRng64` wrappers. + + +# License + +`rand_core` is distributed under the terms of both the MIT license and the +Apache License (Version 2.0). + +See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and +[COPYRIGHT](COPYRIGHT) for details. diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/src/block.rs cargo-0.58.0/vendor/rand_core-0.5.1/src/block.rs --- cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/src/block.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core-0.5.1/src/block.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,437 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The `BlockRngCore` trait and implementation helpers +//! +//! The [`BlockRngCore`] trait exists to assist in the implementation of RNGs +//! which generate a block of data in a cache instead of returning generated +//! values directly. +//! +//! Usage of this trait is optional, but provides two advantages: +//! implementations only need to concern themselves with generation of the +//! block, not the various [`RngCore`] methods (especially [`fill_bytes`], where +//! the optimal implementations are not trivial), and this allows +//! `ReseedingRng` (see [`rand`](https://docs.rs/rand) crate) perform periodic +//! reseeding with very low overhead. +//! +//! # Example +//! +//! ```norun +//! use rand_core::block::{BlockRngCore, BlockRng}; +//! +//! struct MyRngCore; +//! +//! impl BlockRngCore for MyRngCore { +//! type Results = [u32; 16]; +//! +//! fn generate(&mut self, results: &mut Self::Results) { +//! unimplemented!() +//! } +//! } +//! +//! impl SeedableRng for MyRngCore { +//! type Seed = unimplemented!(); +//! fn from_seed(seed: Self::Seed) -> Self { +//! unimplemented!() +//! } +//! } +//! +//! // optionally, also implement CryptoRng for MyRngCore +//! +//! // Final RNG. +//! type MyRng = BlockRng; +//! ``` +//! +//! [`BlockRngCore`]: crate::block::BlockRngCore +//! [`fill_bytes`]: RngCore::fill_bytes + +use core::convert::AsRef; +use core::{fmt, ptr}; +#[cfg(feature="serde1")] use serde::{Serialize, Deserialize}; +use crate::{RngCore, CryptoRng, SeedableRng, Error}; +use crate::impls::{fill_via_u32_chunks, fill_via_u64_chunks}; + +/// A trait for RNGs which do not generate random numbers individually, but in +/// blocks (typically `[u32; N]`). This technique is commonly used by +/// cryptographic RNGs to improve performance. +/// +/// See the [module][crate::block] documentation for details. +pub trait BlockRngCore { + /// Results element type, e.g. `u32`. + type Item; + + /// Results type. This is the 'block' an RNG implementing `BlockRngCore` + /// generates, which will usually be an array like `[u32; 16]`. + type Results: AsRef<[Self::Item]> + AsMut<[Self::Item]> + Default; + + /// Generate a new block of results. + fn generate(&mut self, results: &mut Self::Results); +} + + +/// A wrapper type implementing [`RngCore`] for some type implementing +/// [`BlockRngCore`] with `u32` array buffer; i.e. this can be used to implement +/// a full RNG from just a `generate` function. +/// +/// The `core` field may be accessed directly but the results buffer may not. +/// PRNG implementations can simply use a type alias +/// (`pub type MyRng = BlockRng;`) but might prefer to use a +/// wrapper type (`pub struct MyRng(BlockRng);`); the latter must +/// re-implement `RngCore` but hides the implementation details and allows +/// extra functionality to be defined on the RNG +/// (e.g. `impl MyRng { fn set_stream(...){...} }`). +/// +/// `BlockRng` has heavily optimized implementations of the [`RngCore`] methods +/// reading values from the results buffer, as well as +/// calling [`BlockRngCore::generate`] directly on the output array when +/// [`fill_bytes`] / [`try_fill_bytes`] is called on a large array. These methods +/// also handle the bookkeeping of when to generate a new batch of values. +/// +/// No whole generated `u32` values are thown away and all values are consumed +/// in-order. [`next_u32`] simply takes the next available `u32` value. +/// [`next_u64`] is implemented by combining two `u32` values, least +/// significant first. [`fill_bytes`] and [`try_fill_bytes`] consume a whole +/// number of `u32` values, converting each `u32` to a byte slice in +/// little-endian order. If the requested byte length is not a multiple of 4, +/// some bytes will be discarded. +/// +/// See also [`BlockRng64`] which uses `u64` array buffers. Currently there is +/// no direct support for other buffer types. +/// +/// For easy initialization `BlockRng` also implements [`SeedableRng`]. +/// +/// [`next_u32`]: RngCore::next_u32 +/// [`next_u64`]: RngCore::next_u64 +/// [`fill_bytes`]: RngCore::fill_bytes +/// [`try_fill_bytes`]: RngCore::try_fill_bytes +#[derive(Clone)] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +pub struct BlockRng { + results: R::Results, + index: usize, + /// The *core* part of the RNG, implementing the `generate` function. + pub core: R, +} + +// Custom Debug implementation that does not expose the contents of `results`. +impl fmt::Debug for BlockRng { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BlockRng") + .field("core", &self.core) + .field("result_len", &self.results.as_ref().len()) + .field("index", &self.index) + .finish() + } +} + +impl BlockRng { + /// Create a new `BlockRng` from an existing RNG implementing + /// `BlockRngCore`. Results will be generated on first use. + #[inline] + pub fn new(core: R) -> BlockRng{ + let results_empty = R::Results::default(); + BlockRng { + core, + index: results_empty.as_ref().len(), + results: results_empty, + } + } + + /// Get the index into the result buffer. + /// + /// If this is equal to or larger than the size of the result buffer then + /// the buffer is "empty" and `generate()` must be called to produce new + /// results. + #[inline(always)] + pub fn index(&self) -> usize { + self.index + } + + /// Reset the number of available results. + /// This will force a new set of results to be generated on next use. + #[inline] + pub fn reset(&mut self) { + self.index = self.results.as_ref().len(); + } + + /// Generate a new set of results immediately, setting the index to the + /// given value. + #[inline] + pub fn generate_and_set(&mut self, index: usize) { + assert!(index < self.results.as_ref().len()); + self.core.generate(&mut self.results); + self.index = index; + } +} + +impl> RngCore for BlockRng +where ::Results: AsRef<[u32]> + AsMut<[u32]> +{ + #[inline] + fn next_u32(&mut self) -> u32 { + if self.index >= self.results.as_ref().len() { + self.generate_and_set(0); + } + + let value = self.results.as_ref()[self.index]; + self.index += 1; + value + } + + #[inline] + fn next_u64(&mut self) -> u64 { + let read_u64 = |results: &[u32], index| { + if cfg!(any(target_endian = "little")) { + // requires little-endian CPU + #[allow(clippy::cast_ptr_alignment)] // false positive + let ptr: *const u64 = results[index..=index+1].as_ptr() as *const u64; + unsafe { ptr::read_unaligned(ptr) } + } else { + let x = u64::from(results[index]); + let y = u64::from(results[index + 1]); + (y << 32) | x + } + }; + + let len = self.results.as_ref().len(); + + let index = self.index; + if index < len-1 { + self.index += 2; + // Read an u64 from the current index + read_u64(self.results.as_ref(), index) + } else if index >= len { + self.generate_and_set(2); + read_u64(self.results.as_ref(), 0) + } else { + let x = u64::from(self.results.as_ref()[len-1]); + self.generate_and_set(1); + let y = u64::from(self.results.as_ref()[0]); + (y << 32) | x + } + } + + #[inline] + fn fill_bytes(&mut self, dest: &mut [u8]) { + let mut read_len = 0; + while read_len < dest.len() { + if self.index >= self.results.as_ref().len() { + self.generate_and_set(0); + } + let (consumed_u32, filled_u8) = + fill_via_u32_chunks(&self.results.as_ref()[self.index..], + &mut dest[read_len..]); + + self.index += consumed_u32; + read_len += filled_u8; + } + } + + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.fill_bytes(dest); + Ok(()) + } +} + +impl SeedableRng for BlockRng { + type Seed = R::Seed; + + #[inline(always)] + fn from_seed(seed: Self::Seed) -> Self { + Self::new(R::from_seed(seed)) + } + + #[inline(always)] + fn seed_from_u64(seed: u64) -> Self { + Self::new(R::seed_from_u64(seed)) + } + + #[inline(always)] + fn from_rng(rng: S) -> Result { + Ok(Self::new(R::from_rng(rng)?)) + } +} + + + +/// A wrapper type implementing [`RngCore`] for some type implementing +/// [`BlockRngCore`] with `u64` array buffer; i.e. this can be used to implement +/// a full RNG from just a `generate` function. +/// +/// This is similar to [`BlockRng`], but specialized for algorithms that operate +/// on `u64` values. +/// +/// No whole generated `u64` values are thrown away and all values are consumed +/// in-order. [`next_u64`] simply takes the next available `u64` value. +/// [`next_u32`] is however a bit special: half of a `u64` is consumed, leaving +/// the other half in the buffer. If the next function called is [`next_u32`] +/// then the other half is then consumed, however both [`next_u64`] and +/// [`fill_bytes`] discard the rest of any half-consumed `u64`s when called. +/// +/// [`fill_bytes`] and [`try_fill_bytes`] consume a whole number of `u64` +/// values. If the requested length is not a multiple of 8, some bytes will be +/// discarded. +/// +/// [`next_u32`]: RngCore::next_u32 +/// [`next_u64`]: RngCore::next_u64 +/// [`fill_bytes`]: RngCore::fill_bytes +/// [`try_fill_bytes`]: RngCore::try_fill_bytes +#[derive(Clone)] +#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))] +pub struct BlockRng64 { + results: R::Results, + index: usize, + half_used: bool, // true if only half of the previous result is used + /// The *core* part of the RNG, implementing the `generate` function. + pub core: R, +} + +// Custom Debug implementation that does not expose the contents of `results`. +impl fmt::Debug for BlockRng64 { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("BlockRng64") + .field("core", &self.core) + .field("result_len", &self.results.as_ref().len()) + .field("index", &self.index) + .field("half_used", &self.half_used) + .finish() + } +} + +impl BlockRng64 { + /// Create a new `BlockRng` from an existing RNG implementing + /// `BlockRngCore`. Results will be generated on first use. + #[inline] + pub fn new(core: R) -> BlockRng64{ + let results_empty = R::Results::default(); + BlockRng64 { + core, + index: results_empty.as_ref().len(), + half_used: false, + results: results_empty, + } + } + + /// Get the index into the result buffer. + /// + /// If this is equal to or larger than the size of the result buffer then + /// the buffer is "empty" and `generate()` must be called to produce new + /// results. + #[inline(always)] + pub fn index(&self) -> usize { + self.index + } + + /// Reset the number of available results. + /// This will force a new set of results to be generated on next use. + #[inline] + pub fn reset(&mut self) { + self.index = self.results.as_ref().len(); + self.half_used = false; + } + + /// Generate a new set of results immediately, setting the index to the + /// given value. + #[inline] + pub fn generate_and_set(&mut self, index: usize) { + assert!(index < self.results.as_ref().len()); + self.core.generate(&mut self.results); + self.index = index; + self.half_used = false; + } +} + +impl> RngCore for BlockRng64 +where ::Results: AsRef<[u64]> + AsMut<[u64]> +{ + #[inline] + fn next_u32(&mut self) -> u32 { + let mut index = self.index * 2 - self.half_used as usize; + if index >= self.results.as_ref().len() * 2 { + self.core.generate(&mut self.results); + self.index = 0; + // `self.half_used` is by definition `false` + self.half_used = false; + index = 0; + } + + self.half_used = !self.half_used; + self.index += self.half_used as usize; + + // Index as if this is a u32 slice. + unsafe { + let results = + &*(self.results.as_ref() as *const [u64] as *const [u32]); + if cfg!(target_endian = "little") { + *results.get_unchecked(index) + } else { + *results.get_unchecked(index ^ 1) + } + } + } + + #[inline] + fn next_u64(&mut self) -> u64 { + if self.index >= self.results.as_ref().len() { + self.core.generate(&mut self.results); + self.index = 0; + } + + let value = self.results.as_ref()[self.index]; + self.index += 1; + self.half_used = false; + value + } + + #[inline] + fn fill_bytes(&mut self, dest: &mut [u8]) { + let mut read_len = 0; + self.half_used = false; + while read_len < dest.len() { + if self.index as usize >= self.results.as_ref().len() { + self.core.generate(&mut self.results); + self.index = 0; + } + + let (consumed_u64, filled_u8) = + fill_via_u64_chunks(&self.results.as_ref()[self.index as usize..], + &mut dest[read_len..]); + + self.index += consumed_u64; + read_len += filled_u8; + } + } + + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + self.fill_bytes(dest); + Ok(()) + } +} + +impl SeedableRng for BlockRng64 { + type Seed = R::Seed; + + #[inline(always)] + fn from_seed(seed: Self::Seed) -> Self { + Self::new(R::from_seed(seed)) + } + + #[inline(always)] + fn seed_from_u64(seed: u64) -> Self { + Self::new(R::seed_from_u64(seed)) + } + + #[inline(always)] + fn from_rng(rng: S) -> Result { + Ok(Self::new(R::from_rng(rng)?)) + } +} + +impl CryptoRng for BlockRng {} diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/src/error.rs cargo-0.58.0/vendor/rand_core-0.5.1/src/error.rs --- cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/src/error.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core-0.5.1/src/error.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,190 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Error types + +use core::fmt; +use core::num::NonZeroU32; + + +/// Error type of random number generators +/// +/// In order to be compatible with `std` and `no_std`, this type has two +/// possible implementations: with `std` a boxed `Error` trait object is stored, +/// while with `no_std` we merely store an error code. +pub struct Error { + #[cfg(feature="std")] + inner: Box, + #[cfg(not(feature="std"))] + code: NonZeroU32, +} + +impl Error { + /// Construct from any type supporting `std::error::Error` + /// + /// Available only when configured with `std`. + /// + /// See also `From`, which is available with and without `std`. + #[cfg(feature="std")] + #[inline] + pub fn new(err: E) -> Self + where E: Into> + { + Error { inner: err.into() } + } + + /// Reference the inner error (`std` only) + /// + /// When configured with `std`, this is a trivial operation and never + /// panics. Without `std`, this method is simply unavailable. + #[cfg(feature="std")] + #[inline] + pub fn inner(&self) -> &(dyn std::error::Error + Send + Sync + 'static) { + &*self.inner + } + + /// Unwrap the inner error (`std` only) + /// + /// When configured with `std`, this is a trivial operation and never + /// panics. Without `std`, this method is simply unavailable. + #[cfg(feature="std")] + #[inline] + pub fn take_inner(self) -> Box { + self.inner + } + + /// Codes below this point represent OS Errors (i.e. positive i32 values). + /// Codes at or above this point, but below [`Error::CUSTOM_START`] are + /// reserved for use by the `rand` and `getrandom` crates. + pub const INTERNAL_START: u32 = 1 << 31; + + /// Codes at or above this point can be used by users to define their own + /// custom errors. + pub const CUSTOM_START: u32 = (1 << 31) + (1 << 30); + + /// Extract the raw OS error code (if this error came from the OS) + /// + /// This method is identical to `std::io::Error::raw_os_error()`, except + /// that it works in `no_std` contexts. If this method returns `None`, the + /// error value can still be formatted via the `Diplay` implementation. + #[inline] + pub fn raw_os_error(&self) -> Option { + #[cfg(feature="std")] { + if let Some(e) = self.inner.downcast_ref::() { + return e.raw_os_error(); + } + } + match self.code() { + Some(code) if u32::from(code) < Self::INTERNAL_START => + Some(u32::from(code) as i32), + _ => None, + } + } + + /// Retrieve the error code, if any. + /// + /// If this `Error` was constructed via `From`, then this method + /// will return this `NonZeroU32` code (for `no_std` this is always the + /// case). Otherwise, this method will return `None`. + #[inline] + pub fn code(&self) -> Option { + #[cfg(feature="std")] { + self.inner.downcast_ref::().map(|c| c.0) + } + #[cfg(not(feature="std"))] { + Some(self.code) + } + } +} + +impl fmt::Debug for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + #[cfg(feature="std")] { + write!(f, "Error {{ inner: {:?} }}", self.inner) + } + #[cfg(all(feature="getrandom", not(feature="std")))] { + getrandom::Error::from(self.code).fmt(f) + } + #[cfg(not(feature="getrandom"))] { + write!(f, "Error {{ code: {} }}", self.code) + } + } +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + #[cfg(feature="std")] { + write!(f, "{}", self.inner) + } + #[cfg(all(feature="getrandom", not(feature="std")))] { + getrandom::Error::from(self.code).fmt(f) + } + #[cfg(not(feature="getrandom"))] { + write!(f, "error code {}", self.code) + } + } +} + +impl From for Error { + #[inline] + fn from(code: NonZeroU32) -> Self { + #[cfg(feature="std")] { + Error { inner: Box::new(ErrorCode(code)) } + } + #[cfg(not(feature="std"))] { + Error { code } + } + } +} + +#[cfg(feature="getrandom")] +impl From for Error { + #[inline] + fn from(error: getrandom::Error) -> Self { + #[cfg(feature="std")] { + Error { inner: Box::new(error) } + } + #[cfg(not(feature="std"))] { + Error { code: error.code() } + } + } +} + +#[cfg(feature="std")] +impl std::error::Error for Error { + #[inline] + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + self.inner.source() + } +} + +#[cfg(feature="std")] +impl From for std::io::Error { + #[inline] + fn from(error: Error) -> Self { + if let Some(code) = error.raw_os_error() { + std::io::Error::from_raw_os_error(code) + } else { + std::io::Error::new(std::io::ErrorKind::Other, error) + } + } +} + +#[cfg(feature="std")] +#[derive(Debug, Copy, Clone)] +struct ErrorCode(NonZeroU32); + +#[cfg(feature="std")] +impl fmt::Display for ErrorCode { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "error code {}", self.0) + } +} + +#[cfg(feature="std")] +impl std::error::Error for ErrorCode {} diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/src/impls.rs cargo-0.58.0/vendor/rand_core-0.5.1/src/impls.rs --- cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/src/impls.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core-0.5.1/src/impls.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,158 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Helper functions for implementing `RngCore` functions. +//! +//! For cross-platform reproducibility, these functions all use Little Endian: +//! least-significant part first. For example, `next_u64_via_u32` takes `u32` +//! values `x, y`, then outputs `(y << 32) | x`. To implement `next_u32` +//! from `next_u64` in little-endian order, one should use `next_u64() as u32`. +//! +//! Byte-swapping (like the std `to_le` functions) is only needed to convert +//! to/from byte sequences, and since its purpose is reproducibility, +//! non-reproducible sources (e.g. `OsRng`) need not bother with it. + +use core::ptr::copy_nonoverlapping; +use core::slice; +use core::cmp::min; +use core::mem::size_of; +use crate::RngCore; + + +/// Implement `next_u64` via `next_u32`, little-endian order. +pub fn next_u64_via_u32(rng: &mut R) -> u64 { + // Use LE; we explicitly generate one value before the next. + let x = u64::from(rng.next_u32()); + let y = u64::from(rng.next_u32()); + (y << 32) | x +} + +/// Implement `fill_bytes` via `next_u64` and `next_u32`, little-endian order. +/// +/// The fastest way to fill a slice is usually to work as long as possible with +/// integers. That is why this method mostly uses `next_u64`, and only when +/// there are 4 or less bytes remaining at the end of the slice it uses +/// `next_u32` once. +pub fn fill_bytes_via_next(rng: &mut R, dest: &mut [u8]) { + let mut left = dest; + while left.len() >= 8 { + let (l, r) = {left}.split_at_mut(8); + left = r; + let chunk: [u8; 8] = rng.next_u64().to_le_bytes(); + l.copy_from_slice(&chunk); + } + let n = left.len(); + if n > 4 { + let chunk: [u8; 8] = rng.next_u64().to_le_bytes(); + left.copy_from_slice(&chunk[..n]); + } else if n > 0 { + let chunk: [u8; 4] = rng.next_u32().to_le_bytes(); + left.copy_from_slice(&chunk[..n]); + } +} + +macro_rules! impl_uint_from_fill { + ($rng:expr, $ty:ty, $N:expr) => ({ + debug_assert!($N == size_of::<$ty>()); + + let mut int: $ty = 0; + unsafe { + let ptr = &mut int as *mut $ty as *mut u8; + let slice = slice::from_raw_parts_mut(ptr, $N); + $rng.fill_bytes(slice); + } + int + }); +} + +macro_rules! fill_via_chunks { + ($src:expr, $dst:expr, $ty:ty, $size:expr) => ({ + let chunk_size_u8 = min($src.len() * $size, $dst.len()); + let chunk_size = (chunk_size_u8 + $size - 1) / $size; + if cfg!(target_endian="little") { + unsafe { + copy_nonoverlapping( + $src.as_ptr() as *const u8, + $dst.as_mut_ptr(), + chunk_size_u8); + } + } else { + for (&n, chunk) in $src.iter().zip($dst.chunks_mut($size)) { + let tmp = n.to_le(); + let src_ptr = &tmp as *const $ty as *const u8; + unsafe { + copy_nonoverlapping(src_ptr, + chunk.as_mut_ptr(), + chunk.len()); + } + } + } + + (chunk_size, chunk_size_u8) + }); +} + +/// Implement `fill_bytes` by reading chunks from the output buffer of a block +/// based RNG. +/// +/// The return values are `(consumed_u32, filled_u8)`. +/// +/// `filled_u8` is the number of filled bytes in `dest`, which may be less than +/// the length of `dest`. +/// `consumed_u32` is the number of words consumed from `src`, which is the same +/// as `filled_u8 / 4` rounded up. +/// +/// # Example +/// (from `IsaacRng`) +/// +/// ```ignore +/// fn fill_bytes(&mut self, dest: &mut [u8]) { +/// let mut read_len = 0; +/// while read_len < dest.len() { +/// if self.index >= self.rsl.len() { +/// self.isaac(); +/// } +/// +/// let (consumed_u32, filled_u8) = +/// impls::fill_via_u32_chunks(&mut self.rsl[self.index..], +/// &mut dest[read_len..]); +/// +/// self.index += consumed_u32; +/// read_len += filled_u8; +/// } +/// } +/// ``` +pub fn fill_via_u32_chunks(src: &[u32], dest: &mut [u8]) -> (usize, usize) { + fill_via_chunks!(src, dest, u32, 4) +} + +/// Implement `fill_bytes` by reading chunks from the output buffer of a block +/// based RNG. +/// +/// The return values are `(consumed_u64, filled_u8)`. +/// `filled_u8` is the number of filled bytes in `dest`, which may be less than +/// the length of `dest`. +/// `consumed_u64` is the number of words consumed from `src`, which is the same +/// as `filled_u8 / 8` rounded up. +/// +/// See `fill_via_u32_chunks` for an example. +pub fn fill_via_u64_chunks(src: &[u64], dest: &mut [u8]) -> (usize, usize) { + fill_via_chunks!(src, dest, u64, 8) +} + +/// Implement `next_u32` via `fill_bytes`, little-endian order. +pub fn next_u32_via_fill(rng: &mut R) -> u32 { + impl_uint_from_fill!(rng, u32, 4) +} + +/// Implement `next_u64` via `fill_bytes`, little-endian order. +pub fn next_u64_via_fill(rng: &mut R) -> u64 { + impl_uint_from_fill!(rng, u64, 8) +} + +// TODO: implement tests for the above diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/src/le.rs cargo-0.58.0/vendor/rand_core-0.5.1/src/le.rs --- cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/src/le.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core-0.5.1/src/le.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,68 @@ +// Copyright 2018 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Little-Endian utilities +//! +//! Little-Endian order has been chosen for internal usage; this makes some +//! useful functions available. + +use core::ptr; + +macro_rules! read_slice { + ($src:expr, $dst:expr, $size:expr, $which:ident) => {{ + assert_eq!($src.len(), $size * $dst.len()); + + unsafe { + ptr::copy_nonoverlapping( + $src.as_ptr(), + $dst.as_mut_ptr() as *mut u8, + $src.len()); + } + for v in $dst.iter_mut() { + *v = v.$which(); + } + }}; +} + +/// Reads unsigned 32 bit integers from `src` into `dst`. +/// Borrowed from the `byteorder` crate. +#[inline] +pub fn read_u32_into(src: &[u8], dst: &mut [u32]) { + read_slice!(src, dst, 4, to_le); +} + +/// Reads unsigned 64 bit integers from `src` into `dst`. +/// Borrowed from the `byteorder` crate. +#[inline] +pub fn read_u64_into(src: &[u8], dst: &mut [u64]) { + read_slice!(src, dst, 8, to_le); +} + +#[test] +fn test_read() { + let bytes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]; + + let mut buf = [0u32; 4]; + read_u32_into(&bytes, &mut buf); + assert_eq!(buf[0], 0x04030201); + assert_eq!(buf[3], 0x100F0E0D); + + let mut buf = [0u32; 3]; + read_u32_into(&bytes[1..13], &mut buf); // unaligned + assert_eq!(buf[0], 0x05040302); + assert_eq!(buf[2], 0x0D0C0B0A); + + let mut buf = [0u64; 2]; + read_u64_into(&bytes, &mut buf); + assert_eq!(buf[0], 0x0807060504030201); + assert_eq!(buf[1], 0x100F0E0D0C0B0A09); + + let mut buf = [0u64; 1]; + read_u64_into(&bytes[7..15], &mut buf); // unaligned + assert_eq!(buf[0], 0x0F0E0D0C0B0A0908); +} diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/src/lib.rs cargo-0.58.0/vendor/rand_core-0.5.1/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/src/lib.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core-0.5.1/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,492 @@ +// Copyright 2018 Developers of the Rand project. +// Copyright 2017-2018 The Rust Project Developers. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Random number generation traits +//! +//! This crate is mainly of interest to crates publishing implementations of +//! [`RngCore`]. Other users are encouraged to use the [`rand`] crate instead +//! which re-exports the main traits and error types. +//! +//! [`RngCore`] is the core trait implemented by algorithmic pseudo-random number +//! generators and external random-number sources. +//! +//! [`SeedableRng`] is an extension trait for construction from fixed seeds and +//! other random number generators. +//! +//! [`Error`] is provided for error-handling. It is safe to use in `no_std` +//! environments. +//! +//! The [`impls`] and [`le`] sub-modules include a few small functions to assist +//! implementation of [`RngCore`]. +//! +//! [`rand`]: https://docs.rs/rand + +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", + html_favicon_url = "https://www.rust-lang.org/favicon.ico", + html_root_url = "https://rust-random.github.io/rand/")] + +#![deny(missing_docs)] +#![deny(missing_debug_implementations)] +#![doc(test(attr(allow(unused_variables), deny(warnings))))] + +#![allow(clippy::unreadable_literal)] + +#![cfg_attr(not(feature="std"), no_std)] + + +use core::default::Default; +use core::convert::AsMut; +use core::ptr::copy_nonoverlapping; + +#[cfg(all(feature="alloc", not(feature="std")))] extern crate alloc; +#[cfg(all(feature="alloc", not(feature="std")))] use alloc::boxed::Box; + +pub use error::Error; +#[cfg(feature="getrandom")] pub use os::OsRng; + + +mod error; +pub mod block; +pub mod impls; +pub mod le; +#[cfg(feature="getrandom")] mod os; + + +/// The core of a random number generator. +/// +/// This trait encapsulates the low-level functionality common to all +/// generators, and is the "back end", to be implemented by generators. +/// End users should normally use the `Rng` trait from the [`rand`] crate, +/// which is automatically implemented for every type implementing `RngCore`. +/// +/// Three different methods for generating random data are provided since the +/// optimal implementation of each is dependent on the type of generator. There +/// is no required relationship between the output of each; e.g. many +/// implementations of [`fill_bytes`] consume a whole number of `u32` or `u64` +/// values and drop any remaining unused bytes. +/// +/// The [`try_fill_bytes`] method is a variant of [`fill_bytes`] allowing error +/// handling; it is not deemed sufficiently useful to add equivalents for +/// [`next_u32`] or [`next_u64`] since the latter methods are almost always used +/// with algorithmic generators (PRNGs), which are normally infallible. +/// +/// 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 +/// in this trait directly, then use the helper functions from the +/// [`impls`] module to implement the other methods. +/// +/// It is recommended that implementations also implement: +/// +/// - `Debug` with a custom implementation which *does not* print any internal +/// state (at least, [`CryptoRng`]s should not risk leaking state through +/// `Debug`). +/// - `Serialize` and `Deserialize` (from Serde), preferably making Serde +/// support optional at the crate level in PRNG libs. +/// - `Clone`, if possible. +/// - *never* implement `Copy` (accidental copies may cause repeated values). +/// - *do not* implement `Default` for pseudorandom generators, but instead +/// implement [`SeedableRng`], to guide users towards proper seeding. +/// External / hardware RNGs can choose to implement `Default`. +/// - `Eq` and `PartialEq` could be implemented, but are probably not useful. +/// +/// # Example +/// +/// A simple example, obviously not generating very *random* output: +/// +/// ``` +/// #![allow(dead_code)] +/// use rand_core::{RngCore, Error, impls}; +/// +/// struct CountingRng(u64); +/// +/// impl RngCore for CountingRng { +/// fn next_u32(&mut self) -> u32 { +/// self.next_u64() as u32 +/// } +/// +/// fn next_u64(&mut self) -> u64 { +/// self.0 += 1; +/// self.0 +/// } +/// +/// fn fill_bytes(&mut self, dest: &mut [u8]) { +/// impls::fill_bytes_via_next(self, dest) +/// } +/// +/// fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { +/// Ok(self.fill_bytes(dest)) +/// } +/// } +/// ``` +/// +/// [`rand`]: https://docs.rs/rand +/// [`try_fill_bytes`]: RngCore::try_fill_bytes +/// [`fill_bytes`]: RngCore::fill_bytes +/// [`next_u32`]: RngCore::next_u32 +/// [`next_u64`]: RngCore::next_u64 +pub trait RngCore { + /// Return the next random `u32`. + /// + /// RNGs must implement at least one method from this trait directly. In + /// the case this method is not implemented directly, it can be implemented + /// using `self.next_u64() as u32` or via + /// [`fill_bytes`](impls::next_u32_via_fill). + fn next_u32(&mut self) -> u32; + + /// Return the next random `u64`. + /// + /// RNGs must implement at least one method from this trait directly. In + /// the case this method is not implemented directly, it can be implemented + /// via [`next_u32`](impls::next_u64_via_u32) or via + /// [`fill_bytes`](impls::next_u64_via_fill). + fn next_u64(&mut self) -> u64; + + /// Fill `dest` with random data. + /// + /// RNGs must implement at least one method from this trait directly. In + /// the case this method is not implemented directly, it can be implemented + /// via [`next_u*`](impls::fill_bytes_via_next) or + /// via [`try_fill_bytes`](RngCore::try_fill_bytes); if this generator can + /// fail the implementation must choose how best to handle errors here + /// (e.g. panic with a descriptive message or log a warning and retry a few + /// times). + /// + /// This method should guarantee that `dest` is entirely filled + /// with new data, and may panic if this is impossible + /// (e.g. reading past the end of a file that is being used as the + /// source of randomness). + fn fill_bytes(&mut self, dest: &mut [u8]); + + /// Fill `dest` entirely with random data. + /// + /// This is the only method which allows an RNG to report errors while + /// generating random data thus making this the primary method implemented + /// by external (true) RNGs (e.g. `OsRng`) which can fail. It may be used + /// directly to generate keys and to seed (infallible) PRNGs. + /// + /// Other than error handling, this method is identical to [`fill_bytes`]; + /// thus this may be implemented using `Ok(self.fill_bytes(dest))` or + /// `fill_bytes` may be implemented with + /// `self.try_fill_bytes(dest).unwrap()` or more specific error handling. + /// + /// [`fill_bytes`]: RngCore::fill_bytes + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>; +} + +/// A marker trait used to indicate that an [`RngCore`] or [`BlockRngCore`] +/// implementation is supposed to be cryptographically secure. +/// +/// *Cryptographically secure generators*, also known as *CSPRNGs*, should +/// satisfy an additional properties over other generators: given the first +/// *k* bits of an algorithm's output +/// sequence, it should not be possible using polynomial-time algorithms to +/// predict the next bit with probability significantly greater than 50%. +/// +/// Some generators may satisfy an additional property, however this is not +/// required by this trait: if the CSPRNG's state is revealed, it should not be +/// computationally-feasible to reconstruct output prior to this. Some other +/// generators allow backwards-computation and are consided *reversible*. +/// +/// Note that this trait is provided for guidance only and cannot guarantee +/// suitability for cryptographic applications. In general it should only be +/// implemented for well-reviewed code implementing well-regarded algorithms. +/// +/// Note also that use of a `CryptoRng` does not protect against other +/// weaknesses such as seeding from a weak entropy source or leaking state. +/// +/// [`BlockRngCore`]: block::BlockRngCore +pub trait CryptoRng {} + +/// A random number generator that can be explicitly seeded. +/// +/// This trait encapsulates the low-level functionality common to all +/// pseudo-random number generators (PRNGs, or algorithmic generators). +/// +/// [`rand`]: https://docs.rs/rand +pub trait SeedableRng: Sized { + /// Seed type, which is restricted to types mutably-dereferencable as `u8` + /// arrays (we recommend `[u8; N]` for some `N`). + /// + /// It is recommended to seed PRNGs with a seed of at least circa 100 bits, + /// which means an array of `[u8; 12]` or greater to avoid picking RNGs with + /// partially overlapping periods. + /// + /// For cryptographic RNG's a seed of 256 bits is recommended, `[u8; 32]`. + /// + /// + /// # Implementing `SeedableRng` for RNGs with large seeds + /// + /// Note that the required traits `core::default::Default` and + /// `core::convert::AsMut` are not implemented for large arrays + /// `[u8; N]` with `N` > 32. To be able to implement the traits required by + /// `SeedableRng` for RNGs with such large seeds, the newtype pattern can be + /// used: + /// + /// ``` + /// use rand_core::SeedableRng; + /// + /// const N: usize = 64; + /// pub struct MyRngSeed(pub [u8; N]); + /// pub struct MyRng(MyRngSeed); + /// + /// impl Default for MyRngSeed { + /// fn default() -> MyRngSeed { + /// MyRngSeed([0; N]) + /// } + /// } + /// + /// impl AsMut<[u8]> for MyRngSeed { + /// fn as_mut(&mut self) -> &mut [u8] { + /// &mut self.0 + /// } + /// } + /// + /// impl SeedableRng for MyRng { + /// type Seed = MyRngSeed; + /// + /// fn from_seed(seed: MyRngSeed) -> MyRng { + /// MyRng(seed) + /// } + /// } + /// ``` + type Seed: Sized + Default + AsMut<[u8]>; + + /// Create a new PRNG using the given seed. + /// + /// PRNG implementations are allowed to assume that bits in the seed are + /// well distributed. That means usually that the number of one and zero + /// bits are roughly equal, and values like 0, 1 and (size - 1) are unlikely. + /// Note that many non-cryptographic PRNGs will show poor quality output + /// if this is not adhered to. If you wish to seed from simple numbers, use + /// `seed_from_u64` instead. + /// + /// All PRNG implementations should be reproducible unless otherwise noted: + /// given a fixed `seed`, the same sequence of output should be produced + /// on all runs, library versions and architectures (e.g. check endianness). + /// Any "value-breaking" changes to the generator should require bumping at + /// least the minor version and documentation of the change. + /// + /// It is not required that this function yield the same state as a + /// reference implementation of the PRNG given equivalent seed; if necessary + /// another constructor replicating behaviour from a reference + /// implementation can be added. + /// + /// PRNG implementations should make sure `from_seed` never panics. In the + /// case that some special values (like an all zero seed) are not viable + /// seeds it is preferable to map these to alternative constant value(s), + /// for example `0xBAD5EEDu32` or `0x0DDB1A5E5BAD5EEDu64` ("odd biases? bad + /// seed"). This is assuming only a small number of values must be rejected. + fn from_seed(seed: Self::Seed) -> Self; + + /// Create a new PRNG using a `u64` seed. + /// + /// This is a convenience-wrapper around `from_seed` to allow construction + /// of any `SeedableRng` from a simple `u64` value. It is designed such that + /// low Hamming Weight numbers like 0 and 1 can be used and should still + /// result in good, independent seeds to the PRNG which is returned. + /// + /// This **is not suitable for cryptography**, as should be clear given that + /// the input size is only 64 bits. + /// + /// Implementations for PRNGs *may* provide their own implementations of + /// this function, but the default implementation should be good enough for + /// all purposes. *Changing* the implementation of this function should be + /// considered a value-breaking change. + fn seed_from_u64(mut state: u64) -> Self { + // We use PCG32 to generate a u32 sequence, and copy to the seed + const MUL: u64 = 6364136223846793005; + const INC: u64 = 11634580027462260723; + + let mut seed = Self::Seed::default(); + for chunk in seed.as_mut().chunks_mut(4) { + // We advance the state first (to get away from the input value, + // in case it has low Hamming Weight). + state = state.wrapping_mul(MUL).wrapping_add(INC); + + // Use PCG output function with to_le to generate x: + let xorshifted = (((state >> 18) ^ state) >> 27) as u32; + let rot = (state >> 59) as u32; + let x = xorshifted.rotate_right(rot).to_le(); + + unsafe { + let p = &x as *const u32 as *const u8; + copy_nonoverlapping(p, chunk.as_mut_ptr(), chunk.len()); + } + } + + Self::from_seed(seed) + } + + /// Create a new PRNG seeded from another `Rng`. + /// + /// This may be useful when needing to rapidly seed many PRNGs from a master + /// PRNG, and to allow forking of PRNGs. It may be considered deterministic. + /// + /// The master PRNG should be at least as high quality as the child PRNGs. + /// When seeding non-cryptographic child PRNGs, we recommend using a + /// different algorithm for the master PRNG (ideally a CSPRNG) to avoid + /// correlations between the child PRNGs. If this is not possible (e.g. + /// forking using small non-crypto PRNGs) ensure that your PRNG has a good + /// mixing function on the output or consider use of a hash function with + /// `from_seed`. + /// + /// Note that seeding `XorShiftRng` from another `XorShiftRng` provides an + /// extreme example of what can go wrong: the new PRNG will be a clone + /// of the parent. + /// + /// PRNG implementations are allowed to assume that a good RNG is provided + /// for seeding, and that it is cryptographically secure when appropriate. + /// As of `rand` 0.7 / `rand_core` 0.5, implementations overriding this + /// method should ensure the implementation satisfies reproducibility + /// (in prior versions this was not required). + /// + /// [`rand`]: https://docs.rs/rand + /// [`rand_os`]: https://docs.rs/rand_os + fn from_rng(mut rng: R) -> Result { + let mut seed = Self::Seed::default(); + rng.try_fill_bytes(seed.as_mut())?; + Ok(Self::from_seed(seed)) + } + + /// Creates a new instance of the RNG seeded via [`getrandom`]. + /// + /// This method is the recommended way to construct non-deterministic PRNGs + /// since it is convenient and secure. + /// + /// In case the overhead of using [`getrandom`] to seed *many* PRNGs is an + /// issue, one may prefer to seed from a local PRNG, e.g. + /// `from_rng(thread_rng()).unwrap()`. + /// + /// # Panics + /// + /// If [`getrandom`] is unable to provide secure entropy this method will panic. + /// + /// [`getrandom`]: https://docs.rs/getrandom + #[cfg(feature="getrandom")] + fn from_entropy() -> Self { + let mut seed = Self::Seed::default(); + if let Err(err) = getrandom::getrandom(seed.as_mut()) { + panic!("from_entropy failed: {}", err); + } + Self::from_seed(seed) + } +} + +// Implement `RngCore` for references to an `RngCore`. +// Force inlining all functions, so that it is up to the `RngCore` +// implementation and the optimizer to decide on inlining. +impl<'a, R: RngCore + ?Sized> RngCore for &'a mut R { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + (**self).next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + (**self).next_u64() + } + + #[inline(always)] + fn fill_bytes(&mut self, dest: &mut [u8]) { + (**self).fill_bytes(dest) + } + + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + (**self).try_fill_bytes(dest) + } +} + +// Implement `RngCore` for boxed references to an `RngCore`. +// Force inlining all functions, so that it is up to the `RngCore` +// implementation and the optimizer to decide on inlining. +#[cfg(feature="alloc")] +impl RngCore for Box { + #[inline(always)] + fn next_u32(&mut self) -> u32 { + (**self).next_u32() + } + + #[inline(always)] + fn next_u64(&mut self) -> u64 { + (**self).next_u64() + } + + #[inline(always)] + fn fill_bytes(&mut self, dest: &mut [u8]) { + (**self).fill_bytes(dest) + } + + #[inline(always)] + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + (**self).try_fill_bytes(dest) + } +} + +#[cfg(feature="std")] +impl std::io::Read for dyn RngCore { + fn read(&mut self, buf: &mut [u8]) -> Result { + self.try_fill_bytes(buf)?; + Ok(buf.len()) + } +} + +// Implement `CryptoRng` for references to an `CryptoRng`. +impl<'a, R: CryptoRng + ?Sized> CryptoRng for &'a mut R {} + +// Implement `CryptoRng` for boxed references to an `CryptoRng`. +#[cfg(feature="alloc")] +impl CryptoRng for Box {} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_seed_from_u64() { + struct SeedableNum(u64); + impl SeedableRng for SeedableNum { + type Seed = [u8; 8]; + fn from_seed(seed: Self::Seed) -> Self { + let mut x = [0u64; 1]; + le::read_u64_into(&seed, &mut x); + SeedableNum(x[0]) + } + } + + const N: usize = 8; + const SEEDS: [u64; N] = [0u64, 1, 2, 3, 4, 8, 16, -1i64 as u64]; + let mut results = [0u64; N]; + for (i, seed) in SEEDS.iter().enumerate() { + let SeedableNum(x) = SeedableNum::seed_from_u64(*seed); + results[i] = x; + } + + for (i1, r1) in results.iter().enumerate() { + let weight = r1.count_ones(); + // 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); + + for (i2, r2) in results.iter().enumerate() { + if i1 == i2 { continue; } + let diff_weight = (r1 ^ r2).count_ones(); + assert!(diff_weight >= 20); + } + } + + // value-breakage test: + assert_eq!(results[0], 5029875928683246316); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/src/os.rs cargo-0.58.0/vendor/rand_core-0.5.1/src/os.rs --- cargo-0.57.0+ubuntu/vendor/rand_core-0.5.1/src/os.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/rand_core-0.5.1/src/os.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,85 @@ +// Copyright 2019 Developers of the Rand project. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! Interface to the random number generator of the operating system. +// Note: keep this code in sync with the rand_os crate! + +use getrandom::getrandom; +use crate::{CryptoRng, RngCore, Error, impls}; + +/// A random number generator that retrieves randomness from from the +/// operating system. +/// +/// This is a zero-sized struct. It can be freely constructed with `OsRng`. +/// +/// The implementation is provided by the [getrandom] crate. Refer to +/// [getrandom] documentation for details. +/// +/// This struct is only available when specifying the crate feature `getrandom` +/// or `std`. When using the `rand` lib, it is also available as `rand::rngs::OsRng`. +/// +/// # Blocking and error handling +/// +/// It is possible that when used during early boot the first call to `OsRng` +/// will block until the system's RNG is initialised. It is also possible +/// (though highly unlikely) for `OsRng` to fail on some platforms, most +/// likely due to system mis-configuration. +/// +/// After the first successful call, it is highly unlikely that failures or +/// significant delays will occur (although performance should be expected to +/// be much slower than a user-space PRNG). +/// +/// # Usage example +/// ``` +/// use rand_core::{RngCore, OsRng}; +/// +/// let mut key = [0u8; 16]; +/// OsRng.fill_bytes(&mut key); +/// let random_u64 = OsRng.next_u64(); +/// ``` +/// +/// [getrandom]: https://crates.io/crates/getrandom +#[derive(Clone, Copy, Debug, Default)] +pub struct OsRng; + +impl CryptoRng for OsRng {} + +impl RngCore for OsRng { + fn next_u32(&mut self) -> u32 { + impls::next_u32_via_fill(self) + } + + fn next_u64(&mut self) -> u64 { + impls::next_u64_via_fill(self) + } + + fn fill_bytes(&mut self, dest: &mut [u8]) { + if let Err(e) = self.try_fill_bytes(dest) { + panic!("Error: {}", e); + } + } + + fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> { + getrandom(dest)?; + Ok(()) + } +} + +#[test] +fn test_os_rng() { + let x = OsRng.next_u64(); + let y = OsRng.next_u64(); + assert!(x != 0); + assert!(x != y); +} + +#[test] +fn test_construction() { + let mut rng = OsRng::default(); + assert!(rng.next_u64() != 0); +} diff -Nru cargo-0.57.0+ubuntu/vendor/rand_hc/.cargo-checksum.json cargo-0.58.0/vendor/rand_hc/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/rand_hc/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_hc/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"} \ No newline at end of file +{"files":{},"package":"d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/rand_hc/Cargo.toml cargo-0.58.0/vendor/rand_hc/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/rand_hc/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_hc/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -13,20 +13,15 @@ [package] edition = "2018" name = "rand_hc" -version = "0.2.0" +version = "0.3.1" authors = ["The Rand Project Developers"] description = "HC128 random number generator\n" -homepage = "https://crates.io/crates/rand_hc" -documentation = "https://rust-random.github.io/rand/rand_hc/" +homepage = "https://rust-random.github.io/book" +documentation = "https://docs.rs/rand_hc" readme = "README.md" keywords = ["random", "rng", "hc128"] categories = ["algorithms", "no-std"] -license = "MIT/Apache-2.0" +license = "MIT OR Apache-2.0" repository = "https://github.com/rust-random/rand" [dependencies.rand_core] -version = "0.5" -[badges.appveyor] -repository = "rust-random/rand" - -[badges.travis-ci] -repository = "rust-random/rand" +version = "0.6.0" diff -Nru cargo-0.57.0+ubuntu/vendor/rand_hc/CHANGELOG.md cargo-0.58.0/vendor/rand_hc/CHANGELOG.md --- cargo-0.57.0+ubuntu/vendor/rand_hc/CHANGELOG.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_hc/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 @@ -4,6 +4,15 @@ 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.3.1] - 2021-06-15 +- Adjust crate links + +## [0.3.0] - 2020-12-08 +- Bump `rand_core` version to 0.6.0 +- Bump MSRV to 1.36 (#1011) +- impl PartialEq+Eq for Hc128Rng and Hc128Core (#979) +- Drop some unsafe code, fixing an unsound internal function (#960) + ## [0.2.0] - 2019-06-12 - Bump minor crate version since rand_core bump is a breaking change - Switch to Edition 2018 diff -Nru cargo-0.57.0+ubuntu/vendor/rand_hc/README.md cargo-0.58.0/vendor/rand_hc/README.md --- cargo-0.57.0+ubuntu/vendor/rand_hc/README.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_hc/README.md 2022-01-21 02:47:39.000000000 +0000 @@ -1,12 +1,11 @@ # rand_hc -[![Build Status](https://travis-ci.org/rust-random/rand.svg)](https://travis-ci.org/rust-random/rand) -[![Build Status](https://ci.appveyor.com/api/projects/status/github/rust-random/rand?svg=true)](https://ci.appveyor.com/project/rust-random/rand) +[![Test Status](https://github.com/rust-random/rand/workflows/Tests/badge.svg?event=push)](https://github.com/rust-random/rand/actions) [![Latest version](https://img.shields.io/crates/v/rand_hc.svg)](https://crates.io/crates/rand_hc) [[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) [![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_hc) [![API](https://docs.rs/rand_hc/badge.svg)](https://docs.rs/rand_hc) -[![Minimum rustc version](https://img.shields.io/badge/rustc-1.32+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) +[![Minimum rustc version](https://img.shields.io/badge/rustc-1.36+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) A cryptographically secure random number generator that uses the HC-128 algorithm. diff -Nru cargo-0.57.0+ubuntu/vendor/rand_hc/src/hc128.rs cargo-0.58.0/vendor/rand_hc/src/hc128.rs --- cargo-0.57.0+ubuntu/vendor/rand_hc/src/hc128.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_hc/src/hc128.rs 2022-01-21 02:47:39.000000000 +0000 @@ -6,11 +6,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// Disable some noisy clippy lints. +#![allow(clippy::many_single_char_names)] +#![allow(clippy::identity_op)] +// Disable a lint that cannot be fixed without increasing the MSRV +#![allow(clippy::op_ref)] + //! The HC-128 random number generator. use core::fmt; -use rand_core::{CryptoRng, RngCore, SeedableRng, Error, le}; -use rand_core::block::{BlockRngCore, BlockRng}; +use rand_core::block::{BlockRng, BlockRngCore}; +use rand_core::{le, CryptoRng, Error, RngCore, SeedableRng}; const SEED_WORDS: usize = 8; // 128 bit key followed by 128 bit iv @@ -104,6 +110,13 @@ impl CryptoRng for Hc128Rng {} +impl PartialEq for Hc128Rng { + fn eq(&self, rhs: &Self) -> bool { + self.0.core == rhs.0.core && self.0.index() == rhs.0.index() + } +} +impl Eq for Hc128Rng {} + /// The core of `Hc128Rng`, used with `BlockRng`. #[derive(Clone)] pub struct Hc128Core { @@ -128,6 +141,12 @@ let cc = self.counter1024 % 512; let dd = (cc + 16) % 512; let ee = cc.wrapping_sub(16) % 512; + // These asserts let the compiler optimize out the bounds checks. + // Some of them may be superflous, and that's fine: + // they'll be optimized out if that's the case. + assert!(ee + 15 < 512); + assert!(cc + 15 < 512); + assert!(dd < 512); if self.counter1024 & 512 == 0 { // P block @@ -173,53 +192,43 @@ impl Hc128Core { // One step of HC-128, update P and generate 32 bits keystream #[inline(always)] - fn step_p(&mut self, i: usize, i511: usize, i3: usize, i10: usize, i12: usize) - -> u32 - { + fn step_p(&mut self, i: usize, i511: usize, i3: usize, i10: usize, i12: usize) -> u32 { let (p, q) = self.t.split_at_mut(512); - // FIXME: it would be great if we the bounds checks here could be - // optimized out, and we would not need unsafe. - // This improves performance by about 7%. - unsafe { - let temp0 = p.get_unchecked(i511).rotate_right(23); - let temp1 = p.get_unchecked(i3).rotate_right(10); - let temp2 = p.get_unchecked(i10).rotate_right(8); - *p.get_unchecked_mut(i) = p.get_unchecked(i) - .wrapping_add(temp2) - .wrapping_add(temp0 ^ temp1); - let temp3 = { - // The h1 function in HC-128 - let a = *p.get_unchecked(i12) as u8; - let c = (p.get_unchecked(i12) >> 16) as u8; - q[a as usize].wrapping_add(q[256 + c as usize]) - }; - temp3 ^ p.get_unchecked(i) - } + let temp0 = p[i511].rotate_right(23); + let temp1 = p[i3].rotate_right(10); + let temp2 = p[i10].rotate_right(8); + p[i] = p[i] + .wrapping_add(temp2) + .wrapping_add(temp0 ^ temp1); + let temp3 = { + // The h1 function in HC-128 + let a = p[i12] as u8; + let c = (p[i12] >> 16) as u8; + q[a as usize].wrapping_add(q[256 + c as usize]) + }; + temp3 ^ p[i] } // One step of HC-128, update Q and generate 32 bits keystream // Similar to `step_p`, but `p` and `q` are swapped, and the rotates are to // the left instead of to the right. #[inline(always)] - fn step_q(&mut self, i: usize, i511: usize, i3: usize, i10: usize, i12: usize) - -> u32 - { + fn step_q(&mut self, i: usize, i511: usize, i3: usize, i10: usize, i12: usize) -> u32 { let (p, q) = self.t.split_at_mut(512); - unsafe { - let temp0 = q.get_unchecked(i511).rotate_left(23); - let temp1 = q.get_unchecked(i3).rotate_left(10); - let temp2 = q.get_unchecked(i10).rotate_left(8); - *q.get_unchecked_mut(i) = q.get_unchecked(i) - .wrapping_add(temp2) - .wrapping_add(temp0 ^ temp1); - let temp3 = { - // The h2 function in HC-128 - let a = *q.get_unchecked(i12) as u8; - let c = (q.get_unchecked(i12) >> 16) as u8; - p[a as usize].wrapping_add(p[256 + c as usize]) - }; - temp3 ^ q.get_unchecked(i) - } + let temp0 = q[i511].rotate_left(23); + let temp1 = q[i3].rotate_left(10); + let temp2 = q[i10].rotate_left(8); + q[i] = q + [i] + .wrapping_add(temp2) + .wrapping_add(temp0 ^ temp1); + let temp3 = { + // The h2 function in HC-128 + let a = q[i12] as u8; + let c = (q[i12] >> 16) as u8; + p[a as usize].wrapping_add(p[256 + c as usize]) + }; + temp3 ^ q[i] } fn sixteen_steps(&mut self) { @@ -228,6 +237,12 @@ let cc = self.counter1024 % 512; let dd = (cc + 16) % 512; let ee = cc.wrapping_sub(16) % 512; + // These asserts let the compiler optimize out the bounds checks. + // Some of them may be superflous, and that's fine: + // they'll be optimized out if that's the case. + assert!(ee + 15 < 512); + assert!(cc + 15 < 512); + assert!(dd < 512); if self.counter1024 < 512 { // P block @@ -272,7 +287,7 @@ // Initialize an HC-128 random number generator. The seed has to be // 256 bits in length (`[u32; 8]`), matching the 128 bit `key` followed by // 128 bit `iv` when HC-128 where to be used as a stream cipher. - #[inline(always)] // single use: SeedableRng::from_seed + #[inline(always)] // single use: SeedableRng::from_seed fn init(seed: [u32; SEED_WORDS]) -> Self { #[inline] fn f1(x: u32) -> u32 { @@ -295,9 +310,12 @@ // Generate the 256 intermediate values W[16] ... W[256+16-1], and // copy the last 16 generated values to the start op P. - for i in 16..256+16 { - t[i] = f2(t[i-2]).wrapping_add(t[i-7]).wrapping_add(f1(t[i-15])) - .wrapping_add(t[i-16]).wrapping_add(i as u32); + for i in 16..256 + 16 { + t[i] = f2(t[i - 2]) + .wrapping_add(t[i - 7]) + .wrapping_add(f1(t[i - 15])) + .wrapping_add(t[i - 16]) + .wrapping_add(i as u32); } { let (p1, p2) = t.split_at_mut(256); @@ -306,21 +324,26 @@ // Generate both the P and Q tables for i in 16..1024 { - t[i] = f2(t[i-2]).wrapping_add(t[i-7]).wrapping_add(f1(t[i-15])) - .wrapping_add(t[i-16]).wrapping_add(256 + i as u32); + t[i] = f2(t[i - 2]) + .wrapping_add(t[i - 7]) + .wrapping_add(f1(t[i - 15])) + .wrapping_add(t[i - 16]) + .wrapping_add(256 + i as u32); } let mut core = Self { t, counter1024: 0 }; // run the cipher 1024 steps - for _ in 0..64 { core.sixteen_steps() }; + for _ in 0..64 { + core.sixteen_steps() + } core.counter1024 = 0; core } } impl SeedableRng for Hc128Core { - type Seed = [u8; SEED_WORDS*4]; + type Seed = [u8; SEED_WORDS * 4]; /// Create an HC-128 random number generator with a seed. The seed has to be /// 256 bits in length, matching the 128 bit `key` followed by 128 bit `iv` @@ -334,20 +357,32 @@ impl CryptoRng for Hc128Core {} +// Custom PartialEq implementation as it can't currently be derived from an array of size 1024 +impl PartialEq for Hc128Core { + fn eq(&self, rhs: &Self) -> bool { + &self.t[..] == &rhs.t[..] && self.counter1024 == rhs.counter1024 + } +} +impl Eq for Hc128Core {} + #[cfg(test)] mod test { - use ::rand_core::{RngCore, SeedableRng}; use super::Hc128Rng; + use ::rand_core::{RngCore, SeedableRng}; #[test] // Test vector 1 from the paper "The Stream Cipher HC-128" fn test_hc128_true_values_a() { + #[rustfmt::skip] let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv let mut rng = Hc128Rng::from_seed(seed); let mut results = [0u32; 16]; - for i in results.iter_mut() { *i = rng.next_u32(); } + for i in results.iter_mut() { + *i = rng.next_u32(); + } + #[rustfmt::skip] let expected = [0x73150082, 0x3bfd03a0, 0xfb2fd77f, 0xaa63af0e, 0xde122fc6, 0xa7dc29b6, 0x62a68527, 0x8b75ec68, 0x9036db1e, 0x81896005, 0x00ade078, 0x491fbf9a, @@ -358,12 +393,16 @@ #[test] // Test vector 2 from the paper "The Stream Cipher HC-128" fn test_hc128_true_values_b() { + #[rustfmt::skip] let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key 1,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv let mut rng = Hc128Rng::from_seed(seed); let mut results = [0u32; 16]; - for i in results.iter_mut() { *i = rng.next_u32(); } + for i in results.iter_mut() { + *i = rng.next_u32(); + } + #[rustfmt::skip] let expected = [0xc01893d5, 0xb7dbe958, 0x8f65ec98, 0x64176604, 0x36fc6724, 0xc82c6eec, 0x1b1c38a7, 0xc9b42a95, 0x323ef123, 0x0a6a908b, 0xce757b68, 0x9f14f7bb, @@ -374,12 +413,16 @@ #[test] // Test vector 3 from the paper "The Stream Cipher HC-128" fn test_hc128_true_values_c() { + #[rustfmt::skip] let seed = [0x55,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv let mut rng = Hc128Rng::from_seed(seed); let mut results = [0u32; 16]; - for i in results.iter_mut() { *i = rng.next_u32(); } + for i in results.iter_mut() { + *i = rng.next_u32(); + } + #[rustfmt::skip] let expected = [0x518251a4, 0x04b4930a, 0xb02af931, 0x0639f032, 0xbcb4a47a, 0x5722480b, 0x2bf99f72, 0xcdc0e566, 0x310f0c56, 0xd3cc83e8, 0x663db8ef, 0x62dfe07f, @@ -389,12 +432,16 @@ #[test] fn test_hc128_true_values_u64() { + #[rustfmt::skip] let seed = [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv let mut rng = Hc128Rng::from_seed(seed); let mut results = [0u64; 8]; - for i in results.iter_mut() { *i = rng.next_u64(); } + for i in results.iter_mut() { + *i = rng.next_u64(); + } + #[rustfmt::skip] let expected = [0x3bfd03a073150082, 0xaa63af0efb2fd77f, 0xa7dc29b6de122fc6, 0x8b75ec6862a68527, 0x818960059036db1e, 0x491fbf9a00ade078, @@ -404,9 +451,14 @@ // The RNG operates in a P block of 512 results and next a Q block. // After skipping 2*800 u32 results we end up somewhere in the Q block // of the second round - for _ in 0..800 { rng.next_u64(); } + for _ in 0..800 { + rng.next_u64(); + } - for i in results.iter_mut() { *i = rng.next_u64(); } + for i in results.iter_mut() { + *i = rng.next_u64(); + } + #[rustfmt::skip] let expected = [0xd8c4d6ca84d0fc10, 0xf16a5d91dc66e8e7, 0xd800de5bc37a8653, 0x7bae1f88c0dfbb4c, 0x3bfe1f374e6d4d14, 0x424b55676be3fa06, @@ -416,9 +468,11 @@ #[test] fn test_hc128_true_values_bytes() { + #[rustfmt::skip] let seed = [0x55,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv let mut rng = Hc128Rng::from_seed(seed); + #[rustfmt::skip] let expected = [0x31, 0xf9, 0x2a, 0xb0, 0x32, 0xf0, 0x39, 0x06, 0x7a, 0xa4, 0xb4, 0xbc, 0x0b, 0x48, 0x22, 0x57, 0x72, 0x9f, 0xf9, 0x2b, 0x66, 0xe5, 0xc0, 0xcd, @@ -439,7 +493,7 @@ // Pick a somewhat large buffer so we can test filling with the // remainder from `state.results`, directly filling the buffer, and // filling the remainder of the buffer. - let mut buffer = [0u8; 16*4*2]; + let mut buffer = [0u8; 16 * 4 * 2]; // Consume a value so that we have a remainder. assert!(rng.next_u64() == 0x04b4930a518251a4); rng.fill_bytes(&mut buffer); @@ -453,6 +507,7 @@ #[test] fn test_hc128_clone() { + #[rustfmt::skip] let seed = [0x55,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, // key 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]; // iv let mut rng1 = Hc128Rng::from_seed(seed); diff -Nru cargo-0.57.0+ubuntu/vendor/rand_hc/src/lib.rs cargo-0.58.0/vendor/rand_hc/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/rand_hc/src/lib.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/rand_hc/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -8,16 +8,16 @@ //! The HC128 random number generator. -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", - html_favicon_url = "https://www.rust-lang.org/favicon.ico", - html_root_url = "https://rust-random.github.io/rand/")] - +#![doc( + html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", + html_favicon_url = "https://www.rust-lang.org/favicon.ico", + html_root_url = "https://rust-random.github.io/rand/" +)] #![deny(missing_docs)] #![deny(missing_debug_implementations)] #![doc(test(attr(allow(unused_variables), deny(warnings))))] - #![no_std] mod hc128; -pub use hc128::{Hc128Rng, Hc128Core}; +pub use hc128::{Hc128Core, Hc128Rng}; diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/build.rs cargo-0.58.0/vendor/redox_syscall/build.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/build.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/build.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -use std::env; - -pub fn main() { - if let Ok(os) = env::var("CARGO_CFG_TARGET_OS") { - if os == "redox" { - println!("cargo:rustc-cfg=nightly"); - } - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/.cargo-checksum.json cargo-0.58.0/vendor/redox_syscall/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/redox_syscall/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"} \ No newline at end of file +{"files":{},"package":"8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/Cargo.toml cargo-0.58.0/vendor/redox_syscall/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/redox_syscall/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -3,16 +3,16 @@ # 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 = "redox_syscall" -version = "0.1.57" +version = "0.2.10" authors = ["Jeremy Soller "] description = "A Rust library to access raw Redox system calls" documentation = "https://docs.rs/redox_syscall" @@ -21,3 +21,5 @@ [lib] name = "syscall" +[dependencies.bitflags] +version = "1.1.0" diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/debian/patches/no-nightly.patch cargo-0.58.0/vendor/redox_syscall/debian/patches/no-nightly.patch --- cargo-0.57.0+ubuntu/vendor/redox_syscall/debian/patches/no-nightly.patch 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/debian/patches/no-nightly.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -diff --git a/build.rs b/build.rs -new file mode 100644 -index 0000000..ca906fa ---- /dev/null -+++ b/build.rs -@@ -0,0 +1,9 @@ -+use std::env; -+ -+pub fn main() { -+ if let Ok(os) = env::var("CARGO_CFG_TARGET_OS") { -+ if os == "redox" { -+ println!("cargo:rustc-cfg=nightly"); -+ } -+ } -+} -diff --git a/src/lib.rs b/src/lib.rs -index 6b8d130..42526f0 100644 ---- a/src/lib.rs -+++ b/src/lib.rs -@@ -1,5 +1,5 @@ --#![feature(llvm_asm)] --#![feature(const_fn)] -+#![cfg_attr(nightly, feature(llvm_asm))] -+#![cfg_attr(nightly, feature(const_fn))] - #![cfg_attr(not(test), no_std)] - - #[cfg(test)] -@@ -10,6 +10,7 @@ pub use self::call::*; - pub use self::data::*; - pub use self::error::*; - pub use self::flag::*; -+#[cfg(target_os = "redox")] - pub use self::io::*; - pub use self::number::*; - pub use self::scheme::*; -@@ -47,6 +48,7 @@ pub mod error; - pub mod flag; - - /// Functions for low level hardware control -+#[cfg(target_os = "redox")] - pub mod io; - - /// Call numbers used by each system call diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/debian/patches/series cargo-0.58.0/vendor/redox_syscall/debian/patches/series --- cargo-0.57.0+ubuntu/vendor/redox_syscall/debian/patches/series 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -no-nightly.patch diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/arch/aarch64.rs cargo-0.58.0/vendor/redox_syscall/src/arch/aarch64.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/arch/aarch64.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/arch/aarch64.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,77 +1,132 @@ -use super::error::{Error, Result}; - -pub unsafe fn syscall0(mut a: usize) -> Result { - llvm_asm!("svc 0" - : "={x0}"(a) - : "{x8}"(a) - : "x0", "x8" - : "volatile"); - - Error::demux(a) -} - -pub unsafe fn syscall1(mut a: usize, b: usize) -> Result { - llvm_asm!("svc 0" - : "={x0}"(a) - : "{x8}"(a), "{x0}"(b) - : "x0", "x8" - : "volatile"); - - Error::demux(a) -} - -// Clobbers all registers - special for clone -pub unsafe fn syscall1_clobber(mut a: usize, b: usize) -> Result { - llvm_asm!("svc 0" - : "={x0}"(a) - : "{x8}"(a), "{x0}"(b) - : "memory", - "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", - "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15", - "x16", "x17","x18", "x19", "x20", "x21", "x22", "x23", - "x24", "x25", "x26", "x27", "x28", "x29", "x30" - : "volatile"); - - Error::demux(a) -} +use core::{mem, slice}; +use core::ops::{Deref, DerefMut}; -pub unsafe fn syscall2(mut a: usize, b: usize, c: usize) -> Result { - llvm_asm!("svc 0" - : "={x0}"(a) - : "{x8}"(a), "{x0}"(b), "{x1}"(c) - : "x0", "x1", "x8" - : "volatile"); - - Error::demux(a) -} - -pub unsafe fn syscall3(mut a: usize, b: usize, c: usize, d: usize) -> Result { - llvm_asm!("svc 0" - : "={x0}"(a) - : "{x8}"(a), "{x0}"(b), "{x1}"(c), "{x2}"(d) - : "x0", "x1", "x2", "x8" - : "volatile"); - - Error::demux(a) -} - -pub unsafe fn syscall4(mut a: usize, b: usize, c: usize, d: usize, e: usize) -> Result { - llvm_asm!("svc 0" - : "={x0}"(a) - : "{x8}"(a), "{x0}"(b), "{x1}"(c), "{x2}"(d), "{x3}"(e) - : "x0", "x1", "x2", "x3", "x8" - : "volatile"); - - Error::demux(a) -} - -pub unsafe fn syscall5(mut a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) - -> Result { - llvm_asm!("svc 0" - : "={x0}"(a) - : "{x8}"(a), "{x0}"(b), "{x1}"(c), "{x2}"(d), "{x3}"(e), "{x4}"(f) - : "x0", "x1", "x2", "x3", "x4", "x8" - : "volatile"); +use super::error::{Error, Result}; - Error::demux(a) +macro_rules! syscall { + ($($name:ident($a:ident, $($b:ident, $($c:ident, $($d:ident, $($e:ident, $($f:ident, )?)?)?)?)?);)+) => { + $( + pub unsafe fn $name($a: usize, $($b: usize, $($c: usize, $($d: usize, $($e: usize, $($f: usize)?)?)?)?)?) -> Result { + let ret: usize; + + asm!( + "svc 0", + in("x8") $a, + $( + in("x0") $b, + $( + in("x1") $c, + $( + in("x2") $d, + $( + in("x3") $e, + $( + in("x4") $f, + )? + )? + )? + )? + )? + lateout("x0") ret, + options(nostack), + ); + + Error::demux(ret) + } + )+ + }; +} + +syscall! { + syscall0(a,); + syscall1(a, b,); + syscall2(a, b, c,); + syscall3(a, b, c, d,); + syscall4(a, b, c, d, e,); + syscall5(a, b, c, d, e, f,); +} + +#[derive(Copy, Clone, Debug, Default)] +#[repr(C)] +pub struct IntRegisters { + pub elr_el1: usize, + pub tpidr_el0: usize, + pub tpidrro_el0: usize, + pub spsr_el1: usize, + pub esr_el1: usize, + pub sp_el0: usize, // Shouldn't be used if interrupt occurred at EL1 + pub padding: usize, // To keep the struct even number aligned + pub x30: usize, + pub x29: usize, + pub x28: usize, + pub x27: usize, + pub x26: usize, + pub x25: usize, + pub x24: usize, + pub x23: usize, + pub x22: usize, + pub x21: usize, + pub x20: usize, + pub x19: usize, + pub x18: usize, + pub x17: usize, + pub x16: usize, + pub x15: usize, + pub x14: usize, + pub x13: usize, + pub x12: usize, + pub x11: usize, + pub x10: usize, + pub x9: usize, + pub x8: usize, + pub x7: usize, + pub x6: usize, + pub x5: usize, + pub x4: usize, + pub x3: usize, + pub x2: usize, + pub x1: usize, + pub x0: usize +} + +impl Deref for IntRegisters { + type Target = [u8]; + fn deref(&self) -> &[u8] { + unsafe { + slice::from_raw_parts(self as *const IntRegisters as *const u8, mem::size_of::()) + } + } +} + +impl DerefMut for IntRegisters { + fn deref_mut(&mut self) -> &mut [u8] { + unsafe { + slice::from_raw_parts_mut(self as *mut IntRegisters as *mut u8, mem::size_of::()) + } + } +} + +#[derive(Clone, Copy, Debug, Default)] +#[repr(packed)] +pub struct FloatRegisters { + pub fp_simd_regs: [u128; 32], + pub fpsr: u32, + pub fpcr: u32 +} + +impl Deref for FloatRegisters { + type Target = [u8]; + fn deref(&self) -> &[u8] { + unsafe { + slice::from_raw_parts(self as *const FloatRegisters as *const u8, mem::size_of::()) + } + } +} + +impl DerefMut for FloatRegisters { + fn deref_mut(&mut self) -> &mut [u8] { + unsafe { + slice::from_raw_parts_mut(self as *mut FloatRegisters as *mut u8, mem::size_of::()) + } + } } diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/arch/arm.rs cargo-0.58.0/vendor/redox_syscall/src/arch/arm.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/arch/arm.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/arch/arm.rs 2022-01-21 02:47:39.000000000 +0000 @@ -20,17 +20,6 @@ Error::demux(a) } -// Clobbers all registers - special for clone -pub unsafe fn syscall1_clobber(mut a: usize, b: usize) -> Result { - llvm_asm!("swi $$0" - : "={r0}"(a) - : "{r7}"(a), "{r0}"(b) - : "memory", "r0", "r1", "r2", "r3", "r4" - : "volatile"); - - Error::demux(a) -} - pub unsafe fn syscall2(mut a: usize, b: usize, c: usize) -> Result { llvm_asm!("swi $$0" : "={r0}"(a) diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/arch/nonredox.rs cargo-0.58.0/vendor/redox_syscall/src/arch/nonredox.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/arch/nonredox.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/arch/nonredox.rs 2022-01-21 02:47:39.000000000 +0000 @@ -8,11 +8,6 @@ Err(Error::new(ENOSYS)) } -// Clobbers all registers - special for clone -pub unsafe fn syscall1_clobber(_a: usize, _b: usize) -> Result { - Err(Error::new(ENOSYS)) -} - pub unsafe fn syscall2(_a: usize, _b: usize, _c: usize) -> Result { Err(Error::new(ENOSYS)) } diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/arch/riscv64.rs cargo-0.58.0/vendor/redox_syscall/src/arch/riscv64.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/arch/riscv64.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/arch/riscv64.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,93 @@ +use core::{mem, slice}; +use core::ops::{Deref, DerefMut}; + +use super::error::{Error, Result}; + +macro_rules! syscall { + ($($name:ident($a:ident, $($b:ident, $($c:ident, $($d:ident, $($e:ident, $($f:ident, )?)?)?)?)?);)+) => { + $( + pub unsafe fn $name($a: usize, $($b: usize, $($c: usize, $($d: usize, $($e: usize, $($f: usize)?)?)?)?)?) -> Result { + let ret: usize; + + asm!( + "ecall", + in("a7") $a, + $( + in("a0") $b, + $( + in("a1") $c, + $( + in("a2") $d, + $( + in("a3") $e, + $( + in("a4") $f, + )? + )? + )? + )? + )? + lateout("a0") ret, + options(nostack), + ); + + Error::demux(ret) + } + )+ + }; +} + +syscall! { + syscall0(a,); + syscall1(a, b,); + syscall2(a, b, c,); + syscall3(a, b, c, d,); + syscall4(a, b, c, d, e,); + syscall5(a, b, c, d, e, f,); +} + +#[derive(Copy, Clone, Debug, Default)] +#[repr(C)] +pub struct IntRegisters { + //TODO +} + +impl Deref for IntRegisters { + type Target = [u8]; + fn deref(&self) -> &[u8] { + unsafe { + slice::from_raw_parts(self as *const IntRegisters as *const u8, mem::size_of::()) + } + } +} + +impl DerefMut for IntRegisters { + fn deref_mut(&mut self) -> &mut [u8] { + unsafe { + slice::from_raw_parts_mut(self as *mut IntRegisters as *mut u8, mem::size_of::()) + } + } +} + +#[derive(Clone, Copy, Debug, Default)] +#[repr(packed)] +pub struct FloatRegisters { + //TODO +} + +impl Deref for FloatRegisters { + type Target = [u8]; + fn deref(&self) -> &[u8] { + unsafe { + slice::from_raw_parts(self as *const FloatRegisters as *const u8, mem::size_of::()) + } + } +} + +impl DerefMut for FloatRegisters { + fn deref_mut(&mut self) -> &mut [u8] { + unsafe { + slice::from_raw_parts_mut(self as *mut FloatRegisters as *mut u8, mem::size_of::()) + } + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/arch/x86_64.rs cargo-0.58.0/vendor/redox_syscall/src/arch/x86_64.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/arch/x86_64.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/arch/x86_64.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,74 +1,154 @@ -use super::error::{Error, Result}; - -pub unsafe fn syscall0(mut a: usize) -> Result { - llvm_asm!("syscall" - : "={rax}"(a) - : "{rax}"(a) - : "rcx", "r11", "memory" - : "intel", "volatile"); - - Error::demux(a) -} - -pub unsafe fn syscall1(mut a: usize, b: usize) -> Result { - llvm_asm!("syscall" - : "={rax}"(a) - : "{rax}"(a), "{rdi}"(b) - : "rcx", "r11", "memory" - : "intel", "volatile"); - - Error::demux(a) -} - -// Clobbers all registers - special for clone -pub unsafe fn syscall1_clobber(mut a: usize, b: usize) -> Result { - llvm_asm!("syscall" - : "={rax}"(a) - : "{rax}"(a), "{rdi}"(b) - : "memory", "rbx", "rcx", "rdx", "rsi", "rdi", "r8", - "r9", "r10", "r11", "r12", "r13", "r14", "r15" - : "intel", "volatile"); - - Error::demux(a) -} +use core::{mem, slice}; +use core::ops::{Deref, DerefMut}; -pub unsafe fn syscall2(mut a: usize, b: usize, c: usize) -> Result { - llvm_asm!("syscall" - : "={rax}"(a) - : "{rax}"(a), "{rdi}"(b), "{rsi}"(c) - : "rcx", "r11", "memory" - : "intel", "volatile"); - - Error::demux(a) -} - -pub unsafe fn syscall3(mut a: usize, b: usize, c: usize, d: usize) -> Result { - llvm_asm!("syscall" - : "={rax}"(a) - : "{rax}"(a), "{rdi}"(b), "{rsi}"(c), "{rdx}"(d) - : "rcx", "r11", "memory" - : "intel", "volatile"); - - Error::demux(a) -} - -pub unsafe fn syscall4(mut a: usize, b: usize, c: usize, d: usize, e: usize) -> Result { - llvm_asm!("syscall" - : "={rax}"(a) - : "{rax}"(a), "{rdi}"(b), "{rsi}"(c), "{rdx}"(d), "{r10}"(e) - : "rcx", "r11", "memory" - : "intel", "volatile"); - - Error::demux(a) -} - -pub unsafe fn syscall5(mut a: usize, b: usize, c: usize, d: usize, e: usize, f: usize) - -> Result { - llvm_asm!("syscall" - : "={rax}"(a) - : "{rax}"(a), "{rdi}"(b), "{rsi}"(c), "{rdx}"(d), "{r10}"(e), "{r8}"(f) - : "rcx", "r11", "memory" - : "intel", "volatile"); +use super::error::{Error, Result}; - Error::demux(a) +macro_rules! syscall { + ($($name:ident($a:ident, $($b:ident, $($c:ident, $($d:ident, $($e:ident, $($f:ident, )?)?)?)?)?);)+) => { + $( + pub unsafe fn $name(mut $a: usize, $($b: usize, $($c: usize, $($d: usize, $($e: usize, $($f: usize)?)?)?)?)?) -> Result { + asm!( + "syscall", + inout("rax") $a, + $( + in("rdi") $b, + $( + in("rsi") $c, + $( + in("rdx") $d, + $( + in("r10") $e, + $( + in("r8") $f, + )? + )? + )? + )? + )? + out("rcx") _, + out("r11") _, + options(nostack), + ); + + Error::demux($a) + } + )+ + }; +} + +syscall! { + syscall0(a,); + syscall1(a, b,); + syscall2(a, b, c,); + syscall3(a, b, c, d,); + syscall4(a, b, c, d, e,); + syscall5(a, b, c, d, e, f,); +} + +#[derive(Copy, Clone, Debug, Default)] +#[repr(C)] +pub struct IntRegisters { + // TODO: Some of these don't get set by Redox yet. Should they? + + pub r15: usize, + pub r14: usize, + pub r13: usize, + pub r12: usize, + pub rbp: usize, + pub rbx: usize, + pub r11: usize, + pub r10: usize, + pub r9: usize, + pub r8: usize, + pub rax: usize, + pub rcx: usize, + pub rdx: usize, + pub rsi: usize, + pub rdi: usize, + // pub orig_rax: usize, + pub rip: usize, + pub cs: usize, + pub rflags: usize, + pub rsp: usize, + pub ss: usize, + // pub fs_base: usize, + // pub gs_base: usize, + // pub ds: usize, + // pub es: usize, + pub fs: usize, + // pub gs: usize +} + +impl Deref for IntRegisters { + type Target = [u8]; + fn deref(&self) -> &[u8] { + unsafe { + slice::from_raw_parts(self as *const IntRegisters as *const u8, mem::size_of::()) + } + } +} + +impl DerefMut for IntRegisters { + fn deref_mut(&mut self) -> &mut [u8] { + unsafe { + slice::from_raw_parts_mut(self as *mut IntRegisters as *mut u8, mem::size_of::()) + } + } +} + +#[derive(Clone, Copy, Debug, Default)] +#[repr(packed)] +pub struct FloatRegisters { + pub fcw: u16, + pub fsw: u16, + pub ftw: u8, + pub _reserved: u8, + pub fop: u16, + pub fip: u64, + pub fdp: u64, + pub mxcsr: u32, + pub mxcsr_mask: u32, + pub st_space: [u128; 8], + pub xmm_space: [u128; 16], + // TODO: YMM/ZMM +} + +impl Deref for FloatRegisters { + type Target = [u8]; + fn deref(&self) -> &[u8] { + unsafe { + slice::from_raw_parts(self as *const FloatRegisters as *const u8, mem::size_of::()) + } + } +} + +impl DerefMut for FloatRegisters { + fn deref_mut(&mut self) -> &mut [u8] { + unsafe { + slice::from_raw_parts_mut(self as *mut FloatRegisters as *mut u8, mem::size_of::()) + } + } +} +#[derive(Clone, Copy, Debug, Default)] +#[repr(packed)] +pub struct EnvRegisters { + pub fsbase: u64, + pub gsbase: u64, + // TODO: PKRU? +} +impl Deref for EnvRegisters { + type Target = [u8]; + fn deref(&self) -> &[u8] { + unsafe { + slice::from_raw_parts(self as *const EnvRegisters as *const u8, mem::size_of::()) + } + } +} + +impl DerefMut for EnvRegisters { + fn deref_mut(&mut self) -> &mut [u8] { + unsafe { + slice::from_raw_parts_mut(self as *mut EnvRegisters as *mut u8, mem::size_of::()) + } + } } diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/arch/x86.rs cargo-0.58.0/vendor/redox_syscall/src/arch/x86.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/arch/x86.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/arch/x86.rs 2022-01-21 02:47:39.000000000 +0000 @@ -20,17 +20,6 @@ Error::demux(a) } -// Clobbers all registers - special for clone -pub unsafe fn syscall1_clobber(mut a: usize, b: usize) -> Result { - llvm_asm!("int 0x80" - : "={eax}"(a) - : "{eax}"(a), "{ebx}"(b) - : "memory", "ebx", "ecx", "edx", "esi", "edi" - : "intel", "volatile"); - - Error::demux(a) -} - pub unsafe fn syscall2(mut a: usize, b: usize, c: usize) -> Result { llvm_asm!("int 0x80" : "={eax}"(a) diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/call.rs cargo-0.58.0/vendor/redox_syscall/src/call.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/call.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/call.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,6 +1,7 @@ use super::arch::*; use super::data::{Map, SigAction, Stat, StatVfs, TimeSpec}; use super::error::Result; +use super::flag::*; use super::number::*; use core::{mem, ptr}; @@ -11,20 +12,6 @@ unreachable!(); } -/// Set the end of the process's heap -/// -/// When `addr` is `0`, this function will return the current break. -/// -/// When `addr` is nonzero, this function will attempt to set the end of the process's -/// heap to `addr` and return the new program break. The new program break should be -/// checked by the allocator, it may not be exactly `addr`, as it may be aligned to a page -/// boundary. -/// -/// On error, `Err(ENOMEM)` will be returned indicating that no memory is available -pub unsafe fn brk(addr: usize) -> Result { - syscall1(SYS_BRK, addr) -} - /// Change the process's working directory /// /// This function will attempt to set the process's working directory to `path`, which can be @@ -39,7 +26,7 @@ /// * `EIO` - an I/O error occurred /// * `ENOENT` - `path` does not exit /// * `ENOTDIR` - `path` is not a directory -pub fn chdir>(path: T) -> Result { +pub fn chdir>(path: T) -> Result { unsafe { syscall2(SYS_CHDIR, path.as_ref().as_ptr() as usize, path.as_ref().len()) } } @@ -47,13 +34,13 @@ since = "0.1.55", note = "use fchmod instead" )] -pub fn chmod>(path: T, mode: usize) -> Result { +pub fn chmod>(path: T, mode: usize) -> Result { unsafe { syscall3(SYS_CHMOD, path.as_ref().as_ptr() as usize, path.as_ref().len(), mode) } } /// Produce a fork of the current process, or a new process thread -pub unsafe fn clone(flags: usize) -> Result { - syscall1_clobber(SYS_CLONE, flags) +pub unsafe fn clone(flags: CloneFlags) -> Result { + syscall1(SYS_CLONE, flags.bits()) } /// Close a file @@ -103,14 +90,23 @@ unsafe { syscall5(SYS_FEXEC, fd, args.as_ptr() as usize, args.len(), vars.as_ptr() as usize, vars.len()) } } -/// Map a file into memory +/// Map a file into memory, but with the ability to set the address to map into, either as a hint +/// or as a requirement of the map. +/// +/// # Errors +/// `EACCES` - the file descriptor was not open for reading +/// `EBADF` - if the file descriptor was invalid +/// `ENODEV` - mmapping was not supported +/// `EINVAL` - invalid combination of flags +/// `EEXIST` - if [`MapFlags::MAP_FIXED`] was set, and the address specified was already in use. +/// pub unsafe fn fmap(fd: usize, map: &Map) -> Result { syscall3(SYS_FMAP, fd, map as *const Map as usize, mem::size_of::()) } -/// Unmap a memory-mapped file -pub unsafe fn funmap(addr: usize) -> Result { - syscall1(SYS_FUNMAP, addr) +/// Unmap whole (or partial) continous memory-mapped files +pub unsafe fn funmap(addr: usize, len: usize) -> Result { + syscall2(SYS_FUNMAP, addr, len) } /// Retrieve the canonical path of a file @@ -119,7 +115,7 @@ } /// Rename a file -pub fn frename>(fd: usize, path: T) -> Result { +pub fn frename>(fd: usize, path: T) -> Result { unsafe { syscall3(SYS_FRENAME, fd, path.as_ref().as_ptr() as usize, path.as_ref().len()) } } @@ -235,8 +231,8 @@ } /// Change mapping flags -pub unsafe fn mprotect(addr: usize, size: usize, flags: usize) -> Result { - syscall3(SYS_MPROTECT, addr, size, flags) +pub unsafe fn mprotect(addr: usize, size: usize, flags: MapFlags) -> Result { + syscall3(SYS_MPROTECT, addr, size, flags.bits()) } /// Sleep for the time specified in `req` @@ -246,11 +242,11 @@ } /// Open a file -pub fn open>(path: T, flags: usize) -> Result { +pub fn open>(path: T, flags: usize) -> Result { unsafe { syscall3(SYS_OPEN, path.as_ref().as_ptr() as usize, path.as_ref().len(), flags) } } -/// Allocate pages, linearly in physical memory +/// Allocate frames, linearly in physical memory. /// /// # Errors /// @@ -260,6 +256,37 @@ syscall1(SYS_PHYSALLOC, size) } +/// Allocate frames, linearly in physical memory, with an extra set of flags. If the flags contain +/// [`PARTIAL_ALLOC`], this will result in `physalloc3` with `min = 1`. +/// +/// Refer to the simpler [`physalloc`] and the more complex [`physalloc3`], that this convenience +/// function is based on. +/// +/// # Errors +/// +/// * `EPERM` - `uid != 0` +/// * `ENOMEM` - the system has run out of available memory +pub unsafe fn physalloc2(size: usize, flags: usize) -> Result { + let mut ret = 1usize; + physalloc3(size, flags, &mut ret) +} + +/// Allocate frames, linearly in physical memory, with an extra set of flags. If the flags contain +/// [`PARTIAL_ALLOC`], the `min` parameter specifies the number of frames that have to be allocated +/// for this operation to succeed. The return value is the offset of the first frame, and `min` is +/// overwritten with the number of frames actually allocated. +/// +/// Refer to the simpler [`physalloc`] and the simpler library function [`physalloc2`]. +/// +/// # Errors +/// +/// * `EPERM` - `uid != 0` +/// * `ENOMEM` - the system has run out of available memory +/// * `EINVAL` - `min = 0` +pub unsafe fn physalloc3(size: usize, flags: usize, min: &mut usize) -> Result { + syscall3(SYS_PHYSALLOC3, size, flags, min as *mut usize as usize) +} + /// Free physically allocated pages /// /// # Errors @@ -274,8 +301,8 @@ /// # Errors /// /// * `EPERM` - `uid != 0` -pub unsafe fn physmap(physical_address: usize, size: usize, flags: usize) -> Result { - syscall3(SYS_PHYSMAP, physical_address, size, flags) +pub unsafe fn physmap(physical_address: usize, size: usize, flags: PhysmapFlags) -> Result { + syscall3(SYS_PHYSMAP, physical_address, size, flags.bits()) } /// Unmap previously mapped physical memory @@ -299,7 +326,7 @@ } /// Remove a directory -pub fn rmdir>(path: T) -> Result { +pub fn rmdir>(path: T) -> Result { unsafe { syscall2(SYS_RMDIR, path.as_ref().as_ptr() as usize, path.as_ref().len()) } } @@ -349,7 +376,7 @@ } /// Remove a file -pub fn unlink>(path: T) -> Result { +pub fn unlink>(path: T) -> Result { unsafe { syscall2(SYS_UNLINK, path.as_ref().as_ptr() as usize, path.as_ref().len()) } } @@ -363,8 +390,8 @@ } /// Check if a child process has exited or received a signal -pub fn waitpid(pid: usize, status: &mut usize, options: usize) -> Result { - unsafe { syscall3(SYS_WAITPID, pid, status as *mut usize as usize, options) } +pub fn waitpid(pid: usize, status: &mut usize, options: WaitFlags) -> Result { + unsafe { syscall3(SYS_WAITPID, pid, status as *mut usize as usize, options.bits()) } } /// Write a buffer to a file descriptor diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/data.rs cargo-0.58.0/vendor/redox_syscall/src/data.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/data.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/data.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,11 +1,12 @@ use core::ops::{Deref, DerefMut}; use core::{mem, slice}; +use crate::flag::{EventFlags, MapFlags, PtraceFlags, SigActionFlags}; #[derive(Copy, Clone, Debug, Default)] #[repr(C)] pub struct Event { pub id: usize, - pub flags: usize, + pub flags: EventFlags, pub data: usize } @@ -13,7 +14,7 @@ type Target = [u8]; fn deref(&self) -> &[u8] { unsafe { - slice::from_raw_parts(self as *const Event as *const u8, mem::size_of::()) as &[u8] + slice::from_raw_parts(self as *const Event as *const u8, mem::size_of::()) } } } @@ -21,7 +22,7 @@ impl DerefMut for Event { fn deref_mut(&mut self) -> &mut [u8] { unsafe { - slice::from_raw_parts_mut(self as *mut Event as *mut u8, mem::size_of::()) as &mut [u8] + slice::from_raw_parts_mut(self as *mut Event as *mut u8, mem::size_of::()) } } } @@ -38,7 +39,7 @@ fn deref(&self) -> &[u8] { unsafe { slice::from_raw_parts(self as *const ITimerSpec as *const u8, - mem::size_of::()) as &[u8] + mem::size_of::()) } } } @@ -47,24 +48,58 @@ fn deref_mut(&mut self) -> &mut [u8] { unsafe { slice::from_raw_parts_mut(self as *mut ITimerSpec as *mut u8, - mem::size_of::()) as &mut [u8] + mem::size_of::()) } } } #[derive(Copy, Clone, Debug, Default)] #[repr(C)] +pub struct OldMap { + pub offset: usize, + pub size: usize, + pub flags: MapFlags, +} + +impl Deref for OldMap { + type Target = [u8]; + fn deref(&self) -> &[u8] { + unsafe { + slice::from_raw_parts(self as *const OldMap as *const u8, mem::size_of::()) + } + } +} + +impl DerefMut for OldMap { + fn deref_mut(&mut self) -> &mut [u8] { + unsafe { + slice::from_raw_parts_mut(self as *mut OldMap as *mut u8, mem::size_of::()) + } + } +} +#[derive(Copy, Clone, Debug, Default)] +#[repr(C)] pub struct Map { + /// The offset inside the file that is being mapped. pub offset: usize, + + /// The size of the memory map. pub size: usize, - pub flags: usize, + + /// Contains both prot and map flags. + pub flags: MapFlags, + + /// Functions as a hint to where in the virtual address space of the running process, to place + /// the memory map. If [`MapFlags::MAP_FIXED`] is set, then this address must be the address to + /// map to. + pub address: usize, } impl Deref for Map { type Target = [u8]; fn deref(&self) -> &[u8] { unsafe { - slice::from_raw_parts(self as *const Map as *const u8, mem::size_of::()) as &[u8] + slice::from_raw_parts(self as *const Map as *const u8, mem::size_of::()) } } } @@ -72,7 +107,7 @@ impl DerefMut for Map { fn deref_mut(&mut self) -> &mut [u8] { unsafe { - slice::from_raw_parts_mut(self as *mut Map as *mut u8, mem::size_of::()) as &mut [u8] + slice::from_raw_parts_mut(self as *mut Map as *mut u8, mem::size_of::()) } } } @@ -94,7 +129,7 @@ type Target = [u8]; fn deref(&self) -> &[u8] { unsafe { - slice::from_raw_parts(self as *const Packet as *const u8, mem::size_of::()) as &[u8] + slice::from_raw_parts(self as *const Packet as *const u8, mem::size_of::()) } } } @@ -102,30 +137,29 @@ impl DerefMut for Packet { fn deref_mut(&mut self) -> &mut [u8] { unsafe { - slice::from_raw_parts_mut(self as *mut Packet as *mut u8, mem::size_of::()) as &mut [u8] + slice::from_raw_parts_mut(self as *mut Packet as *mut u8, mem::size_of::()) } } } -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone, Debug, Default, PartialEq)] #[repr(C)] pub struct SigAction { - pub sa_handler: extern "C" fn(usize), + pub sa_handler: Option, pub sa_mask: [u64; 2], - pub sa_flags: usize, + pub sa_flags: SigActionFlags, } -impl Default for SigAction { - fn default() -> Self { - Self { - sa_handler: unsafe { mem::transmute(0usize) }, - sa_mask: [0; 2], - sa_flags: 0, - } - } +#[allow(dead_code)] +unsafe fn _assert_size_of_function_is_sane() { + // Transmuting will complain *at compile time* if sizes differ. + // Rust forbids a fn-pointer from being 0 so to allow SIG_DFL to + // exist, we use Option which will mean 0 + // becomes None + let _ = mem::transmute::, usize>(None); } -#[derive(Copy, Clone, Debug, Default)] +#[derive(Copy, Clone, Debug, Default, PartialEq)] #[repr(C)] pub struct Stat { pub st_dev: u64, @@ -150,7 +184,7 @@ fn deref(&self) -> &[u8] { unsafe { slice::from_raw_parts(self as *const Stat as *const u8, - mem::size_of::()) as &[u8] + mem::size_of::()) } } } @@ -159,12 +193,12 @@ fn deref_mut(&mut self) -> &mut [u8] { unsafe { slice::from_raw_parts_mut(self as *mut Stat as *mut u8, - mem::size_of::()) as &mut [u8] + mem::size_of::()) } } } -#[derive(Copy, Clone, Debug, Default)] +#[derive(Copy, Clone, Debug, Default, PartialEq)] #[repr(C)] pub struct StatVfs { pub f_bsize: u32, @@ -178,7 +212,7 @@ fn deref(&self) -> &[u8] { unsafe { slice::from_raw_parts(self as *const StatVfs as *const u8, - mem::size_of::()) as &[u8] + mem::size_of::()) } } } @@ -187,7 +221,7 @@ fn deref_mut(&mut self) -> &mut [u8] { unsafe { slice::from_raw_parts_mut(self as *mut StatVfs as *mut u8, - mem::size_of::()) as &mut [u8] + mem::size_of::()) } } } @@ -204,7 +238,7 @@ fn deref(&self) -> &[u8] { unsafe { slice::from_raw_parts(self as *const TimeSpec as *const u8, - mem::size_of::()) as &[u8] + mem::size_of::()) } } } @@ -213,97 +247,51 @@ fn deref_mut(&mut self) -> &mut [u8] { unsafe { slice::from_raw_parts_mut(self as *mut TimeSpec as *mut u8, - mem::size_of::()) as &mut [u8] + mem::size_of::()) } } } -#[derive(Copy, Clone, Debug, Default)] +#[derive(Clone, Copy, Debug, Default)] #[repr(C)] -#[cfg(target_arch = "x86_64")] -pub struct IntRegisters { - pub r15: usize, - pub r14: usize, - pub r13: usize, - pub r12: usize, - pub rbp: usize, - pub rbx: usize, - pub r11: usize, - pub r10: usize, - pub r9: usize, - pub r8: usize, - pub rax: usize, - pub rcx: usize, - pub rdx: usize, - pub rsi: usize, - pub rdi: usize, - // pub orig_rax: usize, - pub rip: usize, - pub cs: usize, - pub eflags: usize, - pub rsp: usize, - pub ss: usize, - pub fs_base: usize, - pub gs_base: usize, - pub ds: usize, - pub es: usize, - pub fs: usize, - pub gs: usize +pub struct PtraceEvent { + pub cause: PtraceFlags, + pub a: usize, + pub b: usize, + pub c: usize, + pub d: usize, + pub e: usize, + pub f: usize } -impl Deref for IntRegisters { +impl Deref for PtraceEvent { type Target = [u8]; fn deref(&self) -> &[u8] { unsafe { - slice::from_raw_parts(self as *const IntRegisters as *const u8, mem::size_of::()) as &[u8] + slice::from_raw_parts(self as *const PtraceEvent as *const u8, mem::size_of::()) } } } -impl DerefMut for IntRegisters { +impl DerefMut for PtraceEvent { fn deref_mut(&mut self) -> &mut [u8] { unsafe { - slice::from_raw_parts_mut(self as *mut IntRegisters as *mut u8, mem::size_of::()) as &mut [u8] - } - } -} - -#[derive(Clone, Copy)] -#[repr(C)] -#[cfg(target_arch = "x86_64")] -pub struct FloatRegisters { - pub cwd: u16, - pub swd: u16, - pub ftw: u16, - pub fop: u16, - pub rip: u64, - pub rdp: u64, - pub mxcsr: u32, - pub mxcr_mask: u32, - pub st_space: [u32; 32], - pub xmm_space: [u32; 64] -} - -impl Default for FloatRegisters { - fn default() -> Self { - // xmm_space is not Default until const generics - unsafe { mem::zeroed() } - } -} - -impl Deref for FloatRegisters { - type Target = [u8]; - fn deref(&self) -> &[u8] { - unsafe { - slice::from_raw_parts(self as *const FloatRegisters as *const u8, mem::size_of::()) as &[u8] + slice::from_raw_parts_mut(self as *mut PtraceEvent as *mut u8, mem::size_of::()) } } } -impl DerefMut for FloatRegisters { - fn deref_mut(&mut self) -> &mut [u8] { - unsafe { - slice::from_raw_parts_mut(self as *mut FloatRegisters as *mut u8, mem::size_of::()) as &mut [u8] +#[macro_export] +macro_rules! ptrace_event { + ($cause:expr $(, $a:expr $(, $b:expr $(, $c:expr)?)?)?) => { + $crate::data::PtraceEvent { + cause: $cause, + $(a: $a, + $(b: $b, + $(c: $c,)? + )? + )? + ..Default::default() } } } diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/error.rs cargo-0.58.0/vendor/redox_syscall/src/error.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/error.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/error.rs 2022-01-21 02:47:39.000000000 +0000 @@ -5,7 +5,7 @@ pub errno: i32, } -pub type Result = result::Result; +pub type Result = result::Result; impl Error { pub fn new(errno: i32) -> Error { diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/flag.rs cargo-0.58.0/vendor/redox_syscall/src/flag.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/flag.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/flag.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,17 +1,59 @@ -pub const CLONE_VM: usize = 0x100; -pub const CLONE_FS: usize = 0x200; -pub const CLONE_FILES: usize = 0x400; -pub const CLONE_SIGHAND: usize = 0x800; -pub const CLONE_VFORK: usize = 0x4000; -pub const CLONE_THREAD: usize = 0x10000; -pub const CLONE_STACK: usize = 0x1000_0000; +use bitflags::bitflags as inner_bitflags; +use core::{mem, ops::Deref, slice}; + +macro_rules! bitflags { + ( + $(#[$outer:meta])* + pub struct $BitFlags:ident: $T:ty { + $( + $(#[$inner:ident $($args:tt)*])* + const $Flag:ident = $value:expr; + )+ + } + ) => { + // First, use the inner bitflags + inner_bitflags! { + #[derive(Default)] + $(#[$outer])* + pub struct $BitFlags: $T { + $( + $(#[$inner $($args)*])* + const $Flag = $value; + )+ + } + } + + // Secondly, re-export all inner constants + // (`pub use self::Struct::*` doesn't work) + $( + $(#[$inner $($args)*])* + pub const $Flag: $BitFlags = $BitFlags::$Flag; + )+ + } +} + +bitflags! { + pub struct CloneFlags: usize { + const CLONE_VM = 0x100; + const CLONE_FS = 0x200; + const CLONE_FILES = 0x400; + const CLONE_SIGHAND = 0x800; + const CLONE_VFORK = 0x4000; + const CLONE_THREAD = 0x10000; + const CLONE_STACK = 0x1000_0000; + } +} pub const CLOCK_REALTIME: usize = 1; pub const CLOCK_MONOTONIC: usize = 4; -pub const EVENT_NONE: usize = 0; -pub const EVENT_READ: usize = 1; -pub const EVENT_WRITE: usize = 2; +bitflags! { + pub struct EventFlags: usize { + const EVENT_NONE = 0; + const EVENT_READ = 1; + const EVENT_WRITE = 2; + } +} pub const F_DUPFD: usize = 0; pub const F_GETFD: usize = 1; @@ -22,9 +64,23 @@ pub const FUTEX_WAIT: usize = 0; pub const FUTEX_WAKE: usize = 1; pub const FUTEX_REQUEUE: usize = 2; +pub const FUTEX_WAIT64: usize = 3; -pub const MAP_SHARED: usize = 0x0001; -pub const MAP_PRIVATE: usize = 0x0002; +bitflags! { + pub struct MapFlags: usize { + const PROT_NONE = 0x0000_0000; + const PROT_EXEC = 0x0001_0000; + const PROT_WRITE = 0x0002_0000; + const PROT_READ = 0x0004_0000; + + const MAP_SHARED = 0x0001; + const MAP_PRIVATE = 0x0002; + + /// Only accepted for mmap2(2). + const MAP_FIXED = 0x0004; + const MAP_FIXED_NOREPLACE = 0x000C; + } +} pub const MODE_TYPE: u16 = 0xF000; pub const MODE_DIR: u16 = 0x4000; @@ -56,21 +112,129 @@ pub const O_NOFOLLOW: usize = 0x8000_0000; pub const O_ACCMODE: usize = O_RDONLY | O_WRONLY | O_RDWR; -pub const PHYSMAP_WRITE: usize = 0x0000_0001; -pub const PHYSMAP_WRITE_COMBINE: usize = 0x0000_0002; -pub const PHYSMAP_NO_CACHE: usize = 0x0000_0004; - -pub const PROT_NONE: usize = 0x0000_0000; -pub const PROT_EXEC: usize = 0x0001_0000; -pub const PROT_WRITE: usize = 0x0002_0000; -pub const PROT_READ: usize = 0x0004_0000; - -pub const PTRACE_CONT: u8 = 0b0000_0001; -pub const PTRACE_SINGLESTEP: u8 = 0b0000_0010; -pub const PTRACE_SYSCALL: u8 = 0b0000_0011; -pub const PTRACE_WAIT: u8 = 0b0000_0100; -pub const PTRACE_OPERATIONMASK: u8 = 0b0000_1111; -pub const PTRACE_SYSEMU: u8 = 0b0001_0000; +bitflags! { + pub struct PhysmapFlags: usize { + const PHYSMAP_WRITE = 0x0000_0001; + const PHYSMAP_WRITE_COMBINE = 0x0000_0002; + const PHYSMAP_NO_CACHE = 0x0000_0004; + } +} +bitflags! { + /// Extra flags for [`physalloc2`] or [`physalloc3`]. + /// + /// [`physalloc2`]: ../call/fn.physalloc2.html + /// [`physalloc3`]: ../call/fn.physalloc3.html + pub struct PhysallocFlags: usize { + /// Only allocate memory within the 32-bit physical memory space. This is necessary for + /// some devices may not support 64-bit memory. + const SPACE_32 = 0x0000_0001; + + /// The frame that will be allocated, is going to reside anywhere in 64-bit space. This + /// flag is redundant for the most part, except when overriding some other default. + const SPACE_64 = 0x0000_0002; + + /// Do a "partial allocation", which means that not all of the frames specified in the + /// frame count `size` actually have to be allocated. This means that if the allocator was + /// unable to find a physical memory range large enough, it can instead return whatever + /// range it decides is optimal. Thus, instead of letting one driver get an expensive + /// 128MiB physical memory range when the physical memory has become fragmented, and + /// failing, it can instead be given a more optimal range. If the device supports + /// scatter-gather lists, then the driver only has to allocate more ranges, and the device + /// will do vectored I/O. + /// + /// PARTIAL_ALLOC supports different allocation strategies, refer to + /// [`Optimal`], [`GreatestRange`]. + /// + /// [`Optimal`]: ./enum.PartialAllocStrategy.html + /// [`GreatestRange`]: ./enum.PartialAllocStrategy.html + const PARTIAL_ALLOC = 0x0000_0004; + } +} + +/// The bitmask of the partial allocation strategy. Currently four different strategies are +/// supported. If [`PARTIAL_ALLOC`] is not set, this bitmask is no longer reserved. +pub const PARTIAL_ALLOC_STRATEGY_MASK: usize = 0x0003_0000; + +#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] +#[repr(usize)] +pub enum PartialAllocStrategy { + /// The allocator decides itself the size of the memory range, based on e.g. free memory ranges + /// and other processes which require large physical memory chunks. + Optimal = 0x0001_0000, + + /// The allocator returns the absolute greatest range it can find. + GreatestRange = 0x0002_0000, + + /// The allocator returns the first range that fits the minimum count, without searching extra. + Greedy = 0x0003_0000, +} +impl Default for PartialAllocStrategy { + fn default() -> Self { + Self::Optimal + } +} + +impl PartialAllocStrategy { + pub fn from_raw(raw: usize) -> Option { + match raw { + 0x0001_0000 => Some(Self::Optimal), + 0x0002_0000 => Some(Self::GreatestRange), + 0x0003_0000 => Some(Self::Greedy), + _ => None, + } + } +} + +// The top 48 bits of PTRACE_* are reserved, for now + +bitflags! { + pub struct PtraceFlags: u64 { + /// Stop before a syscall is handled. Send PTRACE_FLAG_IGNORE to not + /// handle the syscall. + const PTRACE_STOP_PRE_SYSCALL = 0x0000_0000_0000_0001; + /// Stop after a syscall is handled. + const PTRACE_STOP_POST_SYSCALL = 0x0000_0000_0000_0002; + /// Stop after exactly one instruction. TODO: This may not handle + /// fexec/signal boundaries. Should it? + const PTRACE_STOP_SINGLESTEP = 0x0000_0000_0000_0004; + /// Stop before a signal is handled. Send PTRACE_FLAG_IGNORE to not + /// handle signal. + const PTRACE_STOP_SIGNAL = 0x0000_0000_0000_0008; + /// Stop on a software breakpoint, such as the int3 instruction for + /// x86_64. + const PTRACE_STOP_BREAKPOINT = 0x0000_0000_0000_0010; + /// Stop just before exiting for good. + const PTRACE_STOP_EXIT = 0x0000_0000_0000_0020; + + const PTRACE_STOP_MASK = 0x0000_0000_0000_00FF; + + + /// Sent when a child is cloned, giving you the opportunity to trace it. + /// If you don't catch this, the child is started as normal. + const PTRACE_EVENT_CLONE = 0x0000_0000_0000_0100; + + const PTRACE_EVENT_MASK = 0x0000_0000_0000_0F00; + + + /// Special meaning, depending on the event. Usually, when fired before + /// an action, it will skip performing that action. + const PTRACE_FLAG_IGNORE = 0x0000_0000_0000_1000; + + const PTRACE_FLAG_MASK = 0x0000_0000_0000_F000; + } +} +impl Deref for PtraceFlags { + type Target = [u8]; + fn deref(&self) -> &Self::Target { + // Same as to_ne_bytes but in-place + unsafe { + slice::from_raw_parts( + &self.bits as *const _ as *const u8, + mem::size_of::() + ) + } + } +} pub const SEEK_SET: usize = 0; pub const SEEK_CUR: usize = 1; @@ -115,18 +279,33 @@ pub const SIG_UNBLOCK: usize = 1; pub const SIG_SETMASK: usize = 2; -pub const SA_NOCLDSTOP: usize = 0x00000001; -pub const SA_NOCLDWAIT: usize = 0x00000002; -pub const SA_SIGINFO: usize = 0x00000004; -pub const SA_RESTORER: usize = 0x04000000; -pub const SA_ONSTACK: usize = 0x08000000; -pub const SA_RESTART: usize = 0x10000000; -pub const SA_NODEFER: usize = 0x40000000; -pub const SA_RESETHAND: usize = 0x80000000; - -pub const WNOHANG: usize = 0x01; -pub const WUNTRACED: usize = 0x02; -pub const WCONTINUED: usize = 0x08; +bitflags! { + pub struct SigActionFlags: usize { + const SA_NOCLDSTOP = 0x00000001; + const SA_NOCLDWAIT = 0x00000002; + const SA_SIGINFO = 0x00000004; + const SA_RESTORER = 0x04000000; + const SA_ONSTACK = 0x08000000; + const SA_RESTART = 0x10000000; + const SA_NODEFER = 0x40000000; + const SA_RESETHAND = 0x80000000; + } +} + +// Auxiliery vector types +pub const AT_NULL: usize = 0; +pub const AT_PHDR: usize = 3; +pub const AT_PHENT: usize = 4; +pub const AT_PHNUM: usize = 5; +pub const AT_ENTRY: usize = 9; + +bitflags! { + pub struct WaitFlags: usize { + const WNOHANG = 0x01; + const WUNTRACED = 0x02; + const WCONTINUED = 0x08; + } +} /// True if status indicates the child is stopped. pub fn wifstopped(status: usize) -> bool { diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/io/dma.rs cargo-0.58.0/vendor/redox_syscall/src/io/dma.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/io/dma.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/io/dma.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,76 +1,200 @@ -use core::{mem, ptr}; +use core::mem::{self, MaybeUninit}; use core::ops::{Deref, DerefMut}; +use core::{ptr, slice}; -use Result; +use crate::Result; +use crate::{PartialAllocStrategy, PhysallocFlags}; -struct PhysBox { +/// An RAII guard of a physical memory allocation. Currently all physically allocated memory are +/// page-aligned and take up at least 4k of space (on x86_64). +#[derive(Debug)] +pub struct PhysBox { address: usize, size: usize } impl PhysBox { - fn new(size: usize) -> Result { - let address = unsafe { ::physalloc(size)? }; - Ok(PhysBox { - address: address, - size: size + /// Construct a PhysBox from an address and a size. + /// + /// # Safety + /// This function is unsafe because when dropping, Self has to a valid allocation. + pub unsafe fn from_raw_parts(address: usize, size: usize) -> Self { + Self { + address, + size, + } + } + + /// Retrieve the byte address in physical memory, of this allocation. + pub fn address(&self) -> usize { + self.address + } + + /// Retrieve the size in bytes of the alloc. + pub fn size(&self) -> usize { + self.size + } + + /// Allocate physical memory that must reside in 32-bit space. + pub fn new_in_32bit_space(size: usize) -> Result { + Self::new_with_flags(size, PhysallocFlags::SPACE_32) + } + + pub fn new_with_flags(size: usize, flags: PhysallocFlags) -> Result { + assert!(!flags.contains(PhysallocFlags::PARTIAL_ALLOC)); + + let address = unsafe { crate::physalloc2(size, flags.bits())? }; + Ok(Self { + address, + size, + }) + } + + /// "Partially" allocate physical memory, in the sense that the allocation may be smaller than + /// expected, but still with a minimum limit. This is particularly useful when the physical + /// memory space is fragmented, and a device supports scatter-gather I/O. In that case, the + /// driver can optimistically request e.g. 1 alloc of 1 MiB, with the minimum of 512 KiB. If + /// that first allocation only returns half the size, the driver can do another allocation + /// and then let the device use both buffers. + pub fn new_partial_allocation(size: usize, flags: PhysallocFlags, strategy: Option, mut min: usize) -> Result { + debug_assert!(!(flags.contains(PhysallocFlags::PARTIAL_ALLOC) && strategy.is_none())); + + let address = unsafe { crate::physalloc3(size, flags.bits() | strategy.map(|s| s as usize).unwrap_or(0), &mut min)? }; + Ok(Self { + address, + size: min, + }) + } + + pub fn new(size: usize) -> Result { + let address = unsafe { crate::physalloc(size)? }; + Ok(Self { + address, + size, }) } } impl Drop for PhysBox { fn drop(&mut self) { - let _ = unsafe { ::physfree(self.address, self.size) }; + let _ = unsafe { crate::physfree(self.address, self.size) }; } } -pub struct Dma { +pub struct Dma { phys: PhysBox, - virt: *mut T + virt: *mut T, } impl Dma { - pub fn new(value: T) -> Result> { - let phys = PhysBox::new(mem::size_of::())?; - let virt = unsafe { ::physmap(phys.address, phys.size, ::PHYSMAP_WRITE)? } as *mut T; - unsafe { ptr::write(virt, value); } + pub fn from_physbox_uninit(phys: PhysBox) -> Result>> { + let virt = unsafe { crate::physmap(phys.address, phys.size, crate::PHYSMAP_WRITE)? } as *mut MaybeUninit; + Ok(Dma { - phys: phys, - virt: virt + phys, + virt, + }) + } + pub fn from_physbox_zeroed(phys: PhysBox) -> Result>> { + let this = Self::from_physbox_uninit(phys)?; + unsafe { ptr::write_bytes(this.virt as *mut MaybeUninit, 0, this.phys.size) } + Ok(this) + } + + pub fn from_physbox(phys: PhysBox, value: T) -> Result { + let this = Self::from_physbox_uninit(phys)?; + + Ok(unsafe { + ptr::write(this.virt, MaybeUninit::new(value)); + this.assume_init() }) } - pub fn zeroed() -> Result> { + pub fn new(value: T) -> Result { + let phys = PhysBox::new(mem::size_of::())?; + Self::from_physbox(phys, value) + } + pub fn zeroed() -> Result>> { let phys = PhysBox::new(mem::size_of::())?; - let virt = unsafe { ::physmap(phys.address, phys.size, ::PHYSMAP_WRITE)? } as *mut T; - unsafe { ptr::write_bytes(virt as *mut u8, 0, phys.size); } + Self::from_physbox_zeroed(phys) + } +} + +impl Dma> { + pub unsafe fn assume_init(self) -> Dma { + let &Dma { phys: PhysBox { address, size }, virt } = &self; + mem::forget(self); + + Dma { + phys: PhysBox { address, size }, + virt: virt as *mut T, + } + } +} +impl Dma { + pub fn physical(&self) -> usize { + self.phys.address() + } + pub fn size(&self) -> usize { + self.phys.size() + } + pub fn phys(&self) -> &PhysBox { + &self.phys + } +} + +impl Dma<[T]> { + pub fn from_physbox_uninit_unsized(phys: PhysBox, len: usize) -> Result]>> { + let max_len = phys.size() / mem::size_of::(); + assert!(len <= max_len); + Ok(Dma { - phys: phys, - virt: virt + virt: unsafe { slice::from_raw_parts_mut(crate::physmap(phys.address, phys.size, crate::PHYSMAP_WRITE)? as *mut MaybeUninit, len) } as *mut [MaybeUninit], + phys, }) } + pub fn from_physbox_zeroed_unsized(phys: PhysBox, len: usize) -> Result]>> { + let this = Self::from_physbox_uninit_unsized(phys, len)?; + unsafe { ptr::write_bytes(this.virt as *mut MaybeUninit, 0, this.phys.size()) } + Ok(this) + } + /// Creates a new DMA buffer with a size only known at runtime. + /// ## Safety + /// * `T` must be properly aligned. + /// * `T` must be valid as zeroed (i.e. no NonNull pointers). + pub unsafe fn zeroed_unsized(count: usize) -> Result { + let phys = PhysBox::new(mem::size_of::() * count)?; + Ok(Self::from_physbox_zeroed_unsized(phys, count)?.assume_init()) + } +} +impl Dma<[MaybeUninit]> { + pub unsafe fn assume_init(self) -> Dma<[T]> { + let &Dma { phys: PhysBox { address, size }, virt } = &self; + mem::forget(self); - pub fn physical(&self) -> usize { - self.phys.address + Dma { + phys: PhysBox { address, size }, + virt: virt as *mut [T], + } } } -impl Deref for Dma { +impl Deref for Dma { type Target = T; fn deref(&self) -> &T { unsafe { &*self.virt } } } -impl DerefMut for Dma { +impl DerefMut for Dma { fn deref_mut(&mut self) -> &mut T { unsafe { &mut *self.virt } } } -impl Drop for Dma { +impl Drop for Dma { fn drop(&mut self) { - unsafe { drop(ptr::read(self.virt)); } - let _ = unsafe { ::physunmap(self.virt as usize) }; + unsafe { ptr::drop_in_place(self.virt) } + let _ = unsafe { crate::physunmap(self.virt as *mut u8 as usize) }; } } diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/io/io.rs cargo-0.58.0/vendor/redox_syscall/src/io/io.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/io/io.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/io/io.rs 2022-01-21 02:47:39.000000000 +0000 @@ -22,17 +22,19 @@ } } -pub struct ReadOnly { +pub struct ReadOnly { inner: I } -impl ReadOnly { +impl ReadOnly { pub const fn new(inner: I) -> ReadOnly { ReadOnly { inner: inner } } +} +impl ReadOnly { #[inline(always)] pub fn read(&self) -> I::Value { self.inner.read() @@ -44,17 +46,19 @@ } } -pub struct WriteOnly { +pub struct WriteOnly { inner: I } -impl WriteOnly { +impl WriteOnly { pub const fn new(inner: I) -> WriteOnly { WriteOnly { inner: inner } } +} +impl WriteOnly { #[inline(always)] pub fn write(&mut self, value: I::Value) { self.inner.write(value) diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/io/mmio.rs cargo-0.58.0/vendor/redox_syscall/src/io/mmio.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/io/mmio.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/io/mmio.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,19 +1,33 @@ use core::ptr::{read_volatile, write_volatile}; -use core::mem::uninitialized; +use core::mem::MaybeUninit; use core::ops::{BitAnd, BitOr, Not}; use super::io::Io; #[repr(packed)] pub struct Mmio { - value: T, + value: MaybeUninit, } impl Mmio { /// Create a new Mmio without initializing + #[deprecated = "unsound because it's possible to read even though it's uninitialized"] pub fn new() -> Self { - Mmio { - value: unsafe { uninitialized() } + unsafe { Self::uninit() } + } + pub unsafe fn zeroed() -> Self { + Self { + value: MaybeUninit::zeroed(), + } + } + pub unsafe fn uninit() -> Self { + Self { + value: MaybeUninit::uninit(), + } + } + pub const fn from(value: T) -> Self { + Self { + value: MaybeUninit::new(value), } } } @@ -22,10 +36,10 @@ type Value = T; fn read(&self) -> T { - unsafe { read_volatile(&self.value) } + unsafe { read_volatile(self.value.as_ptr()) } } fn write(&mut self, value: T) { - unsafe { write_volatile(&mut self.value, value) }; + unsafe { write_volatile(self.value.as_mut_ptr(), value) }; } } diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/lib.rs cargo-0.58.0/vendor/redox_syscall/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/lib.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,5 +1,5 @@ -#![cfg_attr(nightly, feature(llvm_asm))] -#![cfg_attr(nightly, feature(const_fn))] +#![feature(asm)] +#![feature(llvm_asm)] #![cfg_attr(not(test), no_std)] #[cfg(test)] @@ -10,28 +10,31 @@ pub use self::data::*; pub use self::error::*; pub use self::flag::*; -#[cfg(target_os = "redox")] pub use self::io::*; pub use self::number::*; pub use self::scheme::*; -#[cfg(all(target_os = "redox", target_arch = "arm"))] +#[cfg(all(any(target_os = "none", target_os = "redox"), target_arch = "arm"))] #[path="arch/arm.rs"] mod arch; -#[cfg(all(target_os = "redox", target_arch = "aarch64"))] +#[cfg(all(any(target_os = "none", target_os = "redox"), target_arch = "aarch64"))] #[path="arch/aarch64.rs"] mod arch; -#[cfg(all(target_os = "redox", target_arch = "x86"))] +#[cfg(all(any(target_os = "none", target_os = "redox"), target_arch = "riscv64"))] +#[path="arch/riscv64.rs"] +mod arch; + +#[cfg(all(any(target_os = "none", target_os = "redox"), target_arch = "x86"))] #[path="arch/x86.rs"] mod arch; -#[cfg(all(target_os = "redox", target_arch = "x86_64"))] +#[cfg(all(any(target_os = "none", target_os = "redox"), target_arch = "x86_64"))] #[path="arch/x86_64.rs"] mod arch; -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "none", target_os = "redox")))] #[path="arch/nonredox.rs"] mod arch; @@ -48,7 +51,6 @@ pub mod flag; /// Functions for low level hardware control -#[cfg(target_os = "redox")] pub mod io; /// Call numbers used by each system call diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/number.rs cargo-0.58.0/vendor/redox_syscall/src/number.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/number.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/number.rs 2022-01-21 02:47:39.000000000 +0000 @@ -16,28 +16,29 @@ pub const SYS_RMDIR: usize = SYS_CLASS_PATH | 84; pub const SYS_UNLINK: usize = SYS_CLASS_PATH | 10; -pub const SYS_CLOSE: usize = SYS_CLASS_FILE | 6; -pub const SYS_DUP: usize = SYS_CLASS_FILE | SYS_RET_FILE | 41; -pub const SYS_DUP2: usize = SYS_CLASS_FILE | SYS_RET_FILE | 63; -pub const SYS_READ: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 3; -pub const SYS_WRITE: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 4; -pub const SYS_LSEEK: usize = SYS_CLASS_FILE | 19; -pub const SYS_FCHMOD: usize = SYS_CLASS_FILE | 94; -pub const SYS_FCHOWN: usize = SYS_CLASS_FILE | 207; -pub const SYS_FCNTL: usize = SYS_CLASS_FILE | 55; -pub const SYS_FEVENT: usize = SYS_CLASS_FILE | 927; -pub const SYS_FEXEC: usize = SYS_CLASS_FILE | 11; -pub const SYS_FMAP: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 90; -pub const SYS_FUNMAP: usize = SYS_CLASS_FILE | 91; -pub const SYS_FPATH: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 928; -pub const SYS_FRENAME: usize = SYS_CLASS_FILE | SYS_ARG_PATH | 38; -pub const SYS_FSTAT: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 28; -pub const SYS_FSTATVFS: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 100; -pub const SYS_FSYNC: usize = SYS_CLASS_FILE | 118; -pub const SYS_FTRUNCATE: usize =SYS_CLASS_FILE | 93; -pub const SYS_FUTIMENS: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 320; +pub const SYS_CLOSE: usize = SYS_CLASS_FILE | 6; +pub const SYS_DUP: usize = SYS_CLASS_FILE | SYS_RET_FILE | 41; +pub const SYS_DUP2: usize = SYS_CLASS_FILE | SYS_RET_FILE | 63; +pub const SYS_READ: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 3; +pub const SYS_WRITE: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 4; +pub const SYS_LSEEK: usize = SYS_CLASS_FILE | 19; +pub const SYS_FCHMOD: usize = SYS_CLASS_FILE | 94; +pub const SYS_FCHOWN: usize = SYS_CLASS_FILE | 207; +pub const SYS_FCNTL: usize = SYS_CLASS_FILE | 55; +pub const SYS_FEVENT: usize = SYS_CLASS_FILE | 927; +pub const SYS_FEXEC: usize = SYS_CLASS_FILE | 11; +pub const SYS_FMAP_OLD: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 90; +pub const SYS_FMAP: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 900; +pub const SYS_FUNMAP_OLD: usize = SYS_CLASS_FILE | 91; +pub const SYS_FUNMAP: usize = SYS_CLASS_FILE | 92; +pub const SYS_FPATH: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 928; +pub const SYS_FRENAME: usize = SYS_CLASS_FILE | SYS_ARG_PATH | 38; +pub const SYS_FSTAT: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 28; +pub const SYS_FSTATVFS: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 100; +pub const SYS_FSYNC: usize = SYS_CLASS_FILE | 118; +pub const SYS_FTRUNCATE: usize = SYS_CLASS_FILE | 93; +pub const SYS_FUTIMENS: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 320; -pub const SYS_BRK: usize = 45; pub const SYS_CHDIR: usize = 12; pub const SYS_CLOCK_GETTIME: usize = 265; pub const SYS_CLONE: usize = 120; @@ -59,6 +60,7 @@ pub const SYS_MKNS: usize = 984; pub const SYS_NANOSLEEP: usize =162; pub const SYS_PHYSALLOC: usize =945; +pub const SYS_PHYSALLOC3: usize=9453; pub const SYS_PHYSFREE: usize = 946; pub const SYS_PHYSMAP: usize = 947; pub const SYS_PHYSUNMAP: usize =948; diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/scheme/generate.sh cargo-0.58.0/vendor/redox_syscall/src/scheme/generate.sh --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/scheme/generate.sh 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/scheme/generate.sh 2022-01-21 02:47:39.000000000 +0000 @@ -11,7 +11,10 @@ sed 's/trait Scheme/trait SchemeBlock/' scheme.rs \ | sed 's/fn handle(\&self, packet: \&mut Packet)/fn handle(\&self, packet: \&Packet) -> Option/' \ | sed 's/packet.a = Error::mux(res);/res.transpose().map(Error::mux)/' \ -| sed 's/Result/Result>/g' \ +| sed 's/\.map(|f| f\.bits())/\.map(|f| f.map(|f| f.bits()))/' \ +| sed 's/\.map(|o| o as usize)/.map(|o| o.map(|o| o as usize))/' \ +| sed 's/Ok(0)/Ok(Some(0))/g' \ +| sed 's/Result<\([^>]\+\)>/Result>/g' \ > scheme_block.rs echo "Generating SchemeBlockMut from SchemeBlock" diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/scheme/mod.rs cargo-0.58.0/vendor/redox_syscall/src/scheme/mod.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/scheme/mod.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/scheme/mod.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,9 +1,18 @@ +use core::{slice, str}; + pub use self::scheme::Scheme; pub use self::scheme_mut::SchemeMut; pub use self::scheme_block::SchemeBlock; pub use self::scheme_block_mut::SchemeBlockMut; +pub use self::seek::*; + +unsafe fn str_from_raw_parts(ptr: *const u8, len: usize) -> Option<&'static str> { + let slice = slice::from_raw_parts(ptr, len); + str::from_utf8(slice).ok() +} mod scheme; mod scheme_mut; mod scheme_block; mod scheme_block_mut; +mod seek; diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/scheme/scheme_block_mut.rs cargo-0.58.0/vendor/redox_syscall/src/scheme/scheme_block_mut.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/scheme/scheme_block_mut.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/scheme/scheme_block_mut.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,33 +1,61 @@ use core::{mem, slice}; -use data::*; -use error::*; -use number::*; +use crate::data::*; +use crate::error::*; +use crate::flag::*; +use crate::number::*; +use crate::scheme::str_from_raw_parts; pub trait SchemeBlockMut { fn handle(&mut self, packet: &Packet) -> Option { let res = match packet.a { - SYS_OPEN => self.open(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d, packet.uid, packet.gid), - SYS_CHMOD => self.chmod(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d as u16, packet.uid, packet.gid), - SYS_RMDIR => self.rmdir(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid), - SYS_UNLINK => self.unlink(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid), + SYS_OPEN => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { + self.open(path, packet.d, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, + SYS_CHMOD => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { + self.chmod(path, packet.d as u16, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, + SYS_RMDIR => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { + self.rmdir(path, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, + SYS_UNLINK => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { + self.unlink(path, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, SYS_DUP => self.dup(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }), SYS_READ => self.read(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }), SYS_WRITE => self.write(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }), - SYS_LSEEK => self.seek(packet.b, packet.c, packet.d), + SYS_LSEEK => self.seek(packet.b, packet.c as isize, packet.d).map(|o| o.map(|o| o as usize)), SYS_FCHMOD => self.fchmod(packet.b, packet.c as u16), SYS_FCHOWN => self.fchown(packet.b, packet.c as u32, packet.d as u32), SYS_FCNTL => self.fcntl(packet.b, packet.c, packet.d), - SYS_FEVENT => self.fevent(packet.b, packet.c), + SYS_FEVENT => self.fevent(packet.b, EventFlags::from_bits_truncate(packet.c)).map(|f| f.map(|f| f.bits())), + SYS_FMAP_OLD => if packet.d >= mem::size_of::() { + self.fmap_old(packet.b, unsafe { &*(packet.c as *const OldMap) }) + } else { + Err(Error::new(EFAULT)) + }, SYS_FMAP => if packet.d >= mem::size_of::() { self.fmap(packet.b, unsafe { &*(packet.c as *const Map) }) } else { Err(Error::new(EFAULT)) }, - SYS_FUNMAP => self.funmap(packet.b), + SYS_FUNMAP_OLD => self.funmap_old(packet.b), + SYS_FUNMAP => self.funmap(packet.b, packet.c), SYS_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }), - SYS_FRENAME => self.frename(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, packet.uid, packet.gid), + SYS_FRENAME => if let Some(path) = unsafe { str_from_raw_parts(packet.c as *const u8, packet.d) } { + self.frename(packet.b, path, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, SYS_FSTAT => if packet.d >= mem::size_of::() { self.fstat(packet.b, unsafe { &mut *(packet.c as *mut Stat) }) } else { @@ -55,22 +83,22 @@ /* Scheme operations */ #[allow(unused_variables)] - fn open(&mut self, path: &[u8], flags: usize, uid: u32, gid: u32) -> Result> { + fn open(&mut self, path: &str, flags: usize, uid: u32, gid: u32) -> Result> { Err(Error::new(ENOENT)) } #[allow(unused_variables)] - fn chmod(&mut self, path: &[u8], mode: u16, uid: u32, gid: u32) -> Result> { + fn chmod(&mut self, path: &str, mode: u16, uid: u32, gid: u32) -> Result> { Err(Error::new(ENOENT)) } #[allow(unused_variables)] - fn rmdir(&mut self, path: &[u8], uid: u32, gid: u32) -> Result> { + fn rmdir(&mut self, path: &str, uid: u32, gid: u32) -> Result> { Err(Error::new(ENOENT)) } #[allow(unused_variables)] - fn unlink(&mut self, path: &[u8], uid: u32, gid: u32) -> Result> { + fn unlink(&mut self, path: &str, uid: u32, gid: u32) -> Result> { Err(Error::new(ENOENT)) } @@ -91,7 +119,7 @@ } #[allow(unused_variables)] - fn seek(&mut self, id: usize, pos: usize, whence: usize) -> Result> { + fn seek(&mut self, id: usize, pos: isize, whence: usize) -> Result> { Err(Error::new(EBADF)) } @@ -111,18 +139,34 @@ } #[allow(unused_variables)] - fn fevent(&mut self, id: usize, flags: usize) -> Result> { + fn fevent(&mut self, id: usize, flags: EventFlags) -> Result> { Err(Error::new(EBADF)) } #[allow(unused_variables)] - fn fmap(&mut self, id: usize, map: &Map) -> Result> { + fn fmap_old(&mut self, id: usize, map: &OldMap) -> Result> { Err(Error::new(EBADF)) } + #[allow(unused_variables)] + fn fmap(&mut self, id: usize, map: &Map) -> Result> { + if map.flags.contains(MapFlags::MAP_FIXED) { + return Err(Error::new(EINVAL)); + } + self.fmap_old(id, &OldMap { + offset: map.offset, + size: map.size, + flags: map.flags, + }) + } #[allow(unused_variables)] - fn funmap(&mut self, address: usize) -> Result> { - Err(Error::new(EBADF)) + fn funmap_old(&mut self, address: usize) -> Result> { + Ok(Some(0)) + } + + #[allow(unused_variables)] + fn funmap(&mut self, address: usize, length: usize) -> Result> { + Ok(Some(0)) } #[allow(unused_variables)] @@ -131,7 +175,7 @@ } #[allow(unused_variables)] - fn frename(&mut self, id: usize, path: &[u8], uid: u32, gid: u32) -> Result> { + fn frename(&mut self, id: usize, path: &str, uid: u32, gid: u32) -> Result> { Err(Error::new(EBADF)) } diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/scheme/scheme_block.rs cargo-0.58.0/vendor/redox_syscall/src/scheme/scheme_block.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/scheme/scheme_block.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/scheme/scheme_block.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,33 +1,61 @@ use core::{mem, slice}; -use data::*; -use error::*; -use number::*; +use crate::data::*; +use crate::error::*; +use crate::flag::*; +use crate::number::*; +use crate::scheme::str_from_raw_parts; pub trait SchemeBlock { fn handle(&self, packet: &Packet) -> Option { let res = match packet.a { - SYS_OPEN => self.open(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d, packet.uid, packet.gid), - SYS_CHMOD => self.chmod(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d as u16, packet.uid, packet.gid), - SYS_RMDIR => self.rmdir(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid), - SYS_UNLINK => self.unlink(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid), + SYS_OPEN => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { + self.open(path, packet.d, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, + SYS_CHMOD => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { + self.chmod(path, packet.d as u16, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, + SYS_RMDIR => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { + self.rmdir(path, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, + SYS_UNLINK => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { + self.unlink(path, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, SYS_DUP => self.dup(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }), SYS_READ => self.read(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }), SYS_WRITE => self.write(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }), - SYS_LSEEK => self.seek(packet.b, packet.c, packet.d), + SYS_LSEEK => self.seek(packet.b, packet.c as isize, packet.d).map(|o| o.map(|o| o as usize)), SYS_FCHMOD => self.fchmod(packet.b, packet.c as u16), SYS_FCHOWN => self.fchown(packet.b, packet.c as u32, packet.d as u32), SYS_FCNTL => self.fcntl(packet.b, packet.c, packet.d), - SYS_FEVENT => self.fevent(packet.b, packet.c), + SYS_FEVENT => self.fevent(packet.b, EventFlags::from_bits_truncate(packet.c)).map(|f| f.map(|f| f.bits())), + SYS_FMAP_OLD => if packet.d >= mem::size_of::() { + self.fmap_old(packet.b, unsafe { &*(packet.c as *const OldMap) }) + } else { + Err(Error::new(EFAULT)) + }, SYS_FMAP => if packet.d >= mem::size_of::() { self.fmap(packet.b, unsafe { &*(packet.c as *const Map) }) } else { Err(Error::new(EFAULT)) }, - SYS_FUNMAP => self.funmap(packet.b), + SYS_FUNMAP_OLD => self.funmap_old(packet.b), + SYS_FUNMAP => self.funmap(packet.b, packet.c), SYS_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }), - SYS_FRENAME => self.frename(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, packet.uid, packet.gid), + SYS_FRENAME => if let Some(path) = unsafe { str_from_raw_parts(packet.c as *const u8, packet.d) } { + self.frename(packet.b, path, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, SYS_FSTAT => if packet.d >= mem::size_of::() { self.fstat(packet.b, unsafe { &mut *(packet.c as *mut Stat) }) } else { @@ -55,22 +83,22 @@ /* Scheme operations */ #[allow(unused_variables)] - fn open(&self, path: &[u8], flags: usize, uid: u32, gid: u32) -> Result> { + fn open(&self, path: &str, flags: usize, uid: u32, gid: u32) -> Result> { Err(Error::new(ENOENT)) } #[allow(unused_variables)] - fn chmod(&self, path: &[u8], mode: u16, uid: u32, gid: u32) -> Result> { + fn chmod(&self, path: &str, mode: u16, uid: u32, gid: u32) -> Result> { Err(Error::new(ENOENT)) } #[allow(unused_variables)] - fn rmdir(&self, path: &[u8], uid: u32, gid: u32) -> Result> { + fn rmdir(&self, path: &str, uid: u32, gid: u32) -> Result> { Err(Error::new(ENOENT)) } #[allow(unused_variables)] - fn unlink(&self, path: &[u8], uid: u32, gid: u32) -> Result> { + fn unlink(&self, path: &str, uid: u32, gid: u32) -> Result> { Err(Error::new(ENOENT)) } @@ -91,7 +119,7 @@ } #[allow(unused_variables)] - fn seek(&self, id: usize, pos: usize, whence: usize) -> Result> { + fn seek(&self, id: usize, pos: isize, whence: usize) -> Result> { Err(Error::new(EBADF)) } @@ -111,18 +139,34 @@ } #[allow(unused_variables)] - fn fevent(&self, id: usize, flags: usize) -> Result> { + fn fevent(&self, id: usize, flags: EventFlags) -> Result> { Err(Error::new(EBADF)) } #[allow(unused_variables)] - fn fmap(&self, id: usize, map: &Map) -> Result> { + fn fmap_old(&self, id: usize, map: &OldMap) -> Result> { Err(Error::new(EBADF)) } + #[allow(unused_variables)] + fn fmap(&self, id: usize, map: &Map) -> Result> { + if map.flags.contains(MapFlags::MAP_FIXED) { + return Err(Error::new(EINVAL)); + } + self.fmap_old(id, &OldMap { + offset: map.offset, + size: map.size, + flags: map.flags, + }) + } #[allow(unused_variables)] - fn funmap(&self, address: usize) -> Result> { - Err(Error::new(EBADF)) + fn funmap_old(&self, address: usize) -> Result> { + Ok(Some(0)) + } + + #[allow(unused_variables)] + fn funmap(&self, address: usize, length: usize) -> Result> { + Ok(Some(0)) } #[allow(unused_variables)] @@ -131,7 +175,7 @@ } #[allow(unused_variables)] - fn frename(&self, id: usize, path: &[u8], uid: u32, gid: u32) -> Result> { + fn frename(&self, id: usize, path: &str, uid: u32, gid: u32) -> Result> { Err(Error::new(EBADF)) } diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/scheme/scheme_mut.rs cargo-0.58.0/vendor/redox_syscall/src/scheme/scheme_mut.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/scheme/scheme_mut.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/scheme/scheme_mut.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,33 +1,61 @@ use core::{mem, slice}; -use data::*; -use error::*; -use number::*; +use crate::data::*; +use crate::error::*; +use crate::flag::*; +use crate::number::*; +use crate::scheme::str_from_raw_parts; pub trait SchemeMut { fn handle(&mut self, packet: &mut Packet) { let res = match packet.a { - SYS_OPEN => self.open(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d, packet.uid, packet.gid), - SYS_CHMOD => self.chmod(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d as u16, packet.uid, packet.gid), - SYS_RMDIR => self.rmdir(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid), - SYS_UNLINK => self.unlink(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid), + SYS_OPEN => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { + self.open(path, packet.d, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, + SYS_CHMOD => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { + self.chmod(path, packet.d as u16, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, + SYS_RMDIR => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { + self.rmdir(path, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, + SYS_UNLINK => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { + self.unlink(path, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, SYS_DUP => self.dup(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }), SYS_READ => self.read(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }), SYS_WRITE => self.write(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }), - SYS_LSEEK => self.seek(packet.b, packet.c, packet.d), + SYS_LSEEK => self.seek(packet.b, packet.c as isize, packet.d).map(|o| o as usize), SYS_FCHMOD => self.fchmod(packet.b, packet.c as u16), SYS_FCHOWN => self.fchown(packet.b, packet.c as u32, packet.d as u32), SYS_FCNTL => self.fcntl(packet.b, packet.c, packet.d), - SYS_FEVENT => self.fevent(packet.b, packet.c), + SYS_FEVENT => self.fevent(packet.b, EventFlags::from_bits_truncate(packet.c)).map(|f| f.bits()), + SYS_FMAP_OLD => if packet.d >= mem::size_of::() { + self.fmap_old(packet.b, unsafe { &*(packet.c as *const OldMap) }) + } else { + Err(Error::new(EFAULT)) + }, SYS_FMAP => if packet.d >= mem::size_of::() { self.fmap(packet.b, unsafe { &*(packet.c as *const Map) }) } else { Err(Error::new(EFAULT)) }, - SYS_FUNMAP => self.funmap(packet.b), + SYS_FUNMAP_OLD => self.funmap_old(packet.b), + SYS_FUNMAP => self.funmap(packet.b, packet.c), SYS_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }), - SYS_FRENAME => self.frename(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, packet.uid, packet.gid), + SYS_FRENAME => if let Some(path) = unsafe { str_from_raw_parts(packet.c as *const u8, packet.d) } { + self.frename(packet.b, path, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, SYS_FSTAT => if packet.d >= mem::size_of::() { self.fstat(packet.b, unsafe { &mut *(packet.c as *mut Stat) }) } else { @@ -55,22 +83,22 @@ /* Scheme operations */ #[allow(unused_variables)] - fn open(&mut self, path: &[u8], flags: usize, uid: u32, gid: u32) -> Result { + fn open(&mut self, path: &str, flags: usize, uid: u32, gid: u32) -> Result { Err(Error::new(ENOENT)) } #[allow(unused_variables)] - fn chmod(&mut self, path: &[u8], mode: u16, uid: u32, gid: u32) -> Result { + fn chmod(&mut self, path: &str, mode: u16, uid: u32, gid: u32) -> Result { Err(Error::new(ENOENT)) } #[allow(unused_variables)] - fn rmdir(&mut self, path: &[u8], uid: u32, gid: u32) -> Result { + fn rmdir(&mut self, path: &str, uid: u32, gid: u32) -> Result { Err(Error::new(ENOENT)) } #[allow(unused_variables)] - fn unlink(&mut self, path: &[u8], uid: u32, gid: u32) -> Result { + fn unlink(&mut self, path: &str, uid: u32, gid: u32) -> Result { Err(Error::new(ENOENT)) } @@ -91,7 +119,7 @@ } #[allow(unused_variables)] - fn seek(&mut self, id: usize, pos: usize, whence: usize) -> Result { + fn seek(&mut self, id: usize, pos: isize, whence: usize) -> Result { Err(Error::new(EBADF)) } @@ -111,18 +139,34 @@ } #[allow(unused_variables)] - fn fevent(&mut self, id: usize, flags: usize) -> Result { + fn fevent(&mut self, id: usize, flags: EventFlags) -> Result { Err(Error::new(EBADF)) } #[allow(unused_variables)] - fn fmap(&mut self, id: usize, map: &Map) -> Result { + fn fmap_old(&mut self, id: usize, map: &OldMap) -> Result { Err(Error::new(EBADF)) } + #[allow(unused_variables)] + fn fmap(&mut self, id: usize, map: &Map) -> Result { + if map.flags.contains(MapFlags::MAP_FIXED) { + return Err(Error::new(EINVAL)); + } + self.fmap_old(id, &OldMap { + offset: map.offset, + size: map.size, + flags: map.flags, + }) + } #[allow(unused_variables)] - fn funmap(&mut self, address: usize) -> Result { - Err(Error::new(EBADF)) + fn funmap_old(&mut self, address: usize) -> Result { + Ok(0) + } + + #[allow(unused_variables)] + fn funmap(&mut self, address: usize, length: usize) -> Result { + Ok(0) } #[allow(unused_variables)] @@ -131,7 +175,7 @@ } #[allow(unused_variables)] - fn frename(&mut self, id: usize, path: &[u8], uid: u32, gid: u32) -> Result { + fn frename(&mut self, id: usize, path: &str, uid: u32, gid: u32) -> Result { Err(Error::new(EBADF)) } diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/scheme/scheme.rs cargo-0.58.0/vendor/redox_syscall/src/scheme/scheme.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/scheme/scheme.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/scheme/scheme.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,33 +1,61 @@ use core::{mem, slice}; -use data::*; -use error::*; -use number::*; +use crate::data::*; +use crate::error::*; +use crate::flag::*; +use crate::number::*; +use crate::scheme::str_from_raw_parts; pub trait Scheme { fn handle(&self, packet: &mut Packet) { let res = match packet.a { - SYS_OPEN => self.open(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d, packet.uid, packet.gid), - SYS_CHMOD => self.chmod(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.d as u16, packet.uid, packet.gid), - SYS_RMDIR => self.rmdir(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid), - SYS_UNLINK => self.unlink(unsafe { slice::from_raw_parts(packet.b as *const u8, packet.c) }, packet.uid, packet.gid), + SYS_OPEN => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { + self.open(path, packet.d, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, + SYS_CHMOD => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { + self.chmod(path, packet.d as u16, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, + SYS_RMDIR => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { + self.rmdir(path, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, + SYS_UNLINK => if let Some(path) = unsafe { str_from_raw_parts(packet.b as *const u8, packet.c) } { + self.unlink(path, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, SYS_DUP => self.dup(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }), SYS_READ => self.read(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }), SYS_WRITE => self.write(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }), - SYS_LSEEK => self.seek(packet.b, packet.c, packet.d), + SYS_LSEEK => self.seek(packet.b, packet.c as isize, packet.d).map(|o| o as usize), SYS_FCHMOD => self.fchmod(packet.b, packet.c as u16), SYS_FCHOWN => self.fchown(packet.b, packet.c as u32, packet.d as u32), SYS_FCNTL => self.fcntl(packet.b, packet.c, packet.d), - SYS_FEVENT => self.fevent(packet.b, packet.c), + SYS_FEVENT => self.fevent(packet.b, EventFlags::from_bits_truncate(packet.c)).map(|f| f.bits()), + SYS_FMAP_OLD => if packet.d >= mem::size_of::() { + self.fmap_old(packet.b, unsafe { &*(packet.c as *const OldMap) }) + } else { + Err(Error::new(EFAULT)) + }, SYS_FMAP => if packet.d >= mem::size_of::() { self.fmap(packet.b, unsafe { &*(packet.c as *const Map) }) } else { Err(Error::new(EFAULT)) }, - SYS_FUNMAP => self.funmap(packet.b), + SYS_FUNMAP_OLD => self.funmap_old(packet.b), + SYS_FUNMAP => self.funmap(packet.b, packet.c), SYS_FPATH => self.fpath(packet.b, unsafe { slice::from_raw_parts_mut(packet.c as *mut u8, packet.d) }), - SYS_FRENAME => self.frename(packet.b, unsafe { slice::from_raw_parts(packet.c as *const u8, packet.d) }, packet.uid, packet.gid), + SYS_FRENAME => if let Some(path) = unsafe { str_from_raw_parts(packet.c as *const u8, packet.d) } { + self.frename(packet.b, path, packet.uid, packet.gid) + } else { + Err(Error::new(EINVAL)) + }, SYS_FSTAT => if packet.d >= mem::size_of::() { self.fstat(packet.b, unsafe { &mut *(packet.c as *mut Stat) }) } else { @@ -55,22 +83,22 @@ /* Scheme operations */ #[allow(unused_variables)] - fn open(&self, path: &[u8], flags: usize, uid: u32, gid: u32) -> Result { + fn open(&self, path: &str, flags: usize, uid: u32, gid: u32) -> Result { Err(Error::new(ENOENT)) } #[allow(unused_variables)] - fn chmod(&self, path: &[u8], mode: u16, uid: u32, gid: u32) -> Result { + fn chmod(&self, path: &str, mode: u16, uid: u32, gid: u32) -> Result { Err(Error::new(ENOENT)) } #[allow(unused_variables)] - fn rmdir(&self, path: &[u8], uid: u32, gid: u32) -> Result { + fn rmdir(&self, path: &str, uid: u32, gid: u32) -> Result { Err(Error::new(ENOENT)) } #[allow(unused_variables)] - fn unlink(&self, path: &[u8], uid: u32, gid: u32) -> Result { + fn unlink(&self, path: &str, uid: u32, gid: u32) -> Result { Err(Error::new(ENOENT)) } @@ -91,7 +119,7 @@ } #[allow(unused_variables)] - fn seek(&self, id: usize, pos: usize, whence: usize) -> Result { + fn seek(&self, id: usize, pos: isize, whence: usize) -> Result { Err(Error::new(EBADF)) } @@ -111,18 +139,34 @@ } #[allow(unused_variables)] - fn fevent(&self, id: usize, flags: usize) -> Result { + fn fevent(&self, id: usize, flags: EventFlags) -> Result { Err(Error::new(EBADF)) } #[allow(unused_variables)] - fn fmap(&self, id: usize, map: &Map) -> Result { + fn fmap_old(&self, id: usize, map: &OldMap) -> Result { Err(Error::new(EBADF)) } + #[allow(unused_variables)] + fn fmap(&self, id: usize, map: &Map) -> Result { + if map.flags.contains(MapFlags::MAP_FIXED) { + return Err(Error::new(EINVAL)); + } + self.fmap_old(id, &OldMap { + offset: map.offset, + size: map.size, + flags: map.flags, + }) + } #[allow(unused_variables)] - fn funmap(&self, address: usize) -> Result { - Err(Error::new(EBADF)) + fn funmap_old(&self, address: usize) -> Result { + Ok(0) + } + + #[allow(unused_variables)] + fn funmap(&self, address: usize, length: usize) -> Result { + Ok(0) } #[allow(unused_variables)] @@ -131,7 +175,7 @@ } #[allow(unused_variables)] - fn frename(&self, id: usize, path: &[u8], uid: u32, gid: u32) -> Result { + fn frename(&self, id: usize, path: &str, uid: u32, gid: u32) -> Result { Err(Error::new(EBADF)) } diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/scheme/seek.rs cargo-0.58.0/vendor/redox_syscall/src/scheme/seek.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/scheme/seek.rs 1970-01-01 00:00:00.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/scheme/seek.rs 2022-01-21 02:47:39.000000000 +0000 @@ -0,0 +1,33 @@ +use core::cmp; +use core::convert::TryFrom; +use crate::error::*; +use crate::flag::*; + +/// Helper for seek calls +/// In most cases it's easier to use a usize to track the offset and buffer size internally, +/// but the seek interface uses isize. This wrapper ensures EOVERFLOW errors are returned +/// as appropriate if the value in the usize can't fit in the isize. +pub fn calc_seek_offset_usize(cur_offset: usize, pos: isize, whence: usize, buf_len: usize) -> Result { + let cur_offset = isize::try_from(cur_offset).or_else(|_| Err(Error::new(EOVERFLOW)))?; + let buf_len = isize::try_from(buf_len).or_else(|_| Err(Error::new(EOVERFLOW)))?; + calc_seek_offset_isize(cur_offset, pos, whence, buf_len) +} + +/// Helper for seek calls +/// Result is guaranteed to be positive. +/// EOVERFLOW returned if the arguments would cause an overflow. +/// EINVAL returned if the new offset is out of bounds. +pub fn calc_seek_offset_isize(cur_offset: isize, pos: isize, whence: usize, buf_len: isize) -> Result { + let new_offset = match whence { + SEEK_CUR => pos.checked_add(cur_offset), + SEEK_END => pos.checked_add(buf_len), + SEEK_SET => Some(pos), + _ => None, + }; + + match new_offset { + Some(new_offset) if new_offset < 0 => Err(Error::new(EINVAL)), + Some(new_offset) => Ok(cmp::min(new_offset, buf_len)), + None => Err(Error::new(EOVERFLOW)) + } +} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/redox_syscall/src/tests.rs cargo-0.58.0/vendor/redox_syscall/src/tests.rs --- cargo-0.57.0+ubuntu/vendor/redox_syscall/src/tests.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/redox_syscall/src/tests.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,17 +1,25 @@ #[test] -fn brk() { - unsafe { - let start = dbg!(crate::brk(0)).unwrap(); - let end = start + 4 * 1024 * 1024; - assert_eq!(dbg!(crate::brk(end)), Ok(end)); +fn chdir() { + use std::str; + + let mut current_buf = [0; 4096]; + let current_count = dbg!(crate::getcwd(&mut current_buf)).unwrap(); + let current = dbg!(str::from_utf8(¤t_buf[..current_count])).unwrap(); + + let new = "file:"; + assert_eq!(dbg!(crate::chdir(dbg!(new))), Ok(0)); + { + let mut buf = [0; 4096]; + let count = dbg!(crate::getcwd(&mut buf)).unwrap(); + assert_eq!(dbg!(str::from_utf8(&buf[..count])), Ok(new)); } -} -#[test] -fn chdir() { - //TODO: Verify CWD - assert_eq!(dbg!(crate::chdir("file:/")), Ok(0)); - assert_eq!(dbg!(crate::chdir("file:/root")), Ok(0)); + assert_eq!(dbg!(crate::chdir(current)), Ok(0)); + { + let mut buf = [0; 4096]; + let count = dbg!(crate::getcwd(&mut buf)).unwrap(); + assert_eq!(dbg!(str::from_utf8(&buf[..count])), Ok(current)); + } } //TODO: chmod @@ -19,14 +27,14 @@ #[test] fn clone() { let expected_status = 42; - let pid_res = unsafe { crate::clone(0) }; + let pid_res = unsafe { crate::clone(crate::CloneFlags::empty()) }; if pid_res == Ok(0) { crate::exit(expected_status).unwrap(); panic!("failed to exit"); } else { let pid = dbg!(pid_res).unwrap(); let mut status = 0; - assert_eq!(dbg!(crate::waitpid(pid, &mut status, 0)), Ok(pid)); + assert_eq!(dbg!(crate::waitpid(pid, &mut status, crate::WaitFlags::empty())), Ok(pid)); assert_eq!(dbg!(crate::wifexited(status)), true); assert_eq!(dbg!(crate::wexitstatus(status)), expected_status); } @@ -61,7 +69,7 @@ #[test] fn fexec() { - let name = "/bin/ls"; + let name = "file:/bin/ls"; let fd = dbg!( crate::open(name, crate::O_RDONLY | crate::O_CLOEXEC) @@ -73,7 +81,7 @@ let vars = &[]; - let pid_res = unsafe { crate::clone(0) }; + let pid_res = unsafe { crate::clone(crate::CloneFlags::empty()) }; if pid_res == Ok(0) { crate::fexec(fd, args, vars).unwrap(); panic!("failed to fexec"); @@ -82,7 +90,7 @@ let pid = dbg!(pid_res).unwrap(); let mut status = 0; - assert_eq!(dbg!(crate::waitpid(pid, &mut status, 0)), Ok(pid)); + assert_eq!(dbg!(crate::waitpid(pid, &mut status, crate::WaitFlags::empty())), Ok(pid)); assert_eq!(dbg!(crate::wifexited(status)), true); assert_eq!(dbg!(crate::wexitstatus(status)), 0); } @@ -94,17 +102,20 @@ let fd = dbg!( crate::open( - "/tmp/syscall-tests-fmap", + "file:/tmp/syscall-tests-fmap", crate::O_CREAT | crate::O_RDWR | crate::O_CLOEXEC ) ).unwrap(); + let size = 128; + let map = unsafe { slice::from_raw_parts_mut( dbg!( crate::fmap(fd, &crate::Map { + address: 0, offset: 0, - size: 128, + size, flags: crate::PROT_READ | crate::PROT_WRITE }) ).unwrap() as *mut u8, @@ -123,7 +134,337 @@ //TODO: add msync unsafe { assert_eq!(dbg!( - crate::funmap(map.as_mut_ptr() as usize) + crate::funmap(map.as_mut_ptr() as usize, size) ), Ok(0)); } } + +// funmap tested by fmap + +#[test] +fn fpath() { + use std::str; + + let path = "file:/tmp/syscall-tests-fpath"; + let fd = dbg!( + crate::open( + dbg!(path), + crate::O_CREAT | crate::O_RDWR | crate::O_CLOEXEC + ) + ).unwrap(); + + let mut buf = [0; 4096]; + let count = dbg!( + crate::fpath(fd, &mut buf) + ).unwrap(); + + assert_eq!(dbg!(str::from_utf8(&buf[..count])), Ok(path)); + + assert_eq!(dbg!(crate::close(fd)), Ok(0)); +} + +//TODO: frename + +#[test] +fn fstat() { + let path = "file:/tmp/syscall-tests-fstat"; + let fd = dbg!( + crate::open( + dbg!(path), + crate::O_CREAT | crate::O_RDWR | crate::O_CLOEXEC + ) + ).unwrap(); + + let mut stat = crate::Stat::default(); + assert_eq!(dbg!(crate::fstat(fd, &mut stat)), Ok(0)); + assert_ne!(dbg!(stat), crate::Stat::default()); + + assert_eq!(dbg!(crate::close(fd)), Ok(0)); +} + +#[test] +fn fstatvfs() { + let path = "file:/tmp/syscall-tests-fstatvfs"; + let fd = dbg!( + crate::open( + dbg!(path), + crate::O_CREAT | crate::O_RDWR | crate::O_CLOEXEC + ) + ).unwrap(); + + let mut statvfs = crate::StatVfs::default(); + assert_eq!(dbg!(crate::fstatvfs(fd, &mut statvfs)), Ok(0)); + assert_ne!(dbg!(statvfs), crate::StatVfs::default()); + + assert_eq!(dbg!(crate::close(fd)), Ok(0)); +} + +//TODO: fsync + +//TODO: ftruncate + +//TODO: futimens + +//TODO: futex + +// getcwd tested by chdir + +#[test] +fn getegid() { + assert_eq!(crate::getegid(), Ok(0)); +} + +#[test] +fn getens() { + assert_eq!(crate::getens(), Ok(1)); +} + +#[test] +fn geteuid() { + assert_eq!(crate::geteuid(), Ok(0)); +} + +#[test] +fn getgid() { + assert_eq!(crate::getgid(), Ok(0)); +} + +#[test] +fn getns() { + assert_eq!(crate::getns(), Ok(1)); +} + +//TODO: getpid + +//TODO: getpgid + +//TODO: getppid + +#[test] +fn getuid() { + assert_eq!(crate::getuid(), Ok(0)); +} + +//TODO: iopl + +//TODO: kill + +//TODO: link (probably will not work) + +#[test] +fn lseek() { + let path = "file:/tmp/syscall-tests-lseek"; + let fd = dbg!( + crate::open( + dbg!(path), + crate::O_CREAT | crate::O_RDWR | crate::O_CLOEXEC + ) + ).unwrap(); + + { + let mut buf = [0; 256]; + for i in 0..buf.len() { + buf[i] = i as u8; + } + assert_eq!(dbg!(crate::write(fd, &buf)), Ok(buf.len())); + + assert_eq!(dbg!(crate::lseek(fd, 0, crate::SEEK_CUR)), Ok(buf.len())); + assert_eq!(dbg!(crate::lseek(fd, 0, crate::SEEK_SET)), Ok(0)); + assert_eq!(dbg!(crate::lseek(fd, 0, crate::SEEK_END)), Ok(buf.len())); + assert_eq!(dbg!(crate::lseek(fd, 0, crate::SEEK_SET)), Ok(0)); + } + + { + let mut buf = [0; 256]; + assert_eq!(dbg!(crate::read(fd, &mut buf)), Ok(buf.len())); + for i in 0..buf.len() { + assert_eq!(buf[i], i as u8); + } + + assert_eq!(dbg!(crate::lseek(fd, 0, crate::SEEK_CUR)), Ok(buf.len())); + assert_eq!(dbg!(crate::lseek(fd, 0, crate::SEEK_SET)), Ok(0)); + assert_eq!(dbg!(crate::lseek(fd, 0, crate::SEEK_END)), Ok(buf.len())); + assert_eq!(dbg!(crate::lseek(fd, 0, crate::SEEK_SET)), Ok(0)); + } + + assert_eq!(dbg!(crate::close(fd)), Ok(0)); +} + +//TODO: mkns + +//TODO: mprotect + +#[test] +fn nanosleep() { + let req = crate::TimeSpec { + tv_sec: 0, + tv_nsec: 0, + }; + let mut rem = crate::TimeSpec::default(); + assert_eq!(crate::nanosleep(&req, &mut rem), Ok(0)); + assert_eq!(rem, crate::TimeSpec::default()); +} + +//TODO: open + +//TODO: physalloc + +//TODO: physfree + +//TODO: physmap + +//TODO: physunmap + +#[test] +fn pipe2() { + let mut fds = [0, 0]; + assert_eq!(dbg!(crate::pipe2(&mut fds, crate::O_CLOEXEC)), Ok(0)); + assert_ne!(dbg!(fds), [0, 0]); + + { + let mut buf = [0; 256]; + for i in 0..buf.len() { + buf[i] = i as u8; + } + assert_eq!(dbg!(crate::write(fds[1], &buf)), Ok(buf.len())); + } + + { + let mut buf = [0; 256]; + assert_eq!(dbg!(crate::read(fds[0], &mut buf)), Ok(buf.len())); + for i in 0..buf.len() { + assert_eq!(buf[i], i as u8); + } + } + + assert_eq!(dbg!(crate::close(fds[0])), Ok(0)); + assert_eq!(dbg!(crate::close(fds[1])), Ok(0)); +} + +//TODO: read + +#[test] +fn rmdir() { + let path = "file:/tmp/syscall-tests-rmdir"; + let fd = dbg!( + crate::open( + dbg!(path), + crate::O_CREAT | crate::O_DIRECTORY | crate::O_CLOEXEC + ) + ).unwrap(); + + assert_eq!(dbg!(crate::close(fd)), Ok(0)); + + assert_eq!(dbg!(crate::rmdir(path)), Ok(0)); +} + +//TODO: setpgid + +//TODO: setregid + +//TODO: setrens + +//TODO: setreuid + +//TODO: sigaction + +//TODO: sigprocmask + +//TODO: sigreturn + +#[test] +fn umask() { + let old = dbg!(crate::umask(0o244)).unwrap(); + assert_eq!(dbg!(crate::umask(old)), Ok(0o244)); +} + +#[test] +fn unlink() { + let path = "file:/tmp/syscall-tests-unlink"; + let fd = dbg!( + crate::open( + dbg!(path), + crate::O_CREAT | crate::O_RDWR | crate::O_CLOEXEC + ) + ).unwrap(); + + assert_eq!(dbg!(crate::close(fd)), Ok(0)); + + assert_eq!(dbg!(crate::unlink(path)), Ok(0)); +} + +//TODO: virttophys + +// waitpid tested by clone + +//TODO: write + +#[test] +fn sched_yield() { + assert_eq!(dbg!(crate::sched_yield()), Ok(0)); +} + +#[test] +fn sigaction() { + use std::{ + mem, + sync::atomic::{AtomicBool, Ordering} + }; + + static SA_HANDLER_WAS_RAN: AtomicBool = AtomicBool::new(false); + static SA_HANDLER_2_WAS_IGNORED: AtomicBool = AtomicBool::new(false); + + let child = unsafe { crate::clone(crate::CLONE_VM).unwrap() }; + + if child == 0 { + let pid = crate::getpid().unwrap(); + + extern "C" fn hello_im_a_signal_handler(signal: usize) { + assert_eq!(signal, crate::SIGUSR1); + SA_HANDLER_WAS_RAN.store(true, Ordering::SeqCst); + } + + let my_signal_handler = crate::SigAction { + sa_handler: Some(hello_im_a_signal_handler), + ..Default::default() + }; + crate::sigaction(crate::SIGUSR1, Some(&my_signal_handler), None).unwrap(); + + crate::kill(pid, crate::SIGUSR1).unwrap(); // calls handler + + let mut old_signal_handler = crate::SigAction::default(); + crate::sigaction( + crate::SIGUSR1, + Some(&crate::SigAction { + sa_handler: unsafe { mem::transmute::>(crate::SIG_IGN) }, + ..Default::default() + }), + Some(&mut old_signal_handler) + ).unwrap(); + assert_eq!(my_signal_handler, old_signal_handler); + + crate::kill(pid, crate::SIGUSR1).unwrap(); // does nothing + + SA_HANDLER_2_WAS_IGNORED.store(true, Ordering::SeqCst); + + crate::sigaction( + crate::SIGUSR1, + Some(&crate::SigAction { + sa_handler: unsafe { mem::transmute::>(crate::SIG_DFL) }, + ..Default::default() + }), + Some(&mut old_signal_handler) + ).unwrap(); + + crate::kill(pid, crate::SIGUSR1).unwrap(); // actually exits + } else { + let mut status = 0; + dbg!(crate::waitpid(child, &mut status, crate::WaitFlags::empty())).unwrap(); + + assert!(crate::wifsignaled(status)); + assert_eq!(crate::wtermsig(status), crate::SIGUSR1); + + assert!(SA_HANDLER_WAS_RAN.load(Ordering::SeqCst)); + assert!(SA_HANDLER_2_WAS_IGNORED.load(Ordering::SeqCst)); + } +} diff -Nru cargo-0.57.0+ubuntu/vendor/regex/.cargo-checksum.json cargo-0.58.0/vendor/regex/.cargo-checksum.json --- cargo-0.57.0+ubuntu/vendor/regex/.cargo-checksum.json 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/.cargo-checksum.json 2022-01-21 02:47:39.000000000 +0000 @@ -1 +1 @@ -{"files":{},"package":"9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6"} \ No newline at end of file +{"files":{},"package":"d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"} \ No newline at end of file diff -Nru cargo-0.57.0+ubuntu/vendor/regex/Cargo.lock cargo-0.58.0/vendor/regex/Cargo.lock --- cargo-0.57.0+ubuntu/vendor/regex/Cargo.lock 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/Cargo.lock 2022-01-21 02:47:39.000000000 +0000 @@ -1,42 +1,34 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "aho-corasick" -version = "0.7.10" +version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" dependencies = [ "memchr", ] [[package]] -name = "autocfg" -version = "0.1.7" +name = "cfg-if" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "bitflags" -version = "1.2.1" +name = "getrandom" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" - -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8" dependencies = [ - "bitflags", + "cfg-if", + "libc", + "wasi", ] [[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - -[[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -44,144 +36,46 @@ [[package]] name = "libc" -version = "0.2.71" +version = "0.2.80" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49" +checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" [[package]] name = "memchr" -version = "2.3.3" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" +checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" [[package]] name = "quickcheck" -version = "0.8.5" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c35d9c36a562f37eca96e79f66d5fd56eefbc22560dacc4a864cabd2d277456" +checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6" dependencies = [ "rand", - "rand_core 0.4.2", ] [[package]] name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg", - "libc", - "rand_chacha", - "rand_core 0.4.2", - "rand_hc", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift", - "winapi", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" +checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" dependencies = [ - "autocfg", - "rand_core 0.3.1", + "rand_core", ] [[package]] name = "rand_core" -version = "0.3.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7" dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", + "getrandom", ] [[package]] name = "regex" -version = "1.3.9" +version = "1.5.4" dependencies = [ "aho-corasick", "lazy_static", @@ -189,42 +83,16 @@ "quickcheck", "rand", "regex-syntax", - "thread_local", ] [[package]] name = "regex-syntax" -version = "0.6.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8" - -[[package]] -name = "thread_local" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "winapi" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" +version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" diff -Nru cargo-0.57.0+ubuntu/vendor/regex/Cargo.toml cargo-0.58.0/vendor/regex/Cargo.toml --- cargo-0.57.0+ubuntu/vendor/regex/Cargo.toml 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/Cargo.toml 2022-01-21 02:47:39.000000000 +0000 @@ -11,8 +11,9 @@ # will likely look very different (and much more reasonable) [package] +edition = "2018" name = "regex" -version = "1.3.9" +version = "1.5.4" authors = ["The Rust Project Developers"] exclude = ["/scripts/*", "/.github/*"] autotests = false @@ -72,35 +73,33 @@ name = "crates-regex" path = "tests/test_crates_regex.rs" [dependencies.aho-corasick] -version = "0.7.6" +version = "0.7.18" optional = true [dependencies.memchr] -version = "2.2.1" +version = "2.4.0" optional = true [dependencies.regex-syntax] -version = "0.6.18" +version = "0.6.25" default-features = false - -[dependencies.thread_local] -version = "1" -optional = true [dev-dependencies.lazy_static] version = "1" [dev-dependencies.quickcheck] -version = "0.9" +version = "1.0.3" default-features = false [dev-dependencies.rand] -version = "0.7" +version = "0.8.3" +features = ["getrandom", "small_rng"] +default-features = false [features] default = ["std", "perf", "unicode", "regex-syntax/default"] pattern = [] perf = ["perf-cache", "perf-dfa", "perf-inline", "perf-literal"] -perf-cache = ["thread_local"] +perf-cache = [] perf-dfa = [] perf-inline = [] perf-literal = ["aho-corasick", "memchr"] diff -Nru cargo-0.57.0+ubuntu/vendor/regex/CHANGELOG.md cargo-0.58.0/vendor/regex/CHANGELOG.md --- cargo-0.57.0+ubuntu/vendor/regex/CHANGELOG.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/CHANGELOG.md 2022-01-21 02:47:39.000000000 +0000 @@ -1,3 +1,160 @@ +1.5.4 (2021-05-06) +================== +This release fixes another compilation failure when building regex. This time, +the fix is for when the `pattern` feature is enabled, which only works on +nightly Rust. CI has been updated to test this case. + +* [BUG #772](https://github.com/rust-lang/regex/pull/772): + Fix build when `pattern` feature is enabled. + + +1.5.3 (2021-05-01) +================== +This releases fixes a bug when building regex with only the `unicode-perl` +feature. It turns out that while CI was building this configuration, it wasn't +actually failing the overall build on a failed compilation. + +* [BUG #769](https://github.com/rust-lang/regex/issues/769): + Fix build in `regex-syntax` when only the `unicode-perl` feature is enabled. + + +1.5.2 (2021-05-01) +================== +This release fixes a performance bug when Unicode word boundaries are used. +Namely, for certain regexes on certain inputs, it's possible for the lazy DFA +to stop searching (causing a fallback to a slower engine) when it doesn't +actually need to. + +[PR #768](https://github.com/rust-lang/regex/pull/768) fixes the bug, which was +originally reported in +[ripgrep#1860](https://github.com/BurntSushi/ripgrep/issues/1860). + + +1.5.1 (2021-04-30) +================== +This is a patch release that fixes a compilation error when the `perf-literal` +feature is not enabled. + + +1.5.0 (2021-04-30) +================== +This release primarily updates to Rust 2018 (finally) and bumps the MSRV to +Rust 1.41 (from Rust 1.28). Rust 1.41 was chosen because it's still reasonably +old, and is what's in Debian stable at the time of writing. + +This release also drops this crate's own bespoke substring search algorithms +in favor of a new +[`memmem` implementation provided by the `memchr` crate](https://docs.rs/memchr/2.4.0/memchr/memmem/index.html). +This will change the performance profile of some regexes, sometimes getting a +little worse, and hopefully more frequently, getting a lot better. Please +report any serious performance regressions if you find them. + + +1.4.6 (2021-04-22) +================== +This is a small patch release that fixes the compiler's size check on how much +heap memory a regex uses. Previously, the compiler did not account for the +heap usage of Unicode character classes. Now it does. It's possible that this +may make some regexes fail to compile that previously did compile. If that +happens, please file an issue. + +* [BUG OSS-fuzz#33579](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33579): + Some regexes can use more heap memory than one would expect. + + +1.4.5 (2021-03-14) +================== +This is a small patch release that fixes a regression in the size of a `Regex` +in the 1.4.4 release. Prior to 1.4.4, a `Regex` was 552 bytes. In the 1.4.4 +release, it was 856 bytes due to internal changes. In this release, a `Regex` +is now 16 bytes. In general, the size of a `Regex` was never something that was +on my radar, but this increased size in the 1.4.4 release seems to have crossed +a threshold and resulted in stack overflows in some programs. + +* [BUG #750](https://github.com/rust-lang/regex/pull/750): + Fixes stack overflows seemingly caused by a large `Regex` size by decreasing + its size. + + +1.4.4 (2021-03-11) +================== +This is a small patch release that contains some bug fixes. Notably, it also +drops the `thread_local` (and `lazy_static`, via transitivity) dependencies. + +Bug fixes: + +* [BUG #362](https://github.com/rust-lang/regex/pull/362): + Memory leaks caused by an internal caching strategy should now be fixed. +* [BUG #576](https://github.com/rust-lang/regex/pull/576): + All regex types now implement `UnwindSafe` and `RefUnwindSafe`. +* [BUG #728](https://github.com/rust-lang/regex/pull/749): + Add missing `Replacer` impls for `Vec`, `String`, `Cow`, etc. + + +1.4.3 (2021-01-08) +================== +This is a small patch release that adds some missing standard trait +implementations for some types in the public API. + +Bug fixes: + +* [BUG #734](https://github.com/rust-lang/regex/pull/734): + Add `FusedIterator` and `ExactSizeIterator` impls to iterator types. +* [BUG #735](https://github.com/rust-lang/regex/pull/735): + Add missing `Debug` impls to public API types. + + +1.4.2 (2020-11-01) +================== +This is a small bug fix release that bans `\P{any}`. We previously banned empty +classes like `[^\w\W]`, but missed the `\P{any}` case. In the future, we hope +to permit empty classes. + +* [BUG #722](https://github.com/rust-lang/regex/issues/722): + Ban `\P{any}` to avoid a panic in the regex compiler. Found by OSS-Fuzz. + + +1.4.1 (2020-10-13) +================== +This is a small bug fix release that makes `\p{cf}` work. Previously, it would +report "property not found" even though `cf` is a valid abbreviation for the +`Format` general category. + +* [BUG #719](https://github.com/rust-lang/regex/issues/719): + Fixes bug that prevented `\p{cf}` from working. + + +1.4.0 (2020-10-11) +================== +This releases has a few minor documentation fixes as well as some very minor +API additions. The MSRV remains at Rust 1.28 for now, but this is intended to +increase to at least Rust 1.41.1 soon. + +This release also adds support for OSS-Fuzz. Kudos to +[@DavidKorczynski](https://github.com/DavidKorczynski) +for doing the heavy lifting for that! + +New features: + +* [FEATURE #649](https://github.com/rust-lang/regex/issues/649): + Support `[`, `]` and `.` in capture group names. +* [FEATURE #687](https://github.com/rust-lang/regex/issues/687): + Add `is_empty` predicate to `RegexSet`. +* [FEATURE #689](https://github.com/rust-lang/regex/issues/689): + Implement `Clone` for `SubCaptureMatches`. +* [FEATURE #715](https://github.com/rust-lang/regex/issues/715): + Add `empty` constructor to `RegexSet` for convenience. + +Bug fixes: + +* [BUG #694](https://github.com/rust-lang/regex/issues/694): + Fix doc example for `Replacer::replace_append`. +* [BUG #698](https://github.com/rust-lang/regex/issues/698): + Clarify docs for `s` flag when using a `bytes::Regex`. +* [BUG #711](https://github.com/rust-lang/regex/issues/711): + Clarify `is_match` docs to indicate that it can match anywhere in string. + + 1.3.9 (2020-05-28) ================== This release fixes a MSRV (Minimum Support Rust Version) regression in the @@ -6,7 +163,7 @@ Bug fixes: -* [BUG #685](https://github.com/rust-lang/regex/issue/685): +* [BUG #685](https://github.com/rust-lang/regex/issues/685): Remove use of `doc_comment` crate, which cannot be used before Rust 1.43. @@ -22,9 +179,9 @@ * [BUG #523](https://github.com/rust-lang/regex/pull/523): Add note to documentation that spaces can be escaped in `x` mode. -* [BUG #524](https://github.com/rust-lang/regex/issue/524): +* [BUG #524](https://github.com/rust-lang/regex/issues/524): Add support for empty sub-expressions, including empty alternations. -* [BUG #659](https://github.com/rust-lang/regex/issue/659): +* [BUG #659](https://github.com/rust-lang/regex/issues/659): Fix match bug caused by an empty sub-expression miscompilation. diff -Nru cargo-0.57.0+ubuntu/vendor/regex/debian/patches/relax-test-dep.diff cargo-0.58.0/vendor/regex/debian/patches/relax-test-dep.diff --- cargo-0.57.0+ubuntu/vendor/regex/debian/patches/relax-test-dep.diff 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/debian/patches/relax-test-dep.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ ---- a/Cargo.toml -+++ b/Cargo.toml -@@ -93,11 +93,11 @@ - version = "1" - - [dev-dependencies.quickcheck] --version = "0.8" -+version = "0.9" - default-features = false - - [dev-dependencies.rand] --version = "0.6.5" -+version = "0.7" - - [features] - default = ["std", "perf", "unicode", "regex-syntax/default"] diff -Nru cargo-0.57.0+ubuntu/vendor/regex/debian/patches/series cargo-0.58.0/vendor/regex/debian/patches/series --- cargo-0.57.0+ubuntu/vendor/regex/debian/patches/series 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -relax-test-dep.diff diff -Nru cargo-0.57.0+ubuntu/vendor/regex/examples/shootout-regex-dna-bytes.rs cargo-0.58.0/vendor/regex/examples/shootout-regex-dna-bytes.rs --- cargo-0.57.0+ubuntu/vendor/regex/examples/shootout-regex-dna-bytes.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/examples/shootout-regex-dna-bytes.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,12 +1,10 @@ // The Computer Language Benchmarks Game -// http://benchmarksgame.alioth.debian.org/ +// https://benchmarksgame-team.pages.debian.net/benchmarksgame/ // // contributed by the Rust Project Developers // contributed by TeXitoi // contributed by BurntSushi -extern crate regex; - use std::io::{self, Read}; use std::sync::Arc; use std::thread; diff -Nru cargo-0.57.0+ubuntu/vendor/regex/examples/shootout-regex-dna-cheat.rs cargo-0.58.0/vendor/regex/examples/shootout-regex-dna-cheat.rs --- cargo-0.57.0+ubuntu/vendor/regex/examples/shootout-regex-dna-cheat.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/examples/shootout-regex-dna-cheat.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,5 +1,5 @@ // The Computer Language Benchmarks Game -// http://benchmarksgame.alioth.debian.org/ +// https://benchmarksgame-team.pages.debian.net/benchmarksgame/ // // contributed by the Rust Project Developers // contributed by TeXitoi @@ -10,8 +10,6 @@ // replacing them with a single linear scan. i.e., it re-implements // `replace_all`. As a result, this is around 25% faster. ---AG -extern crate regex; - use std::io::{self, Read}; use std::sync::Arc; use std::thread; diff -Nru cargo-0.57.0+ubuntu/vendor/regex/examples/shootout-regex-dna-replace.rs cargo-0.58.0/vendor/regex/examples/shootout-regex-dna-replace.rs --- cargo-0.57.0+ubuntu/vendor/regex/examples/shootout-regex-dna-replace.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/examples/shootout-regex-dna-replace.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,5 +1,3 @@ -extern crate regex; - use std::io::{self, Read}; macro_rules! regex { diff -Nru cargo-0.57.0+ubuntu/vendor/regex/examples/shootout-regex-dna.rs cargo-0.58.0/vendor/regex/examples/shootout-regex-dna.rs --- cargo-0.57.0+ubuntu/vendor/regex/examples/shootout-regex-dna.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/examples/shootout-regex-dna.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,12 +1,10 @@ // The Computer Language Benchmarks Game -// http://benchmarksgame.alioth.debian.org/ +// https://benchmarksgame-team.pages.debian.net/benchmarksgame/ // // contributed by the Rust Project Developers // contributed by TeXitoi // contributed by BurntSushi -extern crate regex; - use std::io::{self, Read}; use std::sync::Arc; use std::thread; diff -Nru cargo-0.57.0+ubuntu/vendor/regex/examples/shootout-regex-dna-single-cheat.rs cargo-0.58.0/vendor/regex/examples/shootout-regex-dna-single-cheat.rs --- cargo-0.57.0+ubuntu/vendor/regex/examples/shootout-regex-dna-single-cheat.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/examples/shootout-regex-dna-single-cheat.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,12 +1,10 @@ // The Computer Language Benchmarks Game -// http://benchmarksgame.alioth.debian.org/ +// https://benchmarksgame-team.pages.debian.net/benchmarksgame/ // // contributed by the Rust Project Developers // contributed by TeXitoi // contributed by BurntSushi -extern crate regex; - use std::io::{self, Read}; macro_rules! regex { diff -Nru cargo-0.57.0+ubuntu/vendor/regex/examples/shootout-regex-dna-single.rs cargo-0.58.0/vendor/regex/examples/shootout-regex-dna-single.rs --- cargo-0.57.0+ubuntu/vendor/regex/examples/shootout-regex-dna-single.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/examples/shootout-regex-dna-single.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,12 +1,10 @@ // The Computer Language Benchmarks Game -// http://benchmarksgame.alioth.debian.org/ +// https://benchmarksgame-team.pages.debian.net/benchmarksgame/ // // contributed by the Rust Project Developers // contributed by TeXitoi // contributed by BurntSushi -extern crate regex; - use std::io::{self, Read}; macro_rules! regex { diff -Nru cargo-0.57.0+ubuntu/vendor/regex/PERFORMANCE.md cargo-0.58.0/vendor/regex/PERFORMANCE.md --- cargo-0.57.0+ubuntu/vendor/regex/PERFORMANCE.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/PERFORMANCE.md 2022-01-21 02:47:39.000000000 +0000 @@ -62,9 +62,7 @@ [`lazy_static`](https://crates.io/crates/lazy_static) crate provides an answer that works well: - #[macro_use] extern crate lazy_static; - extern crate regex; - + use lazy_static::lazy_static; use regex::Regex; fn some_helper_function(text: &str) -> bool { @@ -147,9 +145,9 @@ `is_match` is fastest because it doesn't actually need to find the start or the end of the leftmost-first match. It can quit immediately after it knows there is a match. For example, given the regex `a+` and the haystack, `aaaaa`, the -search will quit after examing the first byte. +search will quit after examining the first byte. -In constrast, `find` must return both the start and end location of the +In contrast, `find` must return both the start and end location of the leftmost-first match. It can use the DFA matcher for this, but must run it forwards once to find the end of the match *and then run it backwards* to find the start of the match. The two scans and the cost of finding the real end of @@ -198,7 +196,7 @@ Literals in anchored regexes can also be used for detecting non-matches very quickly. For example, `^foo\w+` and `\w+foo$` may be able to detect a non-match -just by examing the first (or last) three bytes of the haystack. +just by examining the first (or last) three bytes of the haystack. ## Unicode word boundaries may prevent the DFA from being used diff -Nru cargo-0.57.0+ubuntu/vendor/regex/README.md cargo-0.58.0/vendor/regex/README.md --- cargo-0.57.0+ubuntu/vendor/regex/README.md 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/README.md 2022-01-21 02:47:39.000000000 +0000 @@ -9,7 +9,7 @@ [![Build status](https://github.com/rust-lang/regex/workflows/ci/badge.svg)](https://github.com/rust-lang/regex/actions) [![](https://meritbadge.herokuapp.com/regex)](https://crates.io/crates/regex) -[![Rust](https://img.shields.io/badge/rust-1.28.0%2B-blue.svg?maxAge=3600)](https://github.com/rust-lang/regex) +[![Rust](https://img.shields.io/badge/rust-1.41.1%2B-blue.svg?maxAge=3600)](https://github.com/rust-lang/regex) ### Documentation @@ -27,13 +27,7 @@ ```toml [dependencies] -regex = "1" -``` - -and this to your crate root (if you're using Rust 2015): - -```rust -extern crate regex; +regex = "1.5" ``` Here's a simple example that matches a date in YYYY-MM-DD format and prints the @@ -228,7 +222,7 @@ ### Minimum Rust version policy -This crate's minimum supported `rustc` version is `1.28.0`. +This crate's minimum supported `rustc` version is `1.41.1`. The current **tentative** policy is that the minimum Rust version required to use this crate can be increased in minor version updates. For example, if @@ -245,12 +239,12 @@ This project is licensed under either of * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or - http://www.apache.org/licenses/LICENSE-2.0) + https://www.apache.org/licenses/LICENSE-2.0) * MIT license ([LICENSE-MIT](LICENSE-MIT) or - http://opensource.org/licenses/MIT) + https://opensource.org/licenses/MIT) at your option. The data in `regex-syntax/src/unicode_tables/` is licensed under the Unicode License Agreement -([LICENSE-UNICODE](http://www.unicode.org/copyright.html#License)). +([LICENSE-UNICODE](https://www.unicode.org/copyright.html#License)). diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/backtrack.rs cargo-0.58.0/vendor/regex/src/backtrack.rs --- cargo-0.57.0+ubuntu/vendor/regex/src/backtrack.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/src/backtrack.rs 2022-01-21 02:47:39.000000000 +0000 @@ -16,10 +16,10 @@ // the bitset has to be zeroed on each execution, which becomes quite expensive // on large bitsets. -use exec::ProgramCache; -use input::{Input, InputAt}; -use prog::{InstPtr, Program}; -use re_trait::Slot; +use crate::exec::ProgramCache; +use crate::input::{Input, InputAt}; +use crate::prog::{InstPtr, Program}; +use crate::re_trait::Slot; type Bits = u32; @@ -115,8 +115,8 @@ // Then we reset all existing allocated space to 0. // Finally, we request more space if we need it. // - // This is all a little circuitous, but doing this unsafely - // doesn't seem to have a measurable impact on performance. + // This is all a little circuitous, but doing this using unchecked + // operations doesn't seem to have a measurable impact on performance. // (Probably because backtracking is limited to such small // inputs/regexes in the first place.) let visited_len = @@ -196,7 +196,7 @@ } fn step(&mut self, mut ip: InstPtr, mut at: InputAt) -> bool { - use prog::Inst::*; + use crate::prog::Inst::*; loop { // This loop is an optimization to avoid constantly pushing/popping // from the stack. Namely, if we're pushing a job only to run it diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/cache.rs cargo-0.58.0/vendor/regex/src/cache.rs --- cargo-0.57.0+ubuntu/vendor/regex/src/cache.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/src/cache.rs 1970-01-01 00:00:00.000000000 +0000 @@ -1,100 +0,0 @@ -// This module defines a common API for caching internal runtime state. -// The `thread_local` crate provides an extremely optimized version of this. -// However, if the perf-cache feature is disabled, then we drop the -// thread_local dependency and instead use a pretty naive caching mechanism -// with a mutex. -// -// Strictly speaking, the CachedGuard isn't necessary for the much more -// flexible thread_local API, but implementing thread_local's API doesn't -// seem possible in purely safe code. - -pub use self::imp::{Cached, CachedGuard}; - -#[cfg(feature = "perf-cache")] -mod imp { - use thread_local::CachedThreadLocal; - - #[derive(Debug)] - pub struct Cached(CachedThreadLocal); - - #[derive(Debug)] - pub struct CachedGuard<'a, T: 'a>(&'a T); - - impl Cached { - pub fn new() -> Cached { - Cached(CachedThreadLocal::new()) - } - - pub fn get_or(&self, create: impl FnOnce() -> T) -> CachedGuard { - CachedGuard(self.0.get_or(|| create())) - } - } - - impl<'a, T: Send> CachedGuard<'a, T> { - pub fn value(&self) -> &T { - self.0 - } - } -} - -#[cfg(not(feature = "perf-cache"))] -mod imp { - use std::marker::PhantomData; - use std::panic::UnwindSafe; - use std::sync::Mutex; - - #[derive(Debug)] - pub struct Cached { - stack: Mutex>, - /// When perf-cache is enabled, the thread_local crate is used, and - /// its CachedThreadLocal impls Send, Sync and UnwindSafe, but NOT - /// RefUnwindSafe. However, a Mutex impls RefUnwindSafe. So in order - /// to keep the APIs consistent regardless of whether perf-cache is - /// enabled, we force this type to NOT impl RefUnwindSafe too. - /// - /// Ideally, we should always impl RefUnwindSafe, but it seems a little - /// tricky to do that right now. - /// - /// See also: https://github.com/rust-lang/regex/issues/576 - _phantom: PhantomData>, - } - - #[derive(Debug)] - pub struct CachedGuard<'a, T: 'a + Send> { - cache: &'a Cached, - value: Option, - } - - impl Cached { - pub fn new() -> Cached { - Cached { stack: Mutex::new(vec![]), _phantom: PhantomData } - } - - pub fn get_or(&self, create: impl FnOnce() -> T) -> CachedGuard { - let mut stack = self.stack.lock().unwrap(); - match stack.pop() { - None => CachedGuard { cache: self, value: Some(create()) }, - Some(value) => CachedGuard { cache: self, value: Some(value) }, - } - } - - fn put(&self, value: T) { - let mut stack = self.stack.lock().unwrap(); - stack.push(value); - } - } - - impl<'a, T: Send> CachedGuard<'a, T> { - pub fn value(&self) -> &T { - self.value.as_ref().unwrap() - } - } - - impl<'a, T: Send> Drop for CachedGuard<'a, T> { - fn drop(&mut self) { - if let Some(value) = self.value.take() { - self.cache.put(value); - } - } - } -} diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/compile.rs cargo-0.58.0/vendor/regex/src/compile.rs --- cargo-0.57.0+ubuntu/vendor/regex/src/compile.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/src/compile.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,18 +1,19 @@ use std::collections::HashMap; +use std::fmt; use std::iter; use std::result; use std::sync::Arc; -use syntax::hir::{self, Hir}; -use syntax::is_word_byte; -use syntax::utf8::{Utf8Range, Utf8Sequence, Utf8Sequences}; +use regex_syntax::hir::{self, Hir}; +use regex_syntax::is_word_byte; +use regex_syntax::utf8::{Utf8Range, Utf8Sequence, Utf8Sequences}; -use prog::{ +use crate::prog::{ EmptyLook, Inst, InstBytes, InstChar, InstEmptyLook, InstPtr, InstRanges, InstSave, InstSplit, Program, }; -use Error; +use crate::Error; type Result = result::Result; type ResultOrEmpty = result::Result, Error>; @@ -25,6 +26,9 @@ /// A compiler translates a regular expression AST to a sequence of /// instructions. The sequence of instructions represents an NFA. +// `Compiler` is only public via the `internal` module, so avoid deriving +// `Debug`. +#[allow(missing_debug_implementations)] pub struct Compiler { insts: Vec, compiled: Program, @@ -34,6 +38,7 @@ suffix_cache: SuffixCache, utf8_seqs: Option, byte_classes: ByteClassSet, + extra_inst_bytes: usize, } impl Compiler { @@ -50,6 +55,7 @@ suffix_cache: SuffixCache::new(1000), utf8_seqs: Some(Utf8Sequences::new('\x00', '\x00')), byte_classes: ByteClassSet::new(), + extra_inst_bytes: 0, } } @@ -222,7 +228,7 @@ /// hole /// ``` /// - /// To compile two expressions, e1 and e2, concatinated together we + /// To compile two expressions, e1 and e2, concatenated together we /// would do: /// /// ```ignore @@ -249,8 +255,8 @@ /// Ok(None) is returned when an expression is compiled to no /// instruction, and so no patch.entry value makes sense. fn c(&mut self, expr: &Hir) -> ResultOrEmpty { - use prog; - use syntax::hir::HirKind::*; + use crate::prog; + use regex_syntax::hir::HirKind::*; self.check_size()?; match *expr.kind() { @@ -312,6 +318,13 @@ } self.compiled.has_unicode_word_boundary = true; self.byte_classes.set_word_boundary(); + // We also make sure that all ASCII bytes are in a different + // class from non-ASCII bytes. Otherwise, it's possible for + // ASCII bytes to get lumped into the same class as non-ASCII + // bytes. This in turn may cause the lazy DFA to falsely start + // when it sees an ASCII byte that maps to a byte class with + // non-ASCII bytes. This ensures that never happens. + self.byte_classes.set_range(0, 0x7F); self.c_empty_look(prog::EmptyLook::WordBoundary) } WordBoundary(hir::WordBoundary::UnicodeNegate) => { @@ -324,6 +337,8 @@ } self.compiled.has_unicode_word_boundary = true; self.byte_classes.set_word_boundary(); + // See comments above for why we set the ASCII range here. + self.byte_classes.set_range(0, 0x7F); self.c_empty_look(prog::EmptyLook::NotWordBoundary) } WordBoundary(hir::WordBoundary::Ascii) => { @@ -416,6 +431,8 @@ } fn c_class(&mut self, ranges: &[hir::ClassUnicodeRange]) -> ResultOrEmpty { + use std::mem::size_of; + assert!(!ranges.is_empty()); if self.compiled.uses_bytes() { Ok(Some(CompileClass { c: self, ranges: ranges }.compile()?)) @@ -425,6 +442,8 @@ let hole = if ranges.len() == 1 && ranges[0].0 == ranges[0].1 { self.push_hole(InstHole::Char { c: ranges[0].0 }) } else { + self.extra_inst_bytes += + ranges.len() * (size_of::() * 2); self.push_hole(InstHole::Ranges { ranges: ranges }) }; Ok(Some(Patch { hole: hole, entry: self.insts.len() - 1 })) @@ -544,7 +563,7 @@ } fn c_repeat(&mut self, rep: &hir::Repetition) -> ResultOrEmpty { - use syntax::hir::RepetitionKind::*; + use regex_syntax::hir::RepetitionKind::*; match rep.kind { ZeroOrOne => self.c_repeat_zero_or_one(&rep.hir, rep.greedy), ZeroOrMore => self.c_repeat_zero_or_more(&rep.hir, rep.greedy), @@ -791,7 +810,9 @@ fn check_size(&self) -> result::Result<(), Error> { use std::mem::size_of; - if self.insts.len() * size_of::() > self.size_limit { + let size = + self.extra_inst_bytes + (self.insts.len() * size_of::()); + if size > self.size_limit { Err(Error::CompiledTooBig(self.size_limit)) } else { Ok(()) @@ -923,9 +944,10 @@ Inst::EmptyLook(InstEmptyLook { goto: goto, look: look }) } InstHole::Char { c } => Inst::Char(InstChar { goto: goto, c: c }), - InstHole::Ranges { ref ranges } => { - Inst::Ranges(InstRanges { goto: goto, ranges: ranges.clone() }) - } + InstHole::Ranges { ref ranges } => Inst::Ranges(InstRanges { + goto: goto, + ranges: ranges.clone().into_boxed_slice(), + }), InstHole::Bytes { start, end } => { Inst::Bytes(InstBytes { goto: goto, start: start, end: end }) } @@ -1051,6 +1073,7 @@ /// This uses similar idea to [`SparseSet`](../sparse/struct.SparseSet.html), /// except it uses hashes as original indices and then compares full keys for /// validation against `dense` array. +#[derive(Debug)] struct SuffixCache { sparse: Box<[usize]>, dense: Vec, @@ -1159,6 +1182,12 @@ } } +impl fmt::Debug for ByteClassSet { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_tuple("ByteClassSet").field(&&self.0[..]).finish() + } +} + fn u32_to_usize(n: u32) -> usize { // In case usize is less than 32 bits, we need to guard against overflow. // On most platforms this compiles to nothing. diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/dfa.rs cargo-0.58.0/vendor/regex/src/dfa.rs --- cargo-0.57.0+ubuntu/vendor/regex/src/dfa.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/src/dfa.rs 2022-01-21 02:47:39.000000000 +0000 @@ -42,9 +42,9 @@ use std::mem; use std::sync::Arc; -use exec::ProgramCache; -use prog::{Inst, Program}; -use sparse::SparseSet; +use crate::exec::ProgramCache; +use crate::prog::{Inst, Program}; +use crate::sparse::SparseSet; /// Return true if and only if the given program can be executed by a DFA. /// @@ -55,7 +55,7 @@ /// This function will also return false if the given program has any Unicode /// instructions (Char or Ranges) since the DFA operates on bytes only. pub fn can_exec(insts: &Program) -> bool { - use prog::Inst::*; + use crate::prog::Inst::*; // If for some reason we manage to allocate a regex program with more // than i32::MAX instructions, then we can't execute the DFA because we // use 32 bit instruction pointer deltas for memory savings. @@ -306,7 +306,7 @@ StateFlags(self.data[0]) } - fn inst_ptrs(&self) -> InstPtrs { + fn inst_ptrs(&self) -> InstPtrs<'_> { InstPtrs { base: 0, data: &self.data[1..] } } } @@ -679,7 +679,7 @@ } } else if next_si & STATE_START > 0 { // A start state isn't in the common case because we may - // what to do quick prefix scanning. If the program doesn't + // want to do quick prefix scanning. If the program doesn't // have a detected prefix, then start states are actually // considered common and this case is never reached. debug_assert!(self.has_prefix()); @@ -725,7 +725,7 @@ } } - // Run the DFA once more on the special EOF senitnel value. + // Run the DFA once more on the special EOF sentinel value. // We don't care about the special bits in the state pointer any more, // so get rid of them. prev_si &= STATE_MAX; @@ -830,7 +830,7 @@ } } - // Run the DFA once more on the special EOF senitnel value. + // Run the DFA once more on the special EOF sentinel value. prev_si = match self.next_state(qcur, qnext, prev_si, Byte::eof()) { None => return Result::Quit, Some(STATE_DEAD) => return result.set_non_match(0), @@ -848,7 +848,7 @@ /// next_si transitions to the next state, where the transition input /// corresponds to text[i]. /// - /// This elides bounds checks, and is therefore unsafe. + /// This elides bounds checks, and is therefore not safe. #[cfg_attr(feature = "perf-inline", inline(always))] unsafe fn next_si(&self, si: StatePtr, text: &[u8], i: usize) -> StatePtr { // What is the argument for safety here? @@ -894,7 +894,7 @@ mut si: StatePtr, b: Byte, ) -> Option { - use prog::Inst::*; + use crate::prog::Inst::*; // Initialize a queue with the current DFA state's NFA states. qcur.clear(); @@ -913,8 +913,8 @@ if self.state(si).flags().has_empty() { // Compute the flags immediately preceding the current byte. // This means we only care about the "end" or "end line" flags. - // (The "start" flags are computed immediately proceding the - // current byte and is handled below.) + // (The "start" flags are computed immediately following the + // current byte and are handled below.) let mut flags = EmptyFlags::default(); if b.is_eof() { flags.end = true; @@ -1048,7 +1048,7 @@ /// /// If matching starts after the beginning of the input, then only start /// line should be set if the preceding byte is `\n`. End line should never - /// be set in this case. (Even if the proceding byte is a `\n`, it will + /// be set in this case. (Even if the following byte is a `\n`, it will /// be handled in a subsequent DFA state.) fn follow_epsilons( &mut self, @@ -1056,8 +1056,8 @@ q: &mut SparseSet, flags: EmptyFlags, ) { - use prog::EmptyLook::*; - use prog::Inst::*; + use crate::prog::EmptyLook::*; + use crate::prog::Inst::*; // We need to traverse the NFA to follow epsilon transitions, so avoid // recursion with an explicit stack. @@ -1190,7 +1190,7 @@ q: &SparseSet, state_flags: &mut StateFlags, ) -> Option { - use prog::Inst::*; + use crate::prog::Inst::*; // We need to build up enough information to recognize pre-built states // in the DFA. Generally speaking, this includes every instruction @@ -1688,7 +1688,7 @@ self.num_byte_classes * mem::size_of::() } - /// Like `next`, but uses unchecked access and is therefore unsafe. + /// Like `next`, but uses unchecked access and is therefore not safe. unsafe fn next_unchecked(&self, si: StatePtr, cls: usize) -> StatePtr { debug_assert!((si as usize) < self.table.len()); debug_assert!(cls < self.num_byte_classes); @@ -1754,7 +1754,7 @@ } impl fmt::Debug for State { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let ips: Vec = self.inst_ptrs().collect(); f.debug_struct("State") .field("flags", &self.flags()) @@ -1764,7 +1764,7 @@ } impl fmt::Debug for Transitions { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut fmtd = f.debug_map(); for si in 0..self.num_states() { let s = si * self.num_byte_classes; @@ -1778,7 +1778,7 @@ struct TransitionsRow<'a>(&'a [StatePtr]); impl<'a> fmt::Debug for TransitionsRow<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut fmtd = f.debug_map(); for (b, si) in self.0.iter().enumerate() { match *si { @@ -1796,7 +1796,7 @@ } impl fmt::Debug for StateFlags { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("StateFlags") .field("is_match", &self.is_match()) .field("is_word", &self.is_word()) @@ -1889,18 +1889,27 @@ #[cfg(test)] mod tests { - extern crate rand; use super::{ push_inst_ptr, read_vari32, read_varu32, write_vari32, write_varu32, State, StateFlags, }; - use quickcheck::{quickcheck, QuickCheck, StdGen}; + use quickcheck::{quickcheck, Gen, QuickCheck}; use std::sync::Arc; #[test] fn prop_state_encode_decode() { - fn p(ips: Vec, flags: u8) -> bool { + fn p(mut ips: Vec, flags: u8) -> bool { + // It looks like our encoding scheme can't handle instruction + // pointers at or above 2**31. We should fix that, but it seems + // unlikely to occur in real code due to the amount of memory + // required for such a state machine. So for now, we just clamp + // our test data. + for ip in &mut ips { + if *ip >= 1 << 31 { + *ip = (1 << 31) - 1; + } + } let mut data = vec![flags]; let mut prev = 0; for &ip in ips.iter() { @@ -1914,7 +1923,7 @@ expected == got && state.flags() == StateFlags(flags) } QuickCheck::new() - .gen(StdGen::new(self::rand::thread_rng(), 10_000)) + .gen(Gen::new(10_000)) .quickcheck(p as fn(Vec, u8) -> bool); } diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/error.rs cargo-0.58.0/vendor/regex/src/error.rs --- cargo-0.57.0+ubuntu/vendor/regex/src/error.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/src/error.rs 2022-01-21 02:47:39.000000000 +0000 @@ -31,7 +31,7 @@ } impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::Syntax(ref err) => err.fmt(f), Error::CompiledTooBig(limit) => write!( @@ -49,7 +49,7 @@ // but the `Syntax` variant is already storing a `String` anyway, so we might // as well format it nicely. impl fmt::Debug for Error { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { Error::Syntax(ref err) => { let hr: String = repeat('~').take(79).collect(); diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/exec.rs cargo-0.58.0/vendor/regex/src/exec.rs --- cargo-0.57.0+ubuntu/vendor/regex/src/exec.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/src/exec.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,40 +1,49 @@ use std::cell::RefCell; use std::collections::HashMap; +use std::panic::AssertUnwindSafe; use std::sync::Arc; #[cfg(feature = "perf-literal")] use aho_corasick::{AhoCorasick, AhoCorasickBuilder, MatchKind}; -use syntax::hir::literal::Literals; -use syntax::hir::Hir; -use syntax::ParserBuilder; - -use backtrack; -use cache::{Cached, CachedGuard}; -use compile::Compiler; +use regex_syntax::hir::literal::Literals; +use regex_syntax::hir::Hir; +use regex_syntax::ParserBuilder; + +use crate::backtrack; +use crate::compile::Compiler; #[cfg(feature = "perf-dfa")] -use dfa; -use error::Error; -use input::{ByteInput, CharInput}; -use literal::LiteralSearcher; -use pikevm; -use prog::Program; -use re_builder::RegexOptions; -use re_bytes; -use re_set; -use re_trait::{Locations, RegularExpression, Slot}; -use re_unicode; -use utf8::next_utf8; +use crate::dfa; +use crate::error::Error; +use crate::input::{ByteInput, CharInput}; +use crate::literal::LiteralSearcher; +use crate::pikevm; +use crate::pool::{Pool, PoolGuard}; +use crate::prog::Program; +use crate::re_builder::RegexOptions; +use crate::re_bytes; +use crate::re_set; +use crate::re_trait::{Locations, RegularExpression, Slot}; +use crate::re_unicode; +use crate::utf8::next_utf8; /// `Exec` manages the execution of a regular expression. /// /// In particular, this manages the various compiled forms of a single regular /// expression and the choice of which matching engine to use to execute a /// regular expression. +#[derive(Debug)] pub struct Exec { /// All read only state. ro: Arc, - /// Caches for the various matching engines. - cache: Cached, + /// A pool of reusable values for the various matching engines. + /// + /// Note that boxing this value is not strictly necessary, but it is an + /// easy way to ensure that T does not bloat the stack sized used by a pool + /// in the case where T is big. And this turns out to be the case at the + /// time of writing for regex's use of this pool. At the time of writing, + /// the size of a Regex on the stack is 856 bytes. Boxing this value + /// reduces that size to 16 bytes. + pool: Box>, } /// `ExecNoSync` is like `Exec`, except it embeds a reference to a cache. This @@ -45,10 +54,11 @@ /// All read only state. ro: &'c Arc, /// Caches for the various matching engines. - cache: CachedGuard<'c, ProgramCache>, + cache: PoolGuard<'c, ProgramCache>, } /// `ExecNoSyncStr` is like `ExecNoSync`, but matches on &str instead of &[u8]. +#[derive(Debug)] pub struct ExecNoSyncStr<'c>(ExecNoSync<'c>); /// `ExecReadOnly` comprises all read only state for a regex. Namely, all such @@ -97,6 +107,9 @@ /// Facilitates the construction of an executor by exposing various knobs /// to control how a regex is executed and what kinds of resources it's /// permitted to use. +// `ExecBuilder` is only public via the `internal` module, so avoid deriving +// `Debug`. +#[allow(missing_debug_implementations)] pub struct ExecBuilder { options: RegexOptions, match_type: Option, @@ -127,7 +140,7 @@ /// /// Note that when compiling 2 or more regular expressions, capture groups /// are completely unsupported. (This means both `find` and `captures` - /// wont work.) + /// won't work.) pub fn new_many(res: I) -> Self where S: AsRef, @@ -297,7 +310,8 @@ ac: None, match_type: MatchType::Nothing, }); - return Ok(Exec { ro: ro, cache: Cached::new() }); + let pool = ExecReadOnly::new_pool(&ro); + return Ok(Exec { ro: ro, pool }); } let parsed = self.parse()?; let mut nfa = Compiler::new() @@ -337,7 +351,8 @@ ro.match_type = ro.choose_match_type(self.match_type); let ro = Arc::new(ro); - Ok(Exec { ro: ro, cache: Cached::new() }) + let pool = ExecReadOnly::new_pool(&ro); + Ok(Exec { ro, pool }) } #[cfg(feature = "perf-literal")] @@ -358,9 +373,6 @@ AhoCorasickBuilder::new() .match_kind(MatchKind::LeftmostFirst) .auto_configure(&lits) - // We always want this to reduce size, regardless - // of what auto-configure does. - .byte_classes(true) .build_with_size::(&lits) // This should never happen because we'd long exceed the // compilation limit for regexes first. @@ -724,7 +736,7 @@ text: &[u8], start: usize, ) -> dfa::Result<(usize, usize)> { - use dfa::Result::*; + use crate::dfa::Result::*; let end = match dfa::Fsm::forward( &self.ro.dfa, self.cache.value(), @@ -764,7 +776,7 @@ text: &[u8], start: usize, ) -> dfa::Result<(usize, usize)> { - use dfa::Result::*; + use crate::dfa::Result::*; match dfa::Fsm::reverse( &self.ro.dfa_reverse, self.cache.value(), @@ -820,7 +832,7 @@ text: &[u8], original_start: usize, ) -> Option> { - use dfa::Result::*; + use crate::dfa::Result::*; let lcs = self.ro.suffixes.lcs(); debug_assert!(lcs.len() >= 1); @@ -865,7 +877,7 @@ text: &[u8], start: usize, ) -> dfa::Result<(usize, usize)> { - use dfa::Result::*; + use crate::dfa::Result::*; let match_start = match self.exec_dfa_reverse_suffix(text, start) { None => return self.find_dfa_forward(text, start), @@ -1248,17 +1260,16 @@ impl Exec { /// Get a searcher that isn't Sync. #[cfg_attr(feature = "perf-inline", inline(always))] - pub fn searcher(&self) -> ExecNoSync { - let create = || RefCell::new(ProgramCacheInner::new(&self.ro)); + pub fn searcher(&self) -> ExecNoSync<'_> { ExecNoSync { ro: &self.ro, // a clone is too expensive here! (and not needed) - cache: self.cache.get_or(create), + cache: self.pool.get(), } } /// Get a searcher that isn't Sync and can match on &str. #[cfg_attr(feature = "perf-inline", inline(always))] - pub fn searcher_str(&self) -> ExecNoSyncStr { + pub fn searcher_str(&self) -> ExecNoSyncStr<'_> { ExecNoSyncStr(self.searcher()) } @@ -1304,7 +1315,8 @@ impl Clone for Exec { fn clone(&self) -> Exec { - Exec { ro: self.ro.clone(), cache: Cached::new() } + let pool = ExecReadOnly::new_pool(&self.ro); + Exec { ro: self.ro.clone(), pool } } } @@ -1437,6 +1449,13 @@ let lcs_len = self.suffixes.lcs().char_len(); lcs_len >= 3 && lcs_len > self.dfa.prefixes.lcp().char_len() } + + fn new_pool(ro: &Arc) -> Box> { + let ro = ro.clone(); + Box::new(Pool::new(Box::new(move || { + AssertUnwindSafe(RefCell::new(ProgramCacheInner::new(&ro))) + }))) + } } #[derive(Clone, Copy, Debug)] @@ -1495,7 +1514,11 @@ /// `ProgramCache` maintains reusable allocations for each matching engine /// available to a particular program. -pub type ProgramCache = RefCell; +/// +/// We declare this as unwind safe since it's a cache that's only used for +/// performance purposes. If a panic occurs, it is (or should be) always safe +/// to continue using the same regex object. +pub type ProgramCache = AssertUnwindSafe>; #[derive(Debug)] pub struct ProgramCacheInner { @@ -1524,7 +1547,7 @@ /// literals, and if so, returns them. Otherwise, this returns None. #[cfg(feature = "perf-literal")] fn alternation_literals(expr: &Hir) -> Option>> { - use syntax::hir::{HirKind, Literal}; + use regex_syntax::hir::{HirKind, Literal}; // This is pretty hacky, but basically, if `is_alternation_literal` is // true, then we can make several assumptions about the structure of our @@ -1576,7 +1599,7 @@ mod test { #[test] fn uppercut_s_backtracking_bytes_default_bytes_mismatch() { - use internal::ExecBuilder; + use crate::internal::ExecBuilder; let backtrack_bytes_re = ExecBuilder::new("^S") .bounded_backtracking() @@ -1604,7 +1627,7 @@ #[test] fn unicode_lit_star_backtracking_utf8bytes_default_utf8bytes_mismatch() { - use internal::ExecBuilder; + use crate::internal::ExecBuilder; let backtrack_bytes_re = ExecBuilder::new(r"^(?u:\*)") .bounded_backtracking() diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/expand.rs cargo-0.58.0/vendor/regex/src/expand.rs --- cargo-0.57.0+ubuntu/vendor/regex/src/expand.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/src/expand.rs 2022-01-21 02:47:39.000000000 +0000 @@ -1,12 +1,12 @@ use std::str; -use find_byte::find_byte; +use crate::find_byte::find_byte; -use re_bytes; -use re_unicode; +use crate::re_bytes; +use crate::re_unicode; pub fn expand_str( - caps: &re_unicode::Captures, + caps: &re_unicode::Captures<'_>, mut replacement: &str, dst: &mut String, ) { @@ -24,7 +24,7 @@ continue; } debug_assert!(!replacement.is_empty()); - let cap_ref = match find_cap_ref(replacement) { + let cap_ref = match find_cap_ref(replacement.as_bytes()) { Some(cap_ref) => cap_ref, None => { dst.push_str("$"); @@ -48,7 +48,7 @@ } pub fn expand_bytes( - caps: &re_bytes::Captures, + caps: &re_bytes::Captures<'_>, mut replacement: &[u8], dst: &mut Vec, ) { @@ -125,19 +125,15 @@ /// starting at the beginning of `replacement`. /// /// If no such valid reference could be found, None is returned. -fn find_cap_ref>( - replacement: &T, -) -> Option { +fn find_cap_ref(replacement: &[u8]) -> Option> { let mut i = 0; let rep: &[u8] = replacement.as_ref(); if rep.len() <= 1 || rep[0] != b'$' { return None; } - let mut brace = false; i += 1; if rep[i] == b'{' { - brace = true; - i += 1; + return find_cap_ref_braced(rep, i + 1); } let mut cap_end = i; while rep.get(cap_end).map_or(false, is_valid_cap_letter) { @@ -148,15 +144,10 @@ } // We just verified that the range 0..cap_end is valid ASCII, so it must // therefore be valid UTF-8. If we really cared, we could avoid this UTF-8 - // check with either unsafe or by parsing the number straight from &[u8]. + // check via an unchecked conversion or by parsing the number straight from + // &[u8]. let cap = str::from_utf8(&rep[i..cap_end]).expect("valid UTF-8 capture name"); - if brace { - if !rep.get(cap_end).map_or(false, |&b| b == b'}') { - return None; - } - cap_end += 1; - } Some(CaptureRef { cap: match cap.parse::() { Ok(i) => Ref::Number(i as usize), @@ -166,6 +157,31 @@ }) } +fn find_cap_ref_braced(rep: &[u8], mut i: usize) -> Option> { + let start = i; + while rep.get(i).map_or(false, |&b| b != b'}') { + i += 1; + } + if !rep.get(i).map_or(false, |&b| b == b'}') { + return None; + } + // When looking at braced names, we don't put any restrictions on the name, + // so it's possible it could be invalid UTF-8. But a capture group name + // can never be invalid UTF-8, so if we have invalid UTF-8, then we can + // safely return None. + let cap = match str::from_utf8(&rep[start..i]) { + Err(_) => return None, + Ok(cap) => cap, + }; + Some(CaptureRef { + cap: match cap.parse::() { + Ok(i) => Ref::Number(i as usize), + Err(_) => Ref::Named(cap), + }, + end: i + 1, + }) +} + /// Returns true if and only if the given byte is allowed in a capture name. fn is_valid_cap_letter(b: &u8) -> bool { match *b { @@ -182,13 +198,13 @@ ($name:ident, $text:expr) => { #[test] fn $name() { - assert_eq!(None, find_cap_ref($text)); + assert_eq!(None, find_cap_ref($text.as_bytes())); } }; ($name:ident, $text:expr, $capref:expr) => { #[test] fn $name() { - assert_eq!(Some($capref), find_cap_ref($text)); + assert_eq!(Some($capref), find_cap_ref($text.as_bytes())); } }; } @@ -204,7 +220,8 @@ find!(find_cap_ref3, "$0", c!(0, 2)); find!(find_cap_ref4, "$5", c!(5, 2)); find!(find_cap_ref5, "$10", c!(10, 3)); - // see https://github.com/rust-lang/regex/pull/585 for more on characters following numbers + // See https://github.com/rust-lang/regex/pull/585 + // for more on characters following numbers find!(find_cap_ref6, "$42a", c!("42a", 4)); find!(find_cap_ref7, "${42}a", c!(42, 5)); find!(find_cap_ref8, "${42"); @@ -217,4 +234,6 @@ find!(find_cap_ref15, "$1_$2", c!("1_", 3)); find!(find_cap_ref16, "$x-$y", c!("x", 2)); find!(find_cap_ref17, "$x_$y", c!("x_", 3)); + find!(find_cap_ref18, "${#}", c!("#", 4)); + find!(find_cap_ref19, "${Z[}", c!("Z[", 5)); } diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/input.rs cargo-0.58.0/vendor/regex/src/input.rs --- cargo-0.57.0+ubuntu/vendor/regex/src/input.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/src/input.rs 2022-01-21 02:47:39.000000000 +0000 @@ -4,11 +4,9 @@ use std::ops; use std::u32; -use syntax; - -use literal::LiteralSearcher; -use prog::InstEmptyLook; -use utf8::{decode_last_utf8, decode_utf8}; +use crate::literal::LiteralSearcher; +use crate::prog::InstEmptyLook; +use crate::utf8::{decode_last_utf8, decode_utf8}; /// Represents a location in the input. #[derive(Clone, Copy, Debug)] @@ -175,7 +173,7 @@ } fn is_empty_match(&self, at: InputAt, empty: &InstEmptyLook) -> bool { - use prog::EmptyLook::*; + use crate::prog::EmptyLook::*; match empty.look { StartLine => { let c = self.previous_char(at); @@ -268,7 +266,7 @@ } fn is_empty_match(&self, at: InputAt, empty: &InstEmptyLook) -> bool { - use prog::EmptyLook::*; + use crate::prog::EmptyLook::*; match empty.look { StartLine => { let c = self.previous_char(at); @@ -348,7 +346,7 @@ pub struct Char(u32); impl fmt::Debug for Char { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match char::from_u32(self.0) { None => write!(f, "Empty"), Some(c) => write!(f, "{:?}", c), @@ -379,7 +377,7 @@ // available. However, our compiler ensures that if a Unicode word // boundary is used, then the data must also be available. If it isn't, // then the compiler returns an error. - char::from_u32(self.0).map_or(false, syntax::is_word_character) + char::from_u32(self.0).map_or(false, regex_syntax::is_word_character) } /// Returns true iff the byte is a word byte. @@ -387,7 +385,7 @@ /// If the byte is absent, then false is returned. pub fn is_word_byte(self) -> bool { match char::from_u32(self.0) { - Some(c) if c <= '\u{7F}' => syntax::is_word_byte(c as u8), + Some(c) if c <= '\u{7F}' => regex_syntax::is_word_byte(c as u8), None | Some(_) => false, } } diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/lib.rs cargo-0.58.0/vendor/regex/src/lib.rs --- cargo-0.57.0+ubuntu/vendor/regex/src/lib.rs 2021-10-23 22:01:12.000000000 +0000 +++ cargo-0.58.0/vendor/regex/src/lib.rs 2022-01-21 02:47:39.000000000 +0000 @@ -22,12 +22,6 @@ regex = "1" ``` -If you're using Rust 2015, then you'll also need to add it to your crate root: - -```rust -extern crate regex; -``` - # Example: find a date General use of regular expressions in this package involves compiling an @@ -68,9 +62,7 @@ For example: ```rust -#[macro_use] extern crate lazy_static; -extern crate regex; - +use lazy_static::lazy_static; use regex::Regex; fn some_helper_function(text: &str) -> bool { @@ -94,7 +86,7 @@ them by their component pieces: ```rust -# extern crate regex; use regex::Regex; +# use regex::Regex; # fn main() { let re = Regex::new(r"(\d{4})-(\d{2})-(\d{2})").unwrap(); let text = "2012-03-14, 2013-01-01 and 2014-07-05"; @@ -119,7 +111,7 @@ in our replacement text: ```rust -# extern crate regex; use regex::Regex; +# use regex::Regex; # fn main() { let re = Regex::new(r"(?P\d{4})-(?P\d{2})-(?P\d{2})").unwrap(); let before = "2012-03-14, 2013-01-01 and 2014-07-05"; @@ -136,7 +128,7 @@ enable insignificant whitespace mode, which also lets you write comments: ```rust -# extern crate regex; use regex::Regex; +# use regex::Regex; # fn main() { let re = Regex::new(r"(?x) (?P\d{4}) # the year @@ -217,7 +209,7 @@ in your expression: ```rust -# extern crate regex; use regex::Regex; +# use regex::Regex; # fn main() { let re = Regex::new(r"(?i)Δ+").unwrap(); let mat = re.find("ΔδΔ").unwrap(); @@ -244,7 +236,7 @@ match a sequence of numerals, Greek or Cherokee letters: ```rust -# extern crate regex; use regex::Regex; +# use regex::Regex; # fn main() { let re = Regex::new(r"[\pN\p{Greek}\p{Cherokee}]+").unwrap(); let mat = re.find("abcΔᎠβⅠᏴγδⅡxyz").unwrap(); @@ -253,7 +245,7 @@ ``` For a more detailed breakdown of Unicode support with respect to -[UTS#18](http://unicode.org/reports/tr18/), +[UTS#18](https://unicode.org/reports/tr18/), please see the [UNICODE](https://github.com/rust-lang/regex/blob/master/UNICODE.md) document in the root of the regex repository. @@ -365,7 +357,7 @@
 (exp)          numbered capture group (indexed by opening parenthesis)
-(?P<name>exp)  named (also numbered) capture group (allowed chars: [_0-9a-zA-Z])
+(?P<name>exp)  named (also numbered) capture group (allowed chars: [_0-9a-zA-Z.\[\]])
 (?:exp)        non-capturing group
 (?flags)       set flags within current group
 (?flags:exp)   set flags for exp (non-capturing)
@@ -391,7 +383,7 @@
 case-insensitively for the first part but case-sensitively for the second part:
 
 ```rust
-# extern crate regex; use regex::Regex;
+# use regex::Regex;
 # fn main() {
 let re = Regex::new(r"(?i)a+(?-i)b+").unwrap();
 let cap = re.captures("AaAaAbbBBBb").unwrap();
@@ -425,7 +417,7 @@
 word boundary:
 
 ```rust
-# extern crate regex; use regex::Regex;
+# use regex::Regex;
 # fn main() {
 let re = Regex::new(r"(?-u:\b).+(?-u:\b)").unwrap();
 let cap = re.captures("$$abc$$").unwrap();
@@ -455,7 +447,7 @@
 ## Perl character classes (Unicode friendly)
 
 These classes are based on the definitions provided in
-[UTS#18](http://www.unicode.org/reports/tr18/#Compatibility_Properties):
+[UTS#18](https://www.unicode.org/reports/tr18/#Compatibility_Properties):
 
 
 \d     digit (\p{Nd})
@@ -523,11 +515,6 @@
   Enables all performance related features. This feature is enabled by default
   and will always cover all features that improve performance, even if more
   are added in the future.
-* **perf-cache** -
-  Enables the use of very fast thread safe caching for internal match state.
-  When this is disabled, caching is still used, but with a slower and simpler
-  implementation. Disabling this drops the `thread_local` and `lazy_static`
-  dependencies.
 * **perf-dfa** -
   Enables the use of a lazy DFA for matching. The lazy DFA is used to compile
   portions of a regex to a very fast DFA on an as-needed basis. This can
@@ -542,6 +529,11 @@
   Enables the use of literal optimizations for speeding up matches. In some
   cases, literal optimizations can result in speedups of _several_ orders of
   magnitude. Disabling this drops the `aho-corasick` and `memchr` dependencies.
+* **perf-cache** -
+  This feature used to enable a faster internal cache at the cost of using
+  additional dependencies, but this is no longer an option. A fast internal
+  cache is now used unconditionally with no additional dependencies. This may
+  change in the future.
 
 ### Unicode features
 
@@ -562,7 +554,7 @@
   [Unicode's "simple loose matches" specification](https://www.unicode.org/reports/tr18/#Simple_Loose_Matches).
 * **unicode-gencat** -
   Provide the data for
-  [Uncode general categories](https://www.unicode.org/reports/tr44/tr44-24.html#General_Category_Values).
+  [Unicode general categories](https://www.unicode.org/reports/tr44/tr44-24.html#General_Category_Values).
   This includes, but is not limited to, `Decimal_Number`, `Letter`,
   `Math_Symbol`, `Number` and `Punctuation`.
 * **unicode-perl** -
@@ -614,39 +606,30 @@
 */
 
 #![deny(missing_docs)]
-#![cfg_attr(test, deny(warnings))]
 #![cfg_attr(feature = "pattern", feature(pattern))]
+#![warn(missing_debug_implementations)]
 
 #[cfg(not(feature = "std"))]
 compile_error!("`std` feature is currently required to build this crate");
 
-#[cfg(feature = "perf-literal")]
-extern crate aho_corasick;
-// #[cfg(doctest)]
-// extern crate doc_comment;
-#[cfg(feature = "perf-literal")]
-extern crate memchr;
-#[cfg(test)]
-#[cfg_attr(feature = "perf-literal", macro_use)]
-extern crate quickcheck;
-extern crate regex_syntax as syntax;
-#[cfg(feature = "perf-cache")]
-extern crate thread_local;
-
+// To check README's example
+// TODO: Re-enable this once the MSRV is 1.43 or greater.
+// See: https://github.com/rust-lang/regex/issues/684
+// See: https://github.com/rust-lang/regex/issues/685
 // #[cfg(doctest)]
 // doc_comment::doctest!("../README.md");
 
 #[cfg(feature = "std")]
-pub use error::Error;
+pub use crate::error::Error;
 #[cfg(feature = "std")]
-pub use re_builder::set_unicode::*;
+pub use crate::re_builder::set_unicode::*;
 #[cfg(feature = "std")]
-pub use re_builder::unicode::*;
+pub use crate::re_builder::unicode::*;
 #[cfg(feature = "std")]
-pub use re_set::unicode::*;
+pub use crate::re_set::unicode::*;
 #[cfg(feature = "std")]
 #[cfg(feature = "std")]
-pub use re_unicode::{
+pub use crate::re_unicode::{
     escape, CaptureLocations, CaptureMatches, CaptureNames, Captures,
     Locations, Match, Matches, NoExpand, Regex, Replacer, ReplacerRef, Split,
     SplitN, SubCaptureMatches,
@@ -731,8 +714,8 @@
 literal byte `\xFF`, while in Unicode mode, `\xFF` is a Unicode codepoint that
 matches its UTF-8 encoding of `\xC3\xBF`. Similarly for octal notation when
 enabled.
-6. `.` matches any *byte* except for `\n` instead of any Unicode scalar value.
-When the `s` flag is enabled, `.` matches any byte.
+6. In ASCII compatible mode, `.` matches any *byte* except for `\n`. When the
+`s` flag is additionally enabled, `.` matches any byte.
 
 # Performance
 
@@ -741,14 +724,13 @@
 */
 #[cfg(feature = "std")]
 pub mod bytes {
-    pub use re_builder::bytes::*;
-    pub use re_builder::set_bytes::*;
-    pub use re_bytes::*;
-    pub use re_set::bytes::*;
+    pub use crate::re_builder::bytes::*;
+    pub use crate::re_builder::set_bytes::*;
+    pub use crate::re_bytes::*;
+    pub use crate::re_set::bytes::*;
 }
 
 mod backtrack;
-mod cache;
 mod compile;
 #[cfg(feature = "perf-dfa")]
 mod dfa;
@@ -756,13 +738,12 @@
 mod exec;
 mod expand;
 mod find_byte;
-#[cfg(feature = "perf-literal")]
-mod freqs;
 mod input;
 mod literal;
 #[cfg(feature = "pattern")]
 mod pattern;
 mod pikevm;
+mod pool;
 mod prog;
 mod re_builder;
 mod re_bytes;
@@ -778,9 +759,9 @@
 #[doc(hidden)]
 #[cfg(feature = "std")]
 pub mod internal {
-    pub use compile::Compiler;
-    pub use exec::{Exec, ExecBuilder};
-    pub use input::{Char, CharInput, Input, InputAt};
-    pub use literal::LiteralSearcher;
-    pub use prog::{EmptyLook, Inst, InstRanges, Program};
+    pub use crate::compile::Compiler;
+    pub use crate::exec::{Exec, ExecBuilder};
+    pub use crate::input::{Char, CharInput, Input, InputAt};
+    pub use crate::literal::LiteralSearcher;
+    pub use crate::prog::{EmptyLook, Inst, InstRanges, Program};
 }
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/literal/imp.rs cargo-0.58.0/vendor/regex/src/literal/imp.rs
--- cargo-0.57.0+ubuntu/vendor/regex/src/literal/imp.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/src/literal/imp.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,11 +1,8 @@
-use std::cmp;
 use std::mem;
 
 use aho_corasick::{self, packed, AhoCorasick, AhoCorasickBuilder};
-use memchr::{memchr, memchr2, memchr3};
-use syntax::hir::literal::{Literal, Literals};
-
-use freqs::BYTE_FREQUENCIES;
+use memchr::{memchr, memchr2, memchr3, memmem};
+use regex_syntax::hir::literal::{Literal, Literals};
 
 /// A prefix extracted from a compiled regular expression.
 ///
@@ -15,8 +12,8 @@
 #[derive(Clone, Debug)]
 pub struct LiteralSearcher {
     complete: bool,
-    lcp: FreqyPacked,
-    lcs: FreqyPacked,
+    lcp: Memmem,
+    lcs: Memmem,
     matcher: Matcher,
 }
 
@@ -26,10 +23,8 @@
     Empty,
     /// A set of four or more single byte literals.
     Bytes(SingleByteSet),
-    /// A single substring, find using memchr and frequency analysis.
-    FreqyPacked(FreqyPacked),
-    /// A single substring, find using Boyer-Moore.
-    BoyerMoore(BoyerMooreSearch),
+    /// A single substring, using vector accelerated routines when available.
+    Memmem(Memmem),
     /// An Aho-Corasick automaton.
     AC { ac: AhoCorasick, lits: Vec },
     /// A packed multiple substring searcher, using SIMD.
@@ -63,8 +58,8 @@
         let complete = lits.all_complete();
         LiteralSearcher {
             complete: complete,
-            lcp: FreqyPacked::new(lits.longest_common_prefix().to_vec()),
-            lcs: FreqyPacked::new(lits.longest_common_suffix().to_vec()),
+            lcp: Memmem::new(lits.longest_common_prefix()),
+            lcs: Memmem::new(lits.longest_common_suffix()),
             matcher: matcher,
         }
     }
@@ -72,7 +67,7 @@
     /// Returns true if all matches comprise the entire regular expression.
     ///
     /// This does not necessarily mean that a literal match implies a match
-    /// of the regular expression. For example, the regular expresison `^a`
+    /// of the regular expression. For example, the regular expression `^a`
     /// is comprised of a single complete literal `a`, but the regular
     /// expression demands that it only match at the beginning of a string.
     pub fn complete(&self) -> bool {
@@ -86,8 +81,7 @@
         match self.matcher {
             Empty => Some((0, 0)),
             Bytes(ref sset) => sset.find(haystack).map(|i| (i, i + 1)),
-            FreqyPacked(ref s) => s.find(haystack).map(|i| (i, i + s.len())),
-            BoyerMoore(ref s) => s.find(haystack).map(|i| (i, i + s.len())),
+            Memmem(ref s) => s.find(haystack).map(|i| (i, i + s.len())),
             AC { ref ac, .. } => {
                 ac.find(haystack).map(|m| (m.start(), m.end()))
             }
@@ -124,24 +118,23 @@
     }
 
     /// Returns an iterator over all literals to be matched.
-    pub fn iter(&self) -> LiteralIter {
+    pub fn iter(&self) -> LiteralIter<'_> {
         match self.matcher {
             Matcher::Empty => LiteralIter::Empty,
             Matcher::Bytes(ref sset) => LiteralIter::Bytes(&sset.dense),
-            Matcher::FreqyPacked(ref s) => LiteralIter::Single(&s.pat),
-            Matcher::BoyerMoore(ref s) => LiteralIter::Single(&s.pattern),
+            Matcher::Memmem(ref s) => LiteralIter::Single(&s.finder.needle()),
             Matcher::AC { ref lits, .. } => LiteralIter::AC(lits),
             Matcher::Packed { ref lits, .. } => LiteralIter::Packed(lits),
         }
     }
 
     /// Returns a matcher for the longest common prefix of this matcher.
-    pub fn lcp(&self) -> &FreqyPacked {
+    pub fn lcp(&self) -> &Memmem {
         &self.lcp
     }
 
     /// Returns a matcher for the longest common suffix of this matcher.
-    pub fn lcs(&self) -> &FreqyPacked {
+    pub fn lcs(&self) -> &Memmem {
         &self.lcs
     }
 
@@ -156,8 +149,7 @@
         match self.matcher {
             Empty => 0,
             Bytes(ref sset) => sset.dense.len(),
-            FreqyPacked(_) => 1,
-            BoyerMoore(_) => 1,
+            Memmem(_) => 1,
             AC { ref ac, .. } => ac.pattern_count(),
             Packed { ref lits, .. } => lits.len(),
         }
@@ -169,8 +161,7 @@
         match self.matcher {
             Empty => 0,
             Bytes(ref sset) => sset.approximate_size(),
-            FreqyPacked(ref single) => single.approximate_size(),
-            BoyerMoore(ref single) => single.approximate_size(),
+            Memmem(ref single) => single.approximate_size(),
             AC { ref ac, .. } => ac.heap_bytes(),
             Packed { ref s, .. } => s.heap_bytes(),
         }
@@ -205,12 +196,7 @@
             return Matcher::Bytes(sset);
         }
         if lits.literals().len() == 1 {
-            let lit = lits.literals()[0].to_vec();
-            if BoyerMooreSearch::should_use(lit.as_slice()) {
-                return Matcher::BoyerMoore(BoyerMooreSearch::new(lit));
-            } else {
-                return Matcher::FreqyPacked(FreqyPacked::new(lit));
-            }
+            return Matcher::Memmem(Memmem::new(&lits.literals()[0]));
         }
 
         let pats = lits.literals().to_owned();
@@ -232,6 +218,7 @@
     }
 }
 
+#[derive(Debug)]
 pub enum LiteralIter<'a> {
     Empty,
     Bytes(&'a [u8]),
@@ -366,116 +353,27 @@
     }
 }
 
-/// Provides an implementation of fast subtring search using frequency
-/// analysis.
+/// A simple wrapper around the memchr crate's memmem implementation.
 ///
-/// memchr is so fast that we do everything we can to keep the loop in memchr
-/// for as long as possible. The easiest way to do this is to intelligently
-/// pick the byte to send to memchr. The best byte is the byte that occurs
-/// least frequently in the haystack. Since doing frequency analysis on the
-/// haystack is far too expensive, we compute a set of fixed frequencies up
-/// front and hard code them in src/freqs.rs. Frequency analysis is done via
-/// scripts/frequencies.py.
+/// The API this exposes mirrors the API of previous substring searchers that
+/// this supplanted.
 #[derive(Clone, Debug)]
-pub struct FreqyPacked {
-    /// The pattern.
-    pat: Vec,
-    /// The number of Unicode characters in the pattern. This is useful for
-    /// determining the effective length of a pattern when deciding which
-    /// optimizations to perform. A trailing incomplete UTF-8 sequence counts
-    /// as one character.
+pub struct Memmem {
+    finder: memmem::Finder<'static>,
     char_len: usize,
-    /// The rarest byte in the pattern, according to pre-computed frequency
-    /// analysis.
-    rare1: u8,
-    /// The offset of the rarest byte in `pat`.
-    rare1i: usize,
-    /// The second rarest byte in the pattern, according to pre-computed
-    /// frequency analysis. (This may be equivalent to the rarest byte.)
-    ///
-    /// The second rarest byte is used as a type of guard for quickly detecting
-    /// a mismatch after memchr locates an instance of the rarest byte. This
-    /// is a hedge against pathological cases where the pre-computed frequency
-    /// analysis may be off. (But of course, does not prevent *all*
-    /// pathological cases.)
-    rare2: u8,
-    /// The offset of the second rarest byte in `pat`.
-    rare2i: usize,
 }
 
-impl FreqyPacked {
-    fn new(pat: Vec) -> FreqyPacked {
-        if pat.is_empty() {
-            return FreqyPacked::empty();
-        }
-
-        // Find the rarest two bytes. Try to make them distinct (but it's not
-        // required).
-        let mut rare1 = pat[0];
-        let mut rare2 = pat[0];
-        for b in pat[1..].iter().cloned() {
-            if freq_rank(b) < freq_rank(rare1) {
-                rare1 = b;
-            }
-        }
-        for &b in &pat {
-            if rare1 == rare2 {
-                rare2 = b
-            } else if b != rare1 && freq_rank(b) < freq_rank(rare2) {
-                rare2 = b;
-            }
-        }
-
-        // And find the offsets of their last occurrences.
-        let rare1i = pat.iter().rposition(|&b| b == rare1).unwrap();
-        let rare2i = pat.iter().rposition(|&b| b == rare2).unwrap();
-
-        let char_len = char_len_lossy(&pat);
-        FreqyPacked {
-            pat: pat,
-            char_len: char_len,
-            rare1: rare1,
-            rare1i: rare1i,
-            rare2: rare2,
-            rare2i: rare2i,
-        }
-    }
-
-    fn empty() -> FreqyPacked {
-        FreqyPacked {
-            pat: vec![],
-            char_len: 0,
-            rare1: 0,
-            rare1i: 0,
-            rare2: 0,
-            rare2i: 0,
+impl Memmem {
+    fn new(pat: &[u8]) -> Memmem {
+        Memmem {
+            finder: memmem::Finder::new(pat).into_owned(),
+            char_len: char_len_lossy(pat),
         }
     }
 
     #[cfg_attr(feature = "perf-inline", inline(always))]
     pub fn find(&self, haystack: &[u8]) -> Option {
-        let pat = &*self.pat;
-        if haystack.len() < pat.len() || pat.is_empty() {
-            return None;
-        }
-        let mut i = self.rare1i;
-        while i < haystack.len() {
-            i += match memchr(self.rare1, &haystack[i..]) {
-                None => return None,
-                Some(i) => i,
-            };
-            let start = i - self.rare1i;
-            let end = start + pat.len();
-            if end > haystack.len() {
-                return None;
-            }
-            let aligned = &haystack[start..end];
-            if aligned[self.rare2i] == self.rare2 && aligned == &*self.pat {
-                return Some(start);
-            }
-            i += 1;
-        }
-        None
+        self.finder.find(haystack)
     }
 
     #[cfg_attr(feature = "perf-inline", inline(always))]
@@ -483,11 +381,11 @@
         if text.len() < self.len() {
             return false;
         }
-        text[text.len() - self.len()..] == *self.pat
+        &text[text.len() - self.len()..] == self.finder.needle()
     }
 
     pub fn len(&self) -> usize {
-        self.pat.len()
+        self.finder.needle().len()
     }
 
     pub fn char_len(&self) -> usize {
@@ -495,627 +393,10 @@
     }
 
     fn approximate_size(&self) -> usize {
-        self.pat.len() * mem::size_of::()
+        self.finder.needle().len() * mem::size_of::()
     }
 }
 
 fn char_len_lossy(bytes: &[u8]) -> usize {
     String::from_utf8_lossy(bytes).chars().count()
 }
-
-/// An implementation of Tuned Boyer-Moore as laid out by
-/// Andrew Hume and Daniel Sunday in "Fast String Searching".
-/// O(n) in the size of the input.
-///
-/// Fast string searching algorithms come in many variations,
-/// but they can generally be described in terms of three main
-/// components.
-///
-/// The skip loop is where the string searcher wants to spend
-/// as much time as possible. Exactly which character in the
-/// pattern the skip loop examines varies from algorithm to
-/// algorithm, but in the simplest case this loop repeated
-/// looks at the last character in the pattern and jumps
-/// forward in the input if it is not in the pattern.
-/// Robert Boyer and J Moore called this the "fast" loop in
-/// their original paper.
-///
-/// The match loop is responsible for actually examining the
-/// whole potentially matching substring. In order to fail
-/// faster, the match loop sometimes has a guard test attached.
-/// The guard test uses frequency analysis of the different
-/// characters in the pattern to choose the least frequency
-/// occurring character and use it to find match failures
-/// as quickly as possible.
-///
-/// The shift rule governs how the algorithm will shuffle its
-/// test window in the event of a failure during the match loop.
-/// Certain shift rules allow the worst-case run time of the
-/// algorithm to be shown to be O(n) in the size of the input
-/// rather than O(nm) in the size of the input and the size
-/// of the pattern (as naive Boyer-Moore is).
-///
-/// "Fast String Searching", in addition to presenting a tuned
-/// algorithm, provides a comprehensive taxonomy of the many
-/// different flavors of string searchers. Under that taxonomy
-/// TBM, the algorithm implemented here, uses an unrolled fast
-/// skip loop with memchr fallback, a forward match loop with guard,
-/// and the mini Sunday's delta shift rule. To unpack that you'll have to
-/// read the paper.
-#[derive(Clone, Debug)]
-pub struct BoyerMooreSearch {
-    /// The pattern we are going to look for in the haystack.
-    pattern: Vec,
-
-    /// The skip table for the skip loop.
-    ///
-    /// Maps the character at the end of the input
-    /// to a shift.
-    skip_table: Vec,
-
-    /// The guard character (least frequently occurring char).
-    guard: u8,
-    /// The reverse-index of the guard character in the pattern.
-    guard_reverse_idx: usize,
-
-    /// Daniel Sunday's mini generalized delta2 shift table.
-    ///
-    /// We use a skip loop, so we only have to provide a shift
-    /// for the skip char (last char). This is why it is a mini
-    /// shift rule.
-    md2_shift: usize,
-}
-
-impl BoyerMooreSearch {
-    /// Create a new string searcher, performing whatever
-    /// compilation steps are required.
-    fn new(pattern: Vec) -> Self {
-        debug_assert!(!pattern.is_empty());
-
-        let (g, gi) = Self::select_guard(pattern.as_slice());
-        let skip_table = Self::compile_skip_table(pattern.as_slice());
-        let md2_shift = Self::compile_md2_shift(pattern.as_slice());
-        BoyerMooreSearch {
-            pattern: pattern,
-            skip_table: skip_table,
-            guard: g,
-            guard_reverse_idx: gi,
-            md2_shift: md2_shift,
-        }
-    }
-
-    /// Find the pattern in `haystack`, returning the offset
-    /// of the start of the first occurrence of the pattern
-    /// in `haystack`.
-    #[inline]
-    fn find(&self, haystack: &[u8]) -> Option {
-        if haystack.len() < self.pattern.len() {
-            return None;
-        }
-
-        let mut window_end = self.pattern.len() - 1;
-
-        // Inspired by the grep source. It is a way
-        // to do correct loop unrolling without having to place
-        // a crashpad of terminating charicters at the end in
-        // the way described in the Fast String Searching paper.
-        const NUM_UNROLL: usize = 10;
-        // 1 for the initial position, and 1 for the md2 shift
-        let short_circut = (NUM_UNROLL + 2) * self.pattern.len();
-
-        if haystack.len() > short_circut {
-            // just 1 for the md2 shift
-            let backstop =
-                haystack.len() - ((NUM_UNROLL + 1) * self.pattern.len());
-            loop {
-                window_end =
-                    match self.skip_loop(haystack, window_end, backstop) {
-                        Some(i) => i,
-                        None => return None,
-                    };
-                if window_end >= backstop {
-                    break;
-                }
-
-                if self.check_match(haystack, window_end) {
-                    return Some(window_end - (self.pattern.len() - 1));
-                } else {
-                    let skip = self.skip_table[haystack[window_end] as usize];
-                    window_end +=
-                        if skip == 0 { self.md2_shift } else { skip };
-                    continue;
-                }
-            }
-        }
-
-        // now process the input after the backstop
-        while window_end < haystack.len() {
-            let mut skip = self.skip_table[haystack[window_end] as usize];
-            if skip == 0 {
-                if self.check_match(haystack, window_end) {
-                    return Some(window_end - (self.pattern.len() - 1));
-                } else {
-                    skip = self.md2_shift;
-                }
-            }
-            window_end += skip;
-        }
-
-        None
-    }
-
-    fn len(&self) -> usize {
-        return self.pattern.len();
-    }
-
-    /// The key heuristic behind which the BoyerMooreSearch lives.
-    ///
-    /// See `rust-lang/regex/issues/408`.
-    ///
-    /// Tuned Boyer-Moore is actually pretty slow! It turns out a handrolled
-    /// platform-specific memchr routine with a bit of frequency
-    /// analysis sprinkled on top actually wins most of the time.
-    /// However, there are a few cases where Tuned Boyer-Moore still
-    /// wins.
-    ///
-    /// If the haystack is random, frequency analysis doesn't help us,
-    /// so Boyer-Moore will win for sufficiently large needles.
-    /// Unfortunately, there is no obvious way to determine this
-    /// ahead of time.
-    ///
-    /// If the pattern itself consists of very common characters,
-    /// frequency analysis won't get us anywhere. The most extreme
-    /// example of this is a pattern like `eeeeeeeeeeeeeeee`. Fortunately,
-    /// this case is wholly determined by the pattern, so we can actually
-    /// implement the heuristic.
-    ///
-    /// A third case is if the pattern is sufficiently long. The idea
-    /// here is that once the pattern gets long enough the Tuned
-    /// Boyer-Moore skip loop will start making strides long enough
-    /// to beat the asm deep magic that is memchr.
-    fn should_use(pattern: &[u8]) -> bool {
-        // The minimum pattern length required to use TBM.
-        const MIN_LEN: usize = 9;
-        // The minimum frequency rank (lower is rarer) that every byte in the
-        // pattern must have in order to use TBM. That is, if the pattern
-        // contains _any_ byte with a lower rank, then TBM won't be used.
-        const MIN_CUTOFF: usize = 150;
-        // The maximum frequency rank for any byte.
-        const MAX_CUTOFF: usize = 255;
-        // The scaling factor used to determine the actual cutoff frequency
-        // to use (keeping in mind that the minimum frequency rank is bounded
-        // by MIN_CUTOFF). This scaling factor is an attempt to make TBM more
-        // likely to be used as the pattern grows longer. That is, longer
-        // patterns permit somewhat less frequent bytes than shorter patterns,
-        // under the assumption that TBM gets better as the pattern gets
-        // longer.
-        const LEN_CUTOFF_PROPORTION: usize = 4;
-
-        let scaled_rank = pattern.len().wrapping_mul(LEN_CUTOFF_PROPORTION);
-        let cutoff = cmp::max(
-            MIN_CUTOFF,
-            MAX_CUTOFF - cmp::min(MAX_CUTOFF, scaled_rank),
-        );
-        // The pattern must be long enough to be worthwhile. e.g., memchr will
-        // be faster on `e` because it is short even though e is quite common.
-        pattern.len() > MIN_LEN
-            // all the bytes must be more common than the cutoff.
-            && pattern.iter().all(|c| freq_rank(*c) >= cutoff)
-    }
-
-    /// Check to see if there is a match at the given position
-    #[inline]
-    fn check_match(&self, haystack: &[u8], window_end: usize) -> bool {
-        // guard test
-        if haystack[window_end - self.guard_reverse_idx] != self.guard {
-            return false;
-        }
-
-        // match loop
-        let window_start = window_end - (self.pattern.len() - 1);
-        for i in 0..self.pattern.len() {
-            if self.pattern[i] != haystack[window_start + i] {
-                return false;
-            }
-        }
-
-        true
-    }
-
-    /// Skip forward according to the shift table.
-    ///
-    /// Returns the offset of the next occurrence
-    /// of the last char in the pattern, or the none
-    /// if it never reappears. If `skip_loop` hits the backstop
-    /// it will leave early.
-    #[inline]
-    fn skip_loop(
-        &self,
-        haystack: &[u8],
-        mut window_end: usize,
-        backstop: usize,
-    ) -> Option {
-        let window_end_snapshot = window_end;
-        let skip_of = |we: usize| -> usize {
-            // Unsafe might make this faster, but the benchmarks
-            // were hard to interpret.
-            self.skip_table[haystack[we] as usize]
-        };
-
-        loop {
-            let mut skip = skip_of(window_end);
-            window_end += skip;
-            skip = skip_of(window_end);
-            window_end += skip;
-            if skip != 0 {
-                skip = skip_of(window_end);
-                window_end += skip;
-                skip = skip_of(window_end);
-                window_end += skip;
-                skip = skip_of(window_end);
-                window_end += skip;
-                if skip != 0 {
-                    skip = skip_of(window_end);
-                    window_end += skip;
-                    skip = skip_of(window_end);
-                    window_end += skip;
-                    skip = skip_of(window_end);
-                    window_end += skip;
-                    if skip != 0 {
-                        skip = skip_of(window_end);
-                        window_end += skip;
-                        skip = skip_of(window_end);
-                        window_end += skip;
-
-                        // If ten iterations did not make at least 16 words
-                        // worth of progress, we just fall back on memchr.
-                        if window_end - window_end_snapshot
-                            > 16 * mem::size_of::()
-                        {
-                            // Returning a window_end >= backstop will
-                            // immediatly break us out of the inner loop in
-                            // `find`.
-                            if window_end >= backstop {
-                                return Some(window_end);
-                            }
-
-                            continue; // we made enough progress
-                        } else {
-                            // In case we are already there, and so that
-                            // we will catch the guard char.
-                            window_end = window_end
-                                .checked_sub(1 + self.guard_reverse_idx)
-                                .unwrap_or(0);
-
-                            match memchr(self.guard, &haystack[window_end..]) {
-                                None => return None,
-                                Some(g_idx) => {
-                                    return Some(
-                                        window_end
-                                            + g_idx
-                                            + self.guard_reverse_idx,
-                                    );
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-
-            return Some(window_end);
-        }
-    }
-
-    /// Compute the ufast skip table.
-    fn compile_skip_table(pattern: &[u8]) -> Vec {
-        let mut tab = vec![pattern.len(); 256];
-
-        // For every char in the pattern, we write a skip
-        // that will line us up with the rightmost occurrence.
-        //
-        // N.B. the sentinel (0) is written by the last
-        // loop iteration.
-        for (i, c) in pattern.iter().enumerate() {
-            tab[*c as usize] = (pattern.len() - 1) - i;
-        }
-
-        tab
-    }
-
-    /// Select the guard character based off of the precomputed
-    /// frequency table.
-    fn select_guard(pattern: &[u8]) -> (u8, usize) {
-        let mut rarest = pattern[0];
-        let mut rarest_rev_idx = pattern.len() - 1;
-        for (i, c) in pattern.iter().enumerate() {
-            if freq_rank(*c) < freq_rank(rarest) {
-                rarest = *c;
-                rarest_rev_idx = (pattern.len() - 1) - i;
-            }
-        }
-
-        (rarest, rarest_rev_idx)
-    }
-
-    /// If there is another occurrence of the skip
-    /// char, shift to it, otherwise just shift to
-    /// the next window.
-    fn compile_md2_shift(pattern: &[u8]) -> usize {
-        let shiftc = *pattern.last().unwrap();
-
-        // For a pattern of length 1 we will never apply the
-        // shift rule, so we use a poison value on the principle
-        // that failing fast is a good thing.
-        if pattern.len() == 1 {
-            return 0xDEADBEAF;
-        }
-
-        let mut i = pattern.len() - 2;
-        while i > 0 {
-            if pattern[i] == shiftc {
-                return (pattern.len() - 1) - i;
-            }
-            i -= 1;
-        }
-
-        // The skip char never re-occurs in the pattern, so
-        // we can just shift the whole window length.
-        pattern.len() - 1
-    }
-
-    fn approximate_size(&self) -> usize {
-        (self.pattern.len() * mem::size_of::())
-            + (256 * mem::size_of::()) // skip table
-    }
-}
-
-fn freq_rank(b: u8) -> usize {
-    BYTE_FREQUENCIES[b as usize] as usize
-}
-
-#[cfg(test)]
-mod tests {
-    use super::{BoyerMooreSearch, FreqyPacked};
-
-    //
-    // Unit Tests
-    //
-
-    // The "hello, world" of string searching
-    #[test]
-    fn bm_find_subs() {
-        let searcher = BoyerMooreSearch::new(Vec::from(&b"pattern"[..]));
-        let haystack = b"I keep seeing patterns in this text";
-        assert_eq!(14, searcher.find(haystack).unwrap());
-    }
-
-    #[test]
-    fn bm_find_no_subs() {
-        let searcher = BoyerMooreSearch::new(Vec::from(&b"pattern"[..]));
-        let haystack = b"I keep seeing needles in this text";
-        assert_eq!(None, searcher.find(haystack));
-    }
-
-    //
-    // Regression Tests
-    //
-
-    #[test]
-    fn bm_skip_reset_bug() {
-        let haystack = vec![0, 0, 0, 0, 0, 1, 1, 0];
-        let needle = vec![0, 1, 1, 0];
-
-        let searcher = BoyerMooreSearch::new(needle);
-        let offset = searcher.find(haystack.as_slice()).unwrap();
-        assert_eq!(4, offset);
-    }
-
-    #[test]
-    fn bm_backstop_underflow_bug() {
-        let haystack = vec![0, 0];
-        let needle = vec![0, 0];
-
-        let searcher = BoyerMooreSearch::new(needle);
-        let offset = searcher.find(haystack.as_slice()).unwrap();
-        assert_eq!(0, offset);
-    }
-
-    #[test]
-    fn bm_naive_off_by_one_bug() {
-        let haystack = vec![91];
-        let needle = vec![91];
-
-        let naive_offset = naive_find(&needle, &haystack).unwrap();
-        assert_eq!(0, naive_offset);
-    }
-
-    #[test]
-    fn bm_memchr_fallback_indexing_bug() {
-        let mut haystack = vec![
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        ];
-        let needle = vec![1, 1, 1, 1, 32, 32, 87];
-        let needle_start = haystack.len();
-        haystack.extend(needle.clone());
-
-        let searcher = BoyerMooreSearch::new(needle);
-        assert_eq!(needle_start, searcher.find(haystack.as_slice()).unwrap());
-    }
-
-    #[test]
-    fn bm_backstop_boundary() {
-        let haystack = b"\
-// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-e_data.clone_created(entity_id, entity_to_add.entity_id);
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-"
-        .to_vec();
-        let needle = b"clone_created".to_vec();
-
-        let searcher = BoyerMooreSearch::new(needle);
-        let result = searcher.find(&haystack);
-        assert_eq!(Some(43), result);
-    }
-
-    #[test]
-    fn bm_win_gnu_indexing_bug() {
-        let haystack_raw = vec![
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-        ];
-        let needle = vec![1, 1, 1, 1, 1, 1, 1];
-        let haystack = haystack_raw.as_slice();
-
-        BoyerMooreSearch::new(needle.clone()).find(haystack);
-    }
-
-    //
-    // QuickCheck Properties
-    //
-
-    use quickcheck::TestResult;
-
-    fn naive_find(needle: &[u8], haystack: &[u8]) -> Option {
-        assert!(needle.len() <= haystack.len());
-
-        for i in 0..(haystack.len() - (needle.len() - 1)) {
-            if haystack[i] == needle[0]
-                && &haystack[i..(i + needle.len())] == needle
-            {
-                return Some(i);
-            }
-        }
-
-        None
-    }
-
-    quickcheck! {
-        fn qc_bm_equals_nieve_find(pile1: Vec, pile2: Vec) -> TestResult {
-            if pile1.len() == 0 || pile2.len() == 0 {
-                return TestResult::discard();
-            }
-
-            let (needle, haystack) = if pile1.len() < pile2.len() {
-                (pile1, pile2.as_slice())
-            } else {
-                (pile2, pile1.as_slice())
-            };
-
-            let searcher = BoyerMooreSearch::new(needle.clone());
-            TestResult::from_bool(
-                searcher.find(haystack) == naive_find(&needle, haystack))
-        }
-
-        fn qc_bm_equals_single(pile1: Vec, pile2: Vec) -> TestResult {
-            if pile1.len() == 0 || pile2.len() == 0 {
-                return TestResult::discard();
-            }
-
-            let (needle, haystack) = if pile1.len() < pile2.len() {
-                (pile1, pile2.as_slice())
-            } else {
-                (pile2, pile1.as_slice())
-            };
-
-            let bm_searcher = BoyerMooreSearch::new(needle.clone());
-            let freqy_memchr = FreqyPacked::new(needle);
-            TestResult::from_bool(
-                bm_searcher.find(haystack) == freqy_memchr.find(haystack))
-        }
-
-        fn qc_bm_finds_trailing_needle(
-            haystack_pre: Vec,
-            needle: Vec
-        ) -> TestResult {
-            if needle.len() == 0 {
-                return TestResult::discard();
-            }
-
-            let mut haystack = haystack_pre.clone();
-            let searcher = BoyerMooreSearch::new(needle.clone());
-
-            if haystack.len() >= needle.len() &&
-                searcher.find(haystack.as_slice()).is_some() {
-                return TestResult::discard();
-            }
-
-            haystack.extend(needle.clone());
-
-            // What if the the tail of the haystack can start the
-            // needle?
-            let start = haystack_pre.len()
-                .checked_sub(needle.len())
-                .unwrap_or(0);
-            for i in 0..(needle.len() - 1) {
-                if searcher.find(&haystack[(i + start)..]).is_some() {
-                    return TestResult::discard();
-                }
-            }
-
-            TestResult::from_bool(
-                searcher.find(haystack.as_slice())
-                        .map(|x| x == haystack_pre.len())
-                        .unwrap_or(false))
-        }
-
-        // qc_equals_* is only testing the negative case as @burntsushi
-        // pointed out in https://github.com/rust-lang/regex/issues/446.
-        // This quickcheck prop represents an effort to force testing of
-        // the positive case. qc_bm_finds_first and qc_bm_finds_trailing_needle
-        // already check some of the positive cases, but they don't cover
-        // cases where the needle is in the middle of haystack. This prop
-        // fills that hole.
-        fn qc_bm_finds_subslice(
-            haystack: Vec,
-            needle_start: usize,
-            needle_length: usize
-        ) -> TestResult {
-            if haystack.len() == 0 {
-                return TestResult::discard();
-            }
-
-            let needle_start = needle_start % haystack.len();
-            let needle_length = needle_length % (haystack.len() - needle_start);
-
-            if needle_length == 0 {
-                return TestResult::discard();
-            }
-
-            let needle = &haystack[needle_start..(needle_start + needle_length)];
-
-            let bm_searcher = BoyerMooreSearch::new(needle.to_vec());
-
-            let start = naive_find(&needle, &haystack);
-            match start {
-                None => TestResult::from_bool(false),
-                Some(nf_start) =>
-                    TestResult::from_bool(
-                        nf_start <= needle_start
-                            && bm_searcher.find(&haystack) == start
-                    )
-            }
-        }
-
-        fn qc_bm_finds_first(needle: Vec) -> TestResult {
-            if needle.len() == 0 {
-                return TestResult::discard();
-            }
-
-            let mut haystack = needle.clone();
-            let searcher = BoyerMooreSearch::new(needle.clone());
-            haystack.extend(needle);
-
-            TestResult::from_bool(
-                searcher.find(haystack.as_slice())
-                        .map(|x| x == 0)
-                        .unwrap_or(false))
-        }
-    }
-}
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/literal/mod.rs cargo-0.58.0/vendor/regex/src/literal/mod.rs
--- cargo-0.57.0+ubuntu/vendor/regex/src/literal/mod.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/src/literal/mod.rs	2022-01-21 02:47:39.000000000 +0000
@@ -6,7 +6,7 @@
 #[allow(missing_docs)]
 #[cfg(not(feature = "perf-literal"))]
 mod imp {
-    use syntax::hir::literal::Literals;
+    use regex_syntax::hir::literal::Literals;
 
     #[derive(Clone, Debug)]
     pub struct LiteralSearcher(());
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/pattern.rs cargo-0.58.0/vendor/regex/src/pattern.rs
--- cargo-0.57.0+ubuntu/vendor/regex/src/pattern.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/src/pattern.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,7 +1,8 @@
 use std::str::pattern::{Pattern, SearchStep, Searcher};
 
-use re_unicode::{Matches, Regex};
+use crate::re_unicode::{Matches, Regex};
 
+#[derive(Debug)]
 pub struct RegexSearcher<'r, 't> {
     haystack: &'t str,
     it: Matches<'r, 't>,
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/pikevm.rs cargo-0.58.0/vendor/regex/src/pikevm.rs
--- cargo-0.57.0+ubuntu/vendor/regex/src/pikevm.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/src/pikevm.rs	2022-01-21 02:47:39.000000000 +0000
@@ -8,7 +8,7 @@
 //
 // It can do more than the DFA can (specifically, record capture locations
 // and execute Unicode word boundary assertions), but at a slower speed.
-// Specifically, the Pike VM exectues a DFA implicitly by repeatedly expanding
+// Specifically, the Pike VM executes a DFA implicitly by repeatedly expanding
 // epsilon transitions. That is, the Pike VM engine can be in multiple states
 // at once where as the DFA is only ever in one state at a time.
 //
@@ -17,11 +17,11 @@
 
 use std::mem;
 
-use exec::ProgramCache;
-use input::{Input, InputAt};
-use prog::{InstPtr, Program};
-use re_trait::Slot;
-use sparse::SparseSet;
+use crate::exec::ProgramCache;
+use crate::input::{Input, InputAt};
+use crate::prog::{InstPtr, Program};
+use crate::re_trait::Slot;
+use crate::sparse::SparseSet;
 
 /// An NFA simulation matching engine.
 #[derive(Debug)]
@@ -231,7 +231,7 @@
         at: InputAt,
         at_next: InputAt,
     ) -> bool {
-        use prog::Inst::*;
+        use crate::prog::Inst::*;
         match self.prog[ip] {
             Match(match_slot) => {
                 if match_slot < matches.len() {
@@ -300,7 +300,7 @@
         // traverse the set of states. We only push to the stack when we
         // absolutely need recursion (restoring captures or following a
         // branch).
-        use prog::Inst::*;
+        use crate::prog::Inst::*;
         loop {
             // Don't visit states we've already added.
             if nlist.set.contains(ip) {
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/pool.rs cargo-0.58.0/vendor/regex/src/pool.rs
--- cargo-0.57.0+ubuntu/vendor/regex/src/pool.rs	1970-01-01 00:00:00.000000000 +0000
+++ cargo-0.58.0/vendor/regex/src/pool.rs	2022-01-21 02:47:39.000000000 +0000
@@ -0,0 +1,333 @@
+// This module provides a relatively simple thread-safe pool of reusable
+// objects. For the most part, it's implemented by a stack represented by a
+// Mutex>. It has one small trick: because unlocking a mutex is somewhat
+// costly, in the case where a pool is accessed by the first thread that tried
+// to get a value, we bypass the mutex. Here are some benchmarks showing the
+// difference.
+//
+// 1) misc::anchored_literal_long_non_match    21 (18571 MB/s)
+// 2) misc::anchored_literal_long_non_match   107 (3644 MB/s)
+// 3) misc::anchored_literal_long_non_match    45 (8666 MB/s)
+// 4) misc::anchored_literal_long_non_match    19 (20526 MB/s)
+//
+// (1) represents our baseline: the master branch at the time of writing when
+// using the 'thread_local' crate to implement the pool below.
+//
+// (2) represents a naive pool implemented completely via Mutex>. There
+// is no special trick for bypassing the mutex.
+//
+// (3) is the same as (2), except it uses Mutex>>. It is twice as
+// fast because a Box is much smaller than the T we use with a Pool in this
+// crate. So pushing and popping a Box from a Vec is quite a bit faster
+// than for T.
+//
+// (4) is the same as (3), but with the trick for bypassing the mutex in the
+// case of the first-to-get thread.
+//
+// Why move off of thread_local? Even though (4) is a hair faster than (1)
+// above, this was not the main goal. The main goal was to move off of
+// thread_local and find a way to *simply* re-capture some of its speed for
+// regex's specific case. So again, why move off of it? The *primary* reason is
+// because of memory leaks. See https://github.com/rust-lang/regex/issues/362
+// for example. (Why do I want it to be simple? Well, I suppose what I mean is,
+// "use as much safe code as possible to minimize risk and be as sure as I can
+// be that it is correct.")
+//
+// My guess is that the thread_local design is probably not appropriate for
+// regex since its memory usage scales to the number of active threads that
+// have used a regex, where as the pool below scales to the number of threads
+// that simultaneously use a regex. While neither case permits contraction,
+// since we own the pool data structure below, we can add contraction if a
+// clear use case pops up in the wild. More pressingly though, it seems that
+// there are at least some use case patterns where one might have many threads
+// sitting around that might have used a regex at one point. While thread_local
+// does try to reuse space previously used by a thread that has since stopped,
+// its maximal memory usage still scales with the total number of active
+// threads. In contrast, the pool below scales with the total number of threads
+// *simultaneously* using the pool. The hope is that this uses less memory
+// overall. And if it doesn't, we can hopefully tune it somehow.
+//
+// It seems that these sort of conditions happen frequently
+// in FFI inside of other more "managed" languages. This was
+// mentioned in the issue linked above, and also mentioned here:
+// https://github.com/BurntSushi/rure-go/issues/3. And in particular, users
+// confirm that disabling the use of thread_local resolves the leak.
+//
+// There were other weaker reasons for moving off of thread_local as well.
+// Namely, at the time, I was looking to reduce dependencies. And for something
+// like regex, maintenance can be simpler when we own the full dependency tree.
+
+use std::panic::{RefUnwindSafe, UnwindSafe};
+use std::sync::atomic::{AtomicUsize, Ordering};
+use std::sync::Mutex;
+
+/// An atomic counter used to allocate thread IDs.
+static COUNTER: AtomicUsize = AtomicUsize::new(1);
+
+thread_local!(
+    /// A thread local used to assign an ID to a thread.
+    static THREAD_ID: usize = {
+        let next = COUNTER.fetch_add(1, Ordering::Relaxed);
+        // SAFETY: We cannot permit the reuse of thread IDs since reusing a
+        // thread ID might result in more than one thread "owning" a pool,
+        // and thus, permit accessing a mutable value from multiple threads
+        // simultaneously without synchronization. The intent of this panic is
+        // to be a sanity check. It is not expected that the thread ID space
+        // will actually be exhausted in practice.
+        //
+        // This checks that the counter never wraps around, since atomic
+        // addition wraps around on overflow.
+        if next == 0 {
+            panic!("regex: thread ID allocation space exhausted");
+        }
+        next
+    };
+);
+
+/// The type of the function used to create values in a pool when the pool is
+/// empty and the caller requests one.
+type CreateFn =
+    Box T + Send + Sync + UnwindSafe + RefUnwindSafe + 'static>;
+
+/// A simple thread safe pool for reusing values.
+///
+/// Getting a value out comes with a guard. When that guard is dropped, the
+/// value is automatically put back in the pool.
+///
+/// A Pool impls Sync when T is Send (even if it's not Sync). This means
+/// that T can use interior mutability. This is possible because a pool is
+/// guaranteed to provide a value to exactly one thread at any time.
+///
+/// Currently, a pool never contracts in size. Its size is proportional to the
+/// number of simultaneous uses.
+pub struct Pool {
+    /// A stack of T values to hand out. These are used when a Pool is
+    /// accessed by a thread that didn't create it.
+    stack: Mutex>>,
+    /// A function to create more T values when stack is empty and a caller
+    /// has requested a T.
+    create: CreateFn,
+    /// The ID of the thread that owns this pool. The owner is the thread
+    /// that makes the first call to 'get'. When the owner calls 'get', it
+    /// gets 'owner_val' directly instead of returning a T from 'stack'.
+    /// See comments elsewhere for details, but this is intended to be an
+    /// optimization for the common case that makes getting a T faster.
+    ///
+    /// It is initialized to a value of zero (an impossible thread ID) as a
+    /// sentinel to indicate that it is unowned.
+    owner: AtomicUsize,
+    /// A value to return when the caller is in the same thread that created
+    /// the Pool.
+    owner_val: T,
+}
+
+// SAFETY: Since we want to use a Pool from multiple threads simultaneously
+// behind an Arc, we need for it to be Sync. In cases where T is sync, Pool
+// would be Sync. However, since we use a Pool to store mutable scratch space,
+// we wind up using a T that has interior mutability and is thus itself not
+// Sync. So what we *really* want is for our Pool to by Sync even when T is
+// not Sync (but is at least Send).
+//
+// The only non-sync aspect of a Pool is its 'owner_val' field, which is used
+// to implement faster access to a pool value in the common case of a pool
+// being accessed in the same thread in which it was created. The 'stack' field
+// is also shared, but a Mutex where T: Send is already Sync. So we only
+// need to worry about 'owner_val'.
+//
+// The key is to guarantee that 'owner_val' can only ever be accessed from one
+// thread. In our implementation below, we guarantee this by only returning the
+// 'owner_val' when the ID of the current thread matches the ID of the thread
+// that created the Pool. Since this can only ever be one thread, it follows
+// that only one thread can access 'owner_val' at any point in time. Thus, it
+// is safe to declare that Pool is Sync when T is Send.
+//
+// NOTE: It would also be possible to make the owning thread be the *first*
+// thread that tries to get a value out of a Pool. However, the current
+// implementation is a little simpler and it's not clear if making the first
+// thread (rather than the creating thread) is meaningfully better.
+//
+// If there is a way to achieve our performance goals using safe code, then
+// I would very much welcome a patch. As it stands, the implementation below
+// tries to balance safety with performance. The case where a Regex is used
+// from multiple threads simultaneously will suffer a bit since getting a cache
+// will require unlocking a mutex.
+unsafe impl Sync for Pool {}
+
+impl ::std::fmt::Debug for Pool {
+    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
+        f.debug_struct("Pool")
+            .field("stack", &self.stack)
+            .field("owner", &self.owner)
+            .field("owner_val", &self.owner_val)
+            .finish()
+    }
+}
+
+/// A guard that is returned when a caller requests a value from the pool.
+///
+/// The purpose of the guard is to use RAII to automatically put the value back
+/// in the pool once it's dropped.
+#[derive(Debug)]
+pub struct PoolGuard<'a, T: Send> {
+    /// The pool that this guard is attached to.
+    pool: &'a Pool,
+    /// This is None when the guard represents the special "owned" value. In
+    /// which case, the value is retrieved from 'pool.owner_val'.
+    value: Option>,
+}
+
+impl Pool {
+    /// Create a new pool. The given closure is used to create values in the
+    /// pool when necessary.
+    pub fn new(create: CreateFn) -> Pool {
+        let owner = AtomicUsize::new(0);
+        let owner_val = create();
+        Pool { stack: Mutex::new(vec![]), create, owner, owner_val }
+    }
+
+    /// Get a value from the pool. The caller is guaranteed to have exclusive
+    /// access to the given value.
+    ///
+    /// Note that there is no guarantee provided about which value in the
+    /// pool is returned. That is, calling get, dropping the guard (causing
+    /// the value to go back into the pool) and then calling get again is NOT
+    /// guaranteed to return the same value received in the first get call.
+    #[cfg_attr(feature = "perf-inline", inline(always))]
+    pub fn get(&self) -> PoolGuard<'_, T> {
+        // Our fast path checks if the caller is the thread that "owns" this
+        // pool. Or stated differently, whether it is the first thread that
+        // tried to extract a value from the pool. If it is, then we can return
+        // a T to the caller without going through a mutex.
+        //
+        // SAFETY: We must guarantee that only one thread gets access to this
+        // value. Since a thread is uniquely identified by the THREAD_ID thread
+        // local, it follows that is the caller's thread ID is equal to the
+        // owner, then only one thread may receive this value.
+        let caller = THREAD_ID.with(|id| *id);
+        let owner = self.owner.load(Ordering::Relaxed);
+        if caller == owner {
+            return self.guard_owned();
+        }
+        self.get_slow(caller, owner)
+    }
+
+    /// This is the "slow" version that goes through a mutex to pop an
+    /// allocated value off a stack to return to the caller. (Or, if the stack
+    /// is empty, a new value is created.)
+    ///
+    /// If the pool has no owner, then this will set the owner.
+    #[cold]
+    fn get_slow(&self, caller: usize, owner: usize) -> PoolGuard<'_, T> {
+        use std::sync::atomic::Ordering::Relaxed;
+
+        if owner == 0 {
+            // The sentinel 0 value means this pool is not yet owned. We
+            // try to atomically set the owner. If we do, then this thread
+            // becomes the owner and we can return a guard that represents
+            // the special T for the owner.
+            let res = self.owner.compare_exchange(0, caller, Relaxed, Relaxed);
+            if res.is_ok() {
+                return self.guard_owned();
+            }
+        }
+        let mut stack = self.stack.lock().unwrap();
+        let value = match stack.pop() {
+            None => Box::new((self.create)()),
+            Some(value) => value,
+        };
+        self.guard_stack(value)
+    }
+
+    /// Puts a value back into the pool. Callers don't need to call this. Once
+    /// the guard that's returned by 'get' is dropped, it is put back into the
+    /// pool automatically.
+    fn put(&self, value: Box) {
+        let mut stack = self.stack.lock().unwrap();
+        stack.push(value);
+    }
+
+    /// Create a guard that represents the special owned T.
+    fn guard_owned(&self) -> PoolGuard<'_, T> {
+        PoolGuard { pool: self, value: None }
+    }
+
+    /// Create a guard that contains a value from the pool's stack.
+    fn guard_stack(&self, value: Box) -> PoolGuard<'_, T> {
+        PoolGuard { pool: self, value: Some(value) }
+    }
+}
+
+impl<'a, T: Send> PoolGuard<'a, T> {
+    /// Return the underlying value.
+    pub fn value(&self) -> &T {
+        match self.value {
+            None => &self.pool.owner_val,
+            Some(ref v) => &**v,
+        }
+    }
+}
+
+impl<'a, T: Send> Drop for PoolGuard<'a, T> {
+    #[cfg_attr(feature = "perf-inline", inline(always))]
+    fn drop(&mut self) {
+        if let Some(value) = self.value.take() {
+            self.pool.put(value);
+        }
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use std::panic::{RefUnwindSafe, UnwindSafe};
+
+    use super::*;
+
+    #[test]
+    fn oibits() {
+        use crate::exec::ProgramCache;
+
+        fn has_oibits() {}
+        has_oibits::>();
+    }
+
+    // Tests that Pool implements the "single owner" optimization. That is, the
+    // thread that first accesses the pool gets its own copy, while all other
+    // threads get distinct copies.
+    #[test]
+    fn thread_owner_optimization() {
+        use std::cell::RefCell;
+        use std::sync::Arc;
+
+        let pool: Arc>>> =
+            Arc::new(Pool::new(Box::new(|| RefCell::new(vec!['a']))));
+        pool.get().value().borrow_mut().push('x');
+
+        let pool1 = pool.clone();
+        let t1 = std::thread::spawn(move || {
+            let guard = pool1.get();
+            let v = guard.value();
+            v.borrow_mut().push('y');
+        });
+
+        let pool2 = pool.clone();
+        let t2 = std::thread::spawn(move || {
+            let guard = pool2.get();
+            let v = guard.value();
+            v.borrow_mut().push('z');
+        });
+
+        t1.join().unwrap();
+        t2.join().unwrap();
+
+        // If we didn't implement the single owner optimization, then one of
+        // the threads above is likely to have mutated the [a, x] vec that
+        // we stuffed in the pool before spawning the threads. But since
+        // neither thread was first to access the pool, and because of the
+        // optimization, we should be guaranteed that neither thread mutates
+        // the special owned pool value.
+        //
+        // (Technically this is an implementation detail and not a contract of
+        // Pool's API.)
+        assert_eq!(vec!['a', 'x'], *pool.get().value().borrow());
+    }
+}
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/prog.rs cargo-0.58.0/vendor/regex/src/prog.rs
--- cargo-0.57.0+ubuntu/vendor/regex/src/prog.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/src/prog.rs	2022-01-21 02:47:39.000000000 +0000
@@ -6,8 +6,8 @@
 use std::slice;
 use std::sync::Arc;
 
-use input::Char;
-use literal::LiteralSearcher;
+use crate::input::Char;
+use crate::literal::LiteralSearcher;
 
 /// `InstPtr` represents the index of an instruction in a regex program.
 pub type InstPtr = usize;
@@ -168,7 +168,7 @@
 }
 
 impl fmt::Debug for Program {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         use self::Inst::*;
 
         fn with_goto(cur: usize, goto: usize, fmtd: String) -> String {
@@ -259,8 +259,8 @@
 ///
 /// Other than the benefit of moving invariants into the type system, another
 /// benefit is the decreased size. If we remove the `Char` and `Ranges`
-/// instructions from the `Inst` enum, then its size shrinks from 40 bytes to
-/// 24 bytes. (This is because of the removal of a `Vec` in the `Ranges`
+/// instructions from the `Inst` enum, then its size shrinks from 32 bytes to
+/// 24 bytes. (This is because of the removal of a `Box<[]>` in the `Ranges`
 /// variant.) Given that byte based machines are typically much bigger than
 /// their Unicode analogues (because they can decode UTF-8 directly), this ends
 /// up being a pretty significant savings.
@@ -374,7 +374,7 @@
     /// succeeds.
     pub goto: InstPtr,
     /// The set of Unicode scalar value ranges to test.
-    pub ranges: Vec<(char, char)>,
+    pub ranges: Box<[(char, char)]>,
 }
 
 impl InstRanges {
@@ -432,3 +432,16 @@
         self.start <= byte && byte <= self.end
     }
 }
+
+#[cfg(test)]
+mod test {
+    #[test]
+    #[cfg(target_pointer_width = "64")]
+    fn test_size_of_inst() {
+        use std::mem::size_of;
+
+        use super::Inst;
+
+        assert_eq!(32, size_of::());
+    }
+}
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/re_builder.rs cargo-0.58.0/vendor/regex/src/re_builder.rs
--- cargo-0.57.0+ubuntu/vendor/regex/src/re_builder.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/src/re_builder.rs	2022-01-21 02:47:39.000000000 +0000
@@ -37,16 +37,17 @@
     ($name:ident, $regex_mod:ident, $only_utf8:expr) => {
         pub mod $name {
             use super::RegexOptions;
-            use error::Error;
-            use exec::ExecBuilder;
+            use crate::error::Error;
+            use crate::exec::ExecBuilder;
 
-            use $regex_mod::Regex;
+            use crate::$regex_mod::Regex;
 
             /// A configurable builder for a regular expression.
             ///
             /// A builder can be used to configure how the regex is built, for example, by
             /// setting the default flags (which can be overridden in the expression
             /// itself) or setting various limits.
+            #[derive(Debug)]
             pub struct RegexBuilder(RegexOptions);
 
             impl RegexBuilder {
@@ -234,16 +235,17 @@
     ($name:ident, $regex_mod:ident, $only_utf8:expr) => {
         pub mod $name {
             use super::RegexOptions;
-            use error::Error;
-            use exec::ExecBuilder;
+            use crate::error::Error;
+            use crate::exec::ExecBuilder;
 
-            use re_set::$regex_mod::RegexSet;
+            use crate::re_set::$regex_mod::RegexSet;
 
             /// A configurable builder for a set of regular expressions.
             ///
             /// A builder can be used to configure how the regexes are built, for example,
             /// by setting the default flags (which can be overridden in the expression
             /// itself) or setting various limits.
+            #[derive(Debug)]
             pub struct RegexSetBuilder(RegexOptions);
 
             impl RegexSetBuilder {
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/re_bytes.rs cargo-0.58.0/vendor/regex/src/re_bytes.rs
--- cargo-0.57.0+ubuntu/vendor/regex/src/re_bytes.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/src/re_bytes.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,17 +1,18 @@
 use std::borrow::Cow;
 use std::collections::HashMap;
 use std::fmt;
+use std::iter::FusedIterator;
 use std::ops::{Index, Range};
 use std::str::FromStr;
 use std::sync::Arc;
 
-use find_byte::find_byte;
+use crate::find_byte::find_byte;
 
-use error::Error;
-use exec::{Exec, ExecNoSync};
-use expand::expand_bytes;
-use re_builder::bytes::RegexBuilder;
-use re_trait::{self, RegularExpression, SubCapturesPosIter};
+use crate::error::Error;
+use crate::exec::{Exec, ExecNoSync};
+use crate::expand::expand_bytes;
+use crate::re_builder::bytes::RegexBuilder;
+use crate::re_trait::{self, RegularExpression, SubCapturesPosIter};
 
 /// Match represents a single match of a regex in a haystack.
 ///
@@ -78,14 +79,14 @@
 
 impl fmt::Display for Regex {
     /// Shows the original regular expression.
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(f, "{}", self.as_str())
     }
 }
 
 impl fmt::Debug for Regex {
     /// Shows the original regular expression.
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         fmt::Display::fmt(self, f)
     }
 }
@@ -119,7 +120,8 @@
         RegexBuilder::new(re).build()
     }
 
-    /// Returns true if and only if the regex matches the string given.
+    /// Returns true if and only if there is a match for the regex in the
+    /// string given.
     ///
     /// It is recommended to use this method if all you need to do is test
     /// a match, since the underlying matching engine may be able to do less
@@ -131,7 +133,7 @@
     /// bytes:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::bytes::Regex;
+    /// # use regex::bytes::Regex;
     /// # fn main() {
     /// let text = b"I categorically deny having triskaidekaphobia.";
     /// assert!(Regex::new(r"\b\w{13}\b").unwrap().is_match(text));
@@ -154,7 +156,7 @@
     /// ASCII word bytes:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::bytes::Regex;
+    /// # use regex::bytes::Regex;
     /// # fn main() {
     /// let text = b"I categorically deny having triskaidekaphobia.";
     /// let mat = Regex::new(r"\b\w{13}\b").unwrap().find(text).unwrap();
@@ -175,7 +177,7 @@
     /// word bytes:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::bytes::Regex;
+    /// # use regex::bytes::Regex;
     /// # fn main() {
     /// let text = b"Retroactively relinquishing remunerations is reprehensible.";
     /// for mat in Regex::new(r"\b\w{13}\b").unwrap().find_iter(text) {
@@ -203,7 +205,7 @@
     /// year separately.
     ///
     /// ```rust
-    /// # extern crate regex; use regex::bytes::Regex;
+    /// # use regex::bytes::Regex;
     /// # fn main() {
     /// let re = Regex::new(r"'([^']+)'\s+\((\d{4})\)").unwrap();
     /// let text = b"Not my favorite movie: 'Citizen Kane' (1941).";
@@ -225,7 +227,7 @@
     /// We can make this example a bit clearer by using *named* capture groups:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::bytes::Regex;
+    /// # use regex::bytes::Regex;
     /// # fn main() {
     /// let re = Regex::new(r"'(?P[^']+)'\s+\((?P<year>\d{4})\)")
     ///                .unwrap();
@@ -269,7 +271,7 @@
     /// some text, where the movie is formatted like "'Title' (xxxx)":
     ///
     /// ```rust
-    /// # extern crate regex; use std::str; use regex::bytes::Regex;
+    /// # use std::str; use regex::bytes::Regex;
     /// # fn main() {
     /// let re = Regex::new(r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)")
     ///                .unwrap();
@@ -303,7 +305,7 @@
     /// To split a string delimited by arbitrary amounts of spaces or tabs:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::bytes::Regex;
+    /// # use regex::bytes::Regex;
     /// # fn main() {
     /// let re = Regex::new(r"[ \t]+").unwrap();
     /// let fields: Vec<&[u8]> = re.split(b"a b \t  c\td    e").collect();
@@ -329,7 +331,7 @@
     /// Get the first two words in some text:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::bytes::Regex;
+    /// # use regex::bytes::Regex;
     /// # fn main() {
     /// let re = Regex::new(r"\W+").unwrap();
     /// let fields: Vec<&[u8]> = re.splitn(b"Hey! How are you?", 3).collect();
@@ -377,7 +379,7 @@
     /// In typical usage, this can just be a normal byte string:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::bytes::Regex;
+    /// # use regex::bytes::Regex;
     /// # fn main() {
     /// let re = Regex::new("[^01]+").unwrap();
     /// assert_eq!(re.replace(b"1078910", &b""[..]), &b"1010"[..]);
@@ -390,7 +392,7 @@
     /// group matches easily:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::bytes::Regex;
+    /// # use regex::bytes::Regex;
     /// # use regex::bytes::Captures; fn main() {
     /// let re = Regex::new(r"([^,\s]+),\s+(\S+)").unwrap();
     /// let result = re.replace(b"Springsteen, Bruce", |caps: &Captures| {
@@ -409,7 +411,7 @@
     /// with named capture groups:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::bytes::Regex;
+    /// # use regex::bytes::Regex;
     /// # fn main() {
     /// let re = Regex::new(r"(?P<last>[^,\s]+),\s+(?P<first>\S+)").unwrap();
     /// let result = re.replace(b"Springsteen, Bruce", &b"$first $last"[..]);
@@ -426,7 +428,7 @@
     /// underscore:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::bytes::Regex;
+    /// # use regex::bytes::Regex;
     /// # fn main() {
     /// let re = Regex::new(r"(?P<first>\w+)\s+(?P<second>\w+)").unwrap();
     /// let result = re.replace(b"deep fried", &b"${first}_$second"[..]);
@@ -443,7 +445,7 @@
     /// byte string with `NoExpand`:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::bytes::Regex;
+    /// # use regex::bytes::Regex;
     /// # fn main() {
     /// use regex::bytes::NoExpand;
     ///
@@ -544,7 +546,7 @@
     /// `a`.
     ///
     /// ```rust
-    /// # extern crate regex; use regex::bytes::Regex;
+    /// # use regex::bytes::Regex;
     /// # fn main() {
     /// let text = b"aaaaa";
     /// let pos = Regex::new(r"a+").unwrap().shortest_match(text);
@@ -656,7 +658,7 @@
     }
 
     /// Returns an iterator over the capture names.
-    pub fn capture_names(&self) -> CaptureNames {
+    pub fn capture_names(&self) -> CaptureNames<'_> {
         CaptureNames(self.0.capture_names().iter())
     }
 
@@ -689,6 +691,7 @@
 ///
 /// `'r` is the lifetime of the compiled regular expression and `'t` is the
 /// lifetime of the matched byte string.
+#[derive(Debug)]
 pub struct Matches<'r, 't>(re_trait::Matches<'t, ExecNoSync<'r>>);
 
 impl<'r, 't> Iterator for Matches<'r, 't> {
@@ -700,6 +703,8 @@
     }
 }
 
+impl<'r, 't> FusedIterator for Matches<'r, 't> {}
+
 /// An iterator that yields all non-overlapping capture groups matching a
 /// particular regular expression.
 ///
@@ -707,6 +712,7 @@
 ///
 /// `'r` is the lifetime of the compiled regular expression and `'t` is the
 /// lifetime of the matched byte string.
+#[derive(Debug)]
 pub struct CaptureMatches<'r, 't>(
     re_trait::CaptureMatches<'t, ExecNoSync<'r>>,
 );
@@ -723,10 +729,13 @@
     }
 }
 
+impl<'r, 't> FusedIterator for CaptureMatches<'r, 't> {}
+
 /// Yields all substrings delimited by a regular expression match.
 ///
 /// `'r` is the lifetime of the compiled regular expression and `'t` is the
 /// lifetime of the byte string being split.
+#[derive(Debug)]
 pub struct Split<'r, 't> {
     finder: Matches<'r, 't>,
     last: usize,
@@ -756,12 +765,15 @@
     }
 }
 
+impl<'r, 't> FusedIterator for Split<'r, 't> {}
+
 /// Yields at most `N` substrings delimited by a regular expression match.
 ///
 /// The last substring will be whatever remains after splitting.
 ///
 /// `'r` is the lifetime of the compiled regular expression and `'t` is the
 /// lifetime of the byte string being split.
+#[derive(Debug)]
 pub struct SplitN<'r, 't> {
     splits: Split<'r, 't>,
     n: usize,
@@ -789,14 +801,21 @@
             Some(&text[self.splits.last..])
         }
     }
+
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        (0, Some(self.n))
+    }
 }
 
+impl<'r, 't> FusedIterator for SplitN<'r, 't> {}
+
 /// An iterator over the names of all possible captures.
 ///
 /// `None` indicates an unnamed capture; the first element (capture 0, the
 /// whole matched region) is always unnamed.
 ///
 /// `'r` is the lifetime of the compiled regular expression.
+#[derive(Clone, Debug)]
 pub struct CaptureNames<'r>(::std::slice::Iter<'r, Option<String>>);
 
 impl<'r> Iterator for CaptureNames<'r> {
@@ -812,8 +831,16 @@
     fn size_hint(&self) -> (usize, Option<usize>) {
         self.0.size_hint()
     }
+
+    fn count(self) -> usize {
+        self.0.count()
+    }
 }
 
+impl<'r> ExactSizeIterator for CaptureNames<'r> {}
+
+impl<'r> FusedIterator for CaptureNames<'r> {}
+
 /// CaptureLocations is a low level representation of the raw offsets of each
 /// submatch.
 ///
@@ -930,17 +957,22 @@
     /// Expands all instances of `$name` in `replacement` to the corresponding
     /// capture group `name`, and writes them to the `dst` buffer given.
     ///
-    /// `name` may be an integer corresponding to the index of the
-    /// capture group (counted by order of opening parenthesis where `0` is the
+    /// `name` may be an integer corresponding to the index of the capture
+    /// group (counted by order of opening parenthesis where `0` is the
     /// entire match) or it can be a name (consisting of letters, digits or
     /// underscores) corresponding to a named capture group.
     ///
     /// If `name` isn't a valid capture group (whether the name doesn't exist
     /// or isn't a valid index), then it is replaced with the empty string.
     ///
-    /// The longest possible name is used. e.g., `$1a` looks up the capture
-    /// group named `1a` and not the capture group at index `1`. To exert more
-    /// precise control over the name, use braces, e.g., `${1}a`.
+    /// The longest possible name consisting of the characters `[_0-9A-Za-z]`
+    /// is used. e.g., `$1a` looks up the capture group named `1a` and not the
+    /// capture group at index `1`. To exert more precise control over the
+    /// name, or to refer to a capture group name that uses characters outside
+    /// of `[_0-9A-Za-z]`, use braces, e.g., `${1}a` or `${foo[bar].baz}`. When
+    /// using braces, any sequence of valid UTF-8 bytes is permitted. If the
+    /// sequence does not refer to a capture group name in the corresponding
+    /// regex, then it is replaced with an empty string.
     ///
     /// To write a literal `$` use `$$`.
     pub fn expand(&self, replacement: &[u8], dst: &mut Vec<u8>) {
@@ -958,15 +990,15 @@
 }
 
 impl<'t> fmt::Debug for Captures<'t> {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.debug_tuple("Captures").field(&CapturesDebug(self)).finish()
     }
 }
 
-struct CapturesDebug<'c, 't: 'c>(&'c Captures<'t>);
+struct CapturesDebug<'c, 't>(&'c Captures<'t>);
 
 impl<'c, 't> fmt::Debug for CapturesDebug<'c, 't> {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         fn escape_bytes(bytes: &[u8]) -> String {
             let mut s = String::new();
             for &b in bytes {
@@ -1051,7 +1083,8 @@
 ///
 /// The lifetime `'c` corresponds to the lifetime of the `Captures` value, and
 /// the lifetime `'t` corresponds to the originally matched text.
-pub struct SubCaptureMatches<'c, 't: 'c> {
+#[derive(Clone, Debug)]
+pub struct SubCaptureMatches<'c, 't> {
     caps: &'c Captures<'t>,
     it: SubCapturesPosIter<'c>,
 }
@@ -1066,13 +1099,15 @@
     }
 }
 
+impl<'c, 't> FusedIterator for SubCaptureMatches<'c, 't> {}
+
 /// Replacer describes types that can be used to replace matches in a byte
 /// string.
 ///
 /// In general, users of this crate shouldn't need to implement this trait,
-/// since implementations are already provided for `&[u8]` and
-/// `FnMut(&Captures) -> Vec<u8>` (or any `FnMut(&Captures) -> T`
-/// where `T: AsRef<[u8]>`), which covers most use cases.
+/// since implementations are already provided for `&[u8]` along with other
+/// variants of bytes types and `FnMut(&Captures) -> Vec<u8>` (or any
+/// `FnMut(&Captures) -> T` where `T: AsRef<[u8]>`), which covers most use cases.
 pub trait Replacer {
     /// Appends text to `dst` to replace the current match.
     ///
@@ -1081,7 +1116,7 @@
     ///
     /// For example, a no-op replacement would be
     /// `dst.extend(&caps[0])`.
-    fn replace_append(&mut self, caps: &Captures, dst: &mut Vec<u8>);
+    fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut Vec<u8>);
 
     /// Return a fixed unchanging replacement byte string.
     ///
@@ -1124,10 +1159,10 @@
 ///
 /// Returned by [`Replacer::by_ref`](trait.Replacer.html#method.by_ref).
 #[derive(Debug)]
-pub struct ReplacerRef<'a, R: ?Sized + 'a>(&'a mut R);
+pub struct ReplacerRef<'a, R: ?Sized>(&'a mut R);
 
 impl<'a, R: Replacer + ?Sized + 'a> Replacer for ReplacerRef<'a, R> {
-    fn replace_append(&mut self, caps: &Captures, dst: &mut Vec<u8>) {
+    fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut Vec<u8>) {
         self.0.replace_append(caps, dst)
     }
     fn no_expansion<'r>(&'r mut self) -> Option<Cow<'r, [u8]>> {
@@ -1136,24 +1171,69 @@
 }
 
 impl<'a> Replacer for &'a [u8] {
-    fn replace_append(&mut self, caps: &Captures, dst: &mut Vec<u8>) {
+    fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut Vec<u8>) {
         caps.expand(*self, dst);
     }
 
-    fn no_expansion(&mut self) -> Option<Cow<[u8]>> {
-        match find_byte(b'$', *self) {
-            Some(_) => None,
-            None => Some(Cow::Borrowed(*self)),
-        }
+    fn no_expansion(&mut self) -> Option<Cow<'_, [u8]>> {
+        no_expansion(self)
+    }
+}
+
+impl<'a> Replacer for &'a Vec<u8> {
+    fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut Vec<u8>) {
+        caps.expand(*self, dst);
+    }
+
+    fn no_expansion(&mut self) -> Option<Cow<'_, [u8]>> {
+        no_expansion(self)
+    }
+}
+
+impl Replacer for Vec<u8> {
+    fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut Vec<u8>) {
+        caps.expand(self, dst);
+    }
+
+    fn no_expansion(&mut self) -> Option<Cow<'_, [u8]>> {
+        no_expansion(self)
+    }
+}
+
+impl<'a> Replacer for Cow<'a, [u8]> {
+    fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut Vec<u8>) {
+        caps.expand(self.as_ref(), dst);
+    }
+
+    fn no_expansion(&mut self) -> Option<Cow<'_, [u8]>> {
+        no_expansion(self)
+    }
+}
+
+impl<'a> Replacer for &'a Cow<'a, [u8]> {
+    fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut Vec<u8>) {
+        caps.expand(self.as_ref(), dst);
+    }
+
+    fn no_expansion(&mut self) -> Option<Cow<'_, [u8]>> {
+        no_expansion(self)
+    }
+}
+
+fn no_expansion<T: AsRef<[u8]>>(t: &T) -> Option<Cow<'_, [u8]>> {
+    let s = t.as_ref();
+    match find_byte(b'$', s) {
+        Some(_) => None,
+        None => Some(Cow::Borrowed(s)),
     }
 }
 
 impl<F, T> Replacer for F
 where
-    F: FnMut(&Captures) -> T,
+    F: FnMut(&Captures<'_>) -> T,
     T: AsRef<[u8]>,
 {
-    fn replace_append(&mut self, caps: &Captures, dst: &mut Vec<u8>) {
+    fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut Vec<u8>) {
         dst.extend_from_slice((*self)(caps).as_ref());
     }
 }
@@ -1166,14 +1246,15 @@
 /// and performant (since capture groups don't need to be found).
 ///
 /// `'t` is the lifetime of the literal text.
+#[derive(Clone, Debug)]
 pub struct NoExpand<'t>(pub &'t [u8]);
 
 impl<'t> Replacer for NoExpand<'t> {
-    fn replace_append(&mut self, _: &Captures, dst: &mut Vec<u8>) {
+    fn replace_append(&mut self, _: &Captures<'_>, dst: &mut Vec<u8>) {
         dst.extend_from_slice(self.0);
     }
 
-    fn no_expansion(&mut self) -> Option<Cow<[u8]>> {
+    fn no_expansion(&mut self) -> Option<Cow<'_, [u8]>> {
         Some(Cow::Borrowed(self.0))
     }
 }
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/re_set.rs cargo-0.58.0/vendor/regex/src/re_set.rs
--- cargo-0.57.0+ubuntu/vendor/regex/src/re_set.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/src/re_set.rs	2022-01-21 02:47:39.000000000 +0000
@@ -7,10 +7,10 @@
             use std::slice;
             use std::vec;
 
-            use error::Error;
-            use exec::Exec;
-            use re_builder::$builder_mod::RegexSetBuilder;
-            use re_trait::RegularExpression;
+            use crate::error::Error;
+            use crate::exec::Exec;
+            use crate::re_builder::$builder_mod::RegexSetBuilder;
+            use crate::re_trait::RegularExpression;
 
 /// Match multiple (possibly overlapping) regular expressions in a single scan.
 ///
@@ -43,7 +43,7 @@
 /// Note that it would be possible to adapt the above example to using `Regex`
 /// with an expression like:
 ///
-/// ```ignore
+/// ```text
 /// (?P<email>[a-z]+@(?P<email_domain>[a-z]+[.](com|org|net)))|(?P<domain>[a-z]+[.](com|org|net))
 /// ```
 ///
@@ -96,6 +96,19 @@
         RegexSetBuilder::new(exprs).build()
     }
 
+    /// Create a new empty regex set.
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// # use regex::RegexSet;
+    /// let set = RegexSet::empty();
+    /// assert!(set.is_empty());
+    /// ```
+    pub fn empty() -> RegexSet {
+        RegexSetBuilder::new(&[""; 0]).build().unwrap()
+    }
+
     /// Returns true if and only if one of the regexes in this set matches
     /// the text given.
     ///
@@ -207,6 +220,11 @@
         self.0.regex_strings().len()
     }
 
+    /// Returns `true` if this set contains no regular expressions.
+    pub fn is_empty(&self) -> bool {
+        self.0.regex_strings().is_empty()
+    }
+
     /// Returns the patterns that this set will match on.
     ///
     /// This function can be used to determine the pattern for a match. The
@@ -274,7 +292,7 @@
     /// This will always produces matches in ascending order of index, where
     /// the index corresponds to the index of the regex that matched with
     /// respect to its position when initially building the set.
-    pub fn iter(&self) -> SetMatchesIter {
+    pub fn iter(&self) -> SetMatchesIter<'_> {
         SetMatchesIter((&*self.matches).into_iter().enumerate())
     }
 }
@@ -302,6 +320,7 @@
 /// This will always produces matches in ascending order of index, where the
 /// index corresponds to the index of the regex that matched with respect to
 /// its position when initially building the set.
+#[derive(Debug)]
 pub struct SetMatchesIntoIter(iter::Enumerate<vec::IntoIter<bool>>);
 
 impl Iterator for SetMatchesIntoIter {
@@ -334,6 +353,8 @@
     }
 }
 
+impl iter::FusedIterator for SetMatchesIntoIter {}
+
 /// A borrowed iterator over the set of matches from a regex set.
 ///
 /// The lifetime `'a` refers to the lifetime of a `SetMatches` value.
@@ -341,7 +362,7 @@
 /// This will always produces matches in ascending order of index, where the
 /// index corresponds to the index of the regex that matched with respect to
 /// its position when initially building the set.
-#[derive(Clone)]
+#[derive(Clone, Debug)]
 pub struct SetMatchesIter<'a>(iter::Enumerate<slice::Iter<'a, bool>>);
 
 impl<'a> Iterator for SetMatchesIter<'a> {
@@ -374,6 +395,8 @@
     }
 }
 
+impl<'a> iter::FusedIterator for SetMatchesIter<'a> {}
+
 #[doc(hidden)]
 impl From<Exec> for RegexSet {
     fn from(exec: Exec) -> Self {
@@ -382,7 +405,7 @@
 }
 
 impl fmt::Debug for RegexSet {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(f, "RegexSet({:?})", self.0.regex_strings())
     }
 }
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/re_trait.rs cargo-0.58.0/vendor/regex/src/re_trait.rs
--- cargo-0.57.0+ubuntu/vendor/regex/src/re_trait.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/src/re_trait.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,3 +1,6 @@
+use std::fmt;
+use std::iter::FusedIterator;
+
 /// Slot is a single saved capture location. Note that there are two slots for
 /// every capture in a regular expression (one slot each for the start and end
 /// of the capture).
@@ -27,7 +30,7 @@
     /// Creates an iterator of all the capture group positions in order of
     /// appearance in the regular expression. Positions are byte indices
     /// in terms of the original string matched.
-    pub fn iter(&self) -> SubCapturesPosIter {
+    pub fn iter(&self) -> SubCapturesPosIter<'_> {
         SubCapturesPosIter { idx: 0, locs: self }
     }
 
@@ -51,6 +54,7 @@
 /// Positions are byte indices in terms of the original string matched.
 ///
 /// `'c` is the lifetime of the captures.
+#[derive(Clone, Debug)]
 pub struct SubCapturesPosIter<'c> {
     idx: usize,
     locs: &'c Locations,
@@ -72,6 +76,8 @@
     }
 }
 
+impl<'c> FusedIterator for SubCapturesPosIter<'c> {}
+
 /// `RegularExpression` describes types that can implement regex searching.
 ///
 /// This trait is my attempt at reducing code duplication and to standardize
@@ -84,9 +90,9 @@
 /// somewhat reasonable. One particular thing this trait would expose would be
 /// the ability to start the search of a regex anywhere in a haystack, which
 /// isn't possible in the current public API.
-pub trait RegularExpression: Sized {
+pub trait RegularExpression: Sized + fmt::Debug {
     /// The type of the haystack.
-    type Text: ?Sized;
+    type Text: ?Sized + fmt::Debug;
 
     /// The number of capture slots in the compiled regular expression. This is
     /// always two times the number of capture groups (two slots per group).
@@ -132,18 +138,19 @@
 
     /// Returns an iterator over all non-overlapping successive leftmost-first
     /// matches.
-    fn find_iter(self, text: &Self::Text) -> Matches<Self> {
+    fn find_iter(self, text: &Self::Text) -> Matches<'_, Self> {
         Matches { re: self, text: text, last_end: 0, last_match: None }
     }
 
     /// Returns an iterator over all non-overlapping successive leftmost-first
     /// matches with captures.
-    fn captures_iter(self, text: &Self::Text) -> CaptureMatches<Self> {
+    fn captures_iter(self, text: &Self::Text) -> CaptureMatches<'_, Self> {
         CaptureMatches(self.find_iter(text))
     }
 }
 
 /// An iterator over all non-overlapping successive leftmost-first matches.
+#[derive(Debug)]
 pub struct Matches<'t, R>
 where
     R: RegularExpression,
@@ -204,8 +211,16 @@
     }
 }
 
+impl<'t, R> FusedIterator for Matches<'t, R>
+where
+    R: RegularExpression,
+    R::Text: 't + AsRef<[u8]>,
+{
+}
+
 /// An iterator over all non-overlapping successive leftmost-first matches with
 /// captures.
+#[derive(Debug)]
 pub struct CaptureMatches<'t, R>(Matches<'t, R>)
 where
     R: RegularExpression,
@@ -259,3 +274,10 @@
         Some(locs)
     }
 }
+
+impl<'t, R> FusedIterator for CaptureMatches<'t, R>
+where
+    R: RegularExpression,
+    R::Text: 't + AsRef<[u8]>,
+{
+}
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/re_unicode.rs cargo-0.58.0/vendor/regex/src/re_unicode.rs
--- cargo-0.57.0+ubuntu/vendor/regex/src/re_unicode.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/src/re_unicode.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,25 +1,25 @@
 use std::borrow::Cow;
 use std::collections::HashMap;
 use std::fmt;
+use std::iter::FusedIterator;
 use std::ops::{Index, Range};
 use std::str::FromStr;
 use std::sync::Arc;
 
-use find_byte::find_byte;
-use syntax;
+use crate::find_byte::find_byte;
 
-use error::Error;
-use exec::{Exec, ExecNoSyncStr};
-use expand::expand_str;
-use re_builder::unicode::RegexBuilder;
-use re_trait::{self, RegularExpression, SubCapturesPosIter};
+use crate::error::Error;
+use crate::exec::{Exec, ExecNoSyncStr};
+use crate::expand::expand_str;
+use crate::re_builder::unicode::RegexBuilder;
+use crate::re_trait::{self, RegularExpression, SubCapturesPosIter};
 
 /// Escapes all regular expression meta characters in `text`.
 ///
 /// The string returned may be safely used as a literal in a regular
 /// expression.
 pub fn escape(text: &str) -> String {
-    syntax::escape(text)
+    regex_syntax::escape(text)
 }
 
 /// Match represents a single match of a regex in a haystack.
@@ -137,14 +137,14 @@
 
 impl fmt::Display for Regex {
     /// Shows the original regular expression.
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(f, "{}", self.as_str())
     }
 }
 
 impl fmt::Debug for Regex {
     /// Shows the original regular expression.
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         fmt::Display::fmt(self, f)
     }
 }
@@ -175,7 +175,8 @@
         RegexBuilder::new(re).build()
     }
 
-    /// Returns true if and only if the regex matches the string given.
+    /// Returns true if and only if there is a match for the regex in the
+    /// string given.
     ///
     /// It is recommended to use this method if all you need to do is test
     /// a match, since the underlying matching engine may be able to do less
@@ -187,7 +188,7 @@
     /// Unicode word characters:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::Regex;
+    /// # use regex::Regex;
     /// # fn main() {
     /// let text = "I categorically deny having triskaidekaphobia.";
     /// assert!(Regex::new(r"\b\w{13}\b").unwrap().is_match(text));
@@ -210,7 +211,7 @@
     /// Unicode word characters:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::Regex;
+    /// # use regex::Regex;
     /// # fn main() {
     /// let text = "I categorically deny having triskaidekaphobia.";
     /// let mat = Regex::new(r"\b\w{13}\b").unwrap().find(text).unwrap();
@@ -232,7 +233,7 @@
     /// word characters:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::Regex;
+    /// # use regex::Regex;
     /// # fn main() {
     /// let text = "Retroactively relinquishing remunerations is reprehensible.";
     /// for mat in Regex::new(r"\b\w{13}\b").unwrap().find_iter(text) {
@@ -260,7 +261,7 @@
     /// year separately.
     ///
     /// ```rust
-    /// # extern crate regex; use regex::Regex;
+    /// # use regex::Regex;
     /// # fn main() {
     /// let re = Regex::new(r"'([^']+)'\s+\((\d{4})\)").unwrap();
     /// let text = "Not my favorite movie: 'Citizen Kane' (1941).";
@@ -282,7 +283,7 @@
     /// We can make this example a bit clearer by using *named* capture groups:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::Regex;
+    /// # use regex::Regex;
     /// # fn main() {
     /// let re = Regex::new(r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)")
     ///                .unwrap();
@@ -326,7 +327,7 @@
     /// some text, where the movie is formatted like "'Title' (xxxx)":
     ///
     /// ```rust
-    /// # extern crate regex; use regex::Regex;
+    /// # use regex::Regex;
     /// # fn main() {
     /// let re = Regex::new(r"'(?P<title>[^']+)'\s+\((?P<year>\d{4})\)")
     ///                .unwrap();
@@ -359,7 +360,7 @@
     /// To split a string delimited by arbitrary amounts of spaces or tabs:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::Regex;
+    /// # use regex::Regex;
     /// # fn main() {
     /// let re = Regex::new(r"[ \t]+").unwrap();
     /// let fields: Vec<&str> = re.split("a b \t  c\td    e").collect();
@@ -383,7 +384,7 @@
     /// Get the first two words in some text:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::Regex;
+    /// # use regex::Regex;
     /// # fn main() {
     /// let re = Regex::new(r"\W+").unwrap();
     /// let fields: Vec<&str> = re.splitn("Hey! How are you?", 3).collect();
@@ -430,7 +431,7 @@
     /// In typical usage, this can just be a normal string:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::Regex;
+    /// # use regex::Regex;
     /// # fn main() {
     /// let re = Regex::new("[^01]+").unwrap();
     /// assert_eq!(re.replace("1078910", ""), "1010");
@@ -443,7 +444,7 @@
     /// capturing group matches easily:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::Regex;
+    /// # use regex::Regex;
     /// # use regex::Captures; fn main() {
     /// let re = Regex::new(r"([^,\s]+),\s+(\S+)").unwrap();
     /// let result = re.replace("Springsteen, Bruce", |caps: &Captures| {
@@ -459,7 +460,7 @@
     /// with named capture groups:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::Regex;
+    /// # use regex::Regex;
     /// # fn main() {
     /// let re = Regex::new(r"(?P<last>[^,\s]+),\s+(?P<first>\S+)").unwrap();
     /// let result = re.replace("Springsteen, Bruce", "$first $last");
@@ -476,7 +477,7 @@
     /// underscore:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::Regex;
+    /// # use regex::Regex;
     /// # fn main() {
     /// let re = Regex::new(r"(?P<first>\w+)\s+(?P<second>\w+)").unwrap();
     /// let result = re.replace("deep fried", "${first}_$second");
@@ -493,7 +494,7 @@
     /// byte string with `NoExpand`:
     ///
     /// ```rust
-    /// # extern crate regex; use regex::Regex;
+    /// # use regex::Regex;
     /// # fn main() {
     /// use regex::NoExpand;
     ///
@@ -603,7 +604,7 @@
     /// `a`.
     ///
     /// ```rust
-    /// # extern crate regex; use regex::Regex;
+    /// # use regex::Regex;
     /// # fn main() {
     /// let text = "aaaaa";
     /// let pos = Regex::new(r"a+").unwrap().shortest_match(text);
@@ -715,7 +716,7 @@
     }
 
     /// Returns an iterator over the capture names.
-    pub fn capture_names(&self) -> CaptureNames {
+    pub fn capture_names(&self) -> CaptureNames<'_> {
         CaptureNames(self.0.capture_names().iter())
     }
 
@@ -746,6 +747,7 @@
 /// whole matched region) is always unnamed.
 ///
 /// `'r` is the lifetime of the compiled regular expression.
+#[derive(Clone, Debug)]
 pub struct CaptureNames<'r>(::std::slice::Iter<'r, Option<String>>);
 
 impl<'r> Iterator for CaptureNames<'r> {
@@ -761,12 +763,21 @@
     fn size_hint(&self) -> (usize, Option<usize>) {
         self.0.size_hint()
     }
+
+    fn count(self) -> usize {
+        self.0.count()
+    }
 }
 
+impl<'r> ExactSizeIterator for CaptureNames<'r> {}
+
+impl<'r> FusedIterator for CaptureNames<'r> {}
+
 /// Yields all substrings delimited by a regular expression match.
 ///
 /// `'r` is the lifetime of the compiled regular expression and `'t` is the
 /// lifetime of the string being split.
+#[derive(Debug)]
 pub struct Split<'r, 't> {
     finder: Matches<'r, 't>,
     last: usize,
@@ -796,12 +807,15 @@
     }
 }
 
+impl<'r, 't> FusedIterator for Split<'r, 't> {}
+
 /// Yields at most `N` substrings delimited by a regular expression match.
 ///
 /// The last substring will be whatever remains after splitting.
 ///
 /// `'r` is the lifetime of the compiled regular expression and `'t` is the
 /// lifetime of the string being split.
+#[derive(Debug)]
 pub struct SplitN<'r, 't> {
     splits: Split<'r, 't>,
     n: usize,
@@ -829,8 +843,14 @@
             Some(&text[self.splits.last..])
         }
     }
+
+    fn size_hint(&self) -> (usize, Option<usize>) {
+        (0, Some(self.n))
+    }
 }
 
+impl<'r, 't> FusedIterator for SplitN<'r, 't> {}
+
 /// CaptureLocations is a low level representation of the raw offsets of each
 /// submatch.
 ///
@@ -947,17 +967,22 @@
     /// Expands all instances of `$name` in `replacement` to the corresponding
     /// capture group `name`, and writes them to the `dst` buffer given.
     ///
-    /// `name` may be an integer corresponding to the index of the
-    /// capture group (counted by order of opening parenthesis where `0` is the
+    /// `name` may be an integer corresponding to the index of the capture
+    /// group (counted by order of opening parenthesis where `0` is the
     /// entire match) or it can be a name (consisting of letters, digits or
     /// underscores) corresponding to a named capture group.
     ///
     /// If `name` isn't a valid capture group (whether the name doesn't exist
     /// or isn't a valid index), then it is replaced with the empty string.
     ///
-    /// The longest possible name is used. e.g., `$1a` looks up the capture
-    /// group named `1a` and not the capture group at index `1`. To exert more
-    /// precise control over the name, use braces, e.g., `${1}a`.
+    /// The longest possible name consisting of the characters `[_0-9A-Za-z]`
+    /// is used. e.g., `$1a` looks up the capture group named `1a` and not the
+    /// capture group at index `1`. To exert more precise control over the
+    /// name, or to refer to a capture group name that uses characters outside
+    /// of `[_0-9A-Za-z]`, use braces, e.g., `${1}a` or `${foo[bar].baz}`. When
+    /// using braces, any sequence of characters is permitted. If the sequence
+    /// does not refer to a capture group name in the corresponding regex, then
+    /// it is replaced with an empty string.
     ///
     /// To write a literal `$` use `$$`.
     pub fn expand(&self, replacement: &str, dst: &mut String) {
@@ -975,15 +1000,15 @@
 }
 
 impl<'t> fmt::Debug for Captures<'t> {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.debug_tuple("Captures").field(&CapturesDebug(self)).finish()
     }
 }
 
-struct CapturesDebug<'c, 't: 'c>(&'c Captures<'t>);
+struct CapturesDebug<'c, 't>(&'c Captures<'t>);
 
 impl<'c, 't> fmt::Debug for CapturesDebug<'c, 't> {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         // We'd like to show something nice here, even if it means an
         // allocation to build a reverse index.
         let slot_to_name: HashMap<&usize, &String> =
@@ -1053,7 +1078,8 @@
 ///
 /// The lifetime `'c` corresponds to the lifetime of the `Captures` value, and
 /// the lifetime `'t` corresponds to the originally matched text.
-pub struct SubCaptureMatches<'c, 't: 'c> {
+#[derive(Clone, Debug)]
+pub struct SubCaptureMatches<'c, 't> {
     caps: &'c Captures<'t>,
     it: SubCapturesPosIter<'c>,
 }
@@ -1068,6 +1094,8 @@
     }
 }
 
+impl<'c, 't> FusedIterator for SubCaptureMatches<'c, 't> {}
+
 /// An iterator that yields all non-overlapping capture groups matching a
 /// particular regular expression.
 ///
@@ -1075,6 +1103,7 @@
 ///
 /// `'r` is the lifetime of the compiled regular expression and `'t` is the
 /// lifetime of the matched string.
+#[derive(Debug)]
 pub struct CaptureMatches<'r, 't>(
     re_trait::CaptureMatches<'t, ExecNoSyncStr<'r>>,
 );
@@ -1091,6 +1120,8 @@
     }
 }
 
+impl<'r, 't> FusedIterator for CaptureMatches<'r, 't> {}
+
 /// An iterator over all non-overlapping matches for a particular string.
 ///
 /// The iterator yields a `Match` value. The iterator stops when no more
@@ -1098,6 +1129,7 @@
 ///
 /// `'r` is the lifetime of the compiled regular expression and `'t` is the
 /// lifetime of the matched string.
+#[derive(Debug)]
 pub struct Matches<'r, 't>(re_trait::Matches<'t, ExecNoSyncStr<'r>>);
 
 impl<'r, 't> Iterator for Matches<'r, 't> {
@@ -1109,12 +1141,14 @@
     }
 }
 
+impl<'r, 't> FusedIterator for Matches<'r, 't> {}
+
 /// Replacer describes types that can be used to replace matches in a string.
 ///
 /// In general, users of this crate shouldn't need to implement this trait,
-/// since implementations are already provided for `&str` and
-/// `FnMut(&Captures) -> String` (or any `FnMut(&Captures) -> T`
-/// where `T: AsRef<str>`), which covers most use cases.
+/// since implementations are already provided for `&str` along with other
+/// variants of string types and `FnMut(&Captures) -> String` (or any
+/// `FnMut(&Captures) -> T` where `T: AsRef<str>`), which covers most use cases.
 pub trait Replacer {
     /// Appends text to `dst` to replace the current match.
     ///
@@ -1122,8 +1156,8 @@
     /// have a match at capture group `0`.
     ///
     /// For example, a no-op replacement would be
-    /// `dst.extend(caps.get(0).unwrap().as_str())`.
-    fn replace_append(&mut self, caps: &Captures, dst: &mut String);
+    /// `dst.push_str(caps.get(0).unwrap().as_str())`.
+    fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut String);
 
     /// Return a fixed unchanging replacement string.
     ///
@@ -1166,36 +1200,81 @@
 ///
 /// Returned by [`Replacer::by_ref`](trait.Replacer.html#method.by_ref).
 #[derive(Debug)]
-pub struct ReplacerRef<'a, R: ?Sized + 'a>(&'a mut R);
+pub struct ReplacerRef<'a, R: ?Sized>(&'a mut R);
 
 impl<'a, R: Replacer + ?Sized + 'a> Replacer for ReplacerRef<'a, R> {
-    fn replace_append(&mut self, caps: &Captures, dst: &mut String) {
+    fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut String) {
         self.0.replace_append(caps, dst)
     }
-    fn no_expansion(&mut self) -> Option<Cow<str>> {
+    fn no_expansion(&mut self) -> Option<Cow<'_, str>> {
         self.0.no_expansion()
     }
 }
 
 impl<'a> Replacer for &'a str {
-    fn replace_append(&mut self, caps: &Captures, dst: &mut String) {
+    fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut String) {
         caps.expand(*self, dst);
     }
 
-    fn no_expansion(&mut self) -> Option<Cow<str>> {
-        match find_byte(b'$', self.as_bytes()) {
-            Some(_) => None,
-            None => Some(Cow::Borrowed(*self)),
-        }
+    fn no_expansion(&mut self) -> Option<Cow<'_, str>> {
+        no_expansion(self)
+    }
+}
+
+impl<'a> Replacer for &'a String {
+    fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut String) {
+        self.as_str().replace_append(caps, dst)
+    }
+
+    fn no_expansion(&mut self) -> Option<Cow<'_, str>> {
+        no_expansion(self)
+    }
+}
+
+impl Replacer for String {
+    fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut String) {
+        self.as_str().replace_append(caps, dst)
+    }
+
+    fn no_expansion(&mut self) -> Option<Cow<'_, str>> {
+        no_expansion(self)
+    }
+}
+
+impl<'a> Replacer for Cow<'a, str> {
+    fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut String) {
+        self.as_ref().replace_append(caps, dst)
+    }
+
+    fn no_expansion(&mut self) -> Option<Cow<'_, str>> {
+        no_expansion(self)
+    }
+}
+
+impl<'a> Replacer for &'a Cow<'a, str> {
+    fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut String) {
+        self.as_ref().replace_append(caps, dst)
+    }
+
+    fn no_expansion(&mut self) -> Option<Cow<'_, str>> {
+        no_expansion(self)
+    }
+}
+
+fn no_expansion<T: AsRef<str>>(t: &T) -> Option<Cow<'_, str>> {
+    let s = t.as_ref();
+    match find_byte(b'$', s.as_bytes()) {
+        Some(_) => None,
+        None => Some(Cow::Borrowed(s)),
     }
 }
 
 impl<F, T> Replacer for F
 where
-    F: FnMut(&Captures) -> T,
+    F: FnMut(&Captures<'_>) -> T,
     T: AsRef<str>,
 {
-    fn replace_append(&mut self, caps: &Captures, dst: &mut String) {
+    fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut String) {
         dst.push_str((*self)(caps).as_ref());
     }
 }
@@ -1208,14 +1287,15 @@
 /// and performant (since capture groups don't need to be found).
 ///
 /// `'t` is the lifetime of the literal text.
+#[derive(Clone, Debug)]
 pub struct NoExpand<'t>(pub &'t str);
 
 impl<'t> Replacer for NoExpand<'t> {
-    fn replace_append(&mut self, _: &Captures, dst: &mut String) {
+    fn replace_append(&mut self, _: &Captures<'_>, dst: &mut String) {
         dst.push_str(self.0);
     }
 
-    fn no_expansion(&mut self) -> Option<Cow<str>> {
+    fn no_expansion(&mut self) -> Option<Cow<'_, str>> {
         Some(Cow::Borrowed(self.0))
     }
 }
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/src/sparse.rs cargo-0.58.0/vendor/regex/src/sparse.rs
--- cargo-0.57.0+ubuntu/vendor/regex/src/sparse.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/src/sparse.rs	2022-01-21 02:47:39.000000000 +0000
@@ -8,7 +8,7 @@
 /// entire set can also be done in constant time. Iteration yields elements
 /// in the order in which they were inserted.
 ///
-/// The data structure is based on: http://research.swtch.com/sparse
+/// The data structure is based on: https://research.swtch.com/sparse
 /// Note though that we don't actually use uninitialized memory. We generally
 /// reuse allocations, so the initial allocation cost is bareable. However,
 /// its other properties listed above are extremely useful.
@@ -62,7 +62,7 @@
 }
 
 impl fmt::Debug for SparseSet {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(f, "SparseSet({:?})", self.dense)
     }
 }
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/test cargo-0.58.0/vendor/regex/test
--- cargo-0.57.0+ubuntu/vendor/regex/test	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/test	2022-01-21 02:47:39.000000000 +0000
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+set -e
+
 # This is a convenience script for running a broad swath of tests across
 # features. We don't test the complete space, since the complete space is quite
 # large. Hopefully once we migrate the test suite to better infrastructure
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/tests/api.rs cargo-0.58.0/vendor/regex/tests/api.rs
--- cargo-0.57.0+ubuntu/vendor/regex/tests/api.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/tests/api.rs	2022-01-21 02:47:39.000000000 +0000
@@ -195,6 +195,18 @@
 );
 expand!(expand10, r"(?-u)(?P<a>\w+)\s+(?P<b>\d+)", "abc 123", "$bz$az", "");
 
+expand!(expand_name1, r"%(?P<Z>[a-z]+)", "%abc", "$Z%", "abc%");
+expand!(expand_name2, r"\[(?P<Z>[a-z]+)", "[abc", "$Z[", "abc[");
+expand!(expand_name3, r"\{(?P<Z>[a-z]+)", "{abc", "$Z{", "abc{");
+expand!(expand_name4, r"\}(?P<Z>[a-z]+)", "}abc", "$Z}", "abc}");
+expand!(expand_name5, r"%([a-z]+)", "%abc", "$1a%", "%");
+expand!(expand_name6, r"%([a-z]+)", "%abc", "${1}a%", "abca%");
+expand!(expand_name7, r"\[(?P<Z[>[a-z]+)", "[abc", "${Z[}[", "abc[");
+expand!(expand_name8, r"\[(?P<Z[>[a-z]+)", "[abc", "${foo}[", "[");
+expand!(expand_name9, r"\[(?P<Z[>[a-z]+)", "[abc", "${1a}[", "[");
+expand!(expand_name10, r"\[(?P<Z[>[a-z]+)", "[abc", "${#}[", "[");
+expand!(expand_name11, r"\[(?P<Z[>[a-z]+)", "[abc", "${$$}[", "[");
+
 split!(
     split1,
     r"(?-u)\s+",
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/tests/consistent.rs cargo-0.58.0/vendor/regex/tests/consistent.rs
--- cargo-0.57.0+ubuntu/vendor/regex/tests/consistent.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/tests/consistent.rs	2022-01-21 02:47:39.000000000 +0000
@@ -157,10 +157,7 @@
             }
 
             impl quickcheck::Testable for RegexEqualityTest {
-                fn result<G: quickcheck::Gen>(
-                    &self,
-                    gen: &mut G,
-                ) -> TestResult {
+                fn result(&self, gen: &mut quickcheck::Gen) -> TestResult {
                     let input = $mk_input(gen);
                     let input = &input;
 
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/tests/crazy.rs cargo-0.58.0/vendor/regex/tests/crazy.rs
--- cargo-0.57.0+ubuntu/vendor/regex/tests/crazy.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/tests/crazy.rs	2022-01-21 02:47:39.000000000 +0000
@@ -137,9 +137,10 @@
 #[test]
 fn dfa_handles_pathological_case() {
     fn ones_and_zeroes(count: usize) -> String {
-        use rand::{thread_rng, Rng};
+        use rand::rngs::SmallRng;
+        use rand::{Rng, SeedableRng};
 
-        let mut rng = thread_rng();
+        let mut rng = SmallRng::from_entropy();
         let mut s = String::new();
         for _ in 0..count {
             if rng.gen() {
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/tests/macros_bytes.rs cargo-0.58.0/vendor/regex/tests/macros_bytes.rs
--- cargo-0.57.0+ubuntu/vendor/regex/tests/macros_bytes.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/tests/macros_bytes.rs	2022-01-21 02:47:39.000000000 +0000
@@ -4,7 +4,6 @@
 macro_rules! match_text { ($text:expr) => { $text.as_bytes() } }
 macro_rules! use_ { ($($path: tt)*) => { use regex::bytes::$($path)*; } }
 macro_rules! empty_vec { () => { <Vec<&[u8]>>::new() } }
-
 macro_rules! bytes { ($text:expr) => { $text } }
 
 macro_rules! no_expand {
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/tests/macros_str.rs cargo-0.58.0/vendor/regex/tests/macros_str.rs
--- cargo-0.57.0+ubuntu/vendor/regex/tests/macros_str.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/tests/macros_str.rs	2022-01-21 02:47:39.000000000 +0000
@@ -4,6 +4,7 @@
 macro_rules! match_text { ($text:expr) => { $text.as_str() } }
 macro_rules! use_ { ($($path: tt)*) => { use regex::$($path)*; } }
 macro_rules! empty_vec { () => { <Vec<&str>>::new() } }
+macro_rules! bytes { ($text:expr) => { std::str::from_utf8($text.as_ref()).unwrap() } }
 
 macro_rules! no_expand {
     ($text:expr) => {{
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/tests/regression_fuzz.rs cargo-0.58.0/vendor/regex/tests/regression_fuzz.rs
--- cargo-0.57.0+ubuntu/vendor/regex/tests/regression_fuzz.rs	1970-01-01 00:00:00.000000000 +0000
+++ cargo-0.58.0/vendor/regex/tests/regression_fuzz.rs	2022-01-21 02:47:39.000000000 +0000
@@ -0,0 +1,31 @@
+// These tests are only run for the "default" test target because some of them
+// can take quite a long time. Some of them take long enough that it's not
+// practical to run them in debug mode. :-/
+
+// See: https://oss-fuzz.com/testcase-detail/5673225499181056
+//
+// Ignored by default since it takes too long in debug mode (almost a minute).
+#[test]
+#[ignore]
+fn fuzz1() {
+    regex!(r"1}{55}{0}*{1}{55}{55}{5}*{1}{55}+{56}|;**");
+}
+
+// See: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=26505
+// See: https://github.com/rust-lang/regex/issues/722
+#[test]
+fn empty_any_errors_no_panic() {
+    assert!(regex_new!(r"\P{any}").is_err());
+}
+
+// This tests that a very large regex errors during compilation instead of
+// using gratuitous amounts of memory. The specific problem is that the
+// compiler wasn't accounting for the memory used by Unicode character classes
+// correctly.
+//
+// See: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=33579
+#[test]
+fn big_regex_fails_to_compile() {
+    let pat = "[\u{0}\u{e}\u{2}\\w~~>[l\t\u{0}]p?<]{971158}";
+    assert!(regex_new!(pat).is_err());
+}
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/tests/replace.rs cargo-0.58.0/vendor/regex/tests/replace.rs
--- cargo-0.57.0+ubuntu/vendor/regex/tests/replace.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/tests/replace.rs	2022-01-21 02:47:39.000000000 +0000
@@ -94,7 +94,7 @@
     replace,
     r"([0-9]+)",
     "age: 26",
-    |captures: &Captures| {
+    |captures: &Captures<'_>| {
         match_text!(captures.get(1).unwrap())[0..1].to_owned()
     },
     "age: 2"
@@ -104,7 +104,7 @@
     replace,
     r"[0-9]+",
     "age: 26",
-    |_captures: &Captures| t!("Z").to_owned(),
+    |_captures: &Captures<'_>| t!("Z").to_owned(),
     "age: Z"
 );
 
@@ -130,3 +130,101 @@
     t!("${1}a $1a"),
     "ba "
 );
+
+replace!(
+    impl_string,
+    replace,
+    r"[0-9]",
+    "age: 26",
+    t!("Z".to_string()),
+    "age: Z6"
+);
+replace!(
+    impl_string_ref,
+    replace,
+    r"[0-9]",
+    "age: 26",
+    t!(&"Z".to_string()),
+    "age: Z6"
+);
+replace!(
+    impl_cow_str_borrowed,
+    replace,
+    r"[0-9]",
+    "age: 26",
+    t!(std::borrow::Cow::<'_, str>::Borrowed("Z")),
+    "age: Z6"
+);
+replace!(
+    impl_cow_str_borrowed_ref,
+    replace,
+    r"[0-9]",
+    "age: 26",
+    t!(&std::borrow::Cow::<'_, str>::Borrowed("Z")),
+    "age: Z6"
+);
+replace!(
+    impl_cow_str_owned,
+    replace,
+    r"[0-9]",
+    "age: 26",
+    t!(std::borrow::Cow::<'_, str>::Owned("Z".to_string())),
+    "age: Z6"
+);
+replace!(
+    impl_cow_str_owned_ref,
+    replace,
+    r"[0-9]",
+    "age: 26",
+    t!(&std::borrow::Cow::<'_, str>::Owned("Z".to_string())),
+    "age: Z6"
+);
+
+replace!(
+    impl_vec_u8,
+    replace,
+    r"[0-9]",
+    "age: 26",
+    bytes!(vec![b'Z']),
+    "age: Z6"
+);
+replace!(
+    impl_vec_u8_ref,
+    replace,
+    r"[0-9]",
+    "age: 26",
+    bytes!(&vec![b'Z']),
+    "age: Z6"
+);
+replace!(
+    impl_cow_slice_borrowed,
+    replace,
+    r"[0-9]",
+    "age: 26",
+    bytes!(std::borrow::Cow::<'_, [u8]>::Borrowed(&[b'Z'])),
+    "age: Z6"
+);
+replace!(
+    impl_cow_slice_borrowed_ref,
+    replace,
+    r"[0-9]",
+    "age: 26",
+    bytes!(&std::borrow::Cow::<'_, [u8]>::Borrowed(&[b'Z'])),
+    "age: Z6"
+);
+replace!(
+    impl_cow_slice_owned,
+    replace,
+    r"[0-9]",
+    "age: 26",
+    bytes!(std::borrow::Cow::<'_, [u8]>::Owned(vec![b'Z'])),
+    "age: Z6"
+);
+replace!(
+    impl_cow_slice_owned_ref,
+    replace,
+    r"[0-9]",
+    "age: 26",
+    bytes!(&std::borrow::Cow::<'_, [u8]>::Owned(vec![b'Z'])),
+    "age: Z6"
+);
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/tests/set.rs cargo-0.58.0/vendor/regex/tests/set.rs
--- cargo-0.57.0+ubuntu/vendor/regex/tests/set.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/tests/set.rs	2022-01-21 02:47:39.000000000 +0000
@@ -54,3 +54,14 @@
     let set = regex_set!(&["a", "b"]);
     assert_eq!(vec!["a", "b"], set.patterns());
 }
+
+#[test]
+fn len_and_empty() {
+    let empty = regex_set!(&[""; 0]);
+    assert_eq!(empty.len(), 0);
+    assert!(empty.is_empty());
+
+    let not_empty = regex_set!(&["ab", "b"]);
+    assert_eq!(not_empty.len(), 2);
+    assert!(!not_empty.is_empty());
+}
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/tests/test_backtrack_bytes.rs cargo-0.58.0/vendor/regex/tests/test_backtrack_bytes.rs
--- cargo-0.57.0+ubuntu/vendor/regex/tests/test_backtrack_bytes.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/tests/test_backtrack_bytes.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,6 +1,3 @@
-extern crate rand;
-extern crate regex;
-
 macro_rules! regex_new {
     ($re:expr) => {{
         use regex::internal::ExecBuilder;
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/tests/test_backtrack.rs cargo-0.58.0/vendor/regex/tests/test_backtrack.rs
--- cargo-0.57.0+ubuntu/vendor/regex/tests/test_backtrack.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/tests/test_backtrack.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,8 +1,5 @@
 #![cfg_attr(feature = "pattern", feature(pattern))]
 
-extern crate rand;
-extern crate regex;
-
 macro_rules! regex_new {
     ($re:expr) => {{
         use regex::internal::ExecBuilder;
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/tests/test_backtrack_utf8bytes.rs cargo-0.58.0/vendor/regex/tests/test_backtrack_utf8bytes.rs
--- cargo-0.57.0+ubuntu/vendor/regex/tests/test_backtrack_utf8bytes.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/tests/test_backtrack_utf8bytes.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,8 +1,5 @@
 #![cfg_attr(feature = "pattern", feature(pattern))]
 
-extern crate rand;
-extern crate regex;
-
 macro_rules! regex_new {
     ($re:expr) => {{
         use regex::internal::ExecBuilder;
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/tests/test_crates_regex.rs cargo-0.58.0/vendor/regex/tests/test_crates_regex.rs
--- cargo-0.57.0+ubuntu/vendor/regex/tests/test_crates_regex.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/tests/test_crates_regex.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,6 +1,3 @@
-extern crate quickcheck;
-extern crate regex;
-
 /*
  * This test is a minimal version of <rofl_0> and <subdiff_0>
  *
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/tests/test_default_bytes.rs cargo-0.58.0/vendor/regex/tests/test_default_bytes.rs
--- cargo-0.57.0+ubuntu/vendor/regex/tests/test_default_bytes.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/tests/test_default_bytes.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,6 +1,3 @@
-extern crate rand;
-extern crate regex;
-
 macro_rules! regex_new {
     ($re:expr) => {{
         use regex::bytes::Regex;
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/tests/test_default.rs cargo-0.58.0/vendor/regex/tests/test_default.rs
--- cargo-0.57.0+ubuntu/vendor/regex/tests/test_default.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/tests/test_default.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,7 +1,6 @@
 #![cfg_attr(feature = "pattern", feature(pattern))]
 
-extern crate rand;
-extern crate regex;
+use regex;
 
 // Due to macro scoping rules, this definition only applies for the modules
 // defined below. Effectively, it allows us to use the same tests for both
@@ -49,6 +48,7 @@
 mod multiline;
 mod noparse;
 mod regression;
+mod regression_fuzz;
 mod replace;
 mod searcher;
 mod set;
@@ -82,26 +82,49 @@
 #[test]
 fn oibits() {
     use regex::bytes;
-    use regex::{Regex, RegexBuilder};
-    use std::panic::UnwindSafe;
+    use regex::{Regex, RegexBuilder, RegexSet, RegexSetBuilder};
+    use std::panic::{RefUnwindSafe, UnwindSafe};
 
     fn assert_send<T: Send>() {}
     fn assert_sync<T: Sync>() {}
     fn assert_unwind_safe<T: UnwindSafe>() {}
+    fn assert_ref_unwind_safe<T: RefUnwindSafe>() {}
 
     assert_send::<Regex>();
     assert_sync::<Regex>();
     assert_unwind_safe::<Regex>();
+    assert_ref_unwind_safe::<Regex>();
     assert_send::<RegexBuilder>();
     assert_sync::<RegexBuilder>();
     assert_unwind_safe::<RegexBuilder>();
+    assert_ref_unwind_safe::<RegexBuilder>();
 
     assert_send::<bytes::Regex>();
     assert_sync::<bytes::Regex>();
     assert_unwind_safe::<bytes::Regex>();
+    assert_ref_unwind_safe::<bytes::Regex>();
     assert_send::<bytes::RegexBuilder>();
     assert_sync::<bytes::RegexBuilder>();
     assert_unwind_safe::<bytes::RegexBuilder>();
+    assert_ref_unwind_safe::<bytes::RegexBuilder>();
+
+    assert_send::<RegexSet>();
+    assert_sync::<RegexSet>();
+    assert_unwind_safe::<RegexSet>();
+    assert_ref_unwind_safe::<RegexSet>();
+    assert_send::<RegexSetBuilder>();
+    assert_sync::<RegexSetBuilder>();
+    assert_unwind_safe::<RegexSetBuilder>();
+    assert_ref_unwind_safe::<RegexSetBuilder>();
+
+    assert_send::<bytes::RegexSet>();
+    assert_sync::<bytes::RegexSet>();
+    assert_unwind_safe::<bytes::RegexSet>();
+    assert_ref_unwind_safe::<bytes::RegexSet>();
+    assert_send::<bytes::RegexSetBuilder>();
+    assert_sync::<bytes::RegexSetBuilder>();
+    assert_unwind_safe::<bytes::RegexSetBuilder>();
+    assert_ref_unwind_safe::<bytes::RegexSetBuilder>();
 }
 
 // See: https://github.com/rust-lang/regex/issues/568
@@ -112,3 +135,18 @@
 
     let _ = panic::catch_unwind(|| Regex::new("a").unwrap());
 }
+
+// See: https://github.com/rust-lang/regex/issues/750
+#[test]
+#[cfg(target_pointer_width = "64")]
+fn regex_is_reasonably_small() {
+    use std::mem::size_of;
+
+    use regex::bytes;
+    use regex::{Regex, RegexSet};
+
+    assert_eq!(16, size_of::<Regex>());
+    assert_eq!(16, size_of::<RegexSet>());
+    assert_eq!(16, size_of::<bytes::Regex>());
+    assert_eq!(16, size_of::<bytes::RegexSet>());
+}
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/tests/test_nfa_bytes.rs cargo-0.58.0/vendor/regex/tests/test_nfa_bytes.rs
--- cargo-0.57.0+ubuntu/vendor/regex/tests/test_nfa_bytes.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/tests/test_nfa_bytes.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,6 +1,3 @@
-extern crate rand;
-extern crate regex;
-
 macro_rules! regex_new {
     ($re:expr) => {{
         use regex::internal::ExecBuilder;
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/tests/test_nfa.rs cargo-0.58.0/vendor/regex/tests/test_nfa.rs
--- cargo-0.57.0+ubuntu/vendor/regex/tests/test_nfa.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/tests/test_nfa.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,8 +1,5 @@
 #![cfg_attr(feature = "pattern", feature(pattern))]
 
-extern crate rand;
-extern crate regex;
-
 macro_rules! regex_new {
     ($re:expr) => {{
         use regex::internal::ExecBuilder;
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/tests/test_nfa_utf8bytes.rs cargo-0.58.0/vendor/regex/tests/test_nfa_utf8bytes.rs
--- cargo-0.57.0+ubuntu/vendor/regex/tests/test_nfa_utf8bytes.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/tests/test_nfa_utf8bytes.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,8 +1,5 @@
 #![cfg_attr(feature = "pattern", feature(pattern))]
 
-extern crate rand;
-extern crate regex;
-
 macro_rules! regex_new {
     ($re:expr) => {{
         use regex::internal::ExecBuilder;
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/tests/unicode.rs cargo-0.58.0/vendor/regex/tests/unicode.rs
--- cargo-0.57.0+ubuntu/vendor/regex/tests/unicode.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/tests/unicode.rs	2022-01-21 02:47:39.000000000 +0000
@@ -74,6 +74,9 @@
     Some((0, 3))
 );
 mat!(uni_class_gencat_format, r"\p{Format}", "\u{E007F}", Some((0, 4)));
+// See: https://github.com/rust-lang/regex/issues/719
+mat!(uni_class_gencat_format_abbrev1, r"\p{cf}", "\u{E007F}", Some((0, 4)));
+mat!(uni_class_gencat_format_abbrev2, r"\p{gc=cf}", "\u{E007F}", Some((0, 4)));
 mat!(
     uni_class_gencat_initial_punctuation,
     r"\p{Initial_Punctuation}",
diff -Nru cargo-0.57.0+ubuntu/vendor/regex/UNICODE.md cargo-0.58.0/vendor/regex/UNICODE.md
--- cargo-0.57.0+ubuntu/vendor/regex/UNICODE.md	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/regex/UNICODE.md	2022-01-21 02:47:39.000000000 +0000
@@ -1,7 +1,7 @@
 # Unicode conformance
 
 This document describes the regex crate's conformance to Unicode's
-[UTS#18](http://unicode.org/reports/tr18/)
+[UTS#18](https://unicode.org/reports/tr18/)
 report, which lays out 3 levels of support: Basic, Extended and Tailored.
 
 Full support for Level 1 ("Basic Unicode Support") is provided with two
@@ -10,7 +10,7 @@
 1. Line boundaries are not Unicode aware. Namely, only the `\n`
    (`END OF LINE`) character is recognized as a line boundary.
 2. The compatibility properties specified by
-   [RL1.2a](http://unicode.org/reports/tr18/#RL1.2a)
+   [RL1.2a](https://unicode.org/reports/tr18/#RL1.2a)
    are ASCII-only definitions.
 
 Little to no support is provided for either Level 2 or Level 3. For the most
@@ -61,18 +61,18 @@
 points specified by Unicode. The regex crate does not provide exhaustive
 support, but covers a useful subset. In particular:
 
-* [General categories](http://unicode.org/reports/tr18/#General_Category_Property)
-* [Scripts and Script Extensions](http://unicode.org/reports/tr18/#Script_Property)
-* [Age](http://unicode.org/reports/tr18/#Age)
+* [General categories](https://unicode.org/reports/tr18/#General_Category_Property)
+* [Scripts and Script Extensions](https://unicode.org/reports/tr18/#Script_Property)
+* [Age](https://unicode.org/reports/tr18/#Age)
 * A smattering of boolean properties, including all of those specified by
-  [RL1.2](http://unicode.org/reports/tr18/#RL1.2) explicitly.
+  [RL1.2](https://unicode.org/reports/tr18/#RL1.2) explicitly.
 
 In all cases, property name and value abbreviations are supported, and all
 names/values are matched loosely without regard for case, whitespace or
 underscores. Property name aliases can be found in Unicode's
-[`PropertyAliases.txt`](http://www.unicode.org/Public/UCD/latest/ucd/PropertyAliases.txt)
+[`PropertyAliases.txt`](https://www.unicode.org/Public/UCD/latest/ucd/PropertyAliases.txt)
 file, while property value aliases can be found in Unicode's
-[`PropertyValueAliases.txt`](http://www.unicode.org/Public/UCD/latest/ucd/PropertyValueAliases.txt)
+[`PropertyValueAliases.txt`](https://www.unicode.org/Public/UCD/latest/ucd/PropertyValueAliases.txt)
 file.
 
 The syntax supported is also consistent with the UTS#18 recommendation:
@@ -149,10 +149,10 @@
 
 ## RL1.2a Compatibility Properties
 
-[UTS#18 RL1.2a](http://unicode.org/reports/tr18/#RL1.2a)
+[UTS#18 RL1.2a](https://unicode.org/reports/tr18/#RL1.2a)
 
 The regex crate only provides ASCII definitions of the
-[compatibility properties documented in UTS#18 Annex C](http://unicode.org/reports/tr18/#Compatibility_Properties)
+[compatibility properties documented in UTS#18 Annex C](https://unicode.org/reports/tr18/#Compatibility_Properties)
 (sans the `\X` class, for matching grapheme clusters, which isn't provided
 at all). This is because it seems to be consistent with most other regular
 expression engines, and in particular, because these are often referred to as
@@ -165,7 +165,7 @@
 
 ## RL1.3 Subtraction and Intersection
 
-[UTS#18 RL1.3](http://unicode.org/reports/tr18/#Subtraction_and_Intersection)
+[UTS#18 RL1.3](https://unicode.org/reports/tr18/#Subtraction_and_Intersection)
 
 The regex crate provides full support for nested character classes, along with
 union, intersection (`&&`), difference (`--`) and symmetric difference (`~~`)
@@ -178,7 +178,7 @@
 
 ## RL1.4 Simple Word Boundaries
 
-[UTS#18 RL1.4](http://unicode.org/reports/tr18/#Simple_Word_Boundaries)
+[UTS#18 RL1.4](https://unicode.org/reports/tr18/#Simple_Word_Boundaries)
 
 The regex crate provides basic Unicode aware word boundary assertions. A word
 boundary assertion can be written as `\b`, or `\B` as its negation. A word
@@ -196,9 +196,9 @@
 * `\p{gc:Connector_Punctuation}`
 
 In particular, this differs slightly from the
-[prescription given in RL1.4](http://unicode.org/reports/tr18/#Simple_Word_Boundaries)
+[prescription given in RL1.4](https://unicode.org/reports/tr18/#Simple_Word_Boundaries)
 but is permissible according to
-[UTS#18 Annex C](http://unicode.org/reports/tr18/#Compatibility_Properties).
+[UTS#18 Annex C](https://unicode.org/reports/tr18/#Compatibility_Properties).
 Namely, it is convenient and simpler to have `\w` and `\b` be in sync with
 one another.
 
@@ -211,7 +211,7 @@
 
 ## RL1.5 Simple Loose Matches
 
-[UTS#18 RL1.5](http://unicode.org/reports/tr18/#Simple_Loose_Matches)
+[UTS#18 RL1.5](https://unicode.org/reports/tr18/#Simple_Loose_Matches)
 
 The regex crate provides full support for case insensitive matching in
 accordance with RL1.5. That is, it uses the "simple" case folding mapping. The
@@ -226,7 +226,7 @@
 
 ## RL1.6 Line Boundaries
 
-[UTS#18 RL1.6](http://unicode.org/reports/tr18/#Line_Boundaries)
+[UTS#18 RL1.6](https://unicode.org/reports/tr18/#Line_Boundaries)
 
 The regex crate only provides support for recognizing the `\n` (`END OF LINE`)
 character as a line boundary. This choice was made mostly for implementation
@@ -239,7 +239,7 @@
 
 ## RL1.7 Code Points
 
-[UTS#18 RL1.7](http://unicode.org/reports/tr18/#Supplementary_Characters)
+[UTS#18 RL1.7](https://unicode.org/reports/tr18/#Supplementary_Characters)
 
 The regex crate provides full support for Unicode code point matching. Namely,
 the fundamental atom of any match is always a single code point.
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/build.rs cargo-0.58.0/vendor/ryu/build.rs
--- cargo-0.57.0+ubuntu/vendor/ryu/build.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/build.rs	1970-01-01 00:00:00.000000000 +0000
@@ -1,40 +0,0 @@
-use std::env;
-use std::process::Command;
-use std::str::{self, FromStr};
-
-// 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 minor = match rustc_minor_version() {
-        Some(minor) => minor,
-        None => return,
-    };
-
-    let target = env::var("TARGET").unwrap();
-    let emscripten = target == "asmjs-unknown-emscripten" || target == "wasm32-unknown-emscripten";
-
-    // 128-bit integers disabled on Emscripten targets as Emscripten doesn't
-    // currently support integers larger than 64 bits.
-    if !emscripten {
-        println!("cargo:rustc-cfg=integer128");
-    }
-
-    // MaybeUninit<T> stabilized in Rust 1.36:
-    // https://blog.rust-lang.org/2019/07/04/Rust-1.36.0.html
-    if minor >= 36 {
-        println!("cargo:rustc-cfg=maybe_uninit");
-    }
-}
-
-fn rustc_minor_version() -> Option<u32> {
-    let rustc = env::var_os("RUSTC")?;
-    let output = Command::new(rustc).arg("--version").output().ok()?;
-    let version = str::from_utf8(&output.stdout).ok()?;
-    let mut pieces = version.split('.');
-    if pieces.next() != Some("rustc 1") {
-        return None;
-    }
-    let next = pieces.next()?;
-    u32::from_str(next).ok()
-}
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/.cargo-checksum.json cargo-0.58.0/vendor/ryu/.cargo-checksum.json
--- cargo-0.57.0+ubuntu/vendor/ryu/.cargo-checksum.json	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/.cargo-checksum.json	2022-01-21 02:47:39.000000000 +0000
@@ -1 +1 @@
-{"files":{},"package":"71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"}
\ No newline at end of file
+{"files":{},"package":"73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f"}
\ No newline at end of file
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/Cargo.lock cargo-0.58.0/vendor/ryu/Cargo.lock
--- cargo-0.57.0+ubuntu/vendor/ryu/Cargo.lock	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/Cargo.lock	2022-01-21 02:47:39.000000000 +0000
@@ -1,163 +1,162 @@
 # This file is automatically @generated by Cargo.
 # It is not intended for manual editing.
+version = 3
+
 [[package]]
 name = "cfg-if"
-version = "0.1.10"
+version = "1.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
 
 [[package]]
 name = "getrandom"
-version = "0.1.14"
+version = "0.2.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
 dependencies = [
- "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)",
- "wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "cfg-if",
+ "libc",
+ "wasi",
 ]
 
 [[package]]
 name = "hermit-abi"
-version = "0.1.13"
+version = "0.1.19"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
 dependencies = [
- "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc",
 ]
 
 [[package]]
 name = "libc"
-version = "0.2.71"
+version = "0.2.111"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e167738f1866a7ec625567bae89ca0d44477232a4f7c52b1c7f2adc2c98804f"
 
 [[package]]
 name = "no-panic"
-version = "0.1.13"
+version = "0.1.15"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b884e0f4a7a80970539a7757902675ce503d98615f5b564564b4bd0236f7f36"
 dependencies = [
- "proc-macro2 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)",
- "quote 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2",
+ "quote",
+ "syn",
 ]
 
 [[package]]
 name = "num_cpus"
 version = "1.13.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
 dependencies = [
- "hermit-abi 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)",
+ "hermit-abi",
+ "libc",
 ]
 
 [[package]]
 name = "ppv-lite86"
-version = "0.2.8"
+version = "0.2.15"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba"
 
 [[package]]
 name = "proc-macro2"
-version = "1.0.17"
+version = "1.0.33"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fb37d2df5df740e582f28f8560cf425f52bb267d872fe58358eadb554909f07a"
 dependencies = [
- "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-xid",
 ]
 
 [[package]]
 name = "quote"
-version = "1.0.6"
+version = "1.0.10"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05"
 dependencies = [
- "proc-macro2 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2",
 ]
 
 [[package]]
 name = "rand"
-version = "0.7.3"
+version = "0.8.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8"
 dependencies = [
- "getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc",
+ "rand_chacha",
+ "rand_core",
+ "rand_hc",
 ]
 
 [[package]]
 name = "rand_chacha"
-version = "0.2.2"
+version = "0.3.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
 dependencies = [
- "ppv-lite86 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ppv-lite86",
+ "rand_core",
 ]
 
 [[package]]
 name = "rand_core"
-version = "0.5.1"
+version = "0.6.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
 dependencies = [
- "getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
+ "getrandom",
 ]
 
 [[package]]
 name = "rand_hc"
-version = "0.2.0"
+version = "0.3.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7"
 dependencies = [
- "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand_core",
 ]
 
 [[package]]
 name = "rand_xorshift"
-version = "0.2.0"
+version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f"
 dependencies = [
- "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand_core",
 ]
 
 [[package]]
 name = "ryu"
-version = "1.0.5"
+version = "1.0.9"
 dependencies = [
- "no-panic 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
- "num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "no-panic",
+ "num_cpus",
+ "rand",
+ "rand_xorshift",
 ]
 
 [[package]]
 name = "syn"
-version = "1.0.29"
+version = "1.0.82"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59"
 dependencies = [
- "proc-macro2 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)",
- "quote 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2",
+ "quote",
+ "unicode-xid",
 ]
 
 [[package]]
 name = "unicode-xid"
-version = "0.2.0"
+version = "0.2.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
 
 [[package]]
 name = "wasi"
-version = "0.9.0+wasi-snapshot-preview1"
+version = "0.10.2+wasi-snapshot-preview1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[metadata]
-"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
-"checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
-"checksum hermit-abi 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "91780f809e750b0a89f5544be56617ff6b1227ee485bcb06ebe10cdf89bd3b71"
-"checksum libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)" = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49"
-"checksum no-panic 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "b4da21758193a9f8a8f1dc698f121e70e8df07c71e4968e49762a5604bbdf72b"
-"checksum num_cpus 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3"
-"checksum ppv-lite86 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea"
-"checksum proc-macro2 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)" = "1502d12e458c49a4c9cbff560d0fe0060c252bc29799ed94ca2ed4bb665a0101"
-"checksum quote 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea"
-"checksum rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
-"checksum rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
-"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
-"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
-"checksum rand_xorshift 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "77d416b86801d23dde1aa643023b775c3a462efc0ed96443add11546cdf1dca8"
-"checksum syn 1.0.29 (registry+https://github.com/rust-lang/crates.io-index)" = "bb37da98a55b1d08529362d9cbb863be17556873df2585904ab9d2bc951291d0"
-"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
-"checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
+checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/Cargo.toml cargo-0.58.0/vendor/ryu/Cargo.toml
--- cargo-0.57.0+ubuntu/vendor/ryu/Cargo.toml	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/Cargo.toml	2022-01-21 02:47:39.000000000 +0000
@@ -3,21 +3,23 @@
 # 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 = "ryu"
-version = "1.0.5"
+version = "1.0.9"
 authors = ["David Tolnay <dtolnay@gmail.com>"]
+exclude = ["performance.png", "chart/**"]
 description = "Fast floating point to string conversion"
 documentation = "https://docs.rs/ryu"
 readme = "README.md"
+categories = ["value-formatting"]
 license = "Apache-2.0 OR BSL-1.0"
 repository = "https://github.com/dtolnay/ryu"
 [package.metadata.docs.rs]
@@ -29,10 +31,10 @@
 version = "1.8"
 
 [dev-dependencies.rand]
-version = "0.7"
+version = "0.8"
 
 [dev-dependencies.rand_xorshift]
-version = "0.2"
+version = "0.3"
 
 [features]
 small = []
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/README.md cargo-0.58.0/vendor/ryu/README.md
--- cargo-0.57.0+ubuntu/vendor/ryu/README.md	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/README.md	2022-01-21 02:47:39.000000000 +0000
@@ -15,17 +15,19 @@
 This Rust implementation is a line-by-line port of Ulf Adams' implementation in
 C, [https://github.com/ulfjack/ryu][upstream].
 
-*Requirements: this crate supports any compiler version back to rustc 1.31; it
+*Requirements: this crate supports any compiler version back to rustc 1.36; it
 uses nothing from the Rust standard library so is usable from no_std crates.*
 
 [paper]: https://dl.acm.org/citation.cfm?id=3192369
-[upstream]: https://github.com/ulfjack/ryu/tree/1c413e127f8d02afd12eb6259bc80163722f1385
+[upstream]: https://github.com/ulfjack/ryu/tree/abf76d252bc97300354857e64e80d4a2bf664291
 
 ```toml
 [dependencies]
 ryu = "1.0"
 ```
 
+<br>
+
 ## Example
 
 ```rust
@@ -36,14 +38,18 @@
 }
 ```
 
-## Performance
+<br>
+
+## Performance (lower is better)
+
+![performance](https://raw.githubusercontent.com/dtolnay/ryu/master/performance.png)
 
 You can run upstream's benchmarks with:
 
 ```console
 $ git clone https://github.com/ulfjack/ryu c-ryu
 $ cd c-ryu
-$ bazel run -c opt //ryu/benchmark
+$ bazel run -c opt //ryu/benchmark:ryu_benchmark
 ```
 
 And the same benchmark against our implementation with:
@@ -69,20 +75,10 @@
 $ cargo bench
 ```
 
-The benchmark shows Ryū approximately 4-10x faster than the standard library
+The benchmark shows Ryū approximately 2-5x faster than the standard library
 across a range of f32 and f64 inputs. Measurements are in nanoseconds per
 iteration; smaller is better.
 
-| type=f32 | 0.0  | 0.1234 | 2.718281828459045 | f32::MAX |
-|:--------:|:----:|:------:|:-----------------:|:--------:|
-| RYU      | 3ns  | 28ns   | 23ns              | 22ns     |
-| STD      | 40ns | 106ns  | 128ns             | 110ns    |
-
-| type=f64 | 0.0  | 0.1234 | 2.718281828459045 | f64::MAX |
-|:--------:|:----:|:------:|:-----------------:|:--------:|
-| RYU      | 3ns  | 50ns   | 35ns              | 32ns     |
-| STD      | 39ns | 105ns  | 128ns             | 202ns    |
-
 ## Formatting
 
 This library tends to produce more human-readable output than the standard
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/src/buffer/mod.rs cargo-0.58.0/vendor/ryu/src/buffer/mod.rs
--- cargo-0.57.0+ubuntu/vendor/ryu/src/buffer/mod.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/src/buffer/mod.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,13 +1,12 @@
 use crate::raw;
-#[cfg(maybe_uninit)]
 use core::mem::MaybeUninit;
-use core::{mem, slice, str};
+use core::{slice, str};
 #[cfg(feature = "no-panic")]
 use no_panic::no_panic;
 
-const NAN: &'static str = "NaN";
-const INFINITY: &'static str = "inf";
-const NEG_INFINITY: &'static str = "-inf";
+const NAN: &str = "NaN";
+const INFINITY: &str = "inf";
+const NEG_INFINITY: &str = "-inf";
 
 /// Safe API for formatting floating point numbers to text.
 ///
@@ -19,10 +18,7 @@
 /// assert_eq!(printed, "1.234");
 /// ```
 pub struct Buffer {
-    #[cfg(maybe_uninit)]
     bytes: [MaybeUninit<u8>; 24],
-    #[cfg(not(maybe_uninit))]
-    bytes: [u8; 24],
 }
 
 impl Buffer {
@@ -31,14 +27,8 @@
     #[inline]
     #[cfg_attr(feature = "no-panic", no_panic)]
     pub fn new() -> Self {
-        // assume_init is safe here, since this is an array of MaybeUninit, which does not need
-        // to be initialized.
-        #[cfg(maybe_uninit)]
         let bytes = [MaybeUninit::<u8>::uninit(); 24];
-        #[cfg(not(maybe_uninit))]
-        let bytes = unsafe { mem::uninitialized() };
-
-        Buffer { bytes: bytes }
+        Buffer { bytes }
     }
 
     /// Print a floating point number into this buffer and return a reference to
@@ -125,7 +115,7 @@
     #[inline]
     fn is_nonfinite(self) -> bool {
         const EXP_MASK: u32 = 0x7f800000;
-        let bits = unsafe { mem::transmute::<f32, u32>(self) };
+        let bits = self.to_bits();
         bits & EXP_MASK == EXP_MASK
     }
 
@@ -134,7 +124,7 @@
     fn format_nonfinite(self) -> &'static str {
         const MANTISSA_MASK: u32 = 0x007fffff;
         const SIGN_MASK: u32 = 0x80000000;
-        let bits = unsafe { mem::transmute::<f32, u32>(self) };
+        let bits = self.to_bits();
         if bits & MANTISSA_MASK != 0 {
             NAN
         } else if bits & SIGN_MASK != 0 {
@@ -154,7 +144,7 @@
     #[inline]
     fn is_nonfinite(self) -> bool {
         const EXP_MASK: u64 = 0x7ff0000000000000;
-        let bits = unsafe { mem::transmute::<f64, u64>(self) };
+        let bits = self.to_bits();
         bits & EXP_MASK == EXP_MASK
     }
 
@@ -163,7 +153,7 @@
     fn format_nonfinite(self) -> &'static str {
         const MANTISSA_MASK: u64 = 0x000fffffffffffff;
         const SIGN_MASK: u64 = 0x8000000000000000;
-        let bits = unsafe { mem::transmute::<f64, u64>(self) };
+        let bits = self.to_bits();
         if bits & MANTISSA_MASK != 0 {
             NAN
         } else if bits & SIGN_MASK != 0 {
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/src/d2s_intrinsics.rs cargo-0.58.0/vendor/ryu/src/d2s_intrinsics.rs
--- cargo-0.57.0+ubuntu/vendor/ryu/src/d2s_intrinsics.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/src/d2s_intrinsics.rs	2022-01-21 02:47:39.000000000 +0000
@@ -20,46 +20,6 @@
 
 use core::ptr;
 
-// Returns (lo, hi).
-#[cfg(not(integer128))]
-#[cfg_attr(feature = "no-panic", inline)]
-pub fn umul128(a: u64, b: u64) -> (u64, u64) {
-    let a_lo = a as u32;
-    let a_hi = (a >> 32) as u32;
-    let b_lo = b as u32;
-    let b_hi = (b >> 32) as u32;
-
-    let b00 = a_lo as u64 * b_lo as u64;
-    let b01 = a_lo as u64 * b_hi as u64;
-    let b10 = a_hi as u64 * b_lo as u64;
-    let b11 = a_hi as u64 * b_hi as u64;
-
-    let b00_lo = b00 as u32;
-    let b00_hi = (b00 >> 32) as u32;
-
-    let mid1 = b10 + b00_hi as u64;
-    let mid1_lo = mid1 as u32;
-    let mid1_hi = (mid1 >> 32) as u32;
-
-    let mid2 = b01 + mid1_lo as u64;
-    let mid2_lo = mid2 as u32;
-    let mid2_hi = (mid2 >> 32) as u32;
-
-    let p_hi = b11 + mid1_hi as u64 + mid2_hi as u64;
-    let p_lo = ((mid2_lo as u64) << 32) | b00_lo as u64;
-
-    (p_lo, p_hi)
-}
-
-#[cfg(not(integer128))]
-#[cfg_attr(feature = "no-panic", inline)]
-pub fn shiftright128(lo: u64, hi: u64, dist: u32) -> u64 {
-    // We don't need to handle the case dist >= 64 here (see above).
-    debug_assert!(dist > 0);
-    debug_assert!(dist < 64);
-    (hi << (64 - dist)) | (lo >> dist)
-}
-
 #[cfg_attr(feature = "no-panic", inline)]
 pub fn div5(x: u64) -> u64 {
     x / 5
@@ -107,7 +67,6 @@
     (value & ((1u64 << p) - 1)) == 0
 }
 
-#[cfg(integer128)]
 #[cfg_attr(feature = "no-panic", inline)]
 pub fn mul_shift_64(m: u64, mul: &(u64, u64), j: u32) -> u64 {
     let b0 = m as u128 * mul.0 as u128;
@@ -115,7 +74,6 @@
     (((b0 >> 64) + b2) >> (j - 64)) as u64
 }
 
-#[cfg(integer128)]
 #[cfg_attr(feature = "no-panic", inline)]
 pub unsafe fn mul_shift_all_64(
     m: u64,
@@ -129,43 +87,3 @@
     ptr::write(vm, mul_shift_64(4 * m - 1 - mm_shift as u64, mul, j));
     mul_shift_64(4 * m, mul, j)
 }
-
-#[cfg(not(integer128))]
-#[cfg_attr(feature = "no-panic", inline)]
-pub unsafe fn mul_shift_all_64(
-    mut m: u64,
-    mul: &(u64, u64),
-    j: u32,
-    vp: *mut u64,
-    vm: *mut u64,
-    mm_shift: u32,
-) -> u64 {
-    m <<= 1;
-    // m is maximum 55 bits
-    let (lo, tmp) = umul128(m, mul.0);
-    let (mut mid, mut hi) = umul128(m, mul.1);
-    mid = mid.wrapping_add(tmp);
-    hi = hi.wrapping_add((mid < tmp) as u64); // overflow into hi
-
-    let lo2 = lo.wrapping_add(mul.0);
-    let mid2 = mid.wrapping_add(mul.1).wrapping_add((lo2 < lo) as u64);
-    let hi2 = hi.wrapping_add((mid2 < mid) as u64);
-    ptr::write(vp, shiftright128(mid2, hi2, j - 64 - 1));
-
-    if mm_shift == 1 {
-        let lo3 = lo.wrapping_sub(mul.0);
-        let mid3 = mid.wrapping_sub(mul.1).wrapping_sub((lo3 > lo) as u64);
-        let hi3 = hi.wrapping_sub((mid3 > mid) as u64);
-        ptr::write(vm, shiftright128(mid3, hi3, j - 64 - 1));
-    } else {
-        let lo3 = lo + lo;
-        let mid3 = mid.wrapping_add(mid).wrapping_add((lo3 < lo) as u64);
-        let hi3 = hi.wrapping_add(hi).wrapping_add((mid3 < mid) as u64);
-        let lo4 = lo3.wrapping_sub(mul.0);
-        let mid4 = mid3.wrapping_sub(mul.1).wrapping_sub((lo4 > lo3) as u64);
-        let hi4 = hi3.wrapping_sub((mid4 > mid3) as u64);
-        ptr::write(vm, shiftright128(mid4, hi4, j - 64));
-    }
-
-    shiftright128(mid, hi, j - 64 - 1)
-}
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/src/d2s.rs cargo-0.58.0/vendor/ryu/src/d2s.rs
--- cargo-0.57.0+ubuntu/vendor/ryu/src/d2s.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/src/d2s.rs	2022-01-21 02:47:39.000000000 +0000
@@ -24,9 +24,6 @@
 use crate::d2s_intrinsics::*;
 #[cfg(feature = "small")]
 pub use crate::d2s_small_table::*;
-#[cfg(not(maybe_uninit))]
-use core::mem;
-#[cfg(maybe_uninit)]
 use core::mem::MaybeUninit;
 
 pub const DOUBLE_MANTISSA_BITS: u32 = 52;
@@ -117,14 +114,7 @@
     let mut vr: u64;
     let mut vp: u64;
     let mut vm: u64;
-    #[cfg(not(maybe_uninit))]
-    {
-        vp = unsafe { mem::uninitialized() };
-        vm = unsafe { mem::uninitialized() };
-    }
-    #[cfg(maybe_uninit)]
     let mut vp_uninit: MaybeUninit<u64> = MaybeUninit::uninit();
-    #[cfg(maybe_uninit)]
     let mut vm_uninit: MaybeUninit<u64> = MaybeUninit::uninit();
     let e10: i32;
     let mut vm_is_trailing_zeros = false;
@@ -147,30 +137,13 @@
                     DOUBLE_POW5_INV_SPLIT.get_unchecked(q as usize)
                 },
                 i as u32,
-                #[cfg(maybe_uninit)]
-                {
-                    vp_uninit.as_mut_ptr()
-                },
-                #[cfg(not(maybe_uninit))]
-                {
-                    &mut vp
-                },
-                #[cfg(maybe_uninit)]
-                {
-                    vm_uninit.as_mut_ptr()
-                },
-                #[cfg(not(maybe_uninit))]
-                {
-                    &mut vm
-                },
+                vp_uninit.as_mut_ptr(),
+                vm_uninit.as_mut_ptr(),
                 mm_shift,
             )
         };
-        #[cfg(maybe_uninit)]
-        {
-            vp = unsafe { vp_uninit.assume_init() };
-            vm = unsafe { vm_uninit.assume_init() };
-        }
+        vp = unsafe { vp_uninit.assume_init() };
+        vm = unsafe { vm_uninit.assume_init() };
         if q <= 21 {
             // This should use q <= 22, but I think 21 is also safe. Smaller values
             // may still be safe, but it's more difficult to reason about them.
@@ -206,30 +179,13 @@
                     DOUBLE_POW5_SPLIT.get_unchecked(i as usize)
                 },
                 j as u32,
-                #[cfg(maybe_uninit)]
-                {
-                    vp_uninit.as_mut_ptr()
-                },
-                #[cfg(not(maybe_uninit))]
-                {
-                    &mut vp
-                },
-                #[cfg(maybe_uninit)]
-                {
-                    vm_uninit.as_mut_ptr()
-                },
-                #[cfg(not(maybe_uninit))]
-                {
-                    &mut vm
-                },
+                vp_uninit.as_mut_ptr(),
+                vm_uninit.as_mut_ptr(),
                 mm_shift,
             )
         };
-        #[cfg(maybe_uninit)]
-        {
-            vp = unsafe { vp_uninit.assume_init() };
-            vm = unsafe { vm_uninit.assume_init() };
-        }
+        vp = unsafe { vp_uninit.assume_init() };
+        vm = unsafe { vm_uninit.assume_init() };
         if q <= 1 {
             // {vr,vp,vm} is trailing zeros if {mv,mp,mm} has at least q trailing 0 bits.
             // mv = 4 * m2, so it always has at least two trailing 0 bits.
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/src/d2s_small_table.rs cargo-0.58.0/vendor/ryu/src/d2s_small_table.rs
--- cargo-0.57.0+ubuntu/vendor/ryu/src/d2s_small_table.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/src/d2s_small_table.rs	2022-01-21 02:47:39.000000000 +0000
@@ -19,10 +19,8 @@
 // KIND, either express or implied.
 
 use crate::common::*;
-#[cfg(not(integer128))]
-use crate::d2s_intrinsics::*;
 
-pub static DOUBLE_POW5_INV_SPLIT2: [(u64, u64); 13] = [
+pub static DOUBLE_POW5_INV_SPLIT2: [(u64, u64); 15] = [
     (1, 2305843009213693952),
     (5955668970331000884, 1784059615882449851),
     (8982663654677661702, 1380349269358112757),
@@ -36,6 +34,8 @@
     (12533209867169019542, 1418129833677084982),
     (5577825024675947042, 2194449627517475473),
     (11006974540203867551, 1697873161311732311),
+    (10313493231639821582, 1313665730009899186),
+    (12701016819766672773, 2032799256770390445),
 ];
 
 pub static POW5_INV_OFFSETS: [u32; 19] = [
@@ -96,7 +96,6 @@
 ];
 
 // Computes 5^i in the form required by Ryū.
-#[cfg(integer128)]
 #[cfg_attr(feature = "no-panic", inline)]
 pub unsafe fn compute_pow5(i: u32) -> (u64, u64) {
     let base = i / DOUBLE_POW5_TABLE.len() as u32;
@@ -112,7 +111,7 @@
     let b0 = m as u128 * mul.0 as u128;
     let b2 = m as u128 * mul.1 as u128;
     let delta = pow5bits(i as i32) - pow5bits(base2 as i32);
-    debug_assert!(base < POW5_OFFSETS.len() as u32);
+    debug_assert!(i / 16 < POW5_OFFSETS.len() as u32);
     let shifted_sum = (b0 >> delta)
         + (b2 << (64 - delta))
         + ((*POW5_OFFSETS.get_unchecked((i / 16) as usize) >> ((i % 16) << 1)) & 3) as u128;
@@ -120,7 +119,6 @@
 }
 
 // Computes 5^-i in the form required by Ryū.
-#[cfg(integer128)]
 #[cfg_attr(feature = "no-panic", inline)]
 pub unsafe fn compute_inv_pow5(i: u32) -> (u64, u64) {
     let base = (i + DOUBLE_POW5_TABLE.len() as u32 - 1) / DOUBLE_POW5_TABLE.len() as u32;
@@ -142,64 +140,3 @@
         + ((*POW5_INV_OFFSETS.get_unchecked((i / 16) as usize) >> ((i % 16) << 1)) & 3) as u128;
     (shifted_sum as u64, (shifted_sum >> 64) as u64)
 }
-
-// Computes 5^i in the form required by Ryū, and stores it in the given pointer.
-#[cfg(not(integer128))]
-#[cfg_attr(feature = "no-panic", inline)]
-pub unsafe fn compute_pow5(i: u32) -> (u64, u64) {
-    let base = i / DOUBLE_POW5_TABLE.len() as u32;
-    let base2 = base * DOUBLE_POW5_TABLE.len() as u32;
-    let offset = i - base2;
-    debug_assert!(base < DOUBLE_POW5_SPLIT2.len() as u32);
-    let mul = *DOUBLE_POW5_SPLIT2.get_unchecked(base as usize);
-    if offset == 0 {
-        return mul;
-    }
-    debug_assert!(offset < DOUBLE_POW5_TABLE.len() as u32);
-    let m = *DOUBLE_POW5_TABLE.get_unchecked(offset as usize);
-    let (low1, mut high1) = umul128(m, mul.1);
-    let (low0, high0) = umul128(m, mul.0);
-    let sum = high0 + low1;
-    if sum < high0 {
-        high1 += 1; // overflow into high1
-    }
-    // high1 | sum | low0
-    let delta = pow5bits(i as i32) - pow5bits(base2 as i32);
-    debug_assert!(base < POW5_OFFSETS.len() as u32);
-    (
-        shiftright128(low0, sum, delta as u32)
-            + ((*POW5_OFFSETS.get_unchecked((i / 16) as usize) >> ((i % 16) << 1)) & 3) as u64,
-        shiftright128(sum, high1, delta as u32),
-    )
-}
-
-// Computes 5^-i in the form required by Ryū, and stores it in the given pointer.
-#[cfg(not(integer128))]
-#[cfg_attr(feature = "no-panic", inline)]
-pub unsafe fn compute_inv_pow5(i: u32) -> (u64, u64) {
-    let base = (i + DOUBLE_POW5_TABLE.len() as u32 - 1) / DOUBLE_POW5_TABLE.len() as u32;
-    let base2 = base * DOUBLE_POW5_TABLE.len() as u32;
-    let offset = base2 - i;
-    debug_assert!(base < DOUBLE_POW5_INV_SPLIT2.len() as u32);
-    let mul = *DOUBLE_POW5_INV_SPLIT2.get_unchecked(base as usize); // 1/5^base2
-    if offset == 0 {
-        return mul;
-    }
-    debug_assert!(offset < DOUBLE_POW5_TABLE.len() as u32);
-    let m = *DOUBLE_POW5_TABLE.get_unchecked(offset as usize);
-    let (low1, mut high1) = umul128(m, mul.1);
-    let (low0, high0) = umul128(m, mul.0 - 1);
-    let sum = high0 + low1;
-    if sum < high0 {
-        high1 += 1; // overflow into high1
-    }
-    // high1 | sum | low0
-    let delta = pow5bits(base2 as i32) - pow5bits(i as i32);
-    debug_assert!(base < POW5_INV_OFFSETS.len() as u32);
-    (
-        shiftright128(low0, sum, delta as u32)
-            + 1
-            + ((*POW5_INV_OFFSETS.get_unchecked((i / 16) as usize) >> ((i % 16) << 1)) & 3) as u64,
-        shiftright128(sum, high1, delta as u32),
-    )
-}
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/src/lib.rs cargo-0.58.0/vendor/ryu/src/lib.rs
--- cargo-0.57.0+ubuntu/vendor/ryu/src/lib.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/src/lib.rs	2022-01-21 02:47:39.000000000 +0000
@@ -29,7 +29,9 @@
 //! }
 //! ```
 //!
-//! ## Performance
+//! ## Performance (lower is better)
+//!
+//! ![performance](https://raw.githubusercontent.com/dtolnay/ryu/master/performance.png)
 //!
 //! You can run upstream's benchmarks with:
 //!
@@ -62,20 +64,10 @@
 //! $ cargo bench
 //! ```
 //!
-//! The benchmark shows Ryū approximately 4-10x faster than the standard library
+//! The benchmark shows Ryū approximately 2-5x faster than the standard library
 //! across a range of f32 and f64 inputs. Measurements are in nanoseconds per
 //! iteration; smaller is better.
 //!
-//! | type=f32 | 0.0  | 0.1234 | 2.718281828459045 | f32::MAX |
-//! |:--------:|:----:|:------:|:-----------------:|:--------:|
-//! | RYU      | 3ns  | 28ns   | 23ns              | 22ns     |
-//! | STD      | 40ns | 106ns  | 128ns             | 110ns    |
-//!
-//! | type=f64 | 0.0  | 0.1234 | 2.718281828459045 | f64::MAX |
-//! |:--------:|:----:|:------:|:-----------------:|:--------:|
-//! | RYU      | 3ns  | 50ns   | 35ns              | 32ns     |
-//! | STD      | 39ns | 105ns  | 128ns             | 202ns    |
-//!
 //! ## Formatting
 //!
 //! This library tends to produce more human-readable output than the standard
@@ -89,11 +81,25 @@
 //! notation.
 
 #![no_std]
-#![doc(html_root_url = "https://docs.rs/ryu/1.0.5")]
-#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
-#![cfg_attr(
-    feature = "cargo-clippy",
-    allow(cast_lossless, many_single_char_names, unreadable_literal,)
+#![doc(html_root_url = "https://docs.rs/ryu/1.0.9")]
+#![allow(
+    clippy::cast_lossless,
+    clippy::cast_possible_truncation,
+    clippy::cast_possible_wrap,
+    clippy::cast_sign_loss,
+    clippy::checked_conversions,
+    clippy::doc_markdown,
+    clippy::expl_impl_clone_on_copy,
+    clippy::if_not_else,
+    clippy::many_single_char_names,
+    clippy::missing_panics_doc,
+    clippy::module_name_repetitions,
+    clippy::must_use_candidate,
+    clippy::similar_names,
+    clippy::too_many_lines,
+    clippy::unreadable_literal,
+    clippy::unseparated_literal_suffix,
+    clippy::wildcard_imports
 )]
 
 mod buffer;
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/src/pretty/exponent.rs cargo-0.58.0/vendor/ryu/src/pretty/exponent.rs
--- cargo-0.57.0+ubuntu/vendor/ryu/src/pretty/exponent.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/src/pretty/exponent.rs	2022-01-21 02:47:39.000000000 +0000
@@ -14,11 +14,11 @@
     if k >= 100 {
         *result = b'0' + (k / 100) as u8;
         k %= 100;
-        let d = DIGIT_TABLE.get_unchecked(k as usize * 2);
+        let d = DIGIT_TABLE.as_ptr().offset(k * 2);
         ptr::copy_nonoverlapping(d, result.offset(1), 2);
         sign as usize + 3
     } else if k >= 10 {
-        let d = DIGIT_TABLE.get_unchecked(k as usize * 2);
+        let d = DIGIT_TABLE.as_ptr().offset(k * 2);
         ptr::copy_nonoverlapping(d, result, 2);
         sign as usize + 2
     } else {
@@ -38,7 +38,7 @@
 
     debug_assert!(k < 100);
     if k >= 10 {
-        let d = DIGIT_TABLE.get_unchecked(k as usize * 2);
+        let d = DIGIT_TABLE.as_ptr().offset(k * 2);
         ptr::copy_nonoverlapping(d, result, 2);
         sign as usize + 2
     } else {
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/src/pretty/mantissa.rs cargo-0.58.0/vendor/ryu/src/pretty/mantissa.rs
--- cargo-0.57.0+ubuntu/vendor/ryu/src/pretty/mantissa.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/src/pretty/mantissa.rs	2022-01-21 02:47:39.000000000 +0000
@@ -15,10 +15,26 @@
         let c1 = (c / 100) << 1;
         let d0 = (d % 100) << 1;
         let d1 = (d / 100) << 1;
-        ptr::copy_nonoverlapping(DIGIT_TABLE.get_unchecked(c0 as usize), result.offset(-2), 2);
-        ptr::copy_nonoverlapping(DIGIT_TABLE.get_unchecked(c1 as usize), result.offset(-4), 2);
-        ptr::copy_nonoverlapping(DIGIT_TABLE.get_unchecked(d0 as usize), result.offset(-6), 2);
-        ptr::copy_nonoverlapping(DIGIT_TABLE.get_unchecked(d1 as usize), result.offset(-8), 2);
+        ptr::copy_nonoverlapping(
+            DIGIT_TABLE.as_ptr().offset(c0 as isize),
+            result.offset(-2),
+            2,
+        );
+        ptr::copy_nonoverlapping(
+            DIGIT_TABLE.as_ptr().offset(c1 as isize),
+            result.offset(-4),
+            2,
+        );
+        ptr::copy_nonoverlapping(
+            DIGIT_TABLE.as_ptr().offset(d0 as isize),
+            result.offset(-6),
+            2,
+        );
+        ptr::copy_nonoverlapping(
+            DIGIT_TABLE.as_ptr().offset(d1 as isize),
+            result.offset(-8),
+            2,
+        );
         result = result.offset(-8);
     }
     write_mantissa(output as u32, result);
@@ -31,19 +47,35 @@
         output /= 10_000;
         let c0 = (c % 100) << 1;
         let c1 = (c / 100) << 1;
-        ptr::copy_nonoverlapping(DIGIT_TABLE.get_unchecked(c0 as usize), result.offset(-2), 2);
-        ptr::copy_nonoverlapping(DIGIT_TABLE.get_unchecked(c1 as usize), result.offset(-4), 2);
+        ptr::copy_nonoverlapping(
+            DIGIT_TABLE.as_ptr().offset(c0 as isize),
+            result.offset(-2),
+            2,
+        );
+        ptr::copy_nonoverlapping(
+            DIGIT_TABLE.as_ptr().offset(c1 as isize),
+            result.offset(-4),
+            2,
+        );
         result = result.offset(-4);
     }
     if output >= 100 {
         let c = ((output % 100) << 1) as u32;
         output /= 100;
-        ptr::copy_nonoverlapping(DIGIT_TABLE.get_unchecked(c as usize), result.offset(-2), 2);
+        ptr::copy_nonoverlapping(
+            DIGIT_TABLE.as_ptr().offset(c as isize),
+            result.offset(-2),
+            2,
+        );
         result = result.offset(-2);
     }
     if output >= 10 {
         let c = (output << 1) as u32;
-        ptr::copy_nonoverlapping(DIGIT_TABLE.get_unchecked(c as usize), result.offset(-2), 2);
+        ptr::copy_nonoverlapping(
+            DIGIT_TABLE.as_ptr().offset(c as isize),
+            result.offset(-2),
+            2,
+        );
     } else {
         *result.offset(-1) = b'0' + output as u8;
     }
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/src/pretty/mod.rs cargo-0.58.0/vendor/ryu/src/pretty/mod.rs
--- cargo-0.57.0+ubuntu/vendor/ryu/src/pretty/mod.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/src/pretty/mod.rs	2022-01-21 02:47:39.000000000 +0000
@@ -6,7 +6,7 @@
 use crate::common;
 use crate::d2s::{self, *};
 use crate::f2s::*;
-use core::{mem, ptr};
+use core::ptr;
 #[cfg(feature = "no-panic")]
 use no_panic::no_panic;
 
@@ -50,7 +50,7 @@
 #[must_use]
 #[cfg_attr(feature = "no-panic", no_panic)]
 pub unsafe fn format64(f: f64, result: *mut u8) -> usize {
-    let bits = mem::transmute::<f64, u64>(f);
+    let bits = f.to_bits();
     let sign = ((bits >> (DOUBLE_MANTISSA_BITS + DOUBLE_EXPONENT_BITS)) & 1) != 0;
     let ieee_mantissa = bits & ((1u64 << DOUBLE_MANTISSA_BITS) - 1);
     let ieee_exponent =
@@ -157,7 +157,7 @@
 #[must_use]
 #[cfg_attr(feature = "no-panic", no_panic)]
 pub unsafe fn format32(f: f32, result: *mut u8) -> usize {
-    let bits = mem::transmute::<f32, u32>(f);
+    let bits = f.to_bits();
     let sign = ((bits >> (FLOAT_MANTISSA_BITS + FLOAT_EXPONENT_BITS)) & 1) != 0;
     let ieee_mantissa = bits & ((1u32 << FLOAT_MANTISSA_BITS) - 1);
     let ieee_exponent =
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/src/s2d.rs cargo-0.58.0/vendor/ryu/src/s2d.rs
--- cargo-0.57.0+ubuntu/vendor/ryu/src/s2d.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/src/s2d.rs	2022-01-21 02:47:39.000000000 +0000
@@ -203,12 +203,13 @@
     let round_up = last_removed_bit != 0 && (!trailing_zeros || ((m2 >> shift) & 1) != 0);
 
     let mut ieee_m2 = (m2 >> shift).wrapping_add(round_up as u64);
-    if ieee_m2 == (1_u64 << (d2s::DOUBLE_MANTISSA_BITS + 1)) {
+    debug_assert!(ieee_m2 <= 1_u64 << (d2s::DOUBLE_MANTISSA_BITS + 1));
+    ieee_m2 &= (1_u64 << d2s::DOUBLE_MANTISSA_BITS) - 1;
+    if ieee_m2 == 0 && round_up {
         // Due to how the IEEE represents +/-Infinity, we don't need to check
         // for overflow here.
         ieee_e2 += 1;
     }
-    ieee_m2 &= (1_u64 << d2s::DOUBLE_MANTISSA_BITS) - 1;
     let ieee = ((((signed_m as u64) << d2s::DOUBLE_EXPONENT_BITS) | ieee_e2 as u64)
         << d2s::DOUBLE_MANTISSA_BITS)
         | ieee_m2;
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/src/s2f.rs cargo-0.58.0/vendor/ryu/src/s2f.rs
--- cargo-0.57.0+ubuntu/vendor/ryu/src/s2f.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/src/s2f.rs	2022-01-21 02:47:39.000000000 +0000
@@ -153,13 +153,29 @@
             .wrapping_add(e10 as u32)
             .wrapping_sub(ceil_log2_pow5(-e10) as u32)
             .wrapping_sub(f2s::FLOAT_MANTISSA_BITS + 1) as i32;
+
+        // We now compute [m10 * 10^e10 / 2^e2] = [m10 / (5^(-e10) 2^(e2-e10))].
         let j = e2
             .wrapping_sub(e10)
             .wrapping_add(ceil_log2_pow5(-e10))
             .wrapping_sub(1)
             .wrapping_add(f2s::FLOAT_POW5_INV_BITCOUNT);
         m2 = mul_pow5_inv_div_pow2(m10, -e10 as u32, j);
-        trailing_zeros = multiple_of_power_of_5_32(m10, -e10 as u32);
+
+        // We also compute if the result is exact, i.e.,
+        //   [m10 / (5^(-e10) 2^(e2-e10))] == m10 / (5^(-e10) 2^(e2-e10))
+        //
+        // If e2-e10 >= 0, we need to check whether (5^(-e10) 2^(e2-e10))
+        // divides m10, which is the case iff pow5(m10) >= -e10 AND pow2(m10) >=
+        // e2-e10.
+        //
+        // If e2-e10 < 0, we have actually computed [m10 * 2^(e10 e2) /
+        // 5^(-e10)] above, and we need to check whether 5^(-e10) divides (m10 *
+        // 2^(e10-e2)), which is the case iff pow5(m10 * 2^(e10-e2)) = pow5(m10)
+        // >= -e10.
+        trailing_zeros = (e2 < e10
+            || (e2 - e10 < 32 && multiple_of_power_of_2_32(m10, (e2 - e10) as u32)))
+            && multiple_of_power_of_5_32(m10, -e10 as u32);
     }
 
     // Compute the final IEEE exponent.
@@ -194,12 +210,16 @@
     let round_up = last_removed_bit != 0 && (!trailing_zeros || ((m2 >> shift) & 1) != 0);
 
     let mut ieee_m2 = (m2 >> shift).wrapping_add(round_up as u32);
-    if ieee_m2 == (1_u32 << (f2s::FLOAT_MANTISSA_BITS + 1)) {
+    debug_assert!(ieee_m2 <= 1_u32 << (f2s::FLOAT_MANTISSA_BITS + 1));
+    ieee_m2 &= (1_u32 << f2s::FLOAT_MANTISSA_BITS) - 1;
+    if ieee_m2 == 0 && round_up {
+        // Rounding up may overflow the mantissa.
+        // In this case we move a trailing zero of the mantissa into the
+        // exponent.
         // Due to how the IEEE represents +/-Infinity, we don't need to check
         // for overflow here.
         ieee_e2 += 1;
     }
-    ieee_m2 &= (1_u32 << f2s::FLOAT_MANTISSA_BITS) - 1;
     let ieee = ((((signed_m as u32) << f2s::FLOAT_EXPONENT_BITS) | ieee_e2 as u32)
         << f2s::FLOAT_MANTISSA_BITS)
         | ieee_m2;
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/tests/common_test.rs cargo-0.58.0/vendor/ryu/tests/common_test.rs
--- cargo-0.57.0+ubuntu/vendor/ryu/tests/common_test.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/tests/common_test.rs	2022-01-21 02:47:39.000000000 +0000
@@ -19,6 +19,14 @@
 // KIND, either express or implied.
 
 #![allow(dead_code)]
+#![allow(
+    clippy::approx_constant,
+    clippy::cast_possible_wrap,
+    clippy::cast_sign_loss,
+    clippy::excessive_precision,
+    clippy::unreadable_literal,
+    clippy::wildcard_imports
+)]
 
 #[path = "../src/common.rs"]
 mod common;
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/tests/d2s_table_test.rs cargo-0.58.0/vendor/ryu/tests/d2s_table_test.rs
--- cargo-0.57.0+ubuntu/vendor/ryu/tests/d2s_table_test.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/tests/d2s_table_test.rs	2022-01-21 02:47:39.000000000 +0000
@@ -19,6 +19,15 @@
 // KIND, either express or implied.
 
 #![allow(dead_code)]
+#![allow(
+    clippy::cast_lossless,
+    clippy::cast_possible_truncation,
+    clippy::cast_possible_wrap,
+    clippy::cast_sign_loss,
+    clippy::unreadable_literal,
+    clippy::unseparated_literal_suffix,
+    clippy::wildcard_imports
+)]
 
 #[path = "../src/common.rs"]
 mod common;
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/tests/d2s_test.rs cargo-0.58.0/vendor/ryu/tests/d2s_test.rs
--- cargo-0.57.0+ubuntu/vendor/ryu/tests/d2s_test.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/tests/d2s_test.rs	2022-01-21 02:47:39.000000000 +0000
@@ -18,6 +18,16 @@
 // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 // KIND, either express or implied.
 
+#![allow(
+    clippy::approx_constant,
+    clippy::cast_lossless,
+    clippy::float_cmp,
+    clippy::int_plus_one,
+    clippy::non_ascii_literal,
+    clippy::unreadable_literal,
+    clippy::unseparated_literal_suffix
+)]
+
 #[macro_use]
 mod macros;
 
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/tests/f2s_test.rs cargo-0.58.0/vendor/ryu/tests/f2s_test.rs
--- cargo-0.57.0+ubuntu/vendor/ryu/tests/f2s_test.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/tests/f2s_test.rs	2022-01-21 02:47:39.000000000 +0000
@@ -18,6 +18,14 @@
 // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 // KIND, either express or implied.
 
+#![allow(
+    clippy::approx_constant,
+    clippy::float_cmp,
+    clippy::non_ascii_literal,
+    clippy::unreadable_literal,
+    clippy::unseparated_literal_suffix
+)]
+
 #[macro_use]
 mod macros;
 
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/tests/s2d_test.rs cargo-0.58.0/vendor/ryu/tests/s2d_test.rs
--- cargo-0.57.0+ubuntu/vendor/ryu/tests/s2d_test.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/tests/s2d_test.rs	2022-01-21 02:47:39.000000000 +0000
@@ -20,16 +20,35 @@
 
 #![cfg(not(feature = "small"))]
 #![allow(dead_code)]
+#![allow(
+    clippy::cast_lossless,
+    clippy::cast_possible_truncation,
+    clippy::cast_possible_wrap,
+    clippy::cast_sign_loss,
+    clippy::excessive_precision,
+    clippy::float_cmp,
+    clippy::manual_range_contains,
+    clippy::similar_names,
+    clippy::too_many_lines,
+    clippy::unreadable_literal,
+    clippy::unseparated_literal_suffix,
+    clippy::wildcard_imports
+)]
 
 #[path = "../src/common.rs"]
 mod common;
 
+#[cfg(not(feature = "small"))]
 #[path = "../src/d2s_full_table.rs"]
 mod d2s_full_table;
 
 #[path = "../src/d2s_intrinsics.rs"]
 mod d2s_intrinsics;
 
+#[cfg(feature = "small")]
+#[path = "../src/d2s_small_table.rs"]
+mod d2s_small_table;
+
 #[path = "../src/d2s.rs"]
 mod d2s;
 
@@ -77,6 +96,7 @@
     assert_eq!(1.0, s2d(b"1e0").unwrap());
     assert_eq!(1.0, s2d(b"1E0").unwrap());
     assert_eq!(1.0, s2d(b"000001.000000").unwrap());
+    assert_eq!(0.2316419, s2d(b"0.2316419").unwrap());
 }
 
 #[test]
@@ -128,3 +148,20 @@
         s2d(b"1.2999999999999999E+154").unwrap(),
     );
 }
+
+#[test]
+fn test_issue173() {
+    // Denormal boundary
+    assert_eq!(
+        2.2250738585072012e-308,
+        s2d(b"2.2250738585072012e-308").unwrap(),
+    );
+    assert_eq!(
+        2.2250738585072013e-308,
+        s2d(b"2.2250738585072013e-308").unwrap(),
+    );
+    assert_eq!(
+        2.2250738585072014e-308,
+        s2d(b"2.2250738585072014e-308").unwrap(),
+    );
+}
diff -Nru cargo-0.57.0+ubuntu/vendor/ryu/tests/s2f_test.rs cargo-0.58.0/vendor/ryu/tests/s2f_test.rs
--- cargo-0.57.0+ubuntu/vendor/ryu/tests/s2f_test.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/ryu/tests/s2f_test.rs	2022-01-21 02:47:39.000000000 +0000
@@ -19,16 +19,36 @@
 // KIND, either express or implied.
 
 #![allow(dead_code)]
+#![allow(
+    clippy::cast_lossless,
+    clippy::cast_possible_truncation,
+    clippy::cast_possible_wrap,
+    clippy::cast_possible_wrap,
+    clippy::cast_sign_loss,
+    clippy::checked_conversions,
+    clippy::float_cmp,
+    clippy::manual_range_contains,
+    clippy::similar_names,
+    clippy::too_many_lines,
+    clippy::unreadable_literal,
+    clippy::unseparated_literal_suffix,
+    clippy::wildcard_imports
+)]
 
 #[path = "../src/common.rs"]
 mod common;
 
+#[cfg(not(feature = "small"))]
 #[path = "../src/d2s_full_table.rs"]
 mod d2s_full_table;
 
 #[path = "../src/d2s_intrinsics.rs"]
 mod d2s_intrinsics;
 
+#[cfg(feature = "small")]
+#[path = "../src/d2s_small_table.rs"]
+mod d2s_small_table;
+
 #[path = "../src/d2s.rs"]
 mod d2s;
 
@@ -74,4 +94,17 @@
 fn test_mantissa_rounding_overflow() {
     assert_eq!(1.0, s2f(b"0.999999999").unwrap());
     assert_eq!(f32::INFINITY, s2f(b"3.4028236e+38").unwrap());
+    assert_eq!(1.1754944e-38, s2f(b"1.17549430e-38").unwrap()); // FLT_MIN
+    assert_eq!(1.1754944e-38, s2f(b"1.17549431e-38").unwrap());
+    assert_eq!(1.1754944e-38, s2f(b"1.17549432e-38").unwrap());
+    assert_eq!(1.1754944e-38, s2f(b"1.17549433e-38").unwrap());
+    assert_eq!(1.1754944e-38, s2f(b"1.17549434e-38").unwrap());
+    assert_eq!(1.1754944e-38, s2f(b"1.17549435e-38").unwrap());
+}
+
+#[test]
+fn test_trailing_zeros() {
+    assert_eq!(26843550.0, s2f(b"26843549.5").unwrap());
+    assert_eq!(50000004.0, s2f(b"50000002.5").unwrap());
+    assert_eq!(99999992.0, s2f(b"99999989.5").unwrap());
 }
diff -Nru cargo-0.57.0+ubuntu/vendor/serde/build.rs cargo-0.58.0/vendor/serde/build.rs
--- cargo-0.57.0+ubuntu/vendor/serde/build.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde/build.rs	2022-01-21 02:47:39.000000000 +0000
@@ -91,13 +91,14 @@
 
         // Whitelist of archs that support std::sync::atomic module. Ideally we
         // would use #[cfg(target_has_atomic = "...")] but it is not stable yet.
-        // Instead this is based on rustc's src/librustc_target/spec/*.rs.
+        // Instead this is based on rustc's compiler/rustc_target/src/spec/*.rs.
         let has_atomic64 = target.starts_with("x86_64")
             || target.starts_with("i686")
             || target.starts_with("aarch64")
             || target.starts_with("powerpc64")
             || target.starts_with("sparc64")
-            || target.starts_with("mips64el");
+            || target.starts_with("mips64el")
+            || target.starts_with("riscv64");
         let has_atomic32 = has_atomic64 || emscripten;
         if has_atomic64 {
             println!("cargo:rustc-cfg=std_atomic64");
diff -Nru cargo-0.57.0+ubuntu/vendor/serde/.cargo-checksum.json cargo-0.58.0/vendor/serde/.cargo-checksum.json
--- cargo-0.57.0+ubuntu/vendor/serde/.cargo-checksum.json	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde/.cargo-checksum.json	2022-01-21 02:47:39.000000000 +0000
@@ -1 +1 @@
-{"files":{},"package":"f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913"}
\ No newline at end of file
+{"files":{},"package":"97565067517b60e2d1ea8b268e59ce036de907ac523ad83a0475da04e818989a"}
\ No newline at end of file
diff -Nru cargo-0.57.0+ubuntu/vendor/serde/Cargo.toml cargo-0.58.0/vendor/serde/Cargo.toml
--- cargo-0.57.0+ubuntu/vendor/serde/Cargo.toml	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde/Cargo.toml	2022-01-21 02:47:39.000000000 +0000
@@ -10,8 +10,9 @@
 # See Cargo.toml.orig for the original contents.
 
 [package]
+rust-version = "1.15"
 name = "serde"
-version = "1.0.130"
+version = "1.0.133"
 authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
 build = "build.rs"
 include = ["build.rs", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
@@ -29,7 +30,7 @@
 [package.metadata.playground]
 features = ["derive", "rc"]
 [dependencies.serde_derive]
-version = "=1.0.130"
+version = "=1.0.133"
 optional = true
 [dev-dependencies.serde_derive]
 version = "1.0"
diff -Nru cargo-0.57.0+ubuntu/vendor/serde/src/de/mod.rs cargo-0.58.0/vendor/serde/src/de/mod.rs
--- cargo-0.57.0+ubuntu/vendor/serde/src/de/mod.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde/src/de/mod.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1213,6 +1213,20 @@
     fn is_human_readable(&self) -> bool {
         true
     }
+
+    // Not public API.
+    #[cfg(all(serde_derive, any(feature = "std", feature = "alloc")))]
+    #[doc(hidden)]
+    fn __deserialize_content<V>(
+        self,
+        _: ::actually_private::T,
+        visitor: V,
+    ) -> Result<::private::de::Content<'de>, Self::Error>
+    where
+        V: Visitor<'de, Value = ::private::de::Content<'de>>,
+    {
+        self.deserialize_any(visitor)
+    }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff -Nru cargo-0.57.0+ubuntu/vendor/serde/src/lib.rs cargo-0.58.0/vendor/serde/src/lib.rs
--- cargo-0.57.0+ubuntu/vendor/serde/src/lib.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde/src/lib.rs	2022-01-21 02:47:39.000000000 +0000
@@ -60,7 +60,7 @@
 //!
 //! [JSON]: https://github.com/serde-rs/json
 //! [Bincode]: https://github.com/servo/bincode
-//! [CBOR]: https://github.com/pyfisch/cbor
+//! [CBOR]: https://github.com/enarx/ciborium
 //! [YAML]: https://github.com/dtolnay/serde-yaml
 //! [MessagePack]: https://github.com/3Hren/msgpack-rust
 //! [TOML]: https://github.com/alexcrichton/toml-rs
@@ -73,7 +73,7 @@
 //! [URL]: https://docs.rs/serde_qs
 //! [Envy]: https://github.com/softprops/envy
 //! [Envy Store]: https://github.com/softprops/envy-store
-//! [Cargo]: http://doc.crates.io/manifest.html
+//! [Cargo]: https://doc.rust-lang.org/cargo/reference/manifest.html
 //! [AWS Parameter Store]: https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-paramstore.html
 //! [S-expressions]: https://github.com/rotty/lexpr-rs
 //! [D-Bus]: https://docs.rs/zvariant
@@ -84,7 +84,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 
 // Serde types in rustdoc of other crates get linked to here.
-#![doc(html_root_url = "https://docs.rs/serde/1.0.130")]
+#![doc(html_root_url = "https://docs.rs/serde/1.0.133")]
 // Support using Serde without the standard library!
 #![cfg_attr(not(feature = "std"), no_std)]
 // Unstable functionality only if the user asks for it. For tracking and
@@ -94,13 +94,14 @@
 #![cfg_attr(feature = "unstable", feature(never_type))]
 #![allow(unknown_lints, bare_trait_objects, deprecated)]
 #![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
-#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
 // Ignored clippy and clippy_pedantic lints
 #![cfg_attr(
     feature = "cargo-clippy",
     allow(
         // clippy bug: https://github.com/rust-lang/rust-clippy/issues/5704
         unnested_or_patterns,
+        // clippy bug: https://github.com/rust-lang/rust-clippy/issues/7768
+        semicolon_if_nothing_returned,
         // not available in our oldest supported compiler
         checked_conversions,
         empty_enum,
@@ -294,3 +295,8 @@
 #[cfg(feature = "serde_derive")]
 #[doc(hidden)]
 pub use serde_derive::*;
+
+#[cfg(all(serde_derive, any(feature = "std", feature = "alloc")))]
+mod actually_private {
+    pub struct T;
+}
diff -Nru cargo-0.57.0+ubuntu/vendor/serde/src/private/de.rs cargo-0.58.0/vendor/serde/src/private/de.rs
--- cargo-0.57.0+ubuntu/vendor/serde/src/private/de.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde/src/private/de.rs	2022-01-21 02:47:39.000000000 +0000
@@ -206,6 +206,7 @@
     use lib::*;
 
     use __private::size_hint;
+    use actually_private;
     use de::{
         self, Deserialize, DeserializeSeed, Deserializer, EnumAccess, Expected, IgnoredAny,
         MapAccess, SeqAccess, Unexpected, Visitor,
@@ -215,7 +216,7 @@
     /// deserializing untagged enums and internally tagged enums.
     ///
     /// Not public API. Use serde-value instead.
-    #[derive(Debug)]
+    #[derive(Debug, Clone)]
     pub enum Content<'de> {
         Bool(bool),
 
@@ -294,7 +295,7 @@
             // Untagged and internally tagged enums are only supported in
             // self-describing formats.
             let visitor = ContentVisitor { value: PhantomData };
-            deserializer.deserialize_any(visitor)
+            deserializer.__deserialize_content(actually_private::T, visitor)
         }
     }
 
@@ -1427,6 +1428,18 @@
             drop(self);
             visitor.visit_unit()
         }
+
+        fn __deserialize_content<V>(
+            self,
+            _: actually_private::T,
+            visitor: V,
+        ) -> Result<Content<'de>, Self::Error>
+        where
+            V: Visitor<'de, Value = Content<'de>>,
+        {
+            let _ = visitor;
+            Ok(self.content)
+        }
     }
 
     impl<'de, E> ContentDeserializer<'de, E> {
@@ -2138,6 +2151,18 @@
         {
             visitor.visit_unit()
         }
+
+        fn __deserialize_content<V>(
+            self,
+            _: actually_private::T,
+            visitor: V,
+        ) -> Result<Content<'de>, Self::Error>
+        where
+            V: Visitor<'de, Value = Content<'de>>,
+        {
+            let _ = visitor;
+            Ok(self.content.clone())
+        }
     }
 
     impl<'a, 'de, E> ContentRefDeserializer<'a, 'de, E> {
diff -Nru cargo-0.57.0+ubuntu/vendor/serde/src/ser/impls.rs cargo-0.58.0/vendor/serde/src/ser/impls.rs
--- cargo-0.57.0+ubuntu/vendor/serde/src/ser/impls.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde/src/ser/impls.rs	2022-01-21 02:47:39.000000000 +0000
@@ -915,6 +915,7 @@
                 where
                     S: Serializer,
                 {
+                    // Matches the atomic ordering used in libcore for the Debug impl
                     self.load(Ordering::SeqCst).serialize(serializer)
                 }
             }
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_derive/.cargo-checksum.json cargo-0.58.0/vendor/serde_derive/.cargo-checksum.json
--- cargo-0.57.0+ubuntu/vendor/serde_derive/.cargo-checksum.json	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_derive/.cargo-checksum.json	2022-01-21 02:47:39.000000000 +0000
@@ -1 +1 @@
-{"files":{},"package":"d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b"}
\ No newline at end of file
+{"files":{},"package":"ed201699328568d8d08208fdd080e3ff594e6c422e438b6705905da01005d537"}
\ No newline at end of file
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_derive/Cargo.toml cargo-0.58.0/vendor/serde_derive/Cargo.toml
--- cargo-0.57.0+ubuntu/vendor/serde_derive/Cargo.toml	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_derive/Cargo.toml	2022-01-21 02:47:39.000000000 +0000
@@ -10,8 +10,9 @@
 # See Cargo.toml.orig for the original contents.
 
 [package]
+rust-version = "1.31"
 name = "serde_derive"
-version = "1.0.130"
+version = "1.0.133"
 authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
 include = ["build.rs", "src/**/*.rs", "crates-io.md", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
 description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_derive/src/bound.rs cargo-0.58.0/vendor/serde_derive/src/bound.rs
--- cargo-0.57.0+ubuntu/vendor/serde_derive/src/bound.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_derive/src/bound.rs	2022-01-21 02:47:39.000000000 +0000
@@ -50,7 +50,7 @@
         .data
         .all_fields()
         .filter_map(|field| from_field(&field.attrs))
-        .flat_map(|predicates| predicates.to_vec());
+        .flat_map(<[syn::WherePredicate]>::to_vec);
 
     let mut generics = generics.clone();
     generics.make_where_clause().predicates.extend(predicates);
@@ -72,7 +72,7 @@
     let predicates = variants
         .iter()
         .filter_map(|variant| from_variant(&variant.attrs))
-        .flat_map(|predicates| predicates.to_vec());
+        .flat_map(<[syn::WherePredicate]>::to_vec);
 
     let mut generics = generics.clone();
     generics.make_where_clause().predicates.extend(predicates);
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_derive/src/de.rs cargo-0.58.0/vendor/serde_derive/src/de.rs
--- cargo-0.57.0+ubuntu/vendor/serde_derive/src/de.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_derive/src/de.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1458,7 +1458,7 @@
             while let _serde::__private::Some(__k) = #next_key {
                 match __k {
                     _serde::__private::de::TagContentOtherField::Other => {
-                        try!(_serde::de::MapAccess::next_value::<_serde::de::IgnoredAny>(&mut __map));
+                        let _ = try!(_serde::de::MapAccess::next_value::<_serde::de::IgnoredAny>(&mut __map));
                         continue;
                     },
                     _serde::__private::de::TagContentOtherField::Tag => {
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_derive/src/lib.rs cargo-0.58.0/vendor/serde_derive/src/lib.rs
--- cargo-0.57.0+ubuntu/vendor/serde_derive/src/lib.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_derive/src/lib.rs	2022-01-21 02:47:39.000000000 +0000
@@ -13,9 +13,8 @@
 //!
 //! [https://serde.rs/derive.html]: https://serde.rs/derive.html
 
-#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.130")]
+#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.133")]
 #![allow(unknown_lints, bare_trait_objects)]
-#![deny(clippy::all, clippy::pedantic)]
 // Ignored clippy lints
 #![allow(
     // clippy false positive: https://github.com/rust-lang/rust-clippy/issues/7054
@@ -44,6 +43,7 @@
     clippy::indexing_slicing,
     clippy::items_after_statements,
     clippy::let_underscore_drop,
+    clippy::manual_assert,
     clippy::map_err_ignore,
     clippy::match_same_arms,
     // clippy bug: https://github.com/rust-lang/rust-clippy/issues/6984
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_derive/src/pretend.rs cargo-0.58.0/vendor/serde_derive/src/pretend.rs
--- cargo-0.57.0+ubuntu/vendor/serde_derive/src/pretend.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_derive/src/pretend.rs	2022-01-21 02:47:39.000000000 +0000
@@ -65,11 +65,13 @@
 fn pretend_fields_used(cont: &Container, is_packed: bool) -> TokenStream {
     match &cont.data {
         Data::Enum(variants) => pretend_fields_used_enum(cont, variants),
-        Data::Struct(Style::Struct, fields) => if is_packed {
-            pretend_fields_used_struct_packed(cont, fields)
-        } else {
-            pretend_fields_used_struct(cont, fields)
-        },
+        Data::Struct(Style::Struct, fields) => {
+            if is_packed {
+                pretend_fields_used_struct_packed(cont, fields)
+            } else {
+                pretend_fields_used_struct(cont, fields)
+            }
+        }
         Data::Struct(_, _) => quote!(),
     }
 }
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/build.rs cargo-0.58.0/vendor/serde_json/build.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/build.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/build.rs	2022-01-21 02:47:39.000000000 +0000
@@ -31,6 +31,12 @@
     if minor < 45 {
         println!("cargo:rustc-cfg=no_btreemap_remove_entry");
     }
+
+    // BTreeMap::retain
+    // https://blog.rust-lang.org/2021/06/17/Rust-1.53.0.html#stabilized-apis
+    if minor < 53 {
+        println!("cargo:rustc-cfg=no_btreemap_retain");
+    }
 }
 
 fn rustc_minor_version() -> Option<u32> {
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/.cargo-checksum.json cargo-0.58.0/vendor/serde_json/.cargo-checksum.json
--- cargo-0.57.0+ubuntu/vendor/serde_json/.cargo-checksum.json	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/.cargo-checksum.json	2022-01-21 02:47:39.000000000 +0000
@@ -1 +1 @@
-{"files":{},"package":"0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8"}
\ No newline at end of file
+{"files":{},"package":"c059c05b48c5c0067d4b4b2b4f0732dd65feb52daf7e0ea09cd87e7dadc1af79"}
\ No newline at end of file
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/Cargo.toml cargo-0.58.0/vendor/serde_json/Cargo.toml
--- cargo-0.57.0+ubuntu/vendor/serde_json/Cargo.toml	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/Cargo.toml	2022-01-21 02:47:39.000000000 +0000
@@ -11,8 +11,9 @@
 
 [package]
 edition = "2018"
+rust-version = "1.36"
 name = "serde_json"
-version = "1.0.68"
+version = "1.0.75"
 authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
 include = ["build.rs", "src/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
 description = "A JSON serialization file format"
@@ -34,8 +35,7 @@
 optional = true
 
 [dependencies.itoa]
-version = "0.4.3"
-default-features = false
+version = "1.0"
 
 [dependencies.ryu]
 version = "1.0"
@@ -59,7 +59,7 @@
 version = "0.1"
 
 [dev-dependencies.trybuild]
-version = "1.0.19"
+version = "1.0.49"
 features = ["diff"]
 
 [features]
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/README.md cargo-0.58.0/vendor/serde_json/README.md
--- cargo-0.57.0+ubuntu/vendor/serde_json/README.md	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/README.md	2022-01-21 02:47:39.000000000 +0000
@@ -1,11 +1,11 @@
-# Serde JSON   [![Build Status]][travis] [![Latest Version]][crates.io] [![Rustc Version 1.31+]][rustc]
+# Serde JSON   [![Build Status]][travis] [![Latest Version]][crates.io] [![Rustc Version 1.36+]][rustc]
 
 [Build Status]: https://img.shields.io/github/workflow/status/serde-rs/json/CI/master
 [travis]: https://github.com/serde-rs/json/actions?query=branch%3Amaster
 [Latest Version]: https://img.shields.io/crates/v/serde_json.svg
 [crates.io]: https://crates.io/crates/serde\_json
-[Rustc Version 1.31+]: https://img.shields.io/badge/rustc-1.31+-lightgray.svg
-[rustc]: https://blog.rust-lang.org/2018/12/06/Rust-1.31-and-rust-2018.html
+[Rustc Version 1.36+]: https://img.shields.io/badge/rustc-1.36+-lightgray.svg
+[rustc]: https://blog.rust-lang.org/2019/07/04/Rust-1.36.0.html
 
 **Serde is a framework for *ser*ializing and *de*serializing Rust data structures efficiently and generically.**
 
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/de.rs cargo-0.58.0/vendor/serde_json/src/de.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/de.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/de.rs	2022-01-21 02:47:39.000000000 +0000
@@ -3,10 +3,16 @@
 use crate::error::{Error, ErrorCode, Result};
 #[cfg(feature = "float_roundtrip")]
 use crate::lexical;
-use crate::lib::str::FromStr;
-use crate::lib::*;
 use crate::number::Number;
 use crate::read::{self, Fused, Reference};
+use alloc::string::String;
+use alloc::vec::Vec;
+#[cfg(feature = "float_roundtrip")]
+use core::iter;
+use core::iter::FusedIterator;
+use core::marker::PhantomData;
+use core::result;
+use core::str::FromStr;
 use serde::de::{self, Expected, Unexpected};
 use serde::{forward_to_deserialize_any, serde_if_integer128};
 
@@ -87,7 +93,9 @@
 
 macro_rules! overflow {
     ($a:ident * 10 + $b:ident, $c:expr) => {
-        $a >= $c / 10 && ($a > $c / 10 || $b > $c % 10)
+        match $c {
+            c => $a >= c / 10 && ($a > c / 10 || $b > c % 10),
+        }
     };
 }
 
@@ -856,6 +864,15 @@
             buf.push('-');
         }
         self.scan_integer(&mut buf)?;
+        if positive {
+            if let Ok(unsigned) = buf.parse() {
+                return Ok(ParserNumber::U64(unsigned));
+            }
+        } else {
+            if let Ok(signed) = buf.parse() {
+                return Ok(ParserNumber::I64(signed));
+            }
+        }
         Ok(ParserNumber::String(buf))
     }
 
@@ -1560,7 +1577,8 @@
     ///
     /// # Examples
     ///
-    /// You can use this to parse JSON strings containing invalid UTF-8 bytes.
+    /// You can use this to parse JSON strings containing invalid UTF-8 bytes,
+    /// or unpaired surrogates.
     ///
     /// ```
     /// use serde_bytes::ByteBuf;
@@ -1580,20 +1598,18 @@
     /// ```
     ///
     /// Backslash escape sequences like `\n` are still interpreted and required
-    /// to be valid, and `\u` escape sequences are required to represent valid
-    /// Unicode code points.
+    /// to be valid. `\u` escape sequences are required to represent a valid
+    /// Unicode code point or lone surrogate.
     ///
     /// ```
     /// use serde_bytes::ByteBuf;
     ///
-    /// fn look_at_bytes() {
-    ///     let json_data = b"\"invalid unicode surrogate: \\uD801\"";
-    ///     let parsed: Result<ByteBuf, _> = serde_json::from_slice(json_data);
-    ///
-    ///     assert!(parsed.is_err());
-    ///
-    ///     let expected_msg = "unexpected end of hex escape at line 1 column 35";
-    ///     assert_eq!(expected_msg, parsed.unwrap_err().to_string());
+    /// fn look_at_bytes() -> Result<(), serde_json::Error> {
+    ///     let json_data = b"\"lone surrogate: \\uD801\"";
+    ///     let bytes: ByteBuf = serde_json::from_slice(json_data)?;
+    ///     let expected = b"lone surrogate: \xED\xA0\x81";
+    ///     assert_eq!(expected, bytes.as_slice());
+    ///     Ok(())
     /// }
     /// #
     /// # look_at_bytes();
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/error.rs cargo-0.58.0/vendor/serde_json/src/error.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/error.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/error.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,9 +1,14 @@
 //! When serializing or deserializing JSON goes wrong.
 
 use crate::io;
-use crate::lib::str::FromStr;
-use crate::lib::*;
+use alloc::boxed::Box;
+use alloc::string::{String, ToString};
+use core::fmt::{self, Debug, Display};
+use core::result;
+use core::str::FromStr;
 use serde::{de, ser};
+#[cfg(feature = "std")]
+use std::error;
 
 /// This type represents all possible errors that can occur when serializing or
 /// deserializing JSON data.
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/io/core.rs cargo-0.58.0/vendor/serde_json/src/io/core.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/io/core.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/io/core.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,7 +1,9 @@
 //! Reimplements core logic and types from `std::io` in an `alloc`-friendly
 //! fashion.
 
-use crate::lib::*;
+use alloc::vec::Vec;
+use core::fmt::{self, Display};
+use core::result;
 
 pub enum ErrorKind {
     Other,
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/lexical/algorithm.rs cargo-0.58.0/vendor/serde_json/src/lexical/algorithm.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/lexical/algorithm.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/lexical/algorithm.rs	2022-01-21 02:47:39.000000000 +0000
@@ -133,7 +133,7 @@
         let shift = fp.normalize();
         errors <<= shift;
 
-        u64::error_is_accurate::<F>(errors, &fp)
+        u64::error_is_accurate::<F>(errors, fp)
     }
 }
 
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/lexical/bhcomp.rs cargo-0.58.0/vendor/serde_json/src/lexical/bhcomp.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/lexical/bhcomp.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/lexical/bhcomp.rs	2022-01-21 02:47:39.000000000 +0000
@@ -12,7 +12,7 @@
 use super::math::*;
 use super::num::*;
 use super::rounding::*;
-use crate::lib::{cmp, mem};
+use core::{cmp, mem};
 
 // MANTISSA
 
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/lexical/bignum.rs cargo-0.58.0/vendor/serde_json/src/lexical/bignum.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/lexical/bignum.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/lexical/bignum.rs	2022-01-21 02:47:39.000000000 +0000
@@ -3,7 +3,7 @@
 //! Big integer type definition.
 
 use super::math::*;
-use crate::lib::Vec;
+use alloc::vec::Vec;
 
 /// Storage for a big integer type.
 #[derive(Clone, PartialEq, Eq)]
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/lexical/float.rs cargo-0.58.0/vendor/serde_json/src/lexical/float.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/lexical/float.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/lexical/float.rs	2022-01-21 02:47:39.000000000 +0000
@@ -108,7 +108,7 @@
         F: Float,
         Algorithm: FnOnce(&mut ExtendedFloat, i32),
     {
-        round_to_native::<F, _>(self, algorithm)
+        round_to_native::<F, _>(self, algorithm);
     }
 
     // FROM
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/lexical/math.rs cargo-0.58.0/vendor/serde_json/src/lexical/math.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/lexical/math.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/lexical/math.rs	2022-01-21 02:47:39.000000000 +0000
@@ -9,7 +9,8 @@
 use super::large_powers;
 use super::num::*;
 use super::small_powers::*;
-use crate::lib::{cmp, iter, mem, Vec};
+use alloc::vec::Vec;
+use core::{cmp, iter, mem};
 
 // ALIASES
 // -------
@@ -613,7 +614,7 @@
     /// AddAssign bigint to bigint.
     #[inline]
     pub fn iadd(x: &mut Vec<Limb>, y: &[Limb]) {
-        iadd_impl(x, y, 0)
+        iadd_impl(x, y, 0);
     }
 
     /// Add bigint to bigint.
@@ -859,13 +860,13 @@
     /// Multiply by a power of 2.
     #[inline]
     fn imul_pow2(&mut self, n: u32) {
-        self.ishl(n as usize)
+        self.ishl(n as usize);
     }
 
     /// Multiply by a power of 5.
     #[inline]
     fn imul_pow5(&mut self, n: u32) {
-        small::imul_pow5(self.data_mut(), n)
+        small::imul_pow5(self.data_mut(), n);
     }
 
     /// MulAssign by a power of 10.
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/lexical/num.rs cargo-0.58.0/vendor/serde_json/src/lexical/num.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/lexical/num.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/lexical/num.rs	2022-01-21 02:47:39.000000000 +0000
@@ -2,7 +2,7 @@
 
 //! Utilities for Rust numbers.
 
-use crate::lib::ops;
+use core::ops;
 
 /// Precalculated values of radix**i for i in range [0, arr.len()-1].
 /// Each value can be **exactly** represented as that type.
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/lexical/rounding.rs cargo-0.58.0/vendor/serde_json/src/lexical/rounding.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/lexical/rounding.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/lexical/rounding.rs	2022-01-21 02:47:39.000000000 +0000
@@ -5,7 +5,7 @@
 use super::float::ExtendedFloat;
 use super::num::*;
 use super::shift::*;
-use crate::lib::mem;
+use core::mem;
 
 // MASKS
 
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/lexical/shift.rs cargo-0.58.0/vendor/serde_json/src/lexical/shift.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/lexical/shift.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/lexical/shift.rs	2022-01-21 02:47:39.000000000 +0000
@@ -3,7 +3,7 @@
 //! Bit-shift helpers.
 
 use super::float::ExtendedFloat;
-use crate::lib::mem;
+use core::mem;
 
 // Shift extended-precision float right `shift` bytes.
 #[inline]
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/lib.rs cargo-0.58.0/vendor/serde_json/src/lib.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/lib.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/lib.rs	2022-01-21 02:47:39.000000000 +0000
@@ -300,10 +300,10 @@
 //! [macro]: https://docs.serde.rs/serde_json/macro.json.html
 //! [`serde-json-core`]: https://github.com/rust-embedded-community/serde-json-core
 
-#![doc(html_root_url = "https://docs.rs/serde_json/1.0.68")]
-#![deny(clippy::all, clippy::pedantic)]
+#![doc(html_root_url = "https://docs.rs/serde_json/1.0.75")]
 // Ignored clippy lints
 #![allow(
+    clippy::collapsible_else_if,
     clippy::comparison_chain,
     clippy::deprecated_cfg_attr,
     clippy::doc_markdown,
@@ -313,6 +313,8 @@
     clippy::match_like_matches_macro,
     clippy::match_single_binding,
     clippy::needless_doctest_main,
+    clippy::needless_late_init,
+    clippy::return_self_not_must_use,
     clippy::transmute_ptr_to_ptr,
     clippy::unnecessary_wraps,
     // clippy bug: https://github.com/rust-lang/rust-clippy/issues/5704
@@ -320,6 +322,8 @@
 )]
 // Ignored clippy_pedantic lints
 #![allow(
+    // buggy
+    clippy::iter_not_returning_iterator, // https://github.com/rust-lang/rust-clippy/issues/8285
     // Deserializer::from_str, into_iter
     clippy::should_implement_trait,
     // integer and float ser/de requires these sorts of casts
@@ -359,65 +363,8 @@
 #![cfg_attr(not(feature = "std"), no_std)]
 #![cfg_attr(docsrs, feature(doc_cfg))]
 
-////////////////////////////////////////////////////////////////////////////////
-
-#[cfg(not(feature = "std"))]
 extern crate alloc;
 
-/// A facade around all the types we need from the `std`, `core`, and `alloc`
-/// crates. This avoids elaborate import wrangling having to happen in every
-/// module.
-mod lib {
-    mod core {
-        #[cfg(not(feature = "std"))]
-        pub use core::*;
-        #[cfg(feature = "std")]
-        pub use std::*;
-    }
-
-    pub use self::core::cell::{Cell, RefCell};
-    pub use self::core::clone::{self, Clone};
-    pub use self::core::convert::{self, From, Into};
-    pub use self::core::default::{self, Default};
-    pub use self::core::fmt::{self, Debug, Display};
-    pub use self::core::hash::{self, Hash};
-    pub use self::core::iter::FusedIterator;
-    pub use self::core::marker::{self, PhantomData};
-    pub use self::core::ops::{Bound, RangeBounds};
-    pub use self::core::result::{self, Result};
-    pub use self::core::{borrow, char, cmp, iter, mem, num, ops, slice, str};
-
-    #[cfg(not(feature = "std"))]
-    pub use alloc::borrow::{Cow, ToOwned};
-    #[cfg(feature = "std")]
-    pub use std::borrow::{Cow, ToOwned};
-
-    #[cfg(not(feature = "std"))]
-    pub use alloc::string::{String, ToString};
-    #[cfg(feature = "std")]
-    pub use std::string::{String, ToString};
-
-    #[cfg(not(feature = "std"))]
-    pub use alloc::vec::{self, Vec};
-    #[cfg(feature = "std")]
-    pub use std::vec::{self, Vec};
-
-    #[cfg(not(feature = "std"))]
-    pub use alloc::boxed::Box;
-    #[cfg(feature = "std")]
-    pub use std::boxed::Box;
-
-    #[cfg(not(feature = "std"))]
-    pub use alloc::collections::{btree_map, BTreeMap};
-    #[cfg(feature = "std")]
-    pub use std::collections::{btree_map, BTreeMap};
-
-    #[cfg(feature = "std")]
-    pub use std::error;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
 #[cfg(feature = "std")]
 #[doc(inline)]
 pub use crate::de::from_reader;
@@ -436,15 +383,12 @@
 // We only use our own error type; no need for From conversions provided by the
 // standard library's try! macro. This reduces lines of LLVM IR by 4%.
 macro_rules! tri {
-    ($e:expr) => {
+    ($e:expr $(,)?) => {
         match $e {
-            crate::lib::Result::Ok(val) => val,
-            crate::lib::Result::Err(err) => return crate::lib::Result::Err(err),
+            core::result::Result::Ok(val) => val,
+            core::result::Result::Err(err) => return core::result::Result::Err(err),
         }
     };
-    ($e:expr,) => {
-        tri!($e)
-    };
 }
 
 #[macro_use]
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/map.rs cargo-0.58.0/vendor/serde_json/src/map.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/map.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/map.rs	2022-01-21 02:47:39.000000000 +0000
@@ -6,12 +6,19 @@
 //! [`BTreeMap`]: https://doc.rust-lang.org/std/collections/struct.BTreeMap.html
 //! [`IndexMap`]: https://docs.rs/indexmap/*/indexmap/map/struct.IndexMap.html
 
-use crate::lib::borrow::Borrow;
-use crate::lib::iter::FromIterator;
-use crate::lib::*;
 use crate::value::Value;
+use alloc::string::String;
+use core::borrow::Borrow;
+use core::fmt::{self, Debug};
+use core::hash::Hash;
+use core::iter::{FromIterator, FusedIterator};
+#[cfg(feature = "preserve_order")]
+use core::mem;
+use core::ops;
 use serde::de;
 
+#[cfg(not(feature = "preserve_order"))]
+use alloc::collections::{btree_map, BTreeMap};
 #[cfg(feature = "preserve_order")]
 use indexmap::{self, IndexMap};
 
@@ -94,6 +101,20 @@
         self.map.get_mut(key)
     }
 
+    /// Returns the key-value pair matching the given key.
+    ///
+    /// The key may be any borrowed form of the map's key type, but the ordering
+    /// on the borrowed form *must* match the ordering on the key type.
+    #[inline]
+    #[cfg(any(feature = "preserve_order", not(no_btreemap_get_key_value)))]
+    pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&String, &Value)>
+    where
+        String: Borrow<Q>,
+        Q: ?Sized + Ord + Eq + Hash,
+    {
+        self.map.get_key_value(key)
+    }
+
     /// Inserts a key-value pair into the map.
     ///
     /// If the map did not have this key present, `None` is returned.
@@ -151,6 +172,8 @@
             no_btreemap_get_key_value,
         ))]
         {
+            use core::ops::{Bound, RangeBounds};
+
             struct Key<'a, Q: ?Sized>(&'a Q);
 
             impl<'a, Q: ?Sized> RangeBounds<Q> for Key<'a, Q> {
@@ -188,7 +211,7 @@
         S: Into<String>,
     {
         #[cfg(not(feature = "preserve_order"))]
-        use crate::lib::btree_map::Entry as EntryImpl;
+        use alloc::collections::btree_map::Entry as EntryImpl;
         #[cfg(feature = "preserve_order")]
         use indexmap::map::Entry as EntryImpl;
 
@@ -249,6 +272,19 @@
             iter: self.map.values_mut(),
         }
     }
+
+    /// Retains only the elements specified by the predicate.
+    ///
+    /// In other words, remove all pairs `(k, v)` such that `f(&k, &mut v)`
+    /// returns `false`.
+    #[cfg(not(no_btreemap_retain))]
+    #[inline]
+    pub fn retain<F>(&mut self, f: F)
+    where
+        F: FnMut(&String, &mut Value) -> bool,
+    {
+        self.map.retain(f);
+    }
 }
 
 #[allow(clippy::derivable_impls)] // clippy bug: https://github.com/rust-lang/rust-clippy/issues/7655
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/number.rs cargo-0.58.0/vendor/serde_json/src/number.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/number.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/number.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,6 +1,8 @@
 use crate::de::ParserNumber;
 use crate::error::Error;
-use crate::lib::*;
+use core::fmt::{self, Debug, Display};
+#[cfg(not(feature = "arbitrary_precision"))]
+use core::hash::{Hash, Hasher};
 use serde::de::{self, Unexpected, Visitor};
 use serde::{
     forward_to_deserialize_any, serde_if_integer128, Deserialize, Deserializer, Serialize,
@@ -16,13 +18,13 @@
 pub(crate) const TOKEN: &str = "$serde_json::private::Number";
 
 /// Represents a JSON number, whether integer or floating point.
-#[derive(Clone, Eq, PartialEq)]
+#[derive(Clone, PartialEq, Eq, Hash)]
 pub struct Number {
     n: N,
 }
 
 #[cfg(not(feature = "arbitrary_precision"))]
-#[derive(Copy, Clone, PartialEq)]
+#[derive(Copy, Clone)]
 enum N {
     PosInt(u64),
     /// Always less than zero.
@@ -31,10 +33,42 @@
     Float(f64),
 }
 
+#[cfg(not(feature = "arbitrary_precision"))]
+impl PartialEq for N {
+    fn eq(&self, other: &Self) -> bool {
+        match (self, other) {
+            (N::PosInt(a), N::PosInt(b)) => a == b,
+            (N::NegInt(a), N::NegInt(b)) => a == b,
+            (N::Float(a), N::Float(b)) => a == b,
+            _ => false,
+        }
+    }
+}
+
 // Implementing Eq is fine since any float values are always finite.
 #[cfg(not(feature = "arbitrary_precision"))]
 impl Eq for N {}
 
+#[cfg(not(feature = "arbitrary_precision"))]
+impl Hash for N {
+    fn hash<H: Hasher>(&self, h: &mut H) {
+        match *self {
+            N::PosInt(i) => i.hash(h),
+            N::NegInt(i) => i.hash(h),
+            N::Float(f) => {
+                if f == 0.0f64 {
+                    // There are 2 zero representations, +0 and -0, which
+                    // compare equal but have different bits. We use the +0 hash
+                    // for both so that hash(+0) == hash(-0).
+                    0.0f64.to_bits().hash(h);
+                } else {
+                    f.to_bits().hash(h);
+                }
+            }
+        }
+    }
+}
+
 #[cfg(feature = "arbitrary_precision")]
 type N = String;
 
@@ -130,7 +164,7 @@
         {
             for c in self.n.chars() {
                 if c == '.' || c == 'e' || c == 'E' {
-                    return self.n.parse::<f64>().ok().map_or(false, |f| f.is_finite());
+                    return self.n.parse::<f64>().ok().map_or(false, f64::is_finite);
                 }
             }
             false
@@ -254,7 +288,7 @@
     }
 }
 
-impl fmt::Display for Number {
+impl Display for Number {
     #[cfg(not(feature = "arbitrary_precision"))]
     fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
         match self.n {
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/raw.rs cargo-0.58.0/vendor/serde_json/src/raw.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/raw.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/raw.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,5 +1,6 @@
 use crate::error::Error;
-use crate::lib::*;
+use core::fmt::{self, Debug, Display};
+use core::mem;
 use serde::de::value::BorrowedStrDeserializer;
 use serde::de::{
     self, Deserialize, DeserializeSeed, Deserializer, IntoDeserializer, MapAccess, Unexpected,
@@ -122,6 +123,10 @@
     fn from_owned(json: Box<str>) -> Box<Self> {
         unsafe { mem::transmute::<Box<str>, Box<RawValue>>(json) }
     }
+
+    fn into_owned(raw_value: Box<Self>) -> Box<str> {
+        unsafe { mem::transmute::<Box<RawValue>, Box<str>>(raw_value) }
+    }
 }
 
 impl Clone for Box<RawValue> {
@@ -216,6 +221,12 @@
     }
 }
 
+impl From<Box<RawValue>> for Box<str> {
+    fn from(raw_value: Box<RawValue>) -> Self {
+        RawValue::into_owned(raw_value)
+    }
+}
+
 /// Convert a `T` into a boxed `RawValue`.
 ///
 /// # Example
@@ -271,7 +282,7 @@
 #[cfg_attr(docsrs, doc(cfg(feature = "raw_value")))]
 pub fn to_raw_value<T>(value: &T) -> Result<Box<RawValue>, Error>
 where
-    T: Serialize,
+    T: ?Sized + Serialize,
 {
     let json_string = crate::to_string(value)?;
     Ok(RawValue::from_owned(json_string.into_boxed_str()))
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/read.rs cargo-0.58.0/vendor/serde_json/src/read.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/read.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/read.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,6 +1,9 @@
 use crate::error::{Error, ErrorCode, Result};
-use crate::lib::ops::Deref;
-use crate::lib::*;
+use alloc::vec::Vec;
+use core::char;
+use core::cmp;
+use core::ops::Deref;
+use core::str;
 
 #[cfg(feature = "std")]
 use crate::io;
@@ -225,7 +228,7 @@
                     return result(self, scratch);
                 }
                 b'\\' => {
-                    tri!(parse_escape(self, scratch));
+                    tri!(parse_escape(self, validate, scratch));
                 }
                 _ => {
                     if validate {
@@ -465,7 +468,7 @@
                 b'\\' => {
                     scratch.extend_from_slice(&self.slice[start..self.index]);
                     self.index += 1;
-                    tri!(parse_escape(self, scratch));
+                    tri!(parse_escape(self, validate, scratch));
                     start = self.index;
                 }
                 _ => {
@@ -654,8 +657,9 @@
 
     fn parse_str<'s>(&'s mut self, scratch: &'s mut Vec<u8>) -> Result<Reference<'a, 's, str>> {
         self.delegate.parse_str_bytes(scratch, true, |_, bytes| {
-            // The input is assumed to be valid UTF-8 and the \u-escapes are
-            // checked along the way, so don't need to check here.
+            // The deserialization input came in as &str with a UTF-8 guarantee,
+            // and the \u-escapes are checked along the way, so don't need to
+            // check here.
             Ok(unsafe { str::from_utf8_unchecked(bytes) })
         })
     }
@@ -677,7 +681,7 @@
 
     #[cfg(feature = "raw_value")]
     fn begin_raw_buffering(&mut self) {
-        self.delegate.begin_raw_buffering()
+        self.delegate.begin_raw_buffering();
     }
 
     #[cfg(feature = "raw_value")]
@@ -753,7 +757,7 @@
 
     #[cfg(feature = "raw_value")]
     fn begin_raw_buffering(&mut self) {
-        R::begin_raw_buffering(self)
+        R::begin_raw_buffering(self);
     }
 
     #[cfg(feature = "raw_value")]
@@ -816,6 +820,16 @@
     }
 }
 
+fn peek_or_eof<'de, R>(read: &mut R) -> Result<u8>
+where
+    R: ?Sized + Read<'de>,
+{
+    match tri!(read.peek()) {
+        Some(b) => Ok(b),
+        None => error(read, ErrorCode::EofWhileParsingString),
+    }
+}
+
 fn error<'de, R, T>(read: &R, reason: ErrorCode) -> Result<T>
 where
     R: ?Sized + Read<'de>,
@@ -830,7 +844,11 @@
 
 /// Parses a JSON escape sequence and appends it into the scratch space. Assumes
 /// the previous byte read was a backslash.
-fn parse_escape<'de, R: Read<'de>>(read: &mut R, scratch: &mut Vec<u8>) -> Result<()> {
+fn parse_escape<'de, R: Read<'de>>(
+    read: &mut R,
+    validate: bool,
+    scratch: &mut Vec<u8>,
+) -> Result<()> {
     let ch = tri!(next_or_eof(read));
 
     match ch {
@@ -843,19 +861,56 @@
         b'r' => scratch.push(b'\r'),
         b't' => scratch.push(b'\t'),
         b'u' => {
+            fn encode_surrogate(scratch: &mut Vec<u8>, n: u16) {
+                scratch.extend_from_slice(&[
+                    (n >> 12 & 0b0000_1111) as u8 | 0b1110_0000,
+                    (n >> 6 & 0b0011_1111) as u8 | 0b1000_0000,
+                    (n & 0b0011_1111) as u8 | 0b1000_0000,
+                ]);
+            }
+
             let c = match tri!(read.decode_hex_escape()) {
-                0xDC00..=0xDFFF => {
-                    return error(read, ErrorCode::LoneLeadingSurrogateInHexEscape);
+                n @ 0xDC00..=0xDFFF => {
+                    return if validate {
+                        error(read, ErrorCode::LoneLeadingSurrogateInHexEscape)
+                    } else {
+                        encode_surrogate(scratch, n);
+                        Ok(())
+                    };
                 }
 
-                // Non-BMP characters are encoded as a sequence of
-                // two hex escapes, representing UTF-16 surrogates.
+                // Non-BMP characters are encoded as a sequence of two hex
+                // escapes, representing UTF-16 surrogates. If deserializing a
+                // utf-8 string the surrogates are required to be paired,
+                // whereas deserializing a byte string accepts lone surrogates.
                 n1 @ 0xD800..=0xDBFF => {
-                    if tri!(next_or_eof(read)) != b'\\' {
-                        return error(read, ErrorCode::UnexpectedEndOfHexEscape);
+                    if tri!(peek_or_eof(read)) == b'\\' {
+                        read.discard();
+                    } else {
+                        return if validate {
+                            read.discard();
+                            error(read, ErrorCode::UnexpectedEndOfHexEscape)
+                        } else {
+                            encode_surrogate(scratch, n1);
+                            Ok(())
+                        };
                     }
-                    if tri!(next_or_eof(read)) != b'u' {
-                        return error(read, ErrorCode::UnexpectedEndOfHexEscape);
+
+                    if tri!(peek_or_eof(read)) == b'u' {
+                        read.discard();
+                    } else {
+                        return if validate {
+                            read.discard();
+                            error(read, ErrorCode::UnexpectedEndOfHexEscape)
+                        } else {
+                            encode_surrogate(scratch, n1);
+                            // The \ prior to this byte started an escape sequence,
+                            // so we need to parse that now. This recursive call
+                            // does not blow the stack on malicious input because
+                            // the escape is not \u, so it will be handled by one
+                            // of the easy nonrecursive cases.
+                            parse_escape(read, validate, scratch)
+                        };
                     }
 
                     let n2 = tri!(read.decode_hex_escape());
@@ -874,12 +929,9 @@
                     }
                 }
 
-                n => match char::from_u32(n as u32) {
-                    Some(c) => c,
-                    None => {
-                        return error(read, ErrorCode::InvalidUnicodeCodePoint);
-                    }
-                },
+                // Every u16 outside of the surrogate ranges above is guaranteed
+                // to be a legal char.
+                n => char::from_u32(n as u32).unwrap(),
             };
 
             scratch.extend_from_slice(c.encode_utf8(&mut [0_u8; 4]).as_bytes());
@@ -902,38 +954,34 @@
 
     match ch {
         b'"' | b'\\' | b'/' | b'b' | b'f' | b'n' | b'r' | b't' => {}
-        b'u' => {
-            let n = match tri!(read.decode_hex_escape()) {
-                0xDC00..=0xDFFF => {
-                    return error(read, ErrorCode::LoneLeadingSurrogateInHexEscape);
-                }
-
-                // Non-BMP characters are encoded as a sequence of
-                // two hex escapes, representing UTF-16 surrogates.
-                n1 @ 0xD800..=0xDBFF => {
-                    if tri!(next_or_eof(read)) != b'\\' {
-                        return error(read, ErrorCode::UnexpectedEndOfHexEscape);
-                    }
-                    if tri!(next_or_eof(read)) != b'u' {
-                        return error(read, ErrorCode::UnexpectedEndOfHexEscape);
-                    }
-
-                    let n2 = tri!(read.decode_hex_escape());
-
-                    if n2 < 0xDC00 || n2 > 0xDFFF {
-                        return error(read, ErrorCode::LoneLeadingSurrogateInHexEscape);
-                    }
+        b'u' => match tri!(read.decode_hex_escape()) {
+            0xDC00..=0xDFFF => {
+                return error(read, ErrorCode::LoneLeadingSurrogateInHexEscape);
+            }
 
-                    (((n1 - 0xD800) as u32) << 10 | (n2 - 0xDC00) as u32) + 0x1_0000
+            // Non-BMP characters are encoded as a sequence of
+            // two hex escapes, representing UTF-16 surrogates.
+            n1 @ 0xD800..=0xDBFF => {
+                if tri!(next_or_eof(read)) != b'\\' {
+                    return error(read, ErrorCode::UnexpectedEndOfHexEscape);
+                }
+                if tri!(next_or_eof(read)) != b'u' {
+                    return error(read, ErrorCode::UnexpectedEndOfHexEscape);
                 }
 
-                n => n as u32,
-            };
+                let n2 = tri!(read.decode_hex_escape());
+                if n2 < 0xDC00 || n2 > 0xDFFF {
+                    return error(read, ErrorCode::LoneLeadingSurrogateInHexEscape);
+                }
 
-            if char::from_u32(n).is_none() {
-                return error(read, ErrorCode::InvalidUnicodeCodePoint);
+                let n = (((n1 - 0xD800) as u32) << 10 | (n2 - 0xDC00) as u32) + 0x1_0000;
+                if char::from_u32(n).is_none() {
+                    return error(read, ErrorCode::InvalidUnicodeCodePoint);
+                }
             }
-        }
+
+            _ => {}
+        },
         _ => {
             return error(read, ErrorCode::InvalidEscape);
         }
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/ser.rs cargo-0.58.0/vendor/serde_json/src/ser.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/ser.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/ser.rs	2022-01-21 02:47:39.000000000 +0000
@@ -2,8 +2,10 @@
 
 use crate::error::{Error, ErrorCode, Result};
 use crate::io;
-use crate::lib::num::FpCategory;
-use crate::lib::*;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::fmt::{self, Display};
+use core::num::FpCategory;
 use serde::ser::{self, Impossible, Serialize};
 use serde::serde_if_integer128;
 
@@ -756,7 +758,7 @@
             #[cfg(feature = "arbitrary_precision")]
             Compound::Number { ref mut ser, .. } => {
                 if key == crate::number::TOKEN {
-                    tri!(value.serialize(NumberStrEmitter(&mut *ser)));
+                    tri!(value.serialize(NumberStrEmitter(ser)));
                     Ok(())
                 } else {
                     Err(invalid_number())
@@ -765,7 +767,7 @@
             #[cfg(feature = "raw_value")]
             Compound::RawValue { ref mut ser, .. } => {
                 if key == crate::raw::TOKEN {
-                    tri!(value.serialize(RawValueStrEmitter(&mut *ser)));
+                    tri!(value.serialize(RawValueStrEmitter(ser)));
                     Ok(())
                 } else {
                     Err(invalid_raw_value())
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/value/de.rs cargo-0.58.0/vendor/serde_json/src/value/de.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/value/de.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/value/de.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,9 +1,13 @@
 use crate::error::Error;
-use crate::lib::str::FromStr;
-use crate::lib::*;
 use crate::map::Map;
 use crate::number::Number;
 use crate::value::Value;
+use alloc::borrow::{Cow, ToOwned};
+use alloc::string::String;
+use alloc::vec::{self, Vec};
+use core::fmt;
+use core::slice;
+use core::str::FromStr;
 use serde::de::{
     self, Deserialize, DeserializeSeed, EnumAccess, Expected, IntoDeserializer, MapAccess,
     SeqAccess, Unexpected, VariantAccess, Visitor,
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/value/from.rs cargo-0.58.0/vendor/serde_json/src/value/from.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/value/from.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/value/from.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,8 +1,10 @@
 use super::Value;
-use crate::lib::iter::FromIterator;
-use crate::lib::*;
 use crate::map::Map;
 use crate::number::Number;
+use alloc::borrow::Cow;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::iter::FromIterator;
 
 #[cfg(feature = "arbitrary_precision")]
 use serde::serde_if_integer128;
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/value/index.rs cargo-0.58.0/vendor/serde_json/src/value/index.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/value/index.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/value/index.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,6 +1,9 @@
 use super::Value;
-use crate::lib::*;
 use crate::map::Map;
+use alloc::borrow::ToOwned;
+use alloc::string::String;
+use core::fmt::{self, Display};
+use core::ops;
 
 /// A type that can be used to index into a `serde_json::Value`.
 ///
@@ -133,14 +136,14 @@
     pub trait Sealed {}
     impl Sealed for usize {}
     impl Sealed for str {}
-    impl Sealed for super::String {}
+    impl Sealed for alloc::string::String {}
     impl<'a, T> Sealed for &'a T where T: ?Sized + Sealed {}
 }
 
 /// Used in panic messages.
 struct Type<'a>(&'a Value);
 
-impl<'a> fmt::Display for Type<'a> {
+impl<'a> Display for Type<'a> {
     fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
         match *self.0 {
             Value::Null => formatter.write_str("null"),
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/value/mod.rs cargo-0.58.0/vendor/serde_json/src/value/mod.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/value/mod.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/value/mod.rs	2022-01-21 02:47:39.000000000 +0000
@@ -92,7 +92,11 @@
 
 use crate::error::Error;
 use crate::io;
-use crate::lib::*;
+use alloc::string::String;
+use alloc::vec::Vec;
+use core::fmt::{self, Debug, Display};
+use core::mem;
+use core::str;
 use serde::de::DeserializeOwned;
 use serde::ser::Serialize;
 
@@ -191,7 +195,7 @@
     }
 }
 
-impl fmt::Display for Value {
+impl Display for Value {
     /// Display a JSON value as a string.
     ///
     /// ```
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/value/partial_eq.rs cargo-0.58.0/vendor/serde_json/src/value/partial_eq.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/value/partial_eq.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/value/partial_eq.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,5 +1,5 @@
 use super::Value;
-use crate::lib::*;
+use alloc::string::String;
 
 fn eq_i64(value: &Value, other: i64) -> bool {
     value.as_i64().map_or(false, |i| i == other)
diff -Nru cargo-0.57.0+ubuntu/vendor/serde_json/src/value/ser.rs cargo-0.58.0/vendor/serde_json/src/value/ser.rs
--- cargo-0.57.0+ubuntu/vendor/serde_json/src/value/ser.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/serde_json/src/value/ser.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,8 +1,12 @@
 use crate::error::{Error, ErrorCode, Result};
-use crate::lib::*;
 use crate::map::Map;
 use crate::number::Number;
 use crate::value::{to_value, Value};
+use alloc::borrow::ToOwned;
+use alloc::string::{String, ToString};
+use alloc::vec::Vec;
+use core::fmt::Display;
+use core::result;
 use serde::ser::{Impossible, Serialize};
 
 #[cfg(feature = "arbitrary_precision")]
diff -Nru cargo-0.57.0+ubuntu/vendor/socket2/.cargo-checksum.json cargo-0.58.0/vendor/socket2/.cargo-checksum.json
--- cargo-0.57.0+ubuntu/vendor/socket2/.cargo-checksum.json	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/socket2/.cargo-checksum.json	2022-01-21 02:47:39.000000000 +0000
@@ -1 +1 @@
-{"files":{},"package":"5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516"}
\ No newline at end of file
+{"files":{},"package":"0f82496b90c36d70af5fcd482edaa2e0bd16fade569de1330405fecbbdac736b"}
\ No newline at end of file
diff -Nru cargo-0.57.0+ubuntu/vendor/socket2/Cargo.toml cargo-0.58.0/vendor/socket2/Cargo.toml
--- cargo-0.57.0+ubuntu/vendor/socket2/Cargo.toml	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/socket2/Cargo.toml	2022-01-21 02:47:39.000000000 +0000
@@ -12,7 +12,7 @@
 [package]
 edition = "2018"
 name = "socket2"
-version = "0.4.2"
+version = "0.4.3"
 authors = ["Alex Crichton <alex@alexcrichton.com>", "Thomas de Zeeuw <thomasdezeeuw@gmail.com>"]
 include = ["Cargo.toml", "LICENSE-APACHE", "LICENSE-MIT", "README.md", "src/**/*.rs"]
 description = "Utilities for handling networking sockets with a maximal amount of configuration\npossible intended.\n"
@@ -33,7 +33,7 @@
 [features]
 all = []
 [target."cfg(unix)".dependencies.libc]
-version = "0.2.96"
+version = "0.2.113"
 [target."cfg(windows)".dependencies.winapi]
 version = "0.3.9"
 features = ["handleapi", "ws2ipdef", "ws2tcpip"]
diff -Nru cargo-0.57.0+ubuntu/vendor/socket2/src/lib.rs cargo-0.58.0/vendor/socket2/src/lib.rs
--- cargo-0.57.0+ubuntu/vendor/socket2/src/lib.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/socket2/src/lib.rs	2022-01-21 02:47:39.000000000 +0000
@@ -119,19 +119,28 @@
 mod socket;
 mod sockref;
 
-#[cfg(unix)]
-#[path = "sys/unix.rs"]
-mod sys;
-#[cfg(windows)]
-#[path = "sys/windows.rs"]
+#[cfg_attr(unix, path = "sys/unix.rs")]
+#[cfg_attr(windows, path = "sys/windows.rs")]
 mod sys;
 
+#[cfg(not(any(windows, unix)))]
+compile_error!("Socket2 doesn't support the compile target");
+
 use sys::c_int;
 
 pub use sockaddr::SockAddr;
 pub use socket::Socket;
 pub use sockref::SockRef;
 
+#[cfg(not(any(
+    target_os = "haiku",
+    target_os = "illumos",
+    target_os = "netbsd",
+    target_os = "redox",
+    target_os = "solaris",
+)))]
+pub use socket::InterfaceIndexOrAddress;
+
 /// Specification of the communication domain for a socket.
 ///
 /// This is a newtype wrapper around an integer which provides a nicer API in
@@ -282,10 +291,6 @@
 #[repr(transparent)]
 pub struct MaybeUninitSlice<'a>(sys::MaybeUninitSlice<'a>);
 
-unsafe impl<'a> Send for MaybeUninitSlice<'a> {}
-
-unsafe impl<'a> Sync for MaybeUninitSlice<'a> {}
-
 impl<'a> fmt::Debug for MaybeUninitSlice<'a> {
     fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
         fmt::Debug::fmt(self.0.as_slice(), fmt)
@@ -323,9 +328,9 @@
 #[derive(Debug, Clone)]
 pub struct TcpKeepalive {
     time: Option<Duration>,
-    #[cfg_attr(target_os = "redox", allow(dead_code))]
+    #[cfg(not(any(target_os = "redox", target_os = "solaris")))]
     interval: Option<Duration>,
-    #[cfg_attr(target_os = "redox", allow(dead_code))]
+    #[cfg(not(any(target_os = "redox", target_os = "solaris", target_os = "windows")))]
     retries: Option<u32>,
 }
 
@@ -334,7 +339,9 @@
     pub const fn new() -> TcpKeepalive {
         TcpKeepalive {
             time: None,
+            #[cfg(not(any(target_os = "redox", target_os = "solaris")))]
             interval: None,
+            #[cfg(not(any(target_os = "redox", target_os = "solaris", target_os = "windows")))]
             retries: None,
         }
     }
diff -Nru cargo-0.57.0+ubuntu/vendor/socket2/src/sockaddr.rs cargo-0.58.0/vendor/socket2/src/sockaddr.rs
--- cargo-0.57.0+ubuntu/vendor/socket2/src/sockaddr.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/socket2/src/sockaddr.rs	2022-01-21 02:47:39.000000000 +0000
@@ -224,7 +224,7 @@
         let sockaddr_in = sockaddr_in {
             sin_family: AF_INET as sa_family_t,
             sin_port: addr.port().to_be(),
-            sin_addr: crate::sys::to_in_addr(&addr.ip()),
+            sin_addr: crate::sys::to_in_addr(addr.ip()),
             sin_zero: Default::default(),
             #[cfg(any(
                 target_os = "dragonfly",
diff -Nru cargo-0.57.0+ubuntu/vendor/socket2/src/socket.rs cargo-0.58.0/vendor/socket2/src/socket.rs
--- cargo-0.57.0+ubuntu/vendor/socket2/src/socket.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/socket2/src/socket.rs	2022-01-21 02:47:39.000000000 +0000
@@ -32,9 +32,11 @@
 /// precisely one libc or OS API call which is essentially just a "Rustic
 /// translation" of what's below.
 ///
+/// ## Converting to and from other types
+///
 /// This type can be freely converted into the network primitives provided by
 /// the standard library, such as [`TcpStream`] or [`UdpSocket`], using the
-/// [`Into`] trait, see the example below.
+/// [`From`] trait, see the example below.
 ///
 /// [`TcpStream`]: std::net::TcpStream
 /// [`UdpSocket`]: std::net::UdpSocket
@@ -711,6 +713,25 @@
     Ok(socket)
 }
 
+/// A local interface specified by its index or an address assigned to it.
+///
+/// `Index(0)` and `Address(Ipv4Addr::UNSPECIFIED)` are equivalent and indicate
+/// that an appropriate interface should be selected by the system.
+#[cfg(not(any(
+    target_os = "haiku",
+    target_os = "illumos",
+    target_os = "netbsd",
+    target_os = "redox",
+    target_os = "solaris",
+)))]
+#[derive(Debug)]
+pub enum InterfaceIndexOrAddress {
+    /// An interface index.
+    Index(u32),
+    /// An address assigned to an interface.
+    Address(Ipv4Addr),
+}
+
 /// Socket options get/set using `SOL_SOCKET`.
 ///
 /// Additional documentation can be found in documentation of the OS.
@@ -989,6 +1010,44 @@
 /// * Linux: <https://man7.org/linux/man-pages/man7/ip.7.html>
 /// * Windows: <https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options>
 impl Socket {
+    /// Get the value of the `IP_HDRINCL` option on this socket.
+    ///
+    /// For more information about this option, see [`set_header_included`].
+    ///
+    /// [`set_header_included`]: Socket::set_header_included
+    #[cfg(all(feature = "all", not(target_os = "redox")))]
+    #[cfg_attr(docsrs, doc(all(feature = "all", not(target_os = "redox"))))]
+    pub fn header_included(&self) -> io::Result<bool> {
+        unsafe {
+            getsockopt::<c_int>(self.as_raw(), sys::IPPROTO_IP, sys::IP_HDRINCL)
+                .map(|included| included != 0)
+        }
+    }
+
+    /// Set the value of the `IP_HDRINCL` option on this socket.
+    ///
+    /// If enabled, the user supplies an IP header in front of the user data.
+    /// Valid only for [`SOCK_RAW`] sockets; see [raw(7)] for more information.
+    /// When this flag is enabled, the values set by `IP_OPTIONS`, [`IP_TTL`],
+    /// and [`IP_TOS`] are ignored.
+    ///
+    /// [`SOCK_RAW`]: Type::RAW
+    /// [raw(7)]: https://man7.org/linux/man-pages/man7/raw.7.html
+    /// [`IP_TTL`]: Socket::set_ttl
+    /// [`IP_TOS`]: Socket::set_tos
+    #[cfg(all(feature = "all", not(target_os = "redox")))]
+    #[cfg_attr(docsrs, doc(all(feature = "all", not(target_os = "redox"))))]
+    pub fn set_header_included(&self, included: bool) -> io::Result<()> {
+        unsafe {
+            setsockopt(
+                self.as_raw(),
+                sys::IPPROTO_IP,
+                sys::IP_HDRINCL,
+                included as c_int,
+            )
+        }
+    }
+
     /// Get the value of the `IP_TRANSPARENT` option on this socket.
     ///
     /// For more information about this option, see [`set_ip_transparent`].
@@ -1014,7 +1073,7 @@
     /// are routed through the TProxy box (i.e., the system
     /// hosting the application that employs the IP_TRANSPARENT
     /// socket option).  Enabling this socket option requires
-    /// superuser privileges (the CAP_NET_ADMIN capability).
+    /// superuser privileges (the `CAP_NET_ADMIN` capability).
     ///
     /// TProxy redirection with the iptables TPROXY target also
     /// requires that this option be set on the redirected socket.
@@ -1066,6 +1125,63 @@
         }
     }
 
+    /// Join a multicast group using `IP_ADD_MEMBERSHIP` option on this socket.
+    ///
+    /// This function specifies a new multicast group for this socket to join.
+    /// The address must be a valid multicast address, and `interface` specifies
+    /// the local interface with which the system should join the multicast
+    /// group. See [`InterfaceIndexOrAddress`].
+    #[cfg(not(any(
+        target_os = "haiku",
+        target_os = "illumos",
+        target_os = "netbsd",
+        target_os = "redox",
+        target_os = "solaris",
+    )))]
+    pub fn join_multicast_v4_n(
+        &self,
+        multiaddr: &Ipv4Addr,
+        interface: &InterfaceIndexOrAddress,
+    ) -> io::Result<()> {
+        let mreqn = sys::to_mreqn(multiaddr, interface);
+        unsafe {
+            setsockopt(
+                self.as_raw(),
+                sys::IPPROTO_IP,
+                sys::IP_ADD_MEMBERSHIP,
+                mreqn,
+            )
+        }
+    }
+
+    /// Leave a multicast group using `IP_DROP_MEMBERSHIP` option on this socket.
+    ///
+    /// For more information about this option, see [`join_multicast_v4_n`].
+    ///
+    /// [`join_multicast_v4_n`]: Socket::join_multicast_v4_n
+    #[cfg(not(any(
+        target_os = "haiku",
+        target_os = "illumos",
+        target_os = "netbsd",
+        target_os = "redox",
+        target_os = "solaris",
+    )))]
+    pub fn leave_multicast_v4_n(
+        &self,
+        multiaddr: &Ipv4Addr,
+        interface: &InterfaceIndexOrAddress,
+    ) -> io::Result<()> {
+        let mreqn = sys::to_mreqn(multiaddr, interface);
+        unsafe {
+            setsockopt(
+                self.as_raw(),
+                sys::IPPROTO_IP,
+                sys::IP_DROP_MEMBERSHIP,
+                mreqn,
+            )
+        }
+    }
+
     /// Get the value of the `IP_MULTICAST_IF` option for this socket.
     ///
     /// For more information about this option, see [`set_multicast_if_v4`].
@@ -1191,6 +1307,7 @@
     ///
     /// NOTE: <https://docs.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options>
     /// documents that not all versions of windows support `IP_TOS`.
+    ///
     /// [`set_tos`]: Socket::set_tos
     #[cfg(not(any(
         target_os = "fuschia",
diff -Nru cargo-0.57.0+ubuntu/vendor/socket2/src/sys/unix.rs cargo-0.58.0/vendor/socket2/src/sys/unix.rs
--- cargo-0.57.0+ubuntu/vendor/socket2/src/sys/unix.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/socket2/src/sys/unix.rs	2022-01-21 02:47:39.000000000 +0000
@@ -75,6 +75,8 @@
 #[cfg(not(target_os = "redox"))]
 pub(crate) use libc::{MSG_TRUNC, SO_OOBINLINE};
 // Used in `Socket`.
+#[cfg(all(feature = "all", not(target_os = "redox")))]
+pub(crate) use libc::IP_HDRINCL;
 #[cfg(not(any(
     target_os = "fuschia",
     target_os = "redox",
@@ -414,6 +416,10 @@
     _lifetime: PhantomData<&'a mut [MaybeUninit<u8>]>,
 }
 
+unsafe impl<'a> Send for MaybeUninitSlice<'a> {}
+
+unsafe impl<'a> Sync for MaybeUninitSlice<'a> {}
+
 impl<'a> MaybeUninitSlice<'a> {
     pub(crate) fn new(buf: &'a mut [MaybeUninit<u8>]) -> MaybeUninitSlice<'a> {
         MaybeUninitSlice {
@@ -994,6 +1000,31 @@
     Ipv6Addr::from(addr.s6_addr)
 }
 
+#[cfg(not(any(
+    target_os = "haiku",
+    target_os = "illumos",
+    target_os = "netbsd",
+    target_os = "redox",
+    target_os = "solaris",
+)))]
+pub(crate) fn to_mreqn(
+    multiaddr: &Ipv4Addr,
+    interface: &crate::socket::InterfaceIndexOrAddress,
+) -> libc::ip_mreqn {
+    match interface {
+        crate::socket::InterfaceIndexOrAddress::Index(interface) => libc::ip_mreqn {
+            imr_multiaddr: to_in_addr(multiaddr),
+            imr_address: to_in_addr(&Ipv4Addr::UNSPECIFIED),
+            imr_ifindex: *interface as _,
+        },
+        crate::socket::InterfaceIndexOrAddress::Address(interface) => libc::ip_mreqn {
+            imr_multiaddr: to_in_addr(multiaddr),
+            imr_address: to_in_addr(interface),
+            imr_ifindex: 0,
+        },
+    }
+}
+
 /// Unix only API.
 impl crate::Socket {
     /// Accept a new incoming connection from this listener.
@@ -1277,6 +1308,162 @@
         }
     }
 
+    /// Get the value of the `TCP_CORK` option on this socket.
+    ///
+    /// For more information about this option, see [`set_cork`].
+    ///
+    /// [`set_cork`]: Socket::set_cork
+    #[cfg(all(
+        feature = "all",
+        any(target_os = "android", target_os = "fuchsia", target_os = "linux")
+    ))]
+    #[cfg_attr(
+        docsrs,
+        doc(cfg(all(
+            feature = "all",
+            any(target_os = "android", target_os = "fuchsia", target_os = "linux")
+        )))
+    )]
+    pub fn cork(&self) -> io::Result<bool> {
+        unsafe {
+            getsockopt::<Bool>(self.as_raw(), libc::IPPROTO_TCP, libc::TCP_CORK)
+                .map(|cork| cork != 0)
+        }
+    }
+
+    /// Set the value of the `TCP_CORK` option on this socket.
+    ///
+    /// If set, don't send out partial frames. All queued partial frames are
+    /// sent when the option is cleared again. There is a 200 millisecond ceiling on
+    /// the time for which output is corked by `TCP_CORK`. If this ceiling is reached,
+    /// then queued data is automatically transmitted.
+    #[cfg(all(
+        feature = "all",
+        any(target_os = "android", target_os = "fuchsia", target_os = "linux")
+    ))]
+    #[cfg_attr(
+        docsrs,
+        doc(cfg(all(
+            feature = "all",
+            any(target_os = "android", target_os = "fuchsia", target_os = "linux")
+        )))
+    )]
+    pub fn set_cork(&self, cork: bool) -> io::Result<()> {
+        unsafe {
+            setsockopt(
+                self.as_raw(),
+                libc::IPPROTO_TCP,
+                libc::TCP_CORK,
+                cork as c_int,
+            )
+        }
+    }
+
+    /// Get the value of the `TCP_QUICKACK` option on this socket.
+    ///
+    /// For more information about this option, see [`set_quickack`].
+    ///
+    /// [`set_quickack`]: Socket::set_quickack
+    #[cfg(all(
+        feature = "all",
+        any(target_os = "android", target_os = "fuchsia", target_os = "linux")
+    ))]
+    #[cfg_attr(
+        docsrs,
+        doc(cfg(all(
+            feature = "all",
+            any(target_os = "android", target_os = "fuchsia", target_os = "linux")
+        )))
+    )]
+    pub fn quickack(&self) -> io::Result<bool> {
+        unsafe {
+            getsockopt::<Bool>(self.as_raw(), libc::IPPROTO_TCP, libc::TCP_QUICKACK)
+                .map(|quickack| quickack != 0)
+        }
+    }
+
+    /// Set the value of the `TCP_QUICKACK` option on this socket.
+    ///
+    /// If set, acks are sent immediately, rather than delayed if needed in accordance to normal
+    /// TCP operation. This flag is not permanent, it only enables a switch to or from quickack mode.
+    /// Subsequent operation of the TCP protocol will once again enter/leave quickack mode depending on
+    /// internal protocol processing and factors such as delayed ack timeouts occurring and data transfer.
+    #[cfg(all(
+        feature = "all",
+        any(target_os = "android", target_os = "fuchsia", target_os = "linux")
+    ))]
+    #[cfg_attr(
+        docsrs,
+        doc(cfg(all(
+            feature = "all",
+            any(target_os = "android", target_os = "fuchsia", target_os = "linux")
+        )))
+    )]
+    pub fn set_quickack(&self, quickack: bool) -> io::Result<()> {
+        unsafe {
+            setsockopt(
+                self.as_raw(),
+                libc::IPPROTO_TCP,
+                libc::TCP_QUICKACK,
+                quickack as c_int,
+            )
+        }
+    }
+
+    /// Get the value of the `TCP_THIN_LINEAR_TIMEOUTS` option on this socket.
+    ///
+    /// For more information about this option, see [`set_thin_linear_timeouts`].
+    ///
+    /// [`set_thin_linear_timeouts`]: Socket::set_thin_linear_timeouts
+    #[cfg(all(
+        feature = "all",
+        any(target_os = "android", target_os = "fuchsia", target_os = "linux")
+    ))]
+    #[cfg_attr(
+        docsrs,
+        doc(cfg(all(
+            feature = "all",
+            any(target_os = "android", target_os = "fuchsia", target_os = "linux")
+        )))
+    )]
+    pub fn thin_linear_timeouts(&self) -> io::Result<bool> {
+        unsafe {
+            getsockopt::<Bool>(
+                self.as_raw(),
+                libc::IPPROTO_TCP,
+                libc::TCP_THIN_LINEAR_TIMEOUTS,
+            )
+            .map(|timeouts| timeouts != 0)
+        }
+    }
+
+    /// Set the value of the `TCP_THIN_LINEAR_TIMEOUTS` option on this socket.
+    ///    
+    /// If set, the kernel will dynamically detect a thin-stream connection if there are less than four packets in flight.
+    /// With less than four packets in flight the normal TCP fast retransmission will not be effective.
+    /// The kernel will modify the retransmission to avoid the very high latencies that thin stream suffer because of exponential backoff.
+    #[cfg(all(
+        feature = "all",
+        any(target_os = "android", target_os = "fuchsia", target_os = "linux")
+    ))]
+    #[cfg_attr(
+        docsrs,
+        doc(cfg(all(
+            feature = "all",
+            any(target_os = "android", target_os = "fuchsia", target_os = "linux")
+        )))
+    )]
+    pub fn set_thin_linear_timeouts(&self, timeouts: bool) -> io::Result<()> {
+        unsafe {
+            setsockopt(
+                self.as_raw(),
+                libc::IPPROTO_TCP,
+                libc::TCP_THIN_LINEAR_TIMEOUTS,
+                timeouts as c_int,
+            )
+        }
+    }
+
     /// Gets the value for the `SO_BINDTODEVICE` option on this socket.
     ///
     /// This value gets the socket binded device's interface name.
@@ -1348,6 +1535,22 @@
         .map(|_| ())
     }
 
+    /// Sets the value for the `SO_SETFIB` option on this socket.
+    ///
+    /// Bind socket to the specified forwarding table (VRF) on a FreeBSD.
+    #[cfg(all(feature = "all", any(target_os = "freebsd")))]
+    #[cfg_attr(docsrs, doc(cfg(all(feature = "all", any(target_os = "freebsd")))))]
+    pub fn set_fib(&self, fib: u32) -> io::Result<()> {
+        syscall!(setsockopt(
+            self.as_raw(),
+            libc::SOL_SOCKET,
+            libc::SO_SETFIB,
+            (&fib as *const u32).cast(),
+            mem::size_of::<u32>() as libc::socklen_t,
+        ))
+        .map(|_| ())
+    }
+
     /// Sets the value for `IP_BOUND_IF` option on this socket.
     ///
     /// If a socket is bound to an interface, only packets received from that
@@ -1757,6 +1960,37 @@
                 })
         }
     }
+
+    /// Attach Berkeley Packet Filter(BPF) on this socket.
+    ///
+    /// BPF allows a user-space program to attach a filter onto any socket
+    /// and allow or disallow certain types of data to come through the socket.
+    ///
+    /// For more information about this option, see [filter](https://www.kernel.org/doc/html/v5.12/networking/filter.html)
+    #[cfg(all(feature = "all", any(target_os = "linux", target_os = "android")))]
+    pub fn attach_filter(&self, filters: &[libc::sock_filter]) -> io::Result<()> {
+        let prog = libc::sock_fprog {
+            len: filters.len() as u16,
+            filter: filters.as_ptr() as *mut _,
+        };
+
+        unsafe {
+            setsockopt(
+                self.as_raw(),
+                libc::SOL_SOCKET,
+                libc::SO_ATTACH_FILTER,
+                prog,
+            )
+        }
+    }
+
+    /// Detach Berkeley Packet Filter(BPF) from this socket.
+    ///
+    /// For more information about this option, see [`attach_filter`]
+    #[cfg(all(feature = "all", any(target_os = "linux", target_os = "android")))]
+    pub fn detach_filter(&self) -> io::Result<()> {
+        unsafe { setsockopt(self.as_raw(), libc::SOL_SOCKET, libc::SO_DETACH_FILTER, 0) }
+    }
 }
 
 #[cfg_attr(docsrs, doc(cfg(unix)))]
diff -Nru cargo-0.57.0+ubuntu/vendor/socket2/src/sys/windows.rs cargo-0.58.0/vendor/socket2/src/sys/windows.rs
--- cargo-0.57.0+ubuntu/vendor/socket2/src/sys/windows.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/socket2/src/sys/windows.rs	2022-01-21 02:47:39.000000000 +0000
@@ -66,6 +66,8 @@
     IPPROTO_IP, SOL_SOCKET, SO_BROADCAST, SO_ERROR, SO_KEEPALIVE, SO_LINGER, SO_OOBINLINE,
     SO_RCVBUF, SO_RCVTIMEO, SO_REUSEADDR, SO_SNDBUF, SO_SNDTIMEO, SO_TYPE, TCP_NODELAY,
 };
+#[cfg(feature = "all")]
+pub(crate) use winapi::shared::ws2ipdef::IP_HDRINCL;
 pub(crate) use winapi::shared::ws2ipdef::{
     IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP, IPV6_MREQ as Ipv6Mreq, IPV6_MULTICAST_HOPS,
     IPV6_MULTICAST_IF, IPV6_MULTICAST_LOOP, IPV6_UNICAST_HOPS, IPV6_V6ONLY, IP_ADD_MEMBERSHIP,
@@ -157,6 +159,10 @@
     _lifetime: PhantomData<&'a mut [MaybeUninit<u8>]>,
 }
 
+unsafe impl<'a> Send for MaybeUninitSlice<'a> {}
+
+unsafe impl<'a> Sync for MaybeUninitSlice<'a> {}
+
 impl<'a> MaybeUninitSlice<'a> {
     pub fn new(buf: &'a mut [MaybeUninit<u8>]) -> MaybeUninitSlice<'a> {
         assert!(buf.len() <= ULONG::MAX as usize);
@@ -735,6 +741,32 @@
     Ipv6Addr::from(*unsafe { addr.u.Byte() })
 }
 
+pub(crate) fn to_mreqn(
+    multiaddr: &Ipv4Addr,
+    interface: &crate::socket::InterfaceIndexOrAddress,
+) -> IpMreq {
+    IpMreq {
+        imr_multiaddr: to_in_addr(multiaddr),
+        // Per https://docs.microsoft.com/en-us/windows/win32/api/ws2ipdef/ns-ws2ipdef-ip_mreq#members:
+        //
+        // imr_interface
+        //
+        // The local IPv4 address of the interface or the interface index on
+        // which the multicast group should be joined or dropped. This value is
+        // in network byte order. If this member specifies an IPv4 address of
+        // 0.0.0.0, the default IPv4 multicast interface is used.
+        //
+        // To use an interface index of 1 would be the same as an IP address of
+        // 0.0.0.1.
+        imr_interface: match interface {
+            crate::socket::InterfaceIndexOrAddress::Index(interface) => {
+                to_in_addr(&(*interface).into())
+            }
+            crate::socket::InterfaceIndexOrAddress::Address(interface) => to_in_addr(interface),
+        },
+    }
+}
+
 /// Windows only API.
 impl crate::Socket {
     /// Sets `HANDLE_FLAG_INHERIT` using `SetHandleInformation`.
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/.cargo-checksum.json cargo-0.58.0/vendor/syn/.cargo-checksum.json
--- cargo-0.57.0+ubuntu/vendor/syn/.cargo-checksum.json	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/.cargo-checksum.json	2022-01-21 02:47:39.000000000 +0000
@@ -1 +1 @@
-{"files":{},"package":"d010a1623fbd906d51d650a9916aaefc05ffa0e4053ff7fe601167f3e715d194"}
\ No newline at end of file
+{"files":{},"package":"5239bc68e0fef57495900cfea4e8dc75596d9a319d7e16b1e0a440d24e6fe0a0"}
\ No newline at end of file
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/Cargo.toml cargo-0.58.0/vendor/syn/Cargo.toml
--- cargo-0.57.0+ubuntu/vendor/syn/Cargo.toml	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/Cargo.toml	2022-01-21 02:47:39.000000000 +0000
@@ -11,9 +11,8 @@
 
 [package]
 edition = "2018"
-rust-version = "1.31"
 name = "syn"
-version = "1.0.80"
+version = "1.0.77"
 authors = ["David Tolnay <dtolnay@gmail.com>"]
 include = ["/benches/**", "/build.rs", "/Cargo.toml", "/LICENSE-APACHE", "/LICENSE-MIT", "/README.md", "/src/**", "/tests/**"]
 description = "Parser for Rust source code"
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/src/export.rs cargo-0.58.0/vendor/syn/src/export.rs
--- cargo-0.57.0+ubuntu/vendor/syn/src/export.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/src/export.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,5 +1,6 @@
 pub use std::clone::Clone;
 pub use std::cmp::{Eq, PartialEq};
+pub use std::convert::From;
 pub use std::default::Default;
 pub use std::fmt::{self, Debug, Formatter};
 pub use std::hash::{Hash, Hasher};
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/src/generics.rs cargo-0.58.0/vendor/syn/src/generics.rs
--- cargo-0.57.0+ubuntu/vendor/syn/src/generics.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/src/generics.rs	2022-01-21 02:47:39.000000000 +0000
@@ -831,15 +831,6 @@
     #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
     impl Parse for TraitBound {
         fn parse(input: ParseStream) -> Result<Self> {
-            #[cfg(feature = "full")]
-            let tilde_const = if input.peek(Token![~]) && input.peek2(Token![const]) {
-                let tilde_token = input.parse::<Token![~]>()?;
-                let const_token = input.parse::<Token![const]>()?;
-                Some((tilde_token, const_token))
-            } else {
-                None
-            };
-
             let modifier: TraitBoundModifier = input.parse()?;
             let lifetimes: Option<BoundLifetimes> = input.parse()?;
 
@@ -849,21 +840,6 @@
                 path.segments.last_mut().unwrap().arguments = parenthesized;
             }
 
-            #[cfg(feature = "full")]
-            {
-                if let Some((tilde_token, const_token)) = tilde_const {
-                    path.segments.insert(
-                        0,
-                        PathSegment {
-                            ident: Ident::new("const", const_token.span),
-                            arguments: PathArguments::None,
-                        },
-                    );
-                    let (_const, punct) = path.segments.pairs_mut().next().unwrap().into_tuple();
-                    *punct.unwrap() = Token![::](tilde_token.span);
-                }
-            }
-
             Ok(TraitBound {
                 paren_token: None,
                 modifier,
@@ -1018,8 +994,6 @@
     use super::*;
     use crate::attr::FilterAttrs;
     use crate::print::TokensOrDefault;
-    #[cfg(feature = "full")]
-    use crate::punctuated::Pair;
     use proc_macro2::TokenStream;
     #[cfg(feature = "full")]
     use proc_macro2::TokenTree;
@@ -1240,26 +1214,9 @@
     impl ToTokens for TraitBound {
         fn to_tokens(&self, tokens: &mut TokenStream) {
             let to_tokens = |tokens: &mut TokenStream| {
-                #[cfg(feature = "full")]
-                let skip = match self.path.segments.pairs().next() {
-                    Some(Pair::Punctuated(t, p)) if t.ident == "const" => {
-                        Token![~](p.spans[0]).to_tokens(tokens);
-                        t.to_tokens(tokens);
-                        1
-                    }
-                    _ => 0,
-                };
                 self.modifier.to_tokens(tokens);
                 self.lifetimes.to_tokens(tokens);
-                #[cfg(feature = "full")]
-                {
-                    self.path.leading_colon.to_tokens(tokens);
-                    tokens.append_all(self.path.segments.pairs().skip(skip));
-                }
-                #[cfg(not(feature = "full"))]
-                {
-                    self.path.to_tokens(tokens);
-                }
+                self.path.to_tokens(tokens);
             };
             match &self.paren_token {
                 Some(paren) => paren.surround(tokens, to_tokens),
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/src/lib.rs cargo-0.58.0/vendor/syn/src/lib.rs
--- cargo-0.57.0+ubuntu/vendor/syn/src/lib.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/src/lib.rs	2022-01-21 02:47:39.000000000 +0000
@@ -250,7 +250,7 @@
 //!   dynamic library libproc_macro from rustc toolchain.
 
 // Syn types in rustdoc of other crates get linked to here.
-#![doc(html_root_url = "https://docs.rs/syn/1.0.80")]
+#![doc(html_root_url = "https://docs.rs/syn/1.0.77")]
 #![cfg_attr(doc_cfg, feature(doc_cfg))]
 #![allow(non_camel_case_types)]
 // Ignored clippy lints.
@@ -258,7 +258,6 @@
     clippy::collapsible_match, // https://github.com/rust-lang/rust-clippy/issues/7575
     clippy::doc_markdown,
     clippy::eval_order_dependence,
-    clippy::if_then_panic,
     clippy::inherent_to_string,
     clippy::large_enum_variant,
     clippy::manual_map, // https://github.com/rust-lang/rust-clippy/issues/6795
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/src/parse_quote.rs cargo-0.58.0/vendor/syn/src/parse_quote.rs
--- cargo-0.57.0+ubuntu/vendor/syn/src/parse_quote.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/src/parse_quote.rs	2022-01-21 02:47:39.000000000 +0000
@@ -73,7 +73,11 @@
 #[macro_export]
 macro_rules! parse_quote {
     ($($tt:tt)*) => {
-        $crate::parse_quote::parse($crate::__private::quote::quote!($($tt)*))
+        $crate::parse_quote::parse(
+            $crate::__private::From::from(
+                $crate::__private::quote::quote!($($tt)*)
+            )
+        )
     };
 }
 
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/src/punctuated.rs cargo-0.58.0/vendor/syn/src/punctuated.rs
--- cargo-0.57.0+ubuntu/vendor/syn/src/punctuated.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/src/punctuated.rs	2022-01-21 02:47:39.000000000 +0000
@@ -193,7 +193,7 @@
         if self.last.is_some() {
             self.last.take().map(|t| Pair::End(*t))
         } else {
-            self.inner.pop().map(|(t, p)| Pair::Punctuated(t, p))
+            self.inner.pop().map(|(t, d)| Pair::Punctuated(t, d))
         }
     }
 
@@ -937,16 +937,16 @@
     /// the final one and there is no trailing punctuation.
     pub fn punct(&self) -> Option<&P> {
         match self {
-            Pair::Punctuated(_, p) => Some(p),
+            Pair::Punctuated(_, d) => Some(d),
             Pair::End(_) => None,
         }
     }
 
     /// Creates a punctuated pair out of a syntax tree node and an optional
     /// following punctuation.
-    pub fn new(t: T, p: Option<P>) -> Self {
-        match p {
-            Some(p) => Pair::Punctuated(t, p),
+    pub fn new(t: T, d: Option<P>) -> Self {
+        match d {
+            Some(d) => Pair::Punctuated(t, d),
             None => Pair::End(t),
         }
     }
@@ -955,7 +955,7 @@
     /// optional following punctuation.
     pub fn into_tuple(self) -> (T, Option<P>) {
         match self {
-            Pair::Punctuated(t, p) => (t, Some(p)),
+            Pair::Punctuated(t, d) => (t, Some(d)),
             Pair::End(t) => (t, None),
         }
     }
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/src/ty.rs cargo-0.58.0/vendor/syn/src/ty.rs
--- cargo-0.57.0+ubuntu/vendor/syn/src/ty.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/src/ty.rs	2022-01-21 02:47:39.000000000 +0000
@@ -541,7 +541,7 @@
             || lookahead.peek(Token![<])
         {
             if input.peek(Token![dyn]) {
-                let trait_object = TypeTraitObject::parse(input, allow_plus)?;
+                let trait_object: TypeTraitObject = input.parse()?;
                 return Ok(Type::TraitObject(trait_object));
             }
 
@@ -586,12 +586,7 @@
                 if allow_plus {
                     while input.peek(Token![+]) {
                         bounds.push_punct(input.parse()?);
-                        if !(input.peek(Ident::peek_any)
-                            || input.peek(Token![::])
-                            || input.peek(Token![?])
-                            || input.peek(Lifetime)
-                            || input.peek(token::Paren))
-                        {
+                        if input.peek(Token![>]) {
                             break;
                         }
                         bounds.push_value(input.parse()?);
@@ -628,7 +623,7 @@
         } else if lookahead.peek(Token![!]) && !input.peek(Token![=]) {
             input.parse().map(Type::Never)
         } else if lookahead.peek(Token![impl]) {
-            TypeImplTrait::parse(input, allow_plus).map(Type::ImplTrait)
+            input.parse().map(Type::ImplTrait)
         } else if lookahead.peek(Token![_]) {
             input.parse().map(Type::Infer)
         } else if lookahead.peek(Lifetime) {
@@ -832,13 +827,13 @@
     }
 
     impl ReturnType {
-        #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
         pub fn without_plus(input: ParseStream) -> Result<Self> {
             let allow_plus = false;
             Self::parse(input, allow_plus)
         }
 
-        pub(crate) fn parse(input: ParseStream, allow_plus: bool) -> Result<Self> {
+        #[doc(hidden)]
+        pub fn parse(input: ParseStream, allow_plus: bool) -> Result<Self> {
             if input.peek(Token![->]) {
                 let arrow = input.parse()?;
                 let ty = ambig_ty(input, allow_plus)?;
@@ -852,16 +847,14 @@
     #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
     impl Parse for ReturnType {
         fn parse(input: ParseStream) -> Result<Self> {
-            let allow_plus = true;
-            Self::parse(input, allow_plus)
+            Self::parse(input, true)
         }
     }
 
     #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
     impl Parse for TypeTraitObject {
         fn parse(input: ParseStream) -> Result<Self> {
-            let allow_plus = true;
-            Self::parse(input, allow_plus)
+            Self::parse(input, true)
         }
     }
 
@@ -875,67 +868,60 @@
     }
 
     impl TypeTraitObject {
-        #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
         pub fn without_plus(input: ParseStream) -> Result<Self> {
             let allow_plus = false;
             Self::parse(input, allow_plus)
         }
 
         // Only allow multiple trait references if allow_plus is true.
-        pub(crate) fn parse(input: ParseStream, allow_plus: bool) -> Result<Self> {
+        #[doc(hidden)]
+        pub fn parse(input: ParseStream, allow_plus: bool) -> Result<Self> {
             Ok(TypeTraitObject {
                 dyn_token: input.parse()?,
-                bounds: Self::parse_bounds(input, allow_plus)?,
+                bounds: {
+                    let mut bounds = Punctuated::new();
+                    if allow_plus {
+                        loop {
+                            bounds.push_value(input.parse()?);
+                            if !input.peek(Token![+]) {
+                                break;
+                            }
+                            bounds.push_punct(input.parse()?);
+                            if input.peek(Token![>]) {
+                                break;
+                            }
+                        }
+                    } else {
+                        bounds.push_value(input.parse()?);
+                    }
+                    // Just lifetimes like `'a + 'b` is not a TraitObject.
+                    if !at_least_one_type(&bounds) {
+                        return Err(input.error("expected at least one type"));
+                    }
+                    bounds
+                },
             })
         }
-
-        fn parse_bounds(
-            input: ParseStream,
-            allow_plus: bool,
-        ) -> Result<Punctuated<TypeParamBound, Token![+]>> {
-            let mut bounds = Punctuated::new();
-            loop {
-                bounds.push_value(input.parse()?);
-                if !(allow_plus && input.peek(Token![+])) {
-                    break;
-                }
-                bounds.push_punct(input.parse()?);
-                if !(input.peek(Ident::peek_any)
-                    || input.peek(Token![::])
-                    || input.peek(Token![?])
-                    || input.peek(Lifetime)
-                    || input.peek(token::Paren))
-                {
-                    break;
-                }
-            }
-            // Just lifetimes like `'a + 'b` is not a TraitObject.
-            if !at_least_one_type(&bounds) {
-                return Err(input.error("expected at least one type"));
-            }
-            Ok(bounds)
-        }
     }
 
     #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
     impl Parse for TypeImplTrait {
         fn parse(input: ParseStream) -> Result<Self> {
-            let allow_plus = true;
-            Self::parse(input, allow_plus)
-        }
-    }
-
-    impl TypeImplTrait {
-        #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
-        pub fn without_plus(input: ParseStream) -> Result<Self> {
-            let allow_plus = false;
-            Self::parse(input, allow_plus)
-        }
-
-        pub(crate) fn parse(input: ParseStream, allow_plus: bool) -> Result<Self> {
             Ok(TypeImplTrait {
                 impl_token: input.parse()?,
-                bounds: TypeTraitObject::parse_bounds(input, allow_plus)?,
+                // NOTE: rust-lang/rust#34511 includes discussion about whether
+                // or not + should be allowed in ImplTrait directly without ().
+                bounds: {
+                    let mut bounds = Punctuated::new();
+                    loop {
+                        bounds.push_value(input.parse()?);
+                        if !input.peek(Token![+]) {
+                            break;
+                        }
+                        bounds.push_punct(input.parse()?);
+                    }
+                    bounds
+                },
             })
         }
     }
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/tests/common/eq.rs cargo-0.58.0/vendor/syn/tests/common/eq.rs
--- cargo-0.57.0+ubuntu/vendor/syn/tests/common/eq.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/tests/common/eq.rs	2022-01-21 02:47:39.000000000 +0000
@@ -528,7 +528,7 @@
     }
 }
 
-fn doc_comment(
+fn doc_comment<'a>(
     style: AttrStyle,
     unescaped: Symbol,
     trees: &mut impl Iterator<Item = TokenTree>,
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/tests/common/mod.rs cargo-0.58.0/vendor/syn/tests/common/mod.rs
--- cargo-0.57.0+ubuntu/vendor/syn/tests/common/mod.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/tests/common/mod.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,5 +1,4 @@
 #![allow(dead_code)]
-#![allow(clippy::module_name_repetitions, clippy::shadow_unrelated)]
 
 use rayon::ThreadPoolBuilder;
 use std::env;
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/tests/debug/mod.rs cargo-0.58.0/vendor/syn/tests/debug/mod.rs
--- cargo-0.57.0+ubuntu/vendor/syn/tests/debug/mod.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/tests/debug/mod.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,5 +1,3 @@
-#![allow(clippy::too_many_lines, clippy::used_underscore_binding)]
-
 mod gen;
 
 use proc_macro2::{Ident, Literal, TokenStream};
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/tests/repo/mod.rs cargo-0.58.0/vendor/syn/tests/repo/mod.rs
--- cargo-0.57.0+ubuntu/vendor/syn/tests/repo/mod.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/tests/repo/mod.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,5 +1,3 @@
-#![allow(clippy::if_then_panic)]
-
 mod progress;
 
 use self::progress::Progress;
@@ -18,6 +16,13 @@
     // https://github.com/dtolnay/syn/issues/1051
     "src/test/ui/rfc-2632-const-trait-impl/syntax.rs",
 
+    // TODO: ~const in where-clause
+    // https://github.com/dtolnay/syn/issues/1051
+    "library/alloc/src/borrow.rs",
+    "src/test/ui/rfc-2632-const-trait-impl/inherent-impl-const-bounds.rs",
+    "src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-run.rs",
+    "src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-self-referential.rs",
+
     // Compile-fail expr parameter in const generic position: f::<1 + 2>()
     "src/test/ui/const-generics/early/closing-args-token.rs",
     "src/test/ui/const-generics/early/const-expression-parameter.rs",
@@ -63,7 +68,7 @@
     if path.is_dir() {
         return true; // otherwise walkdir does not visit the files
     }
-    if path.extension().map_or(true, |e| e != "rs") {
+    if path.extension().map(|e| e != "rs").unwrap_or(true) {
         return false;
     }
 
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/tests/test_derive_input.rs cargo-0.58.0/vendor/syn/tests/test_derive_input.rs
--- cargo-0.57.0+ubuntu/vendor/syn/tests/test_derive_input.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/tests/test_derive_input.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,5 +1,3 @@
-#![allow(clippy::too_many_lines)]
-
 #[macro_use]
 mod macros;
 
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/tests/test_generics.rs cargo-0.58.0/vendor/syn/tests/test_generics.rs
--- cargo-0.57.0+ubuntu/vendor/syn/tests/test_generics.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/tests/test_generics.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,5 +1,3 @@
-#![allow(clippy::too_many_lines)]
-
 #[macro_use]
 mod macros;
 
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/tests/test_item.rs cargo-0.58.0/vendor/syn/tests/test_item.rs
--- cargo-0.57.0+ubuntu/vendor/syn/tests/test_item.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/tests/test_item.rs	2022-01-21 02:47:39.000000000 +0000
@@ -299,38 +299,3 @@
         self_ty: Type::Tuple,
     }"###);
 }
-
-#[test]
-fn test_impl_trait_trailing_plus() {
-    let tokens = quote! {
-        fn f() -> impl Sized + {}
-    };
-
-    snapshot!(tokens as Item, @r###"
-    Item::Fn {
-        vis: Inherited,
-        sig: Signature {
-            ident: "f",
-            generics: Generics,
-            output: Type(
-                Type::ImplTrait {
-                    bounds: [
-                        Trait(TraitBound {
-                            modifier: None,
-                            path: Path {
-                                segments: [
-                                    PathSegment {
-                                        ident: "Sized",
-                                        arguments: None,
-                                    },
-                                ],
-                            },
-                        }),
-                    ],
-                },
-            ),
-        },
-        block: Block,
-    }
-    "###);
-}
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/tests/test_lit.rs cargo-0.58.0/vendor/syn/tests/test_lit.rs
--- cargo-0.57.0+ubuntu/vendor/syn/tests/test_lit.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/tests/test_lit.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,5 +1,3 @@
-#![allow(clippy::float_cmp, clippy::non_ascii_literal)]
-
 #[macro_use]
 mod macros;
 
@@ -178,6 +176,7 @@
 
 #[test]
 fn floats() {
+    #[cfg_attr(feature = "cargo-clippy", allow(float_cmp))]
     fn test_float(s: &str, value: f64, suffix: &str) {
         match lit(s) {
             Lit::Float(lit) => {
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/tests/test_meta.rs cargo-0.58.0/vendor/syn/tests/test_meta.rs
--- cargo-0.57.0+ubuntu/vendor/syn/tests/test_meta.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/tests/test_meta.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,5 +1,3 @@
-#![allow(clippy::shadow_unrelated, clippy::too_many_lines)]
-
 #[macro_use]
 mod macros;
 
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/tests/test_parse_buffer.rs cargo-0.58.0/vendor/syn/tests/test_parse_buffer.rs
--- cargo-0.57.0+ubuntu/vendor/syn/tests/test_parse_buffer.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/tests/test_parse_buffer.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,5 +1,3 @@
-#![allow(clippy::non_ascii_literal)]
-
 use proc_macro2::{Delimiter, Group, Punct, Spacing, TokenStream, TokenTree};
 use std::iter::FromIterator;
 use syn::parse::{discouraged::Speculative, Parse, ParseStream, Parser, Result};
@@ -12,7 +10,7 @@
     impl Parse for BreakRules {
         fn parse(input1: ParseStream) -> Result<Self> {
             let nested = |input2: ParseStream| {
-                input1.advance_to(input2);
+                input1.advance_to(&input2);
                 Ok(Self)
             };
             nested.parse_str("")
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/tests/test_precedence.rs cargo-0.58.0/vendor/syn/tests/test_precedence.rs
--- cargo-0.57.0+ubuntu/vendor/syn/tests/test_precedence.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/tests/test_precedence.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,12 +1,6 @@
 #![cfg(not(syn_disable_nightly_tests))]
 #![recursion_limit = "1024"]
 #![feature(rustc_private)]
-#![allow(
-    clippy::explicit_deref_methods,
-    clippy::if_then_panic,
-    clippy::match_wildcard_for_single_variants,
-    clippy::too_many_lines
-)]
 
 //! The tests in this module do the following:
 //!
@@ -346,8 +340,8 @@
 /// reveal the precedence of the parsed expressions, and produce a stringified
 /// form of the resulting expression.
 fn syn_brackets(syn_expr: syn::Expr) -> syn::Expr {
-    use syn::fold::{fold_expr, fold_generic_argument, fold_generic_method_argument, Fold};
-    use syn::{token, Expr, ExprParen, GenericArgument, GenericMethodArgument, Pat, Stmt, Type};
+    use syn::fold::*;
+    use syn::*;
 
     struct ParenthesizeEveryExpr;
     impl Fold for ParenthesizeEveryExpr {
@@ -423,9 +417,9 @@
 
 /// Walk through a crate collecting all expressions we can find in it.
 fn collect_exprs(file: syn::File) -> Vec<syn::Expr> {
-    use syn::fold::Fold;
+    use syn::fold::*;
     use syn::punctuated::Punctuated;
-    use syn::{token, Expr, ExprTuple};
+    use syn::*;
 
     struct CollectExprs(Vec<Expr>);
     impl Fold for CollectExprs {
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/tests/test_round_trip.rs cargo-0.58.0/vendor/syn/tests/test_round_trip.rs
--- cargo-0.57.0+ubuntu/vendor/syn/tests/test_round_trip.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/tests/test_round_trip.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,7 +1,6 @@
 #![cfg(not(syn_disable_nightly_tests))]
 #![recursion_limit = "1024"]
 #![feature(rustc_private)]
-#![allow(clippy::if_then_panic)]
 
 extern crate rustc_ast;
 extern crate rustc_errors;
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/tests/test_size.rs cargo-0.58.0/vendor/syn/tests/test_size.rs
--- cargo-0.57.0+ubuntu/vendor/syn/tests/test_size.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/tests/test_size.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,7 +1,7 @@
 #![cfg(target_pointer_width = "64")]
 
 use std::mem;
-use syn::{Expr, Item, Lit, Pat, Type};
+use syn::*;
 
 #[test]
 fn test_expr_size() {
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/tests/test_stmt.rs cargo-0.58.0/vendor/syn/tests/test_stmt.rs
--- cargo-0.57.0+ubuntu/vendor/syn/tests/test_stmt.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/tests/test_stmt.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,5 +1,3 @@
-#![allow(clippy::non_ascii_literal)]
-
 #[macro_use]
 mod macros;
 
diff -Nru cargo-0.57.0+ubuntu/vendor/syn/tests/test_ty.rs cargo-0.58.0/vendor/syn/tests/test_ty.rs
--- cargo-0.57.0+ubuntu/vendor/syn/tests/test_ty.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/syn/tests/test_ty.rs	2022-01-21 02:47:39.000000000 +0000
@@ -285,67 +285,3 @@
     syn::parse_str::<Type>("for<'a> dyn Trait<'a>").unwrap_err();
     syn::parse_str::<Type>("dyn for<'a> 'a + Trait").unwrap_err();
 }
-
-#[test]
-fn test_trailing_plus() {
-    #[rustfmt::skip]
-    let tokens = quote!(impl Trait +);
-    snapshot!(tokens as Type, @r###"
-    Type::ImplTrait {
-        bounds: [
-            Trait(TraitBound {
-                modifier: None,
-                path: Path {
-                    segments: [
-                        PathSegment {
-                            ident: "Trait",
-                            arguments: None,
-                        },
-                    ],
-                },
-            }),
-        ],
-    }
-    "###);
-
-    #[rustfmt::skip]
-    let tokens = quote!(dyn Trait +);
-    snapshot!(tokens as Type, @r###"
-    Type::TraitObject {
-        dyn_token: Some,
-        bounds: [
-            Trait(TraitBound {
-                modifier: None,
-                path: Path {
-                    segments: [
-                        PathSegment {
-                            ident: "Trait",
-                            arguments: None,
-                        },
-                    ],
-                },
-            }),
-        ],
-    }
-    "###);
-
-    #[rustfmt::skip]
-    let tokens = quote!(Trait +);
-    snapshot!(tokens as Type, @r###"
-    Type::TraitObject {
-        bounds: [
-            Trait(TraitBound {
-                modifier: None,
-                path: Path {
-                    segments: [
-                        PathSegment {
-                            ident: "Trait",
-                            arguments: None,
-                        },
-                    ],
-                },
-            }),
-        ],
-    }
-    "###);
-}
diff -Nru cargo-0.57.0+ubuntu/vendor/tempfile/.cargo-checksum.json cargo-0.58.0/vendor/tempfile/.cargo-checksum.json
--- cargo-0.57.0+ubuntu/vendor/tempfile/.cargo-checksum.json	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/tempfile/.cargo-checksum.json	2022-01-21 02:47:39.000000000 +0000
@@ -1 +1 @@
-{"files":{},"package":"7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"}
\ No newline at end of file
+{"files":{},"package":"dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"}
\ No newline at end of file
diff -Nru cargo-0.57.0+ubuntu/vendor/tempfile/Cargo.toml cargo-0.58.0/vendor/tempfile/Cargo.toml
--- cargo-0.57.0+ubuntu/vendor/tempfile/Cargo.toml	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/tempfile/Cargo.toml	2022-01-21 02:47:39.000000000 +0000
@@ -13,7 +13,7 @@
 [package]
 edition = "2018"
 name = "tempfile"
-version = "3.1.0"
+version = "3.2.0"
 authors = ["Steven Allen <steven@stebalien.com>", "The Rust Project Developers", "Ashley Mannix <ashleymannix@live.com.au>", "Jason White <jasonaw0@gmail.com>"]
 exclude = ["/.travis.yml", "/appveyor.yml"]
 description = "A library for managing temporary files and directories."
@@ -23,15 +23,15 @@
 license = "MIT OR Apache-2.0"
 repository = "https://github.com/Stebalien/tempfile"
 [dependencies.cfg-if]
-version = "0.1"
+version = "1"
 
 [dependencies.rand]
-version = "0.7"
+version = "0.8"
 
 [dependencies.remove_dir_all]
 version = "0.5"
 [target."cfg(target_os = \"redox\")".dependencies.redox_syscall]
-version = "0.1"
+version = "0.2"
 [target."cfg(unix)".dependencies.libc]
 version = "0.2.27"
 [target."cfg(windows)".dependencies.winapi]
diff -Nru cargo-0.57.0+ubuntu/vendor/tempfile/NEWS cargo-0.58.0/vendor/tempfile/NEWS
--- cargo-0.57.0+ubuntu/vendor/tempfile/NEWS	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/tempfile/NEWS	2022-01-21 02:47:39.000000000 +0000
@@ -1,3 +1,15 @@
+3.2.0
+=====
+
+Features:
+
+* Bump rand dependency to `0.8`.
+* Bump cfg-if dependency to `1.0`
+
+Other than that, this release mostly includes small cleanups and simplifications.
+
+Breaking: The minimum rust version is now `1.40.0`.
+
 3.1.0
 =====
 
diff -Nru cargo-0.57.0+ubuntu/vendor/tempfile/README.md cargo-0.58.0/vendor/tempfile/README.md
--- cargo-0.57.0+ubuntu/vendor/tempfile/README.md	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/tempfile/README.md	2022-01-21 02:47:39.000000000 +0000
@@ -15,7 +15,7 @@
 Usage
 -----
 
-Minimum required Rust version: 1.32.0
+Minimum required Rust version: 1.40.0
 
 Add this to your `Cargo.toml`:
 ```toml
diff -Nru cargo-0.57.0+ubuntu/vendor/tempfile/src/dir.rs cargo-0.58.0/vendor/tempfile/src/dir.rs
--- cargo-0.57.0+ubuntu/vendor/tempfile/src/dir.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/tempfile/src/dir.rs	2022-01-21 02:47:39.000000000 +0000
@@ -20,7 +20,7 @@
 /// The `tempdir` function creates a directory in the file system
 /// and returns a [`TempDir`].
 /// The directory will be automatically deleted when the `TempDir`s
-/// desctructor is run.
+/// destructor is run.
 ///
 /// # Resource Leaking
 ///
@@ -69,7 +69,7 @@
 /// The `tempdir` function creates a directory in the file system
 /// and returns a [`TempDir`].
 /// The directory will be automatically deleted when the `TempDir`s
-/// desctructor is run.
+/// destructor is run.
 ///
 /// # Resource Leaking
 ///
@@ -326,7 +326,7 @@
         self.path.take().unwrap()
     }
 
-    /// Closes and removes the temporary directory, returing a `Result`.
+    /// Closes and removes the temporary directory, returning a `Result`.
     ///
     /// Although `TempDir` removes the directory on drop, in the destructor
     /// any errors are ignored. To detect errors cleaning up the temporary
diff -Nru cargo-0.57.0+ubuntu/vendor/tempfile/src/file/mod.rs cargo-0.58.0/vendor/tempfile/src/file/mod.rs
--- cargo-0.57.0+ubuntu/vendor/tempfile/src/file/mod.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/tempfile/src/file/mod.rs	2022-01-21 02:47:39.000000000 +0000
@@ -1,4 +1,3 @@
-use std;
 use std::env;
 use std::error;
 use std::ffi::OsStr;
@@ -178,7 +177,7 @@
     /// ```
     pub fn close(mut self) -> io::Result<()> {
         let result = fs::remove_file(&self.path).with_err_path(|| &self.path);
-        mem::replace(&mut self.path, PathBuf::new());
+        self.path = PathBuf::new();
         mem::forget(self);
         result
     }
@@ -189,7 +188,10 @@
     /// If this method fails, it will return `self` in the resulting
     /// [`PathPersistError`].
     ///
-    /// Note: Temporary files cannot be persisted across filesystems.
+    /// Note: Temporary files cannot be persisted across filesystems. Also
+    /// neither the file contents nor the containing directory are
+    /// synchronized, so the update may not yet have reached the disk when
+    /// `persist` returns.
     ///
     /// # Security
     ///
@@ -229,7 +231,7 @@
                 // Don't drop `self`. We don't want to try deleting the old
                 // temporary file path. (It'll fail, but the failure is never
                 // seen.)
-                mem::replace(&mut self.path, PathBuf::new());
+                self.path = PathBuf::new();
                 mem::forget(self);
                 Ok(())
             }
@@ -240,7 +242,7 @@
         }
     }
 
-    /// Persist the temporary file at the target path iff no file exists there.
+    /// Persist the temporary file at the target path if and only if no file exists there.
     ///
     /// If a file exists at the target path, fail. If this method fails, it will
     /// return `self` in the resulting [`PathPersistError`].
@@ -291,7 +293,7 @@
                 // Don't drop `self`. We don't want to try deleting the old
                 // temporary file path. (It'll fail, but the failure is never
                 // seen.)
-                mem::replace(&mut self.path, PathBuf::new());
+                self.path = PathBuf::new();
                 mem::forget(self);
                 Ok(())
             }
@@ -339,8 +341,7 @@
                 // Don't drop `self`. We don't want to try deleting the old
                 // temporary file path. (It'll fail, but the failure is never
                 // seen.)
-                let mut path = PathBuf::new();
-                mem::swap(&mut self.path, &mut path);
+                let path = mem::replace(&mut self.path, PathBuf::new());
                 mem::forget(self);
                 Ok(path)
             }
@@ -584,7 +585,7 @@
     ///
     /// See [`NamedTempFile::new()`] for details.
     ///
-    /// [`NamedTempFile::new()`]: #method.new_in
+    /// [`NamedTempFile::new()`]: #method.new
     pub fn new_in<P: AsRef<Path>>(dir: P) -> io::Result<NamedTempFile> {
         Builder::new().tempfile_in(dir)
     }
@@ -662,11 +663,14 @@
     /// If this method fails, it will return `self` in the resulting
     /// [`PersistError`].
     ///
-    /// Note: Temporary files cannot be persisted across filesystems.
+    /// Note: Temporary files cannot be persisted across filesystems. Also
+    /// neither the file contents nor the containing directory are
+    /// synchronized, so the update may not yet have reached the disk when
+    /// `persist` returns.
     ///
     /// # Security
     ///
-    /// This method persists the temporary file using it's path and may not be
+    /// This method persists the temporary file using its path and may not be
     /// secure in the in all cases. Please read the security section on the top
     /// level documentation of this type for details.
     ///
@@ -709,7 +713,7 @@
         }
     }
 
-    /// Persist the temporary file at the target path iff no file exists there.
+    /// Persist the temporary file at the target path if and only if no file exists there.
     ///
     /// If a file exists at the target path, fail. If this method fails, it will
     /// return `self` in the resulting PersistError.
@@ -720,7 +724,7 @@
     ///
     /// # Security
     ///
-    /// This method persists the temporary file using it's path and may not be
+    /// This method persists the temporary file using its path and may not be
     /// secure in the in all cases. Please read the security section on the top
     /// level documentation of this type for details.
     ///
diff -Nru cargo-0.57.0+ubuntu/vendor/tempfile/src/lib.rs cargo-0.58.0/vendor/tempfile/src/lib.rs
--- cargo-0.57.0+ubuntu/vendor/tempfile/src/lib.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/tempfile/src/lib.rs	2022-01-21 02:47:39.000000000 +0000
@@ -124,6 +124,7 @@
 )]
 #![cfg_attr(test, deny(warnings))]
 #![deny(rust_2018_idioms)]
+#![allow(clippy::redundant_field_names)]
 
 #[macro_use]
 extern crate cfg_if;
@@ -143,7 +144,9 @@
 mod util;
 
 pub use crate::dir::{tempdir, tempdir_in, TempDir};
-pub use crate::file::{tempfile, tempfile_in, NamedTempFile, PathPersistError, PersistError, TempPath};
+pub use crate::file::{
+    tempfile, tempfile_in, NamedTempFile, PathPersistError, PersistError, TempPath,
+};
 pub use crate::spooled::{spooled_tempfile, SpooledTempFile};
 
 /// Create a new temporary file or directory with custom parameters.
diff -Nru cargo-0.57.0+ubuntu/vendor/tempfile/src/util.rs cargo-0.58.0/vendor/tempfile/src/util.rs
--- cargo-0.57.0+ubuntu/vendor/tempfile/src/util.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/tempfile/src/util.rs	2022-01-21 02:47:39.000000000 +0000
@@ -33,7 +33,11 @@
 where
     F: Fn(PathBuf) -> io::Result<R>,
 {
-    let num_retries = if random_len != 0 { crate::NUM_RETRIES } else { 1 };
+    let num_retries = if random_len != 0 {
+        crate::NUM_RETRIES
+    } else {
+        1
+    };
 
     for _ in 0..num_retries {
         let path = base.join(tmpname(prefix, suffix, random_len));
diff -Nru cargo-0.57.0+ubuntu/vendor/tinyvec/benches/smallvec.rs cargo-0.58.0/vendor/tinyvec/benches/smallvec.rs
--- cargo-0.57.0+ubuntu/vendor/tinyvec/benches/smallvec.rs	1970-01-01 00:00:00.000000000 +0000
+++ cargo-0.58.0/vendor/tinyvec/benches/smallvec.rs	2022-01-21 02:47:39.000000000 +0000
@@ -0,0 +1,500 @@
+//! Benchmarks that compare TinyVec to SmallVec
+//!
+//! All the following commentary is based on the latest nightly at the time:
+//! rustc 1.55.0 (c8dfcfe04 2021-09-06).
+//!
+//! Some of these benchmarks are just a few instructions, so we put our own for loop inside
+//! the criterion::Bencher::iter call. This seems to improve the stability of measurements, and it
+//! has the wonderful side effect of making the emitted assembly easier to follow. Some of these
+//! benchmarks are totally inlined so that there are no calls at all in the hot path, so finding
+//! this for loop is an easy way to find your way around the emitted assembly.
+//!
+//! The clear method is cheaper to call for arrays of elements without a Drop impl, so wherever
+//! possible we reuse a single object in the benchmark loop, with a clear + black_box on each
+//! iteration in an attempt to not make that visible to the optimizer.
+//!
+//! We always call black_box(&v), instead of v = black_box(v) because the latter does a move of the
+//! inline array, which is linear in the size of the array and thus varies based on the array type
+//! being benchmarked, and this move can be more expensive than the function we're trying to
+//! benchmark.
+//!
+//! We also black_box the input to each method call. This has a significant effect on the assembly
+//! emitted, for example if we do not black_box the range we iterate over in the ::push benchmarks,
+//! the loop is unrolled. It's not entirely clear if it's better to black_box the iterator that
+//! yields the items being pushed, or to black_box at a deeper level: v.push(black_box(i)) for
+//! example. Anecdotally, it seems like the latter approach produces unreasonably bad assembly.
+//!
+
+use criterion::{black_box, criterion_group, criterion_main, Criterion};
+use smallvec::SmallVec;
+use std::iter::FromIterator;
+use tinyvec::TinyVec;
+
+const ITERS: usize = 10_000;
+
+macro_rules! tinyvec_benches {
+  ($c:expr, $type:ty ; $len:expr) => {{
+    let mut g = $c.benchmark_group(concat!(
+      "TinyVec_",
+      stringify!($type),
+      "_",
+      stringify!($len)
+    ));
+
+    g.bench_function(
+      concat!(
+        "TinyVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::default"
+      ),
+      |b| {
+        b.iter(|| {
+          for _ in 0..ITERS {
+            let v: TinyVec<[$type; $len]> = TinyVec::default();
+            black_box(&v);
+          }
+        });
+      },
+    );
+
+    g.bench_function(
+      concat!(
+        "TinyVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::clone"
+      ),
+      |b| {
+        b.iter(|| {
+          let outer: TinyVec<[$type; $len]> =
+            black_box(TinyVec::from_iter(0..=($len as usize - 1) as _));
+          for _ in 0..ITERS {
+            let v = outer.clone();
+            black_box(&v);
+          }
+        });
+      },
+    );
+
+    g.bench_function(
+      concat!(
+        "TinyVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::clear"
+      ),
+      |b| {
+        b.iter(|| {
+          let mut v: TinyVec<[$type; $len]> = TinyVec::default();
+          for _ in 0..ITERS {
+            v.clear();
+            black_box(&v);
+          }
+        });
+      },
+    );
+
+    g.bench_function(
+      concat!(
+        "TinyVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::push"
+      ),
+      |b| {
+        b.iter(|| {
+          let mut v: TinyVec<[$type; $len]> = TinyVec::default();
+          for _ in 0..ITERS {
+            v.clear();
+            black_box(&v);
+            for i in black_box(0..=($len as usize - 1) as _) {
+              v.push(i);
+            }
+            black_box(&v);
+          }
+        });
+      },
+    );
+
+    g.bench_function(
+      concat!(
+        "TinyVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::from_iter"
+      ),
+      |b| {
+        b.iter(|| {
+          for _ in 0..ITERS {
+            let v: TinyVec<[$type; $len]> =
+              TinyVec::from_iter(black_box(0..=($len as usize - 1) as _));
+            black_box(&v);
+          }
+        });
+      },
+    );
+
+    g.bench_function(
+      concat!(
+        "TinyVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::from_slice"
+      ),
+      |b| {
+        b.iter(|| {
+          let data: &[$type] = &[0, 1, 2, 3, 4, 5, 6, 7];
+          for _ in 0..ITERS {
+            let v: TinyVec<[$type; $len]> = TinyVec::from(black_box(data));
+            black_box(&v);
+          }
+        });
+      },
+    );
+
+    g.bench_function(
+      concat!(
+        "TinyVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::extend"
+      ),
+      |b| {
+        b.iter(|| {
+          let mut v: TinyVec<[$type; $len]> = black_box(TinyVec::default());
+          for _ in 0..ITERS {
+            v.clear();
+            black_box(&v);
+            v.extend(black_box(0..=($len as usize - 1) as _));
+            black_box(&v);
+          }
+        });
+      },
+    );
+
+    g.bench_function(
+      concat!(
+        "TinyVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::extend_from_slice"
+      ),
+      |b| {
+        b.iter(|| {
+          let data: &[$type] = black_box(&[0, 1, 2, 3, 4, 5, 6, 7]);
+          let mut v: TinyVec<[$type; $len]> = black_box(TinyVec::default());
+          for _ in 0..ITERS {
+            v.clear();
+            black_box(&v);
+            v.extend_from_slice(data);
+            black_box(&v);
+          }
+        });
+      },
+    );
+
+    g.bench_function(
+      concat!(
+        "TinyVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::insert"
+      ),
+      |b| {
+        b.iter(|| {
+          let mut v: TinyVec<[$type; $len]> = TinyVec::default();
+          for _ in 0..ITERS {
+            v.clear();
+            black_box(&v);
+            for i in black_box(0..=($len as usize - 1) as _) {
+              v.insert(i as usize, i);
+            }
+            black_box(&v);
+          }
+        });
+      },
+    );
+
+    g.bench_function(
+      concat!(
+        "TinyVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::remove"
+      ),
+      |b| {
+        b.iter(|| {
+          let outer: TinyVec<[$type; $len]> =
+            black_box(TinyVec::from_iter(0..=($len as usize - 1) as _));
+          for _ in 0..ITERS {
+            let mut v = outer.clone();
+            for i in black_box((0..=($len as usize - 1) as _).rev()) {
+              v.remove(i);
+            }
+            black_box(&v);
+          }
+        });
+      },
+    );
+  }};
+}
+
+fn tinyvec_benches(c: &mut Criterion) {
+  tinyvec_benches!(c, u8; 8);
+  tinyvec_benches!(c, u8; 16);
+  tinyvec_benches!(c, u8; 32);
+  tinyvec_benches!(c, u8; 64);
+  tinyvec_benches!(c, u8; 128);
+  tinyvec_benches!(c, u8; 256);
+  tinyvec_benches!(c, u64; 2);
+  tinyvec_benches!(c, u64; 4);
+  tinyvec_benches!(c, u64; 8);
+  tinyvec_benches!(c, u64; 16);
+  tinyvec_benches!(c, u64; 32);
+}
+
+macro_rules! smallvec_benches {
+  ($c:expr, $type:ty ; $len:expr) => {{
+    let mut g = $c.benchmark_group(concat!(
+      "SmallVec_",
+      stringify!($type),
+      "_",
+      stringify!($len)
+    ));
+
+    g.bench_function(
+      concat!(
+        "SmallVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::default"
+      ),
+      |b| {
+        b.iter(|| {
+          for _ in 0..ITERS {
+            let v: SmallVec<[$type; $len]> = SmallVec::default();
+            black_box(&v);
+          }
+        });
+      },
+    );
+
+    g.bench_function(
+      concat!(
+        "SmallVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::clone"
+      ),
+      |b| {
+        b.iter(|| {
+          let outer: SmallVec<[$type; $len]> =
+            black_box(SmallVec::from_iter(0..=($len as usize - 1) as _));
+          for _ in 0..ITERS {
+            let v = outer.clone();
+            black_box(&v);
+          }
+        });
+      },
+    );
+
+    g.bench_function(
+      concat!(
+        "SmallVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::clear"
+      ),
+      |b| {
+        b.iter(|| {
+          let mut v: SmallVec<[$type; $len]> = SmallVec::default();
+          for _ in 0..ITERS {
+            v.clear();
+            black_box(&v);
+          }
+        });
+      },
+    );
+
+    g.bench_function(
+      concat!(
+        "SmallVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::push"
+      ),
+      |b| {
+        b.iter(|| {
+          let mut v: SmallVec<[$type; $len]> = SmallVec::default();
+          for _ in 0..ITERS {
+            v.clear();
+            black_box(&v);
+            for i in black_box(0..=($len as usize - 1) as _) {
+              v.push(i);
+            }
+            black_box(&v);
+          }
+        });
+      },
+    );
+
+    g.bench_function(
+      concat!(
+        "SmallVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::from_iter"
+      ),
+      |b| {
+        b.iter(|| {
+          for _ in 0..ITERS {
+            let v: SmallVec<[$type; $len]> =
+              SmallVec::from_iter(black_box(0..=($len as usize - 1) as _));
+            black_box(&v);
+          }
+        });
+      },
+    );
+
+    g.bench_function(
+      concat!(
+        "SmallVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::from_slice"
+      ),
+      |b| {
+        b.iter(|| {
+          let data: &[$type] = &[0, 1, 2, 3, 4, 5, 6, 7];
+          for _ in 0..ITERS {
+            let v: SmallVec<[$type; $len]> = SmallVec::from(black_box(data));
+            black_box(&v);
+          }
+        });
+      },
+    );
+
+    g.bench_function(
+      concat!(
+        "SmallVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::extend"
+      ),
+      |b| {
+        b.iter(|| {
+          let mut v: SmallVec<[$type; $len]> = black_box(SmallVec::default());
+          for _ in 0..ITERS {
+            v.clear();
+            black_box(&v);
+            v.extend(black_box(0..=($len as usize - 1) as _));
+            black_box(&v);
+          }
+        });
+      },
+    );
+
+    g.bench_function(
+      concat!(
+        "SmallVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::extend_from_slice"
+      ),
+      |b| {
+        b.iter(|| {
+          let data: &[$type] = black_box(&[0, 1, 2, 3, 4, 5, 6, 7]);
+          let mut v: SmallVec<[$type; $len]> = black_box(SmallVec::default());
+          for _ in 0..ITERS {
+            v.clear();
+            black_box(&v);
+            v.extend_from_slice(data);
+            black_box(&v);
+          }
+        });
+      },
+    );
+
+    g.bench_function(
+      concat!(
+        "SmallVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::insert"
+      ),
+      |b| {
+        b.iter(|| {
+          let mut v: SmallVec<[$type; $len]> = SmallVec::default();
+          for _ in 0..ITERS {
+            v.clear();
+            black_box(&v);
+            for i in black_box(0..=($len as usize - 1) as _) {
+              v.insert(i as usize, i);
+            }
+            black_box(&v);
+          }
+        });
+      },
+    );
+
+    g.bench_function(
+      concat!(
+        "SmallVec<[",
+        stringify!($type),
+        "; ",
+        stringify!($len),
+        "]>::remove"
+      ),
+      |b| {
+        b.iter(|| {
+          let outer: SmallVec<[$type; $len]> =
+            black_box(SmallVec::from_iter(0..=($len as usize - 1) as _));
+          for _ in 0..ITERS {
+            let mut v = outer.clone();
+            for i in black_box((0..=($len as usize - 1) as _).rev()) {
+              v.remove(i);
+            }
+            black_box(&v);
+          }
+        });
+      },
+    );
+  }};
+}
+
+fn smallvec_benches(c: &mut Criterion) {
+  smallvec_benches!(c, u8; 8);
+  smallvec_benches!(c, u8; 16);
+  smallvec_benches!(c, u8; 32);
+  smallvec_benches!(c, u8; 64);
+  smallvec_benches!(c, u8; 128);
+  smallvec_benches!(c, u8; 256);
+  smallvec_benches!(c, u64; 2);
+  smallvec_benches!(c, u64; 4);
+  smallvec_benches!(c, u64; 8);
+  smallvec_benches!(c, u64; 16);
+  smallvec_benches!(c, u64; 32);
+}
+
+criterion_group!(benches, tinyvec_benches, smallvec_benches);
+criterion_main!(benches);
diff -Nru cargo-0.57.0+ubuntu/vendor/tinyvec/.cargo-checksum.json cargo-0.58.0/vendor/tinyvec/.cargo-checksum.json
--- cargo-0.57.0+ubuntu/vendor/tinyvec/.cargo-checksum.json	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/tinyvec/.cargo-checksum.json	2022-01-21 02:47:39.000000000 +0000
@@ -1 +1 @@
-{"files":{},"package":"f83b2a3d4d9091d0abd7eba4dc2710b1718583bd4d8992e2190720ea38f391f7"}
\ No newline at end of file
+{"files":{},"package":"2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2"}
\ No newline at end of file
diff -Nru cargo-0.57.0+ubuntu/vendor/tinyvec/Cargo.toml cargo-0.58.0/vendor/tinyvec/Cargo.toml
--- cargo-0.57.0+ubuntu/vendor/tinyvec/Cargo.toml	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/tinyvec/Cargo.toml	2022-01-21 02:47:39.000000000 +0000
@@ -12,7 +12,7 @@
 [package]
 edition = "2018"
 name = "tinyvec"
-version = "1.5.0"
+version = "1.5.1"
 authors = ["Lokathor <zefria@gmail.com>"]
 description = "`tinyvec` provides 100% safe vec-like data structures."
 keywords = ["vec", "no_std", "no-std"]
@@ -25,6 +25,9 @@
 
 [package.metadata.playground]
 features = ["alloc", "std", "grab_spare_slice", "rustc_1_40", "rustc_1_55", "serde"]
+[profile.bench]
+debug = 2
+
 [profile.test]
 opt-level = 3
 
@@ -36,6 +39,11 @@
 name = "macros"
 harness = false
 required-features = ["alloc"]
+
+[[bench]]
+name = "smallvec"
+harness = false
+required-features = ["alloc", "real_blackbox"]
 [dependencies.arbitrary]
 version = "1"
 optional = true
@@ -54,12 +62,16 @@
 [dev-dependencies.serde_test]
 version = "1.0"
 
+[dev-dependencies.smallvec]
+version = "1"
+
 [features]
 alloc = ["tinyvec_macros"]
 default = []
 experimental_write_impl = []
 grab_spare_slice = []
 nightly_slice_partition_dedup = []
+real_blackbox = ["criterion/real_blackbox"]
 rustc_1_40 = []
 rustc_1_55 = ["rustc_1_40"]
 std = []
diff -Nru cargo-0.57.0+ubuntu/vendor/tinyvec/CHANGELOG.md cargo-0.58.0/vendor/tinyvec/CHANGELOG.md
--- cargo-0.57.0+ubuntu/vendor/tinyvec/CHANGELOG.md	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/tinyvec/CHANGELOG.md	2022-01-21 02:47:39.000000000 +0000
@@ -1,5 +1,10 @@
 # Changelog
 
+## 1.5.1
+
+* [madsmtm](https://github.com/madsmtm) fixed an error with the `alloc` feature on very old rustc versions.
+  [pr 154](https://github.com/Lokathor/tinyvec/pull/154)
+
 ## 1.5.0
 
 * [eeeebbbbrrrr](https://github.com/eeeebbbbrrrr) added an impl for [std::io::Write](https://doc.rust-lang.org/std/io/trait.Write.html) to `TinyVec` when the element type is `u8`.
diff -Nru cargo-0.57.0+ubuntu/vendor/tinyvec/compare_benchmarks.py cargo-0.58.0/vendor/tinyvec/compare_benchmarks.py
--- cargo-0.57.0+ubuntu/vendor/tinyvec/compare_benchmarks.py	1970-01-01 00:00:00.000000000 +0000
+++ cargo-0.58.0/vendor/tinyvec/compare_benchmarks.py	2022-01-21 02:47:39.000000000 +0000
@@ -0,0 +1,30 @@
+import os
+import os.path
+import json
+
+comparisons = []
+
+for (root, _dirs, files) in os.walk('target/criterion'):
+    for file in files:
+        if file == 'estimates.json' and root.endswith(
+                'new') and 'TinyVec' in root:
+            path = os.path.join(root, file)
+
+            bench_name = path.split('/')[3]
+            tinyvec_time = json.load(open(path))['mean']['point_estimate']
+
+            path = path.replace('TinyVec', 'SmallVec')
+
+            smallvec_time = json.load(open(path))['mean']['point_estimate']
+
+            comparisons.append((bench_name, tinyvec_time / smallvec_time))
+
+comparisons.sort(key=lambda x: x[1])
+longest_name = max(len(c[0]) for c in comparisons)
+for (name, ratio) in comparisons:
+    # Undo the criterion name mangling
+    name = name.replace('_[', '<[')
+    name = name.replace(']___', ']>::')
+
+    name = name.ljust(longest_name)
+    print(f"{name} {ratio:.2f}")
diff -Nru cargo-0.57.0+ubuntu/vendor/tinyvec/src/tinyvec.rs cargo-0.58.0/vendor/tinyvec/src/tinyvec.rs
--- cargo-0.57.0+ubuntu/vendor/tinyvec/src/tinyvec.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/tinyvec/src/tinyvec.rs	2022-01-21 02:47:39.000000000 +0000
@@ -107,8 +107,8 @@
   #[inline]
   fn clone(&self) -> Self {
     match self {
-      Self::Heap(v) => Self::Heap(v.clone()),
-      Self::Inline(v) => Self::Inline(v.clone()),
+      TinyVec::Heap(v) => TinyVec::Heap(v.clone()),
+      TinyVec::Inline(v) => TinyVec::Inline(v.clone()),
     }
   }
 
diff -Nru cargo-0.57.0+ubuntu/vendor/typenum/build/main.rs cargo-0.58.0/vendor/typenum/build/main.rs
--- cargo-0.57.0+ubuntu/vendor/typenum/build/main.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/typenum/build/main.rs	2022-01-21 02:47:39.000000000 +0000
@@ -80,8 +80,10 @@
 fn main() {
     let highest: u64 = 1024;
 
-    let first2: u32 = (highest as f64).log(2.0).round() as u32 + 1;
-    let first10: u32 = (highest as f64).log(10.0) as u32 + 1;
+    // Use hardcoded values to avoid issues with cross-compilation.
+    // See https://github.com/paholg/typenum/issues/162
+    let first2: u32 = 11; // (highest as f64).log(2.0).round() as u32 + 1;
+    let first10: u32 = 4; // (highest as f64).log(10.0) as u32 + 1;
     let uints = (0..(highest + 1))
         .chain((first2..64).map(|i| 2u64.pow(i)))
         .chain((first10..20).map(|i| 10u64.pow(i)));
diff -Nru cargo-0.57.0+ubuntu/vendor/typenum/.cargo-checksum.json cargo-0.58.0/vendor/typenum/.cargo-checksum.json
--- cargo-0.57.0+ubuntu/vendor/typenum/.cargo-checksum.json	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/typenum/.cargo-checksum.json	2022-01-21 02:47:39.000000000 +0000
@@ -1 +1 @@
-{"files":{},"package":"b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec"}
\ No newline at end of file
+{"files":{},"package":"dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987"}
\ No newline at end of file
diff -Nru cargo-0.57.0+ubuntu/vendor/typenum/Cargo.toml cargo-0.58.0/vendor/typenum/Cargo.toml
--- cargo-0.57.0+ubuntu/vendor/typenum/Cargo.toml	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/typenum/Cargo.toml	2022-01-21 02:47:39.000000000 +0000
@@ -3,17 +3,16 @@
 # 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 = "typenum"
-version = "1.14.0"
+version = "1.15.0"
 authors = ["Paho Lurie-Gregg <paho@paholg.com>", "Andre Bogus <bogusandre@gmail.com>"]
 build = "build/main.rs"
 description = "Typenum is a Rust library for type-level numbers evaluated at\n    compile time. It currently supports bits, unsigned integers, and signed\n    integers. It also provides a type-level array of type-level numbers, but its\n    implementation is incomplete."
@@ -25,9 +24,14 @@
 
 [lib]
 name = "typenum"
+[dependencies.scale-info]
+version = "1.0"
+optional = true
+default-features = false
 
 [features]
 force_unix_path_separator = []
 i128 = []
 no_std = []
+scale_info = ["scale-info/derive"]
 strict = []
diff -Nru cargo-0.57.0+ubuntu/vendor/typenum/CHANGELOG.md cargo-0.58.0/vendor/typenum/CHANGELOG.md
--- cargo-0.57.0+ubuntu/vendor/typenum/CHANGELOG.md	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/typenum/CHANGELOG.md	2022-01-21 02:47:39.000000000 +0000
@@ -7,6 +7,12 @@
 
 ### Unreleased
 
+### 1.15.0 (2021-12-25)
+- [fixed] Cross-compilation issue due to doing math in build script. (PR #177)
+- [added] New feature `scale_info` for using inside
+  [Substrate](https://github.com/paritytech/substrate.git)-based runtimes (PR
+  #175)
+
 ### 1.14.0 (2021-09-01)
 - [changed] Sealed all marker traits. Documentation already stated that these
   should not be implemented outside the crate, so this is not considered a
diff -Nru cargo-0.57.0+ubuntu/vendor/typenum/src/array.rs cargo-0.58.0/vendor/typenum/src/array.rs
--- cargo-0.57.0+ubuntu/vendor/typenum/src/array.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/typenum/src/array.rs	2022-01-21 02:47:39.000000000 +0000
@@ -8,6 +8,7 @@
 
 /// The terminating type for type arrays.
 #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug)]
+#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
 pub struct ATerm;
 
 impl TypeArray for ATerm {}
@@ -19,6 +20,7 @@
 /// This array is only really designed to contain `Integer` types. If you use it with others, you
 /// may find it lacking functionality.
 #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug)]
+#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
 pub struct TArr<V, A> {
     first: V,
     rest: A,
diff -Nru cargo-0.57.0+ubuntu/vendor/typenum/src/bit.rs cargo-0.58.0/vendor/typenum/src/bit.rs
--- cargo-0.57.0+ubuntu/vendor/typenum/src/bit.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/typenum/src/bit.rs	2022-01-21 02:47:39.000000000 +0000
@@ -16,6 +16,7 @@
 
 /// The type-level bit 0.
 #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
+#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
 pub struct B0;
 
 impl B0 {
@@ -28,6 +29,7 @@
 
 /// The type-level bit 1.
 #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
+#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
 pub struct B1;
 
 impl B1 {
diff -Nru cargo-0.57.0+ubuntu/vendor/typenum/src/int.rs cargo-0.58.0/vendor/typenum/src/int.rs
--- cargo-0.57.0+ubuntu/vendor/typenum/src/int.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/typenum/src/int.rs	2022-01-21 02:47:39.000000000 +0000
@@ -38,12 +38,14 @@
 
 /// Type-level signed integers with positive sign.
 #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
+#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
 pub struct PInt<U: Unsigned + NonZero> {
     pub(crate) n: U,
 }
 
 /// Type-level signed integers with negative sign.
 #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
+#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
 pub struct NInt<U: Unsigned + NonZero> {
     pub(crate) n: U,
 }
@@ -66,6 +68,7 @@
 
 /// The type-level signed integer 0.
 #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
+#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
 pub struct Z0;
 
 impl Z0 {
diff -Nru cargo-0.57.0+ubuntu/vendor/typenum/src/lib.rs cargo-0.58.0/vendor/typenum/src/lib.rs
--- cargo-0.57.0+ubuntu/vendor/typenum/src/lib.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/typenum/src/lib.rs	2022-01-21 02:47:39.000000000 +0000
@@ -59,7 +59,7 @@
     )
 )]
 #![cfg_attr(feature = "cargo-clippy", deny(clippy::missing_inline_in_public_items))]
-#![doc(html_root_url = "https://docs.rs/typenum/1.14.0")]
+#![doc(html_root_url = "https://docs.rs/typenum/1.15.0")]
 
 // For debugging macros:
 // #![feature(trace_macros)]
@@ -103,16 +103,19 @@
 /// A potential output from `Cmp`, this is the type equivalent to the enum variant
 /// `core::cmp::Ordering::Greater`.
 #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
+#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
 pub struct Greater;
 
 /// A potential output from `Cmp`, this is the type equivalent to the enum variant
 /// `core::cmp::Ordering::Less`.
 #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
+#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
 pub struct Less;
 
 /// A potential output from `Cmp`, this is the type equivalent to the enum variant
 /// `core::cmp::Ordering::Equal`.
 #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
+#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
 pub struct Equal;
 
 /// Returns `core::cmp::Ordering::Greater`
diff -Nru cargo-0.57.0+ubuntu/vendor/typenum/src/uint.rs cargo-0.58.0/vendor/typenum/src/uint.rs
--- cargo-0.57.0+ubuntu/vendor/typenum/src/uint.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/typenum/src/uint.rs	2022-01-21 02:47:39.000000000 +0000
@@ -46,6 +46,7 @@
 /// The terminating type for `UInt`; it always comes after the most significant
 /// bit. `UTerm` by itself represents zero, which is aliased to `U0`.
 #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
+#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
 pub struct UTerm;
 
 impl UTerm {
@@ -143,6 +144,7 @@
 /// type U6 = UInt<UInt<UInt<UTerm, B1>, B1>, B0>;
 /// ```
 #[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Hash, Debug, Default)]
+#[cfg_attr(feature = "scale_info", derive(scale_info::TypeInfo))]
 pub struct UInt<U, B> {
     /// The more significant bits of `Self`.
     pub(crate) msb: U,
diff -Nru cargo-0.57.0+ubuntu/vendor/version_check/.cargo-checksum.json cargo-0.58.0/vendor/version_check/.cargo-checksum.json
--- cargo-0.57.0+ubuntu/vendor/version_check/.cargo-checksum.json	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/version_check/.cargo-checksum.json	2022-01-21 02:47:39.000000000 +0000
@@ -1 +1 @@
-{"files":{},"package":"5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"}
\ No newline at end of file
+{"files":{},"package":"49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"}
\ No newline at end of file
diff -Nru cargo-0.57.0+ubuntu/vendor/version_check/Cargo.toml cargo-0.58.0/vendor/version_check/Cargo.toml
--- cargo-0.57.0+ubuntu/vendor/version_check/Cargo.toml	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/version_check/Cargo.toml	2022-01-21 02:47:39.000000000 +0000
@@ -3,17 +3,17 @@
 # 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 = "version_check"
-version = "0.9.3"
+version = "0.9.4"
 authors = ["Sergio Benitez <sb@sergio.bz>"]
+exclude = ["static"]
 description = "Tiny crate to check the version of the installed/running rustc."
 documentation = "https://docs.rs/version_check/"
 readme = "README.md"
diff -Nru cargo-0.57.0+ubuntu/vendor/version_check/README.md cargo-0.58.0/vendor/version_check/README.md
--- cargo-0.57.0+ubuntu/vendor/version_check/README.md	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/version_check/README.md	2022-01-21 02:47:39.000000000 +0000
@@ -1,6 +1,6 @@
 # version\_check
 
-[![Build Status](https://travis-ci.com/SergioBenitez/version_check.svg?branch=master)](https://travis-ci.com/SergioBenitez/version_check)
+[![Build Status](https://github.com/SergioBenitez/version_check/workflows/CI/badge.svg)](https://github.com/SergioBenitez/version_check/actions)
 [![Current Crates.io Version](https://img.shields.io/crates/v/version_check.svg)](https://crates.io/crates/version_check)
 [![rustdocs on docs.rs](https://docs.rs/version_check/badge.svg)](https://docs.rs/version_check)
 
@@ -63,10 +63,14 @@
 
 ## Alternatives
 
-This crate is dead simple with no dependencies. If you need something more
-and don't care about panicking if the version cannot be obtained, or if you
-don't mind adding dependencies, see
-[rustc_version](https://crates.io/crates/rustc_version).
+This crate is dead simple with no dependencies. If you need something more and
+don't care about panicking if the version cannot be obtained, or if you don't
+mind adding dependencies, see [rustc_version]. If you'd instead prefer a feature
+detection library that works by dynamically invoking `rustc` with a
+representative code sample, see [autocfg].
+
+[rustc_version]: https://crates.io/crates/rustc_version
+[autocfg]: https://crates.io/crates/autocfg
 
 ## License
 
diff -Nru cargo-0.57.0+ubuntu/vendor/version_check/src/channel.rs cargo-0.58.0/vendor/version_check/src/channel.rs
--- cargo-0.57.0+ubuntu/vendor/version_check/src/channel.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/version_check/src/channel.rs	2022-01-21 02:47:39.000000000 +0000
@@ -54,11 +54,12 @@
     /// assert!(stable.is_stable());
     /// ```
     pub fn parse(version: &str) -> Option<Channel> {
-        if version.contains("-dev") {
+        let version = version.trim();
+        if version.contains("-dev") || version == "dev" {
             Some(Channel(Kind::Dev))
-        } else if version.contains("-nightly") {
+        } else if version.contains("-nightly") || version == "nightly" {
             Some(Channel(Kind::Nightly))
-        } else if version.contains("-beta") {
+        } else if version.contains("-beta") || version == "beta" {
             Some(Channel(Kind::Beta))
         } else if !version.contains("-") {
             Some(Channel(Kind::Stable))
diff -Nru cargo-0.57.0+ubuntu/vendor/version_check/src/date.rs cargo-0.58.0/vendor/version_check/src/date.rs
--- cargo-0.57.0+ubuntu/vendor/version_check/src/date.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/version_check/src/date.rs	2022-01-21 02:47:39.000000000 +0000
@@ -25,14 +25,6 @@
             .and_then(|date| Date::parse(&date))
     }
 
-    /// Return the original (YYYY, MM, DD).
-    fn to_ymd(&self) -> (u16, u8, u8) {
-        let y = self.0 >> 9;
-        let m = (self.0 << 23) >> 28;
-        let d = (self.0 << 27) >> 27;
-        (y as u16, m as u8, d as u8)
-    }
-
     /// Parse a release date of the form `%Y-%m-%d`. Returns `None` if `date` is
     /// not in `%Y-%m-%d` format.
     ///
@@ -47,20 +39,63 @@
     /// assert!(date.at_most("2016-04-20"));
     /// assert!(date.exactly("2016-04-20"));
     ///
+    /// assert!(Date::parse("2021-12-31").unwrap().exactly("2021-12-31"));
+    ///
     /// assert!(Date::parse("March 13, 2018").is_none());
     /// assert!(Date::parse("1-2-3-4-5").is_none());
+    /// assert!(Date::parse("2020-300-23120").is_none());
+    /// assert!(Date::parse("2020-12-12 1").is_none());
+    /// assert!(Date::parse("2020-10").is_none());
+    /// assert!(Date::parse("2020").is_none());
     /// ```
     pub fn parse(date: &str) -> Option<Date> {
-        let ymd: Vec<u32> = date.split("-")
-            .filter_map(|s| s.parse::<u32>().ok())
-            .collect();
+        let mut ymd = [0u16; 3];
+        for (i, split) in date.split('-').map(|s| s.parse::<u16>()).enumerate() {
+            ymd[i] = match (i, split) {
+                (3, _) | (_, Err(_)) => return None,
+                (_, Ok(v)) => v,
+            };
+        }
 
-        if ymd.len() != 3 {
-            return None
+        let (year, month, day) = (ymd[0], ymd[1], ymd[2]);
+        if year == 0 || month == 0 || month > 12 || day == 0 || day > 31 {
+            return None;
         }
 
-        let (y, m, d) = (ymd[0], ymd[1], ymd[2]);
-        Some(Date((y << 9) | ((m & 0xF) << 5) | (d & 0x1F)))
+        Some(Date::from_ymd(year, month as u8, day as u8))
+    }
+
+    /// Creates a `Date` from `(year, month, day)` date components.
+    ///
+    /// Does not check the validity of `year`, `month`, or `day`, but `year` is
+    /// truncated to 23 bits (% 8,388,608), `month` to 4 bits (% 16), and `day`
+    /// to 5 bits (% 32).
+    ///
+    /// # Example
+    ///
+    /// ```rust
+    /// use version_check::Date;
+    ///
+    /// assert!(Date::from_ymd(2021, 7, 30).exactly("2021-07-30"));
+    /// assert!(Date::from_ymd(2010, 3, 23).exactly("2010-03-23"));
+    /// assert!(Date::from_ymd(2090, 1, 31).exactly("2090-01-31"));
+    ///
+    /// // Truncation: 33 % 32 == 0x21 & 0x1F == 1.
+    /// assert!(Date::from_ymd(2090, 1, 33).exactly("2090-01-01"));
+    /// ```
+    pub fn from_ymd(year: u16, month: u8, day: u8) -> Date {
+        let year = (year as u32) << 9;
+        let month = ((month as u32) & 0xF) << 5;
+        let day = (day as u32) & 0x1F;
+        Date(year | month | day)
+    }
+
+    /// Return the original (YYYY, MM, DD).
+    fn to_ymd(&self) -> (u16, u8, u8) {
+        let y = self.0 >> 9;
+        let m = (self.0 >> 5) & 0xF;
+        let d = self.0 & 0x1F;
+        (y as u16, m as u8, d as u8)
     }
 
     /// Returns `true` if `self` occurs on or after `date`.
@@ -163,5 +198,6 @@
         reflexive_display!("2000-12-31");
         reflexive_display!("2090-12-31");
         reflexive_display!("1999-02-19");
+        reflexive_display!("9999-12-31");
     }
 }
diff -Nru cargo-0.57.0+ubuntu/vendor/version_check/src/lib.rs cargo-0.58.0/vendor/version_check/src/lib.rs
--- cargo-0.57.0+ubuntu/vendor/version_check/src/lib.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/version_check/src/lib.rs	2022-01-21 02:47:39.000000000 +0000
@@ -6,58 +6,68 @@
 //!
 //! # Examples
 //!
-//! Set a `cfg` flag in `build.rs` if the running compiler was determined to be
-//! at least version `1.13.0`:
+//! * Set a `cfg` flag in `build.rs` if the running compiler was determined to
+//!   be at least version `1.13.0`:
 //!
-//! ```rust
-//! extern crate version_check as rustc;
+//!   ```rust
+//!   extern crate version_check as rustc;
 //!
-//! if rustc::is_min_version("1.13.0").unwrap_or(false) {
-//!     println!("cargo:rustc-cfg=question_mark_operator");
-//! }
-//! ```
-//!
-//! See [`is_max_version`] or [`is_exact_version`] to check if the compiler
-//! is _at most_ or _exactly_ a certain version.
-//!
-//! Check that the running compiler was released on or after `2018-12-18`:
-//!
-//! ```rust
-//! extern crate version_check as rustc;
-//!
-//! match rustc::is_min_date("2018-12-18") {
-//!     Some(true) => "Yep! It's recent!",
-//!     Some(false) => "No, it's older.",
-//!     None => "Couldn't determine the rustc version."
-//! };
-//! ```
-//!
-//! See [`is_max_date`] or [`is_exact_date`] to check if the compiler was
-//! released _prior to_ or _exactly on_ a certain date.
-//!
-//! Check that the running compiler supports feature flags:
-//!
-//! ```rust
-//! extern crate version_check as rustc;
-//!
-//! match rustc::is_feature_flaggable() {
-//!     Some(true) => "Yes! It's a dev or nightly release!",
-//!     Some(false) => "No, it's stable or beta.",
-//!     None => "Couldn't determine the rustc version."
-//! };
-//! ```
-//!
-//! Check that the running compiler is on the stable channel:
-//!
-//! ```rust
-//! extern crate version_check as rustc;
-//!
-//! match rustc::Channel::read() {
-//!     Some(c) if c.is_stable() => format!("Yes! It's stable."),
-//!     Some(c) => format!("No, the channel {} is not stable.", c),
-//!     None => format!("Couldn't determine the rustc version.")
-//! };
-//! ```
+//!   if rustc::is_min_version("1.13.0").unwrap_or(false) {
+//!       println!("cargo:rustc-cfg=question_mark_operator");
+//!   }
+//!   ```
+//!
+//!   See [`is_max_version`] or [`is_exact_version`] to check if the compiler
+//!   is _at most_ or _exactly_ a certain version.
+//!
+//! * Check that the running compiler was released on or after `2018-12-18`:
+//!
+//!   ```rust
+//!   extern crate version_check as rustc;
+//!
+//!   match rustc::is_min_date("2018-12-18") {
+//!       Some(true) => "Yep! It's recent!",
+//!       Some(false) => "No, it's older.",
+//!       None => "Couldn't determine the rustc version."
+//!   };
+//!   ```
+//!
+//!   See [`is_max_date`] or [`is_exact_date`] to check if the compiler was
+//!   released _prior to_ or _exactly on_ a certain date.
+//!
+//! * Check that the running compiler supports feature flags:
+//!
+//!   ```rust
+//!   extern crate version_check as rustc;
+//!
+//!   match rustc::is_feature_flaggable() {
+//!       Some(true) => "Yes! It's a dev or nightly release!",
+//!       Some(false) => "No, it's stable or beta.",
+//!       None => "Couldn't determine the rustc version."
+//!   };
+//!   ```
+//!
+//! * Check that the running compiler supports a specific feature:
+//!
+//!   ```rust
+//!   extern crate version_check as rustc;
+//!
+//!   if let Some(true) = rustc::supports_feature("doc_cfg") {
+//!      println!("cargo:rustc-cfg=has_doc_cfg");
+//!   }
+//!   ```
+//!
+//! * Check that the running compiler is on the stable channel:
+//!
+//!   ```rust
+//!   extern crate version_check as rustc;
+//!
+//!   match rustc::Channel::read() {
+//!       Some(c) if c.is_stable() => format!("Yes! It's stable."),
+//!       Some(c) => format!("No, the channel {} is not stable.", c),
+//!       None => format!("Couldn't determine the rustc version.")
+//!   };
+//!   ```
 //!
 //! To interact with the version, release date, and release channel as structs,
 //! use [`Version`], [`Date`], and [`Channel`], respectively. The [`triple()`]
@@ -248,22 +258,76 @@
 ///
 /// In other words, if the channel is either "nightly" or "dev".
 ///
+/// Note that support for specific `rustc` features can be enabled or disabled
+/// via the `allow-features` compiler flag, which this function _does not_
+/// check. That is, this function _does not_ check whether a _specific_ feature
+/// is supported, but instead whether features are supported at all. To check
+/// for support for a specific feature, use [`supports_feature()`].
+///
 /// If the version could not be determined, returns `None`. Otherwise returns
 /// `true` if the running version supports feature flags and `false` otherwise.
 pub fn is_feature_flaggable() -> Option<bool> {
     Channel::read().map(|c| c.supports_features())
 }
 
+/// Checks whether the running or installed `rustc` supports `feature`.
+///
+/// Returns _true_ _iff_ [`is_feature_flaggable()`] returns `true` _and_ the
+/// feature is not disabled via exclusion in `allow-features` via `RUSTFLAGS` or
+/// `CARGO_ENCODED_RUSTFLAGS`. If the version could not be determined, returns
+/// `None`.
+///
+/// # Example
+///
+/// ```rust
+/// use version_check as rustc;
+///
+/// if let Some(true) = rustc::supports_feature("doc_cfg") {
+///    println!("cargo:rustc-cfg=has_doc_cfg");
+/// }
+/// ```
+pub fn supports_feature(feature: &str) -> Option<bool> {
+    match is_feature_flaggable() {
+        Some(true) => { /* continue */ }
+        Some(false) => return Some(false),
+        None => return None,
+    }
+
+    let env_flags = env::var_os("CARGO_ENCODED_RUSTFLAGS")
+        .map(|flags| (flags, '\x1f'))
+        .or_else(|| env::var_os("RUSTFLAGS").map(|flags| (flags, ' ')));
+
+    if let Some((flags, delim)) = env_flags {
+        const ALLOW_FEATURES: &'static str = "allow-features=";
+
+        let rustflags = flags.to_string_lossy();
+        let allow_features = rustflags.split(delim)
+            .map(|flag| flag.trim_left_matches("-Z").trim())
+            .filter(|flag| flag.starts_with(ALLOW_FEATURES))
+            .map(|flag| &flag[ALLOW_FEATURES.len()..]);
+
+        if let Some(allow_features) = allow_features.last() {
+            return Some(allow_features.split(',').any(|f| f.trim() == feature));
+        }
+    }
+
+    // If there are no `RUSTFLAGS` or `CARGO_ENCODED_RUSTFLAGS` or they don't
+    // contain an `allow-features` flag, assume compiler allows all features.
+    Some(true)
+}
+
 #[cfg(test)]
 mod tests {
+    use std::{env, fs};
+
     use super::version_and_date_from_rustc_version;
     use super::version_and_date_from_rustc_verbose_version;
 
     macro_rules! check_parse {
         (@ $f:expr, $s:expr => $v:expr, $d:expr) => ({
-            if let (Some(v), d) = $f($s) {
+            if let (Some(v), d) = $f(&$s) {
                 let e_d: Option<&str> = $d.into();
-                assert_eq!((v, d), ($v.into(), e_d.map(|s| s.into())));
+                assert_eq!((v, d), ($v.to_string(), e_d.map(|s| s.into())));
             } else {
                 panic!("{:?} didn't parse for version testing.", $s);
             }
@@ -365,4 +429,65 @@
                 release: 1.50.0" => "1.50.0", None,
         };
     }
+
+    fn read_static(verbose: bool, channel: &str, minor: usize) -> String {
+        use std::fs::File;
+        use std::path::Path;
+        use std::io::{BufReader, Read};
+
+        let subdir = if verbose { "verbose" } else { "terse" };
+        let path = Path::new(STATIC_PATH)
+            .join(channel)
+            .join(subdir)
+            .join(format!("rustc-1.{}.0", minor));
+
+        let file = File::open(path).unwrap();
+        let mut buf_reader = BufReader::new(file);
+        let mut contents = String::new();
+        buf_reader.read_to_string(&mut contents).unwrap();
+        contents
+    }
+
+    static STATIC_PATH: &'static str = concat!(env!("CARGO_MANIFEST_DIR"), "/static");
+
+    static DATES: [&'static str; 51] = [
+        "2015-05-13", "2015-06-19", "2015-08-03", "2015-09-15", "2015-10-27",
+        "2015-12-04", "2016-01-19", "2016-02-29", "2016-04-11", "2016-05-18",
+        "2016-07-03", "2016-08-15", "2016-09-23", "2016-11-07", "2016-12-16",
+        "2017-01-19", "2017-03-10", "2017-04-24", "2017-06-06", "2017-07-17",
+        "2017-08-27", "2017-10-09", "2017-11-20", "2018-01-01", "2018-02-12",
+        "2018-03-25", "2018-05-07", "2018-06-19", "2018-07-30", "2018-09-11",
+        "2018-10-24", "2018-12-04", "2019-01-16", "2019-02-28", "2019-04-10",
+        "2019-05-20", "2019-07-03", "2019-08-13", "2019-09-23", "2019-11-04",
+        "2019-12-16", "2020-01-27", "2020-03-09", "2020-04-20", "2020-06-01",
+        "2020-07-13", "2020-08-24", "2020-10-07", "2020-11-16", "2020-12-29",
+        "2021-02-10",
+    ];
+
+    #[test]
+    fn test_stable_compatibility() {
+        if env::var_os("FORCE_STATIC").is_none() && fs::metadata(STATIC_PATH).is_err() {
+            // We exclude `/static` when we package `version_check`, so don't
+            // run if static files aren't present unless we know they should be.
+            return;
+        }
+
+        // Ensure we can parse all output from all Linux stable releases.
+        for v in 0..DATES.len() {
+            let (version, date) = (&format!("1.{}.0", v), Some(DATES[v]));
+            check_terse_parse!(read_static(false, "stable", v) => version, date,);
+            check_verbose_parse!(read_static(true, "stable", v) => version, date,);
+        }
+    }
+
+    #[test]
+    fn test_parse_current() {
+        let (version, channel) = (::Version::read(), ::Channel::read());
+        assert!(version.is_some());
+        assert!(channel.is_some());
+
+        if let Ok(known_channel) = env::var("KNOWN_CHANNEL") {
+            assert_eq!(channel, ::Channel::parse(&known_channel));
+        }
+    }
 }
diff -Nru cargo-0.57.0+ubuntu/vendor/version_check/src/version.rs cargo-0.58.0/vendor/version_check/src/version.rs
--- cargo-0.57.0+ubuntu/vendor/version_check/src/version.rs	2021-10-23 22:01:12.000000000 +0000
+++ cargo-0.58.0/vendor/version_check/src/version.rs	2022-01-21 02:47:39.000000000 +0000
@@ -59,13 +59,13 @@
             .nth(0)
             .unwrap_or("")
             .split('.')
-            .map(|s| s.parse::<u16>().ok());
+            .map(|s| s.parse::<u16>());
 
         let mut mmp = [0u16; 3];
         for (i, split) in splits.enumerate() {
             mmp[i] = match (i, split) {
-                (3, _) | (_, None) => return None,
-                (_, Some(v)) => v,
+                (3, _) | (_, Err(_)) => return None,
+                (_, Ok(v)) => v,
             };
         }
 
@@ -103,8 +103,8 @@
     /// ```
     pub fn to_mmp(&self) -> (u16, u16, u16) {
         let major = self.0 >> 32;
-        let minor = (self.0 << 32) >> 48;
-        let patch = (self.0 << 48) >> 48;
+        let minor = self.0 >> 16;
+        let patch = self.0;
         (major as u16, minor as u16, patch as u16)
     }