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
+
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.
+
+
+
--profilename
+
Remove all artifacts in the directory with the given profile name.
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.
+
+
+
+
--profilename
+
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.
--profilename
-
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.
@@ -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.
+
+
+
--profilename
+
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.
+
+
+
+
--profilename
+
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.
+
--profilename
+
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.
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.
+
+
+
+
--profilename
+
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.
+
+
+
+
--profilename
+
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 @@
-
-
-
\ 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